/[PAMELA software]/DarthVader/TrackerLevel2/src/TrkLevel2.cpp
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/src/TrkLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by pam-fi, Tue Sep 5 12:52:20 2006 UTC revision 1.14 by pam-fi, Fri Oct 27 16:59:20 2006 UTC
# Line 4  Line 4 
4   */   */
5  #include <TrkLevel2.h>  #include <TrkLevel2.h>
6  #include <iostream>  #include <iostream>
7    #include <math.h>
8  using namespace std;  using namespace std;
9  //......................................  //......................................
10  // F77 routines  // F77 routines
# Line 11  using namespace std; Line 12  using namespace std;
12  extern "C" {      extern "C" {    
13      void dotrack_(int*, double*, double*, double*, double*, int*);      void dotrack_(int*, double*, double*, double*, double*, int*);
14      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);
15      int  readb_(const char*);      int  readb_(const char*);
16        void mini2_(int*,int*,int*);
17  }  }
18  //--------------------------------------  //--------------------------------------
19  //  //
# Line 21  TrkTrack::TrkTrack(){ Line 23  TrkTrack::TrkTrack(){
23      seqno = -1;      seqno = -1;
24      image = -1;      image = -1;
25      chi2  = 0;      chi2  = 0;
26        nstep = 0;
27      for(int it1=0;it1<5;it1++){      for(int it1=0;it1<5;it1++){
28                  al[it1] = 0;          al[it1] = 0;
29                  for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;          for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;
30      };      };
31      for(int ip=0;ip<6;ip++){      for(int ip=0;ip<6;ip++){
32                  xgood[ip]  = 0;                  xgood[ip]  = 0;
# Line 54  TrkTrack::TrkTrack(const TrkTrack& t){ Line 57  TrkTrack::TrkTrack(const TrkTrack& t){
57      seqno = t.seqno;      seqno = t.seqno;
58      image = t.image;      image = t.image;
59      chi2  = t.chi2;      chi2  = t.chi2;
60        nstep = t.nstep;
61      for(int it1=0;it1<5;it1++){      for(int it1=0;it1<5;it1++){
62                  al[it1] = t.al[it1];          al[it1] = t.al[it1];
63                  for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2];          for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2];
64      };      };
65      for(int ip=0;ip<6;ip++){      for(int ip=0;ip<6;ip++){
66                  xgood[ip]  = t.xgood[ip];                  xgood[ip]  = t.xgood[ip];
# Line 194  Float_t TrkTrack::GetDEDX(){ Line 198  Float_t TrkTrack::GetDEDX(){
198  //--------------------------------------  //--------------------------------------
199  void TrkTrack::Dump(){  void TrkTrack::Dump(){
200      cout << endl << "========== Track " ;      cout << endl << "========== Track " ;
201        cout << endl << "seq.  n. : "<< seqno;
202        cout << endl << "image n. : "<< image;
203      cout << endl << "al       : "; for(int i=0; i<5; i++)cout << al[i] << " ";      cout << endl << "al       : "; for(int i=0; i<5; i++)cout << al[i] << " ";
204      cout << endl << "chi^2    : "<< chi2;      cout << endl << "chi^2    : "<< chi2;
205        cout << endl << "n.step   : "<< nstep;
206      cout << endl << "xgood    : "; for(int i=0; i<6; i++)cout << xgood[i] ;      cout << endl << "xgood    : "; for(int i=0; i<6; i++)cout << xgood[i] ;
207      cout << endl << "ygood    : "; for(int i=0; i<6; i++)cout << ygood[i] ;      cout << endl << "ygood    : "; for(int i=0; i<6; i++)cout << ygood[i] ;
208      cout << endl << "xm       : "; for(int i=0; i<6; i++)cout << xm[i] << " ";      cout << endl << "xm       : "; for(int i=0; i<6; i++)cout << xm[i] << " ";
209      cout << endl << "ym       : "; for(int i=0; i<6; i++)cout << ym[i] << " ";      cout << endl << "ym       : "; for(int i=0; i<6; i++)cout << ym[i] << " ";
210      cout << endl << "zm       : "; for(int i=0; i<6; i++)cout << zm[i] << " ";      cout << endl << "zm       : "; for(int i=0; i<6; i++)cout << zm[i] << " ";
211        cout << endl << "xv       : "; for(int i=0; i<6; i++)cout << xv[i] << " ";
212        cout << endl << "yv       : "; for(int i=0; i<6; i++)cout << yv[i] << " ";
213        cout << endl << "zv       : "; for(int i=0; i<6; i++)cout << zv[i] << " ";
214        cout << endl << "resx     : "; for(int i=0; i<6; i++)cout << resx[i] << " ";
215        cout << endl << "resy     : "; for(int i=0; i<6; i++)cout << resy[i] << " ";
216        cout << endl << "coval    : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" ";
217        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[1][i]<<" ";
218        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[2][i]<<" ";
219        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[3][i]<<" ";
220        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[4][i]<<" ";
221      cout << endl << "dedx_x   : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " ";      cout << endl << "dedx_x   : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " ";
222      cout << endl << "dedx_y   : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " ";      cout << endl << "dedx_y   : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " ";
223        cout << endl;
224    }
225    /**
226     * Set the TrkTrack position measurements
227     */
228    void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){
229        for(int i=0; i<6; i++) xm[i]=*xmeas++;
230        for(int i=0; i<6; i++) ym[i]=*ymeas++;
231        for(int i=0; i<6; i++) zm[i]=*zmeas++;
232    }
233    /**
234     * Set the TrkTrack position resolution
235     */
236    void TrkTrack::SetResolution(double *rx, double *ry){
237        for(int i=0; i<6; i++) resx[i]=*rx++;
238        for(int i=0; i<6; i++) resy[i]=*ry++;
239    }
240    /**
241     * Set the TrkTrack good measurement
242     */
243    void TrkTrack::SetGood(int *xg, int *yg){
244        for(int i=0; i<6; i++) xgood[i]=*xg++;
245        for(int i=0; i<6; i++) ygood[i]=*yg++;
246  }  }
247    
248    /**
249     * Load the magnetic field
250     */
251    void TrkTrack::LoadField(TString s){
252        readb_(s.Data());
253    };
254    /**
255     * Tracking method. It calls F77 mini routine.
256     */
257    void TrkTrack::Fit(double pfixed, int& fail, int iprint){
258        extern cMini2track track_;
259        fail = 0;
260    //    extern cMini2fitinfo fit_info_;
261    //    extern void mini_2_(int*,int*);
262    //    track_.xm[0]=1.0;
263        for(int i=0; i<6; i++) track_.xm[i]=xm[i];
264        for(int i=0; i<6; i++) track_.ym[i]=ym[i];
265        for(int i=0; i<6; i++) track_.zm[i]=zm[i];
266        for(int i=0; i<6; i++) track_.resx[i]=resx[i];
267        for(int i=0; i<6; i++) track_.resy[i]=resy[i];
268        for(int i=0; i<6; i++) track_.xgood[i]=xgood[i];
269        for(int i=0; i<6; i++) track_.ygood[i]=ygood[i];
270    // initial guess of "al" with linear fit
271        if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){
272            double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.;
273            double det, ax, ay, bx, by;
274            for(int i=0; i<NPLANE; i++) {
275                szz=szz+zm[i]*zm[i];
276                szx=szx+zm[i]*xm[i];
277                szy=szy+zm[i]*ym[i];
278                ssx=ssx+xm[i];
279                ssy=ssy+ym[i];
280                sz=sz+zm[i];
281                s1=s1+1.;
282            }
283            det=szz*s1-sz*sz;
284            ax=(szx*s1-sz*ssx)/det;
285            bx=(szz*ssx-szx*sz)/det;
286            ay=(szy*s1-sz*ssy)/det;
287            by=(szz*ssy-szy*sz)/det;
288            al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes
289            al[1]=ay*23.5+by; //  "  
290            al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.);
291            al[3]=0.;
292            if( (ax!=0.)||(ay!=0.) ) {
293                al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2)));
294                if(ax<0.) al[3]=acos(-1.)-al[3];
295            }
296            al[4]=0.;
297        }
298    // end guess
299        if(pfixed==0.) {
300            al[4]=0.;         // free momentum
301            track_.pfixed=0.; //         "
302        }
303        if(pfixed!=0.) {
304            al[4]=1./pfixed;      // to fix the momentum
305            track_.pfixed=pfixed; //         "
306        }
307        track_.zini = 23.5; // ZINI = 23.5 !!! it should be the same parameter in all codes
308        for(int i=0; i<5; i++) track_.al[i]=al[i];
309        int istep=0;
310        int ifail=0;
311        mini2_(&istep,&ifail, &iprint);
312        if(ifail!=0) {
313            if(iprint==1)cout << "ERROR: ifail= " << ifail << endl;
314            fail = 1;
315    //      return;
316        }
317    
318    //    cout << endl << "eta ===> " << track_.al[4] << endl;
319    
320        for(int i=0; i<5; i++) al[i]=track_.al[i];
321        chi2=track_.chi2;
322        nstep=track_.nstep;
323        for(int i=0; i<6; i++) xv[i]=track_.xv[i];
324        for(int i=0; i<6; i++) yv[i]=track_.yv[i];
325        for(int i=0; i<6; i++) zv[i]=track_.zv[i];
326        for(int i=0; i<6; i++) axv[i]=track_.axv[i];
327        for(int i=0; i<6; i++) ayv[i]=track_.ayv[i];
328        for(int i=0; i<5; i++) {
329            for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j];
330        }
331    };
332    /*
333     * Reset the parameters fit
334     */
335    void TrkTrack::FitReset(){
336        for(int i=0; i<5; i++) al[i]=-9999.;
337        chi2=0.;
338        nstep=0;
339        for(int i=0; i<6; i++) xv[i]=0.;
340        for(int i=0; i<6; i++) yv[i]=0.;
341        for(int i=0; i<6; i++) zv[i]=0.;
342        for(int i=0; i<6; i++) axv[i]=0.;
343        for(int i=0; i<6; i++) ayv[i]=0.;
344        for(int i=0; i<5; i++) {
345            for(int j=0; j<5; j++) coval[i][j]=0.;
346        }
347    }
348    
349    //--------------------------------------
350    //
351    //
352    //--------------------------------------
353    void TrkTrack::Clear(){
354            seqno = -1;
355            image = -1;
356            chi2  = 0;
357            nstep = 0;
358            for(int it1=0;it1<5;it1++){
359                    al[it1] = 0;
360                    for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;
361            };
362            for(int ip=0;ip<6;ip++){
363                    xgood[ip]  = 0;
364                    ygood[ip]  = 0;
365                    xm[ip]     = 0;
366                    ym[ip]     = 0;
367                    zm[ip]     = 0;
368                    resx[ip]   = 0;
369                    resy[ip]   = 0;
370                    xv[ip]     = 0;
371                    yv[ip]     = 0;
372                    zv[ip]     = 0;
373                    axv[ip]    = 0;
374                    ayv[ip]    = 0;
375                    dedx_x[ip] = 0;
376                    dedx_y[ip] = 0;
377    //              clx[ip]    = 0;
378    //              cly[ip]    = 0;
379            };
380            clx->Clear();
381            cly->Clear();
382    };
383    //--------------------------------------
384    //
385    //
386    //--------------------------------------
387    void TrkTrack::Delete(){
388            Clear();
389            clx->Delete();
390            cly->Delete();
391    };
392            //--------------------------------------
393    //
394    //
395    //--------------------------------------
396    
397  //--------------------------------------  //--------------------------------------
398  //  //
399  //  //
# Line 243  void TrkSinglet::Dump(){ Line 433  void TrkSinglet::Dump(){
433  //  //
434  //--------------------------------------  //--------------------------------------
435  TrkLevel2::TrkLevel2(){  TrkLevel2::TrkLevel2(){
436      good2    = -1;  //    good2    = -1;
437      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
438          crc[i] = -1;  //      crc[i] = -1;
439      };                  good[i] = -1;
440            };
441      Track    = new TClonesArray("TrkTrack");      Track    = new TClonesArray("TrkTrack");
442      SingletX = new TClonesArray("TrkSinglet");      SingletX = new TClonesArray("TrkSinglet");
443      SingletY = new TClonesArray("TrkSinglet");      SingletY = new TClonesArray("TrkSinglet");
# Line 259  TrkLevel2::TrkLevel2(){ Line 450  TrkLevel2::TrkLevel2(){
450  //  //
451  //--------------------------------------  //--------------------------------------
452  void TrkLevel2::Dump(){  void TrkLevel2::Dump(){
453            
454      TClonesArray &t  = *Track;      TClonesArray &t  = *Track;
455      TClonesArray &sx = *SingletX;      TClonesArray &sx = *SingletX;
456      TClonesArray &sy = *SingletY;      TClonesArray &sy = *SingletY;
457            //
458      cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";      cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
459      cout << endl << "good2    : " << good2;      cout << endl << "good     : "; for(int i=0; i<12; i++) cout << good[i]<<" ";
     cout << endl << "crc      : "; for(int i=0; i<12; i++) cout << crc[i];  
460      cout << endl << "ntrk()   : " << this->ntrk() ;      cout << endl << "ntrk()   : " << this->ntrk() ;
461      cout << endl << "nclsx()  : " << this->nclsx();      cout << endl << "nclsx()  : " << this->nclsx();
462      cout << endl << "nclsy()  : " << this->nclsy();      cout << endl << "nclsy()  : " << this->nclsy();
# Line 281  void TrkLevel2::Dump(){ Line 472  void TrkLevel2::Dump(){
472   * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common).   * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common).
473   */   */
474  void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){  void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){
475      //  
476  //    Track    = new TClonesArray("TrkTrack");          //  temporary objects:
 //    SingletX = new TClonesArray("TrkSinglet");  
 //    SingletY = new TClonesArray("TrkSinglet");  
 //  temporary objects:  
477      TrkSinglet* t_singlet = new TrkSinglet();      TrkSinglet* t_singlet = new TrkSinglet();
478      TrkTrack*   t_track   = new TrkTrack();      TrkTrack*   t_track   = new TrkTrack();
479  //  general variables  
480      good2 = l2->good2;          //  **** general variables ****
481    //    good2 = l2->good2;
482      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
483          crc[i] = l2->crc[i];  //              crc[i] = l2->crc[i];
484      };                  good[i] = l2->good[i];
485  //  *** TRACKS ***          };
486            //  *** TRACKS ***
487      TClonesArray &t = *Track;      TClonesArray &t = *Track;
488      for(int i=0; i<l2->ntrk; i++){      for(int i=0; i<l2->ntrk; i++){
489                  t_track->seqno = i;// NBNBNBNB deve sempre essere = i                  t_track->seqno = i;// NBNBNBNB deve sempre essere = i
490                  t_track->image = l2->image[i]-1;                  t_track->image = l2->image[i]-1;
491          //      cout << "track "<<i<<t_track->seqno << t_track->image<<endl;          //      cout << "track "<<i<<t_track->seqno << t_track->image<<endl;
492                  t_track->chi2  = l2->chi2_nt[i];                  t_track->chi2  = l2->chi2_nt[i];
493                    t_track->nstep = l2->nstep_nt[i];
494                  for(int it1=0;it1<5;it1++){                  for(int it1=0;it1<5;it1++){
495                          t_track->al[it1] = l2->al_nt[i][it1];                          t_track->al[it1] = l2->al_nt[i][it1];
496                          for(int it2=0;it2<5;it2++)                          for(int it2=0;it2<5;it2++)
# Line 365  void TrkLevel2::SetFromLevel2Struct(cTrk Line 556  void TrkLevel2::SetFromLevel2Struct(cTrk
556          TrkSinglet* t_singlet = new TrkSinglet();          TrkSinglet* t_singlet = new TrkSinglet();
557          TrkTrack*   t_track   = new TrkTrack();          TrkTrack*   t_track   = new TrkTrack();
558  // general variables  // general variables
559          good2 = l2->good2;  //      good2 = l2->good2;
560          for(Int_t i=0; i<12 ; i++){          for(Int_t i=0; i<12 ; i++){
561                  crc[i] = l2->crc[i];  //              crc[i] = l2->crc[i];
562                    good[i] = l2->good[i];
563          };          };
564  // *** TRACKS ***  // *** TRACKS ***
565          TClonesArray &t = *Track;          TClonesArray &t = *Track;
# Line 376  void TrkLevel2::SetFromLevel2Struct(cTrk Line 568  void TrkLevel2::SetFromLevel2Struct(cTrk
568                  t_track->image = l2->image[i]-1;                  t_track->image = l2->image[i]-1;
569  //              cout << "track "<<i<<t_track->seqno << t_track->image<<endl;  //              cout << "track "<<i<<t_track->seqno << t_track->image<<endl;
570                  t_track->chi2  = l2->chi2_nt[i];                  t_track->chi2  = l2->chi2_nt[i];
571                    t_track->nstep = l2->nstep_nt[i];
572                  for(int it1=0;it1<5;it1++){                  for(int it1=0;it1<5;it1++){
573                          t_track->al[it1] = l2->al_nt[i][it1];                          t_track->al[it1] = l2->al_nt[i][it1];
574                          for(int it2=0;it2<5;it2++)                          for(int it2=0;it2<5;it2++)
# Line 402  void TrkLevel2::SetFromLevel2Struct(cTrk Line 595  void TrkLevel2::SetFromLevel2Struct(cTrk
595  //                      t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1);  //                      t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1);
596                          if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip);                          if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip);
597                          if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip);                          if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip);
598    //                      if(t_track->ygood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltry[i][ip] "<<l2->cltry[i][ip]<< " l1->GetCluster(l2->cltry[i][ip]-1) "<<l1->GetCluster(l2->cltry[i][ip]-1)<<endl;
599    //                      if(t_track->xgood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltrx[i][ip] "<<l2->cltrx[i][ip]<< " l1->GetCluster(l2->cltrx[i][ip]-1) "<<l1->GetCluster(l2->cltrx[i][ip]-1)<<endl;
600                          //-----------------------------------------------------                          //-----------------------------------------------------
601                  };                  };
602                  new(t[i]) TrkTrack(*t_track);                  new(t[i]) TrkTrack(*t_track);
# Line 417  void TrkLevel2::SetFromLevel2Struct(cTrk Line 612  void TrkLevel2::SetFromLevel2Struct(cTrk
612                  //-----------------------------------------------------                  //-----------------------------------------------------
613  //              cout << "singolo x "<<i<<"  --  "<<  l2->clsx[i] <<endl;  //              cout << "singolo x "<<i<<"  --  "<<  l2->clsx[i] <<endl;
614                  t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);                  t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
615    //              cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl;          
616                  //-----------------------------------------------------                  //-----------------------------------------------------
617                  new(sx[i]) TrkSinglet(*t_singlet);                  new(sx[i]) TrkSinglet(*t_singlet);
618                  t_singlet->Clear();                  t_singlet->Clear();
# Line 430  void TrkLevel2::SetFromLevel2Struct(cTrk Line 626  void TrkLevel2::SetFromLevel2Struct(cTrk
626                  //-----------------------------------------------------                  //-----------------------------------------------------
627  //              cout << "singolo y "<<i<<"  --  "<<  l2->clsy[i] <<endl;  //              cout << "singolo y "<<i<<"  --  "<<  l2->clsy[i] <<endl;
628                  t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);                  t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
629    //              cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl;          
630                  //-----------------------------------------------------                  //-----------------------------------------------------
631                  new(sy[i]) TrkSinglet(*t_singlet);                  new(sy[i]) TrkSinglet(*t_singlet);
632                  t_singlet->Clear();                  t_singlet->Clear();
# Line 445  void TrkLevel2::SetFromLevel2Struct(cTrk Line 642  void TrkLevel2::SetFromLevel2Struct(cTrk
642  void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const {  void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const {
643        
644  //  general variables  //  general variables
645      l2->good2 = good2 ;  //    l2->good2 = good2 ;
646      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
647          l2->crc[i] = crc[i];  //      l2->crc[i] = crc[i];
648                    l2->good[i] = good[i];
649      };      };
650  //  *** TRACKS ***  //  *** TRACKS ***
651    
# Line 455  void TrkLevel2::GetLevel2Struct(cTrkLeve Line 653  void TrkLevel2::GetLevel2Struct(cTrkLeve
653      for(Int_t i=0;i<l2->ntrk;i++){      for(Int_t i=0;i<l2->ntrk;i++){
654        l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image;        l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image;
655        l2->chi2_nt[i] =  ((TrkTrack *)Track->At(i))->chi2;        l2->chi2_nt[i] =  ((TrkTrack *)Track->At(i))->chi2;
656        for(int it1=0;it1<5;it1++){            l2->nstep_nt[i] =  ((TrkTrack *)Track->At(i))->nstep;
657              for(int it1=0;it1<5;it1++){
658          l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1];          l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1];
659          for(int it2=0;it2<5;it2++)          for(int it2=0;it2<5;it2++)
660            l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2];            l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2];
# Line 499  void TrkLevel2::GetLevel2Struct(cTrkLeve Line 698  void TrkLevel2::GetLevel2Struct(cTrkLeve
698  //  //
699  //--------------------------------------  //--------------------------------------
700  void TrkLevel2::Clear(){  void TrkLevel2::Clear(){
701      good2    = -1;  //    good2    = -1;
702      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
703          crc[i] = -1;  //      crc[i] = -1;
704      };                  good[i] = -1;
705            };
706  /*    Track->RemoveAll();  /*    Track->RemoveAll();
707      SingletX->RemoveAll();      SingletX->RemoveAll();
708      SingletY->RemoveAll();*/      SingletY->RemoveAll();*/
# Line 515  void TrkLevel2::Clear(){ Line 715  void TrkLevel2::Clear(){
715  //  //
716  //  //
717  //--------------------------------------  //--------------------------------------
718    void TrkLevel2::Delete(){
719            
720            Clear();
721            Track->Delete();
722            SingletX->Delete();
723            SingletY->Delete();
724    }
725    //--------------------------------------
726    //
727    //
728    //--------------------------------------
729  /**  /**
730   * Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it).   * Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it).
731   * This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used.   * This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used.
732   */   */
 // TClonesArray *TrkLevel2::GetTracks(){  
 //      TClonesArray *sorted = GetTracks_NFitSorted();  
 //      return sorted;  
 // };  
   
 /*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){  
   
     TClonesArray *sorted = new TClonesArray("TrkTrack");  
     TClonesArray &t = *Track;  
     TClonesArray &ts = *sorted;  
     int N=this->ntrk();  
     vector<int> m(N); for(int i=0; i<N; i++)m[i]=1;  
   
     int indo=0;  
     int indi=0;  
     while(N != 0){  
         float chi2ref=1000000;  
         for(int i=0; i<this->ntrk(); i++){  
             if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){  
                 chi2ref = ((TrkTrack *)t[i])->chi2;  
                 indi = i;  
             }  
         }  
         if( ((TrkTrack *)t[indi])->image != -1 ){  
             m[((TrkTrack *)t[indi])->image] = 0;  
             N--;  
         }  
         new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]);  
         m[indi] = 0;  
         N--;      
         indo++;  
     }  
     return sorted;  
 }*/  
 /*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){  
   
         TClonesArray *sorted = new TClonesArray("TrkTrack");      
     TClonesArray &t  = *Track;  
         TClonesArray &ts = *sorted;  
 //    TClonesArray &ts = *PhysicalTrack;  
         int N = ntrk();  
     vector<int> m(N); for(int i=0; i<N; i++)m[i]=1;  
 //      int m[50]; for(int i=0; i<N; i++)m[i]=1;  
           
     int indo=0;  
     int indi=0;  
     while(N != 0){  
                 int nfit =0;  
                 float chi2ref = numeric_limits<float>::max();  
                 // first loop to search maximum num. of fit points  
                 for(int i=0; i < ntrk(); i++){  
 //                      if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl;  
                         if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){  
                         nfit =    ((TrkTrack *)t[i])->GetNtot();  
                         }  
                 }  
                 //second loop to search minimum chi2 among selected  
                 for(int i=0; i<this->ntrk(); i++){  
                         if(    ((TrkTrack *)t[i])->chi2 < chi2ref  
                         && ((TrkTrack *)t[i])->GetNtot()== nfit  
                         && m[i]==1){  
                         chi2ref = ((TrkTrack *)t[i])->chi2;  
                         indi = i;  
         //              cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl;  
                         }  
                 }  
                 if( ((TrkTrack *)t[indi])->HasImage() ){  
                         m[((TrkTrack *)t[indi])->image] = 0;  
                         N--;  
           
         //          Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->GetNtot();  
         //          Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->chi2;  
                           
         //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;  
                 }  
                 new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]);  
                 m[indi] = 0;  
 //              cout << "SORTED "<< indo << " "<< indi << " "<< N << endl;  
                 N--;      
                 indo++;  
     }  
         m.clear();  
     return sorted;  
 //    return PhysicalTrack;  
 }*/  
 //TClonesArray *TrkLevel2::GetTracks_NFitSorted(){  
