/[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.2 by pam-fi, Thu Jun 1 09:03:09 2006 UTC revision 1.5 by pam-fi, Fri Jun 30 09:48:15 2006 UTC
# Line 18  extern "C" {     Line 18  extern "C" {    
18  //  //
19  //--------------------------------------  //--------------------------------------
20  TrkTrack::TrkTrack(){  TrkTrack::TrkTrack(){
21      image = 0;      seqno = -1;
22        image = -1;
23      chi2  = 0;      chi2  = 0;
24      for(int it1=0;it1<5;it1++){      for(int it1=0;it1<5;it1++){
25          al[it1] = 0;          al[it1] = 0;
# Line 47  TrkTrack::TrkTrack(){ Line 48  TrkTrack::TrkTrack(){
48  //  //
49  //--------------------------------------  //--------------------------------------
50  TrkTrack::TrkTrack(const TrkTrack& t){  TrkTrack::TrkTrack(const TrkTrack& t){
51        seqno = t.seqno;
52      image = t.image;      image = t.image;
53      chi2  = t.chi2;      chi2  = t.chi2;
54      for(int it1=0;it1<5;it1++){      for(int it1=0;it1<5;it1++){
# Line 238  TrkLevel2::TrkLevel2(){ Line 240  TrkLevel2::TrkLevel2(){
240      Track    = new TClonesArray("TrkTrack");      Track    = new TClonesArray("TrkTrack");
241      SingletX = new TClonesArray("TrkSinglet");      SingletX = new TClonesArray("TrkSinglet");
242      SingletY = new TClonesArray("TrkSinglet");      SingletY = new TClonesArray("TrkSinglet");
243    //    Track    = 0;
244    //    Singlet = 0;
245    //    SingletY = 0;
246  }  }
247  //--------------------------------------  //--------------------------------------
248  //  //
# Line 266  void TrkLevel2::Dump(){ Line 271  void TrkLevel2::Dump(){
271   * 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).
272   */   */
273  void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){  void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){
274        //
275    //    Track    = new TClonesArray("TrkTrack");
276    //    SingletX = new TClonesArray("TrkSinglet");
277    //    SingletY = new TClonesArray("TrkSinglet");
278  //  temporary objects:  //  temporary objects:
279      TrkSinglet* t_singlet = new TrkSinglet();      TrkSinglet* t_singlet = new TrkSinglet();
280      TrkTrack*   t_track   = new TrkTrack();      TrkTrack*   t_track   = new TrkTrack();
# Line 277  void TrkLevel2::FillCommonVar(cTrkLevel2 Line 286  void TrkLevel2::FillCommonVar(cTrkLevel2
286  //  *** TRACKS ***  //  *** TRACKS ***
287      TClonesArray &t = *Track;      TClonesArray &t = *Track;
288      for(int i=0; i<l2->ntrk; i++){      for(int i=0; i<l2->ntrk; i++){
289            t_track->seqno = i;
290          t_track->image = l2->image[i]-1;          t_track->image = l2->image[i]-1;
291    //      cout << "track "<<i<<t_track->seqno << t_track->image<<endl;
292          t_track->chi2  = l2->chi2_nt[i];          t_track->chi2  = l2->chi2_nt[i];
293          for(int it1=0;it1<5;it1++){          for(int it1=0;it1<5;it1++){
294              t_track->al[it1] = l2->al_nt[i][it1];              t_track->al[it1] = l2->al_nt[i][it1];
# Line 322  void TrkLevel2::FillCommonVar(cTrkLevel2 Line 333  void TrkLevel2::FillCommonVar(cTrkLevel2
333          new(sy[i]) TrkSinglet(*t_singlet);          new(sy[i]) TrkSinglet(*t_singlet);
334          t_singlet->Clear();          t_singlet->Clear();
335          };          };
336            
337            delete t_track;
338            delete t_singlet;
339  }  }
340  //--------------------------------------  //--------------------------------------
341  //  //
# Line 332  void TrkLevel2::Clear(){ Line 346  void TrkLevel2::Clear(){
346      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
347          crc[i] = -1;          crc[i] = -1;
348      };      };
349      Track->RemoveAll();  /*    Track->RemoveAll();
350      SingletX->RemoveAll();      SingletX->RemoveAll();
351      SingletY->RemoveAll();      SingletY->RemoveAll();*/
352            // modify to avoid memory leakage
353            Track->Clear();
354            SingletX->Clear();
355            SingletY->Clear();
356  }  }
357  //--------------------------------------  //--------------------------------------
358  //  //
# Line 345  void TrkLevel2::Clear(){ Line 363  void TrkLevel2::Clear(){
363   * 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.
364   */   */
365  TClonesArray *TrkLevel2::GetTracks(){  TClonesArray *TrkLevel2::GetTracks(){
366        TClonesArray *sorted = GetTracks_NFitSorted();
367        return sorted;
368    };
369    
370    TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){
371    
372      TClonesArray *sorted = new TClonesArray("TrkTrack");      TClonesArray *sorted = new TClonesArray("TrkTrack");
373      TClonesArray &t = *Track;      TClonesArray &t = *Track;
# Line 373  TClonesArray *TrkLevel2::GetTracks(){ Line 396  TClonesArray *TrkLevel2::GetTracks(){
396      }      }
397      return sorted;      return sorted;
398  }  }
399    TClonesArray *TrkLevel2::GetTracks_NFitSorted(){
400    
401        TClonesArray *sorted = new TClonesArray("TrkTrack");
402        TClonesArray &t = *Track;
403        TClonesArray &ts = *sorted;
404        int N=this->ntrk();
405        vector<int> m(N); for(int i=0; i<N; i++)m[i]=1;
406    
407        int indo=0;
408        int indi=0;
409        while(N != 0){
410            int nfit =0;
411            float chi2ref=1000000;
412            // first loop to search maximum num. of fit points
413            for(int i=0; i<this->ntrk(); i++){
414                if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){
415                    nfit =    ((TrkTrack *)t[i])->GetNtot();
416    //              cout << "1** "<<i<< " " << nfit<<endl;
417                }
418            }
419            //second loop to search minimum chi2 among selected
420            for(int i=0; i<this->ntrk(); i++){
421                if(    ((TrkTrack *)t[i])->chi2 < chi2ref
422                    && ((TrkTrack *)t[i])->GetNtot()== nfit
423                    && m[i]==1){
424                    chi2ref = ((TrkTrack *)t[i])->chi2;
425                    indi = i;
426    //              cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl;
427                }
428            }
429            if( ((TrkTrack *)t[indi])->HasImage() ){
430                m[((TrkTrack *)t[indi])->image] = 0;
431                N--;
432    
433    //          Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->GetNtot();
434    //          Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image  ])->chi2;
435                    
436    //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
437            }
438            new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]);
439            m[indi] = 0;
440            N--;    
441            indo++;
442        }
443        return sorted;
444    }
445  //--------------------------------------  //--------------------------------------
446  //  //
447  //  //
# Line 409  TrkTrack *TrkLevel2::GetTrack(int it){ Line 478  TrkTrack *TrkLevel2::GetTrack(int it){
478          return 0;          return 0;
479      }      }
480      TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it];      TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it];
481            GetTracks()->Delete();////TEMPORANEO
482      return track;      return track;
483  }  }
484    Int_t TrkLevel2::GetNTracks(){
485            Int_t ntot=0;
486            ntot = GetTracks()->GetEntries();
487            GetTracks()->Delete();////TEMPORANEO
488            return ntot;
489    };
490  //--------------------------------------  //--------------------------------------
491  //  //
492  //  //

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23