/[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.13 by pam-fi, Thu Oct 26 16:22:37 2006 UTC
# Line 11  using namespace std; Line 11  using namespace std;
11  extern "C" {      extern "C" {    
12      void dotrack_(int*, double*, double*, double*, double*, int*);      void dotrack_(int*, double*, double*, double*, double*, int*);
13      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);
14      int  readb_(const char*);      int  readb_(const char*);
15        void mini2_(int*,int*,int*);
16  }  }
17  //--------------------------------------  //--------------------------------------
18  //  //
# Line 21  TrkTrack::TrkTrack(){ Line 22  TrkTrack::TrkTrack(){
22      seqno = -1;      seqno = -1;
23      image = -1;      image = -1;
24      chi2  = 0;      chi2  = 0;
25      for(int it1=0;it1<5;it1++){          nstep = 0;
26            for(int it1=0;it1<5;it1++){
27                  al[it1] = 0;                  al[it1] = 0;
28                  for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;                  for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;
29      };      };
# Line 54  TrkTrack::TrkTrack(const TrkTrack& t){ Line 56  TrkTrack::TrkTrack(const TrkTrack& t){
56      seqno = t.seqno;      seqno = t.seqno;
57      image = t.image;      image = t.image;
58      chi2  = t.chi2;      chi2  = t.chi2;
59      for(int it1=0;it1<5;it1++){          nstep = t.nstep;
60            for(int it1=0;it1<5;it1++){
61                  al[it1] = t.al[it1];                  al[it1] = t.al[it1];
62                  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];
63      };      };
# Line 194  Float_t TrkTrack::GetDEDX(){ Line 197  Float_t TrkTrack::GetDEDX(){
197  //--------------------------------------  //--------------------------------------
198  void TrkTrack::Dump(){  void TrkTrack::Dump(){
199      cout << endl << "========== Track " ;      cout << endl << "========== Track " ;
200        cout << endl << "seq.  n. : "<< seqno;
201        cout << endl << "image n. : "<< image;
202      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] << " ";
203      cout << endl << "chi^2    : "<< chi2;      cout << endl << "chi^2    : "<< chi2;
204        cout << endl << "n.step   : "<< nstep;
205      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] ;
206      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] ;
207      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] << " ";
208      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] << " ";
209      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] << " ";
210        cout << endl << "xv       : "; for(int i=0; i<6; i++)cout << xv[i] << " ";
211        cout << endl << "yv       : "; for(int i=0; i<6; i++)cout << yv[i] << " ";
212        cout << endl << "zv       : "; for(int i=0; i<6; i++)cout << zv[i] << " ";
213        cout << endl << "resx     : "; for(int i=0; i<6; i++)cout << resx[i] << " ";
214        cout << endl << "resy     : "; for(int i=0; i<6; i++)cout << resy[i] << " ";
215        cout << endl << "coval    : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" ";
216        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[1][i]<<" ";
217        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[2][i]<<" ";
218        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[3][i]<<" ";
219        cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[4][i]<<" ";
220      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] << " ";
221      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] << " ";
222  }  }
223    /**
224     * Set the TrkTrack position measurements
225     */
226    void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){
227        for(int i=0; i<6; i++) xm[i]=*xmeas++;
228        for(int i=0; i<6; i++) ym[i]=*ymeas++;
229        for(int i=0; i<6; i++) zm[i]=*zmeas++;
230    }
231    /**
232     * Set the TrkTrack position resolution
233     */
234    void TrkTrack::SetResolution(double *rx, double *ry){
235        for(int i=0; i<6; i++) resx[i]=*rx++;
236        for(int i=0; i<6; i++) resy[i]=*ry++;
237    }
238    /**
239     * Set the TrkTrack good measurement
240     */
241    void TrkTrack::SetGood(int *xg, int *yg){
242        for(int i=0; i<6; i++) xgood[i]=*xg++;
243        for(int i=0; i<6; i++) ygood[i]=*yg++;
244    }
245    
246    /**
247     * Load the magnetic field
248     */
249    void TrkTrack::LoadField(TString s){
250        readb_(s.Data());
251    };
252    /**
253     * Tracking method. It calls F77 mini routine.
254     */
255    void TrkTrack::Fit(double pfixed, int& fail, int iprint){
256        extern cMini2track track_;
257        fail = 0;
258    //    extern cMini2fitinfo fit_info_;
259    //    extern void mini_2_(int*,int*);
260    //    track_.xm[0]=1.0;
261        for(int i=0; i<6; i++) track_.xm[i]=xm[i];
262        for(int i=0; i<6; i++) track_.ym[i]=ym[i];
263        for(int i=0; i<6; i++) track_.zm[i]=zm[i];
264        for(int i=0; i<6; i++) track_.resx[i]=resx[i];
265        for(int i=0; i<6; i++) track_.resy[i]=resy[i];
266        for(int i=0; i<6; i++) track_.xgood[i]=xgood[i];
267        for(int i=0; i<6; i++) track_.ygood[i]=ygood[i];
268    // initial guess of "al" with linear fit
269        if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){
270            double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.;
271            double det, ax, ay, bx, by;
272            for(int i=0; i<NPLANE; i++) {
273                szz=szz+zm[i]*zm[i];
274                szx=szx+zm[i]*xm[i];
275                szy=szy+zm[i]*ym[i];
276                ssx=ssx+xm[i];
277                ssy=ssy+ym[i];
278                sz=sz+zm[i];
279                s1=s1+1.;
280            }
281            det=szz*s1-sz*sz;
282            ax=(szx*s1-sz*ssx)/det;
283            bx=(szz*ssx-szx*sz)/det;
284            ay=(szy*s1-sz*ssy)/det;
285            by=(szz*ssy-szy*sz)/det;
286            al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes
287            al[1]=ay*23.5+by; //  "  
288            al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.);
289            al[3]=0.;
290            if( (ax!=0.)||(ay!=0.) ) {
291                al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2)));
292                if(ax<0.) al[3]=acos(-1.)-al[3];
293            }
294            al[4]=0.;
295        }
296    // end guess
297        for(int i=0; i<5; i++) track_.al[i]=al[i];
298        if(pfixed!=0.) {
299            al[4]=1./pfixed;      // to fix the momentum
300            track_.pfixed=pfixed; //         "
301        }
302        int istep=0;
303        int ifail=0;
304        mini2_(&istep,&ifail, &iprint);
305        if(ifail!=0) {
306            if(iprint==1)cout << "ERROR: ifail= " << ifail << endl;
307            fail = 1;
308    //      return;
309        }
310    
311    //    cout << endl << "eta ===> " << track_.al[4] << endl;
312    
313        for(int i=0; i<5; i++) al[i]=track_.al[i];
314        chi2=track_.chi2;
315        nstep=track_.nstep;
316        for(int i=0; i<6; i++) xv[i]=track_.xv[i];
317        for(int i=0; i<6; i++) yv[i]=track_.yv[i];
318        for(int i=0; i<6; i++) zv[i]=track_.zv[i];
319        for(int i=0; i<6; i++) axv[i]=track_.axv[i];
320        for(int i=0; i<6; i++) ayv[i]=track_.ayv[i];
321        for(int i=0; i<5; i++) {
322            for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j];
323        }
324    };
325    /*
326     * Reset the parameters fit
327     */
328    void TrkTrack::FitReset(){
329        for(int i=0; i<5; i++) al[i]=-9999.;
330        chi2=0.;
331        nstep=0;
332        for(int i=0; i<6; i++) xv[i]=0.;
333        for(int i=0; i<6; i++) yv[i]=0.;
334        for(int i=0; i<6; i++) zv[i]=0.;
335        for(int i=0; i<6; i++) axv[i]=0.;
336        for(int i=0; i<6; i++) ayv[i]=0.;
337        for(int i=0; i<5; i++) {
338            for(int j=0; j<5; j++) coval[i][j]=0.;
339        }
340    }
341    
342    //--------------------------------------
343    //
344    //
345    //--------------------------------------
346    void TrkTrack::Clear(){
347            seqno = -1;
348            image = -1;
349            chi2  = 0;
350            nstep = 0;
351            for(int it1=0;it1<5;it1++){
352                    al[it1] = 0;
353                    for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;
354            };
355            for(int ip=0;ip<6;ip++){
356                    xgood[ip]  = 0;
357                    ygood[ip]  = 0;
358                    xm[ip]     = 0;
359                    ym[ip]     = 0;
360                    zm[ip]     = 0;
361                    resx[ip]   = 0;
362                    resy[ip]   = 0;
363                    xv[ip]     = 0;
364                    yv[ip]     = 0;
365                    zv[ip]     = 0;
366                    axv[ip]    = 0;
367                    ayv[ip]    = 0;
368                    dedx_x[ip] = 0;
369                    dedx_y[ip] = 0;
370    //              clx[ip]    = 0;
371    //              cly[ip]    = 0;
372            };
373            clx->Clear();
374            cly->Clear();
375    };
376    //--------------------------------------
377    //
378    //
379    //--------------------------------------
380    void TrkTrack::Delete(){
381            Clear();
382            clx->Delete();
383            cly->Delete();
384    };
385            //--------------------------------------
386    //
387    //
388    //--------------------------------------
389    
390  //--------------------------------------  //--------------------------------------
391  //  //
392  //  //
# Line 243  void TrkSinglet::Dump(){ Line 426  void TrkSinglet::Dump(){
426  //  //
427  //--------------------------------------  //--------------------------------------
428  TrkLevel2::TrkLevel2(){  TrkLevel2::TrkLevel2(){
429      good2    = -1;  //    good2    = -1;
430      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
431          crc[i] = -1;  //      crc[i] = -1;
432      };                  good[i] = -1;
433            };
434      Track    = new TClonesArray("TrkTrack");      Track    = new TClonesArray("TrkTrack");
435      SingletX = new TClonesArray("TrkSinglet");      SingletX = new TClonesArray("TrkSinglet");
436      SingletY = new TClonesArray("TrkSinglet");      SingletY = new TClonesArray("TrkSinglet");
# Line 259  TrkLevel2::TrkLevel2(){ Line 443  TrkLevel2::TrkLevel2(){
443  //  //
444  //--------------------------------------  //--------------------------------------
445  void TrkLevel2::Dump(){  void TrkLevel2::Dump(){
446            
447      TClonesArray &t  = *Track;      TClonesArray &t  = *Track;
448      TClonesArray &sx = *SingletX;      TClonesArray &sx = *SingletX;
449      TClonesArray &sy = *SingletY;      TClonesArray &sy = *SingletY;
450            //
451      cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";      cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
452      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];  
453      cout << endl << "ntrk()   : " << this->ntrk() ;      cout << endl << "ntrk()   : " << this->ntrk() ;
454      cout << endl << "nclsx()  : " << this->nclsx();      cout << endl << "nclsx()  : " << this->nclsx();
455      cout << endl << "nclsy()  : " << this->nclsy();      cout << endl << "nclsy()  : " << this->nclsy();
# Line 281  void TrkLevel2::Dump(){ Line 465  void TrkLevel2::Dump(){
465   * 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).
466   */   */
467  void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){  void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){
468      //  
469  //    Track    = new TClonesArray("TrkTrack");          //  temporary objects:
 //    SingletX = new TClonesArray("TrkSinglet");  
 //    SingletY = new TClonesArray("TrkSinglet");  
 //  temporary objects:  
470      TrkSinglet* t_singlet = new TrkSinglet();      TrkSinglet* t_singlet = new TrkSinglet();
471      TrkTrack*   t_track   = new TrkTrack();      TrkTrack*   t_track   = new TrkTrack();
472  //  general variables  
473      good2 = l2->good2;          //  **** general variables ****
474    //    good2 = l2->good2;
475      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
476          crc[i] = l2->crc[i];  //              crc[i] = l2->crc[i];
477      };                  good[i] = l2->good[i];
478  //  *** TRACKS ***          };
479            //  *** TRACKS ***
480      TClonesArray &t = *Track;      TClonesArray &t = *Track;
481      for(int i=0; i<l2->ntrk; i++){      for(int i=0; i<l2->ntrk; i++){
482                  t_track->seqno = i;// NBNBNBNB deve sempre essere = i                  t_track->seqno = i;// NBNBNBNB deve sempre essere = i
483                  t_track->image = l2->image[i]-1;                  t_track->image = l2->image[i]-1;
484          //      cout << "track "<<i<<t_track->seqno << t_track->image<<endl;          //      cout << "track "<<i<<t_track->seqno << t_track->image<<endl;
485                  t_track->chi2  = l2->chi2_nt[i];                  t_track->chi2  = l2->chi2_nt[i];
486                    t_track->nstep = l2->nstep_nt[i];
487                  for(int it1=0;it1<5;it1++){                  for(int it1=0;it1<5;it1++){
488                          t_track->al[it1] = l2->al_nt[i][it1];                          t_track->al[it1] = l2->al_nt[i][it1];
489                          for(int it2=0;it2<5;it2++)                          for(int it2=0;it2<5;it2++)
# Line 365  void TrkLevel2::SetFromLevel2Struct(cTrk Line 549  void TrkLevel2::SetFromLevel2Struct(cTrk
549          TrkSinglet* t_singlet = new TrkSinglet();          TrkSinglet* t_singlet = new TrkSinglet();
550          TrkTrack*   t_track   = new TrkTrack();          TrkTrack*   t_track   = new TrkTrack();
551  // general variables  // general variables
552          good2 = l2->good2;  //      good2 = l2->good2;
553          for(Int_t i=0; i<12 ; i++){          for(Int_t i=0; i<12 ; i++){
554                  crc[i] = l2->crc[i];  //              crc[i] = l2->crc[i];
555                    good[i] = l2->good[i];
556          };          };
557  // *** TRACKS ***  // *** TRACKS ***
558          TClonesArray &t = *Track;          TClonesArray &t = *Track;
# Line 376  void TrkLevel2::SetFromLevel2Struct(cTrk Line 561  void TrkLevel2::SetFromLevel2Struct(cTrk
561                  t_track->image = l2->image[i]-1;                  t_track->image = l2->image[i]-1;
562  //              cout << "track "<<i<<t_track->seqno << t_track->image<<endl;  //              cout << "track "<<i<<t_track->seqno << t_track->image<<endl;
563                  t_track->chi2  = l2->chi2_nt[i];                  t_track->chi2  = l2->chi2_nt[i];
564                    t_track->nstep = l2->nstep_nt[i];
565                  for(int it1=0;it1<5;it1++){                  for(int it1=0;it1<5;it1++){
566                          t_track->al[it1] = l2->al_nt[i][it1];                          t_track->al[it1] = l2->al_nt[i][it1];
567                          for(int it2=0;it2<5;it2++)                          for(int it2=0;it2<5;it2++)
# Line 402  void TrkLevel2::SetFromLevel2Struct(cTrk Line 588  void TrkLevel2::SetFromLevel2Struct(cTrk
588  //                      t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1);  //                      t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1);
589                          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);
590                          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);
591    //                      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;
592    //                      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;
593                          //-----------------------------------------------------                          //-----------------------------------------------------
594                  };                  };
595                  new(t[i]) TrkTrack(*t_track);                  new(t[i]) TrkTrack(*t_track);
# Line 417  void TrkLevel2::SetFromLevel2Struct(cTrk Line 605  void TrkLevel2::SetFromLevel2Struct(cTrk
605                  //-----------------------------------------------------                  //-----------------------------------------------------
606  //              cout << "singolo x "<<i<<"  --  "<<  l2->clsx[i] <<endl;  //              cout << "singolo x "<<i<<"  --  "<<  l2->clsx[i] <<endl;
607                  t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);                  t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
608    //              cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl;          
609                  //-----------------------------------------------------                  //-----------------------------------------------------
610                  new(sx[i]) TrkSinglet(*t_singlet);                  new(sx[i]) TrkSinglet(*t_singlet);
611                  t_singlet->Clear();                  t_singlet->Clear();
# Line 430  void TrkLevel2::SetFromLevel2Struct(cTrk Line 619  void TrkLevel2::SetFromLevel2Struct(cTrk
619                  //-----------------------------------------------------                  //-----------------------------------------------------
620  //              cout << "singolo y "<<i<<"  --  "<<  l2->clsy[i] <<endl;  //              cout << "singolo y "<<i<<"  --  "<<  l2->clsy[i] <<endl;
621                  t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);                  t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
622    //              cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl;          
623                  //-----------------------------------------------------                  //-----------------------------------------------------
624                  new(sy[i]) TrkSinglet(*t_singlet);                  new(sy[i]) TrkSinglet(*t_singlet);
625                  t_singlet->Clear();                  t_singlet->Clear();
# Line 445  void TrkLevel2::SetFromLevel2Struct(cTrk Line 635  void TrkLevel2::SetFromLevel2Struct(cTrk
635  void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const {  void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const {
636        
637  //  general variables  //  general variables
638      l2->good2 = good2 ;  //    l2->good2 = good2 ;
639      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
640          l2->crc[i] = crc[i];  //      l2->crc[i] = crc[i];
641                    l2->good[i] = good[i];
642      };      };
643  //  *** TRACKS ***  //  *** TRACKS ***
644    
# Line 455  void TrkLevel2::GetLevel2Struct(cTrkLeve Line 646  void TrkLevel2::GetLevel2Struct(cTrkLeve
646      for(Int_t i=0;i<l2->ntrk;i++){      for(Int_t i=0;i<l2->ntrk;i++){
647        l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image;        l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image;
648        l2->chi2_nt[i] =  ((TrkTrack *)Track->At(i))->chi2;        l2->chi2_nt[i] =  ((TrkTrack *)Track->At(i))->chi2;
649        for(int it1=0;it1<5;it1++){            l2->nstep_nt[i] =  ((TrkTrack *)Track->At(i))->nstep;
650              for(int it1=0;it1<5;it1++){
651          l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1];          l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1];
652          for(int it2=0;it2<5;it2++)          for(int it2=0;it2<5;it2++)
653            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 691  void TrkLevel2::GetLevel2Struct(cTrkLeve
691  //  //
692  //--------------------------------------  //--------------------------------------
693  void TrkLevel2::Clear(){  void TrkLevel2::Clear(){
694      good2    = -1;  //    good2    = -1;
695      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
696          crc[i] = -1;  //      crc[i] = -1;
697      };                  good[i] = -1;
698            };
699  /*    Track->RemoveAll();  /*    Track->RemoveAll();
700      SingletX->RemoveAll();      SingletX->RemoveAll();
701      SingletY->RemoveAll();*/      SingletY->RemoveAll();*/
# Line 515  void TrkLevel2::Clear(){ Line 708  void TrkLevel2::Clear(){
708  //  //
709  //  //
710  //--------------------------------------  //--------------------------------------
711    void TrkLevel2::Delete(){
712            
713            Clear();
714            Track->Delete();
715            SingletX->Delete();
716            SingletY->Delete();
717    }
718    //--------------------------------------
719    //
720    //
721    //--------------------------------------
722  /**  /**
723   * 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).
724   * 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.
725   */   */
 // 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(){  
726  TRefArray *TrkLevel2::GetTracks_NFitSorted(){  TRefArray *TrkLevel2::GetTracks_NFitSorted(){
727    
 //      cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl;  
 //      TClonesArray *sorted = new TClonesArray("TrkTrack");  
 //      TClonesArray &ts = *sorted;  
728          TRefArray *sorted = new TRefArray();          TRefArray *sorted = new TRefArray();
729                    
730          TClonesArray &t  = *Track;          TClonesArray &t  = *Track;
# Line 645  TRefArray *TrkLevel2::GetTracks_NFitSort Line 760  TRefArray *TrkLevel2::GetTracks_NFitSort
760                          m[((TrkTrack *)t[indi])->image] = 0;                          m[((TrkTrack *)t[indi])->image] = 0;
761                          N--;                          N--;
762                    
         //          Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->GetNtot();  
         //          Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->chi2;  
                           
763          //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;          //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
764                  };                  };
 //              new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]);  
 //              cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl;  
765                  sorted->Add( (TrkTrack*)t[indi] );                        sorted->Add( (TrkTrack*)t[indi] );      
766                                    
767                  m[indi] = 0;                  m[indi] = 0;
# Line 731  TrkSinglet *TrkLevel2::GetSingletY(int i Line 841  TrkSinglet *TrkLevel2::GetSingletY(int i
841   * Retrieves the it-th "physical" track, sorted by the method GetNTracks().   * Retrieves the it-th "physical" track, sorted by the method GetNTracks().
842   * @param it Track number, ranging from 0 to GetNTracks().   * @param it Track number, ranging from 0 to GetNTracks().
843   */   */
844  /*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;  
 }*/  
845  TrkTrack *TrkLevel2::GetTrack(int it){  TrkTrack *TrkLevel2::GetTrack(int it){
846            
847          if(it >= this->GetNTracks()){          if(it >= this->GetNTracks()){
# Line 766  Int_t TrkLevel2::GetNTracks(){ Line 862  Int_t TrkLevel2::GetNTracks(){
862                                    
863          Float_t ntot=0;          Float_t ntot=0;
864          TClonesArray &t = *Track;          TClonesArray &t = *Track;
865          for(int i=0; i<ntrk(); i++) {          for(int i=0; i<ntrk(); i++) {    
866                  if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.;                  if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.;
867                  else ntot+=0.5;                  else ntot+=0.5;
868          }          }
# Line 781  Int_t TrkLevel2::GetNTracks(){ Line 877  Int_t TrkLevel2::GetNTracks(){
877   * 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().
878   * @param it Track number, ranging from 0 to GetNTracks().   * @param it Track number, ranging from 0 to GetNTracks().
879   */   */
 /*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;  
       
 }*/  
880  TrkTrack *TrkLevel2::GetTrackImage(int it){  TrkTrack *TrkLevel2::GetTrackImage(int it){
881    
882          if(it >= this->GetNTracks()){          if(it >= this->GetNTracks()){
# Line 984  float Trajectory::GetLength(int ifirst, Line 1055  float Trajectory::GetLength(int ifirst,
1055    
1056  }  }
1057    
1058    
1059  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
1060  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
1061  ClassImp(TrkTrack);  ClassImp(TrkTrack);

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

  ViewVC Help
Powered by ViewVC 1.1.23