733  TRefArray *TrkLevel2::GetTracks_NFitSorted(){  TRefArray *TrkLevel2::GetTracks_NFitSorted(){
734    
 //      cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl;  
 //      TClonesArray *sorted = new TClonesArray("TrkTrack");  
 //      TClonesArray &ts = *sorted;  
735          TRefArray *sorted = new TRefArray();          TRefArray *sorted = new TRefArray();
736                    
737          TClonesArray &t  = *Track;          TClonesArray &t  = *Track;
# Line 645  TRefArray *TrkLevel2::GetTracks_NFitSort Line 767  TRefArray *TrkLevel2::GetTracks_NFitSort
767                          m[((TrkTrack *)t[indi])->image] = 0;                          m[((TrkTrack *)t[indi])->image] = 0;
768                          N--;                          N--;
769                    
         //          Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->GetNtot();  
         //          Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->chi2;  
                           
770          //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;          //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
771                  };                  };
 //              new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]);  
 //              cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl;  
772                  sorted->Add( (TrkTrack*)t[indi] );                        sorted->Add( (TrkTrack*)t[indi] );      
773                                    
774                  m[indi] = 0;                  m[indi] = 0;
# Line 731  TrkSinglet *TrkLevel2::GetSingletY(int i Line 848  TrkSinglet *TrkLevel2::GetSingletY(int i
848   * Retrieves the it-th "physical" track, sorted by the method GetNTracks().   * Retrieves the it-th "physical" track, sorted by the method GetNTracks().
849   * @param it Track number, ranging from 0 to GetNTracks().   * @param it Track number, ranging from 0 to GetNTracks().
850   */   */
851  /*TrkTrack *TrkLevel2::GetTrack(int it){  
       
     if(it >= this->GetNTracks()){  
         cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl;  
         cout << "                Physical tracks GetNTracks() = "<< this->ntrk() << endl;  
         return 0;  
     }  
         TClonesArray* sorted = GetTracks();  
         TClonesArray &ts = *sorted;  
           
 //    TrkTrack *track = (TrkTrack*)ts[it];  
         TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia  
         sorted->Delete("all");////TEMPORANEO  
         return track;  
 }*/  
852  TrkTrack *TrkLevel2::GetTrack(int it){  TrkTrack *TrkLevel2::GetTrack(int it){
853            
854          if(it >= this->GetNTracks()){          if(it >= this->GetNTracks()){
# Line 766  Int_t TrkLevel2::GetNTracks(){ Line 869  Int_t TrkLevel2::GetNTracks(){
869                                    
870          Float_t ntot=0;          Float_t ntot=0;
871          TClonesArray &t = *Track;          TClonesArray &t = *Track;
872          for(int i=0; i<ntrk(); i++) {          for(int i=0; i<ntrk(); i++) {    
873                  if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.;                  if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.;
874                  else ntot+=0.5;                  else ntot+=0.5;
875          }          }
# Line 781  Int_t TrkLevel2::GetNTracks(){ Line 884  Int_t TrkLevel2::GetNTracks(){
884   * Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks().   * Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks().
885   * @param it Track number, ranging from 0 to GetNTracks().   * @param it Track number, ranging from 0 to GetNTracks().
886   */   */
 /*TrkTrack *TrkLevel2::GetTrackImage(int it){  
   
     if(it >= this->GetNTracks()){  
         cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl;  
         cout << "                Physical tracks GetNTracks() = "<< this->ntrk() << endl;  
         return 0;  
     }  
           
         TClonesArray* sorted = GetTracks();  
         TClonesArray &ts = *sorted;  
         TrkTrack *track = (TrkTrack*)ts[it];  
 //    TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it];  
       
         if(!track->HasImage()){  
         cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl;  
         return 0;  
     }  
     TrkTrack *image = (TrkTrack*)(*Track)[track->image];  
   
 //      GetTracks()->Delete(); ////TEMPORANEO  
         sorted->Delete(); ////TEMPORANEO  
           
     return image;  
       
 }*/  
887  TrkTrack *TrkLevel2::GetTrackImage(int it){  TrkTrack *TrkLevel2::GetTrackImage(int it){
888    
889          if(it >= this->GetNTracks()){          if(it >= this->GetNTracks()){
# Line 984  float Trajectory::GetLength(int ifirst, Line 1062  float Trajectory::GetLength(int ifirst,
1062    
1063  }  }
1064    
1065    
1066  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
1067  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
1068  ClassImp(TrkTrack);  ClassImp(TrkTrack);

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.23