/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Diff of /PamelaLevel2/src/PamLevel2.cpp

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

revision 1.6 by pam-fi, Tue Oct 24 10:24:27 2006 UTC revision 1.8 by pam-fi, Tue Nov 28 10:58:34 2006 UTC
# Line 36  PamTrack::PamTrack(TrkTrack* t, CaloTrkV Line 36  PamTrack::PamTrack(TrkTrack* t, CaloTrkV
36   */   */
37  PamLevel2::PamLevel2(){  PamLevel2::PamLevel2(){
38                    
39      trk_l1_obj  = this->TrkLevel1::GetTrkLevel1();            trk1_obj  = this->TrkLevel1::GetTrkLevel1();        
40      trk_obj     = this->TrkLevel2::GetTrkLevel2();      trk2_obj  = this->TrkLevel2::GetTrkLevel2();
41      calo_obj    = this->CaloLevel2::GetCaloLevel2();      trkh_obj  = this->TrkHough::GetTrkHough();
42      tof_obj     = this->ToFLevel2::GetToFLevel2();      calo1_obj = this->CaloLevel1::GetCaloLevel1();
43      trig_obj    = this->TrigLevel2::GetTrigLevel2();      calo2_obj = this->CaloLevel2::GetCaloLevel2();
44      s4_obj      = this->S4Level2::GetS4Level2();      tof_obj   = this->ToFLevel2::GetToFLevel2();
45      nd_obj      = this->NDLevel2::GetNDLevel2();      trig_obj  = this->TrigLevel2::GetTrigLevel2();
46      ac_obj      = this->AcLevel2::GetAcLevel2();      s4_obj    = this->S4Level2::GetS4Level2();
47      orb_obj     = this->OrbitalInfo::GetOrbitalInfo();      nd_obj    = this->NDLevel2::GetNDLevel2();
48        ac_obj    = this->AcLevel2::GetAcLevel2();
49        orb_obj   = this->OrbitalInfo::GetOrbitalInfo();
50    
51      run_obj     = new GL_RUN();      run_obj   = new GL_RUN();
52            
53      sorted_tracks = new TRefArray();      sorted_tracks = new TRefArray();
54            
55      CAL = true;      CAL2 = true;
56      TRK = true;      TRK2 = true;
57        TRK1 = false;
58        TRKh = false;
59      TRG = true;      TRG = true;
60      TOF = true;      TOF = true;
61      S4  = true;      S4  = true;
# Line 59  PamLevel2::PamLevel2(){ Line 63  PamLevel2::PamLevel2(){
63      AC  = true;      AC  = true;
64      ORB = true;      ORB = true;
65            
66      TRK_L1 = false;  
       
     Tout  = NULL;  
67  };  };
68  /**  /**
69   * Destructor   * Destructor
# Line 84  PamLevel2::~PamLevel2(){ Line 86  PamLevel2::~PamLevel2(){
86  //      delete sorted_tracks;  //      delete sorted_tracks;
87      sorted_tracks->Delete(); // clean the reference array      sorted_tracks->Delete(); // clean the reference array
88                    
     if(Tout)Tout->Delete(); // delete loaded tree from memory  
89                    
90  };  };
91  /**  /**
# Line 181  void PamLevel2::Clear(){ Line 182  void PamLevel2::Clear(){
182       CaloTrkVar *c = 0;       CaloTrkVar *c = 0;
183       ToFTrkVar  *o = 0;       ToFTrkVar  *o = 0;
184            
185       if(CAL) c = GetCaloStoredTrack(t->GetSeqNo());       if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo());
186       if(TOF) o = GetToFStoredTrack(t->GetSeqNo());       if(TOF) o = GetToFStoredTrack(t->GetSeqNo());
187            
188  //    if(t && c && o)track = new PamTrack(t,c,o);  //    if(t && c && o)track = new PamTrack(t,c,o);
# Line 224  PamTrack* PamLevel2::GetStoredTrack(Int_ Line 225  PamTrack* PamLevel2::GetStoredTrack(Int_
225   * Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is  PamLevel2::sorted_tracks.   * Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is  PamLevel2::sorted_tracks.
226   * @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...).   * @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...).
227   * Sorting cryteria:   * Sorting cryteria:
228   * TRK: lower chi**2   * TRK: lower chi**2
229   * CAL: lower Y spatial residual on the first calorimeter plane   * CAL: lower Y spatial residual on the first calorimeter plane
230   * TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis).   * TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis).
231   * The default sorting cryterium is "TOF+CAL".   * The default sorting cryterium is "TOF+CAL".
# Line 243  void PamLevel2::SortTracks(TString how){ Line 244  void PamLevel2::SortTracks(TString how){
244      Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase);      Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase);
245      Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase);      Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase);
246            
247      if( !CAL &&  use_CAL) use_CAL = false;      if( !CAL2 &&  use_CAL) use_CAL = false;
248      if( !TOF &&  use_TOF) use_TOF = false;      if( !TOF &&  use_TOF) use_TOF = false;
249            
250      if( !TRK ){      if( !TRK2 ){
251          cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl;          cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl;
252          return;          return;
253      };      };
# Line 257  void PamLevel2::SortTracks(TString how){ Line 258  void PamLevel2::SortTracks(TString how){
258                    
259          // get tracker tracks          // get tracker tracks
260          TrkTrack   *tp = TrkLevel2::GetTrack(i);                    //tracker          TrkTrack   *tp = TrkLevel2::GetTrack(i);                    //tracker
 //              CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo());  
 //              ToFTrkVar  *op = GetToFStoredTrack(tp->GetSeqNo());  
261          CaloTrkVar *cp = 0;          CaloTrkVar *cp = 0;
262          ToFTrkVar  *op = 0;          ToFTrkVar  *op = 0;
263                    
# Line 266  void PamLevel2::SortTracks(TString how){ Line 265  void PamLevel2::SortTracks(TString how){
265          if(tp->HasImage()){          if(tp->HasImage()){
266                            
267              TrkTrack   *ti = TrkLevel2::GetTrackImage(i);              //tracker (image)              TrkTrack   *ti = TrkLevel2::GetTrackImage(i);              //tracker (image)
 //                      CaloTrkVar *ci = GetCaloStoredTrack(ti->GetSeqNo());  
 //                      ToFTrkVar  *oi = GetToFStoredTrack(ti->GetSeqNo());  
268              CaloTrkVar *ci = 0;              CaloTrkVar *ci = 0;
269              ToFTrkVar  *oi = 0;              ToFTrkVar  *oi = 0;
270                            
# Line 379  void PamLevel2::SortTracks(TString how){ Line 376  void PamLevel2::SortTracks(TString how){
376   * This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2.   * This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2.
377   * PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information.   * PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information.
378   */   */
379   TRefArray *PamLevel2::GetTracks(){  TRefArray *PamLevel2::GetTracks(){
380           //  
381  //      SortTracks("+CAL+TOF");  //  *-*-*-*-*-*-*-*-*-*-*-*-*
382           SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!!      SortTracks("+CAL+TOF");
383          //  //  *-*-*-*-*-*-*-*-*-*-*-*-*
384          return sorted_tracks;  
385        return sorted_tracks;
386   };   };
387  //--------------------------------------  //--------------------------------------
388   //   //
# Line 397  void PamLevel2::SortTracks(TString how){ Line 395  void PamLevel2::SortTracks(TString how){
395   */   */
396  PamTrack *PamLevel2::GetTrack(int it){  PamTrack *PamLevel2::GetTrack(int it){
397                    
398  //  *-*-*-*-*-*-*  //  *-*-*-*-*-*-*-*-*-*-*-*-*
399  //      SortTracks("+CAL+TOF");      SortTracks("+CAL+TOF");
400      SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!!  //  *-*-*-*-*-*-*-*-*-*-*-*-*
401  //  *-*-*-*-*-*-*      
   
402      PamTrack *track = 0;      PamTrack *track = 0;
403            
404      if( it >=0 && it < TrkLevel2::GetNTracks() && it<sorted_tracks->GetEntriesFast() ){      if( it >=0 && it < TrkLevel2::GetNTracks() && it<sorted_tracks->GetEntriesFast() ){
# Line 425  PamTrack *PamLevel2::GetTrack(int it){ Line 422  PamTrack *PamLevel2::GetTrack(int it){
422   */   */
423  PamTrack *PamLevel2::GetTrackImage(int it){  PamTrack *PamLevel2::GetTrackImage(int it){
424    
425  //      SortTracks("+CAL+TOF");  //  *-*-*-*-*-*-*-*-*-*-*-*-*
426          SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!!      SortTracks("+CAL+TOF");
427            //  *-*-*-*-*-*-*-*-*-*-*-*-*
428          PamTrack *image = 0;      
429        PamTrack *image = 0;
430          if( it >=0 && it < TrkLevel2::GetNTracks() ){      
431                  TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it);      if( it >=0 && it < TrkLevel2::GetNTracks() ){
432                  if( temp->HasImage() ){          TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it);
433                          TrkTrack   *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo());          if( temp->HasImage() ){
434                          image = GetPamTrackAlong(t);              TrkTrack   *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo());
435                  }else{              image = GetPamTrackAlong(t);
                         cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl;  
                 };  
436          }else{          }else{
437                  cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl;              cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl;
438          };          };
439        }else{
440            cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl;
441        };
442            
443          return image;      return image;
444  }  }
445    
446  //--------------------------------------  //--------------------------------------
# Line 465  TTree *PamLevel2::GetPamTree(TFile *f, T Line 463  TTree *PamLevel2::GetPamTree(TFile *f, T
463      SetWhichTrees(detlist);      SetWhichTrees(detlist);
464  // Tracker  // Tracker
465      TTree *T = (TTree*)f->Get("Tracker");      TTree *T = (TTree*)f->Get("Tracker");
466      if(T && TRK) {      if(T && (TRK2||TRK1||TRKh)) {
467          if(TRK_L1){          if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2));
468              T->SetBranchAddress("TrkLevel1", GetPointerToTrk(1));          if(TRK2)cout << "Tracker      : set branch address TrkLevel2"<<endl;
469              cout << "Tracker      : set branch address TrkLevel1"<<endl;          if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerToTrk(1));
470          };          if(TRK1)cout << "Tracker      : set branch address TrkLevel1"<<endl;
471          T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2));  //      if(TRKh)T->SetBranchAddress("TrkHough", GetPointerToTrk(3));
472          cout << "Tracker      : set branch address TrkLevel2"<<endl;  //      if(TRKh)cout << "Tracker      : set branch address TrkHough"<<endl;
473          Trout=T;          Trout=T;
474      }else{      }else{
475          cout << "Tracker      : missing tree"<<endl;          cout << "Tracker      : missing tree"<<endl;
476      };      };
477      // Calorimeter      // Calorimeter
478      TTree *C = (TTree*)f->Get("Calorimeter");      TTree *C = (TTree*)f->Get("Calorimeter");
479      if(C && CAL) {      if(C && CAL2) {
480          C->SetBranchAddress("CaloLevel2", GetPointerToCalo());          C->SetBranchAddress("CaloLevel2", GetPointerToCalo());
481          cout << "Calorimeter  : set branch address CaloLevel2"<<endl;          cout << "Calorimeter  : set branch address CaloLevel2"<<endl;
482          if(!Trout)Trout=C;          if(!Trout)Trout=C;
# Line 593  TList*  PamLevel2::GetListOfLevel2Files( Line 591  TList*  PamLevel2::GetListOfLevel2Files(
591              TString file;              TString file;
592              in >> file;              in >> file;
593              if (!in.good()) break;              if (!in.good()) break;
594    //          cout <<"(1) " << file << endl;
595                if(file.Contains("#"))file = file(0,file.First("#"));
596    //          cout <<"(2) " << file << endl;
597    
598              if( gSystem->IsFileInIncludePath(file,&fullpath) ){              if( gSystem->IsFileInIncludePath(file,&fullpath) ){
599  //                              contents->Add(new TSystemDirectory(fullpath,ddir)); // add file to the list  
 //                              contents->Add(new TSystemFile(fullpath,ddir)); // add file to the list  
600                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list                  contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
601    
602              }else{              }else{
603                  cout << "warning! --- File "<<file<<" does not exists"<< endl;                  if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl;
604              };              };
605          };          };
606          in.close();          in.close();
# Line 651  TList*  PamLevel2::GetListOfLevel2Files( Line 653  TList*  PamLevel2::GetListOfLevel2Files(
653  TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){  TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){
654    
655  //      TChain *Tout=0;  //      TChain *Tout=0;
656      if(Tout)Tout->Delete();  //    if(Tout)Tout->Delete();
657      Tout = NULL;  //    Tout = NULL;
658            
659        TChain *Tout =0;
660    
661      SetWhichTrees(detlist);      SetWhichTrees(detlist);
662            
663      TChain *T = 0;            TChain *T = 0;      
# Line 665  TChain *PamLevel2::GetPamTree(TList *fl, Line 669  TChain *PamLevel2::GetPamTree(TList *fl,
669      TChain *A = 0;      TChain *A = 0;
670      TChain *B = 0;      TChain *B = 0;
671            
672      if(TRK) T = new TChain("Tracker");        if(TRK2||TRK1||TRKh) T = new TChain("Tracker");    
673      if(CAL) C = new TChain("Calorimeter");      if(CAL2||CAL1) C = new TChain("Calorimeter");
674      if(TOF) O = new TChain("ToF");      if(TOF) O = new TChain("ToF");
675      if(TRG) R = new TChain("Trigger");      if(TRG) R = new TChain("Trigger");
676      if(S4)  S = new TChain("S4");      if(S4)  S = new TChain("S4");
# Line 681  TChain *PamLevel2::GetPamTree(TList *fl, Line 685  TChain *PamLevel2::GetPamTree(TList *fl,
685          TString name =  questo->GetName();          TString name =  questo->GetName();
686  //              cout << "File: "<< name << endl;  //              cout << "File: "<< name << endl;
687          if( CheckLevel2File(name) ){          if( CheckLevel2File(name) ){
688              if(TRK) T->Add(name);              if(TRK2||TRK1||TRKh) T->Add(name);
689              if(CAL) C->Add(name);              if(CAL1||CAL2) C->Add(name);
690              if(TOF) O->Add(name);              if(TOF) O->Add(name);
691              if(TRG) R->Add(name);              if(TRG) R->Add(name);
692              if(S4)  S->Add(name);              if(S4)  S->Add(name);
# Line 693  TChain *PamLevel2::GetPamTree(TList *fl, Line 697  TChain *PamLevel2::GetPamTree(TList *fl,
697      }      }
698            
699      cout << "done chain \n";      cout << "done chain \n";
700        
701      // Tracker      // Tracker
702      if(TRK) if(!Tout)Tout=T;      if(TRK2||TRK1||TRKh)if(!Tout)Tout=T;
703      // Calorimeter      // Calorimeter
704      if(CAL) {                if(CAL2||CAL1) {            
705          if(!Tout)Tout=C;          if(!Tout)Tout=C;
706          else Tout->AddFriend("Calorimeter");          else Tout->AddFriend("Calorimeter");
707      };      };
# Line 734  TChain *PamLevel2::GetPamTree(TList *fl, Line 738  TChain *PamLevel2::GetPamTree(TList *fl,
738            
739  //    cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl;  //    cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl;
740            
741      if( Tout->GetEntries() )PamLevel2::SetBranchAddress();  //    if( Tout->GetEntries() )PamLevel2::SetBranchAddress();
742        if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout );
743            
744      return Tout;      return Tout;
745  }  }
746    
747    
748    
749  //--------------------------------------  //--------------------------------------
750  //  //
751  //  //
# Line 745  TChain *PamLevel2::GetPamTree(TList *fl, Line 753  TChain *PamLevel2::GetPamTree(TList *fl,
753  /**  /**
754   * Set branch addresses for Pamela friend trees   * Set branch addresses for Pamela friend trees
755   */   */
756  void PamLevel2::SetBranchAddress(){  void PamLevel2::SetBranchAddress(TTree *t){
757    
758    
759    
760        TRK2    = TRK2 & t->GetBranchStatus("TrkLevel2");
761        TRK1    = TRK1 & t->GetBranchStatus("TrkLevel1");
762        TRKh    = TRKh & t->GetBranchStatus("TrkHough");
763        CAL2    = CAL2 & t->GetBranchStatus("CaloLevel2");
764        CAL1    = CAL1 & t->GetBranchStatus("CaloLevel1");
765        TOF    = TOF & t->GetBranchStatus("ToFLevel2");
766        TRG    = TRG & t->GetBranchStatus("TrigLevel2");
767        S4     = S4  & t->GetBranchStatus("S4Level2");
768        ND     = ND  & t->GetBranchStatus("NDLevel2");
769        AC     = AC  & t->GetBranchStatus("AcLevel2");
770        ORB    = ORB & t->GetBranchStatus("OrbitalInfo");
771    
772    
773      // Tracker      // Tracker
774      if(TRK) {      if(TRK1) {
775          if(TRK_L1){          t->SetBranchAddress("TrkLevel1", GetPointerToTrk(1));
776              Tout->SetBranchAddress("TrkLevel1", GetPointerToTrk(1));          cout << "Tracker      : set branch address TrkLevel1"<<endl;
777              cout << "Tracker      : set branch address TrkLevel1"<<endl;      };
778          };      if(TRK2) {
779          Tout->SetBranchAddress("TrkLevel2", GetPointerToTrk(2));          t->SetBranchAddress("TrkLevel2", GetPointerToTrk(2));
780          cout << "Tracker      : set branch address TrkLevel2"<<endl;          cout << "Tracker      : set branch address TrkLevel2"<<endl;
781      };      };
782        if(TRKh) {
783            t->SetBranchAddress("TrkHough", GetPointerToTrk(3));
784            cout << "Tracker      : set branch address TrkHough"<<endl;
785        };
786            
787      // Calorimeter      // Calorimeter
788      if(CAL) {      if(CAL1) {
789          Tout->SetBranchAddress("CaloLevel2", GetPointerToCalo());          t->SetBranchAddress("CaloLevel1", GetPointerToCalo(1));
790            cout << "Calorimeter  : set branch address CaloLevel1"<<endl;
791        };
792        if(CAL2) {
793            t->SetBranchAddress("CaloLevel2", GetPointerToCalo(2));
794          cout << "Calorimeter  : set branch address CaloLevel2"<<endl;          cout << "Calorimeter  : set branch address CaloLevel2"<<endl;
795      };      };
796            
797      // ToF          // ToF    
798      if(TOF) {      if(TOF) {
799          Tout->SetBranchAddress("ToFLevel2", GetPointerToToF());          t->SetBranchAddress("ToFLevel2", GetPointerToToF());
800          cout << "ToF          : set branch address ToFLevel2"<<endl;          cout << "ToF          : set branch address ToFLevel2"<<endl;
801      };      };
802      // Trigger      // Trigger
803      if(TRG) {      if(TRG) {
804          Tout->SetBranchAddress("TrigLevel2", GetPointerToTrig());          t->SetBranchAddress("TrigLevel2", GetPointerToTrig());
805          cout << "Trigger      : set branch address TrigLevel2"<<endl;          cout << "Trigger      : set branch address TrigLevel2"<<endl;
806      };      };
807      // S4      // S4
808      if(S4) {      if(S4) {
809          Tout->SetBranchAddress("S4Level2", GetPointerToS4());          t->SetBranchAddress("S4Level2", GetPointerToS4());
810          cout << "S4           : set branch address S4Level2"<<endl;          cout << "S4           : set branch address S4Level2"<<endl;
811      };      };
812      // Neutron Detector      // Neutron Detector
813      if(ND) {      if(ND) {
814          Tout->SetBranchAddress("NDLevel2", GetPointerToND());          t->SetBranchAddress("NDLevel2", GetPointerToND());
815          cout << "NeutronD     : set branch address NDLevel2"<<endl;          cout << "NeutronD     : set branch address NDLevel2"<<endl;
816      };      };
817      // Anticounters      // Anticounters
818      if(AC) {      if(AC) {
819          Tout->SetBranchAddress("AcLevel2", GetPointerToAc());          t->SetBranchAddress("AcLevel2", GetPointerToAc());
820          cout << "Anticounter  : set branch address AcLevel2"<<endl;          cout << "Anticounter  : set branch address AcLevel2"<<endl;
821      };      };
822      // OrbitalInfo      // OrbitalInfo
823      if(ORB) {      if(ORB) {
824          Tout->SetBranchAddress("OrbitalInfo", GetPointerToOrb());          t->SetBranchAddress("OrbitalInfo", GetPointerToOrb());
825          cout << "OrbitalInfo  : set branch address OrbitalInfo"<<endl;          cout << "OrbitalInfo  : set branch address OrbitalInfo"<<endl;
826      };      };
827            
828  }  }
829    /**
830     * Set branch addresses for Pamela friend trees
831     */
832    void PamLevel2::SetBranchAddress(TChain *t){
833    
834    
835    
836    
837        TRK2    = TRK2 & t->GetBranchStatus("TrkLevel2");
838        TRK1    = TRK1 & t->GetBranchStatus("TrkLevel1");
839        TRKh    = TRKh & t->GetBranchStatus("TrkHough");
840        CAL1    = CAL1 & t->GetBranchStatus("CaloLevel1");
841        CAL2    = CAL2 & t->GetBranchStatus("CaloLevel2");
842        TOF    = TOF & t->GetBranchStatus("ToFLevel2");
843        TRG    = TRG & t->GetBranchStatus("TrigLevel2");
844        S4     = S4  & t->GetBranchStatus("S4Level2");
845        ND     = ND  & t->GetBranchStatus("NDLevel2");
846        AC     = AC  & t->GetBranchStatus("AcLevel2");
847        ORB    = ORB & t->GetBranchStatus("OrbitalInfo");
848    
849    
850    
851        // Tracker
852        if(TRK1) {
853            t->SetBranchAddress("TrkLevel1", GetPointerToTrk(1));
854            cout << "Tracker      : set branch address TrkLevel1"<<endl;
855        };
856        if(TRK2) {
857            t->SetBranchAddress("TrkLevel2", GetPointerToTrk(2));
858            cout << "Tracker      : set branch address TrkLevel2"<<endl;
859        };
860         if(TRKh) {
861            t->SetBranchAddress("TrkHough", GetPointerToTrk(3));
862            cout << "Tracker      : set branch address TrkHough"<<endl;
863         };
864        
865        // Calorimeter
866        if(CAL1) {
867            t->SetBranchAddress("CaloLevel1", GetPointerToCalo(1));
868            cout << "Calorimeter  : set branch address CaloLevel1"<<endl;
869        };
870        if(CAL2) {
871            t->SetBranchAddress("CaloLevel2", GetPointerToCalo(2));
872            cout << "Calorimeter  : set branch address CaloLevel2"<<endl;
873        };  
874        
875        // ToF    
876        if(TOF) {
877            t->SetBranchAddress("ToFLevel2", GetPointerToToF());
878            cout << "ToF          : set branch address ToFLevel2"<<endl;
879        };
880        // Trigger
881        if(TRG) {
882            t->SetBranchAddress("TrigLevel2", GetPointerToTrig());
883            cout << "Trigger      : set branch address TrigLevel2"<<endl;
884        };
885        // S4
886        if(S4) {
887            t->SetBranchAddress("S4Level2", GetPointerToS4());
888            cout << "S4           : set branch address S4Level2"<<endl;
889        };
890        // Neutron Detector
891        if(ND) {
892            t->SetBranchAddress("NDLevel2", GetPointerToND());
893            cout << "NeutronD     : set branch address NDLevel2"<<endl;
894        };
895        // Anticounters
896        if(AC) {
897            t->SetBranchAddress("AcLevel2", GetPointerToAc());
898            cout << "Anticounter  : set branch address AcLevel2"<<endl;
899        };
900        // OrbitalInfo
901        if(ORB) {
902            t->SetBranchAddress("OrbitalInfo", GetPointerToOrb());
903            cout << "OrbitalInfo  : set branch address OrbitalInfo"<<endl;
904        };
905        
906    }
907  //--------------------------------------  //--------------------------------------
908  //  //
909  //  //
# Line 802  void PamLevel2::SetBranchAddress(){ Line 911  void PamLevel2::SetBranchAddress(){
911  void *PamLevel2::GetPointerTo(const char* c ){  void *PamLevel2::GetPointerTo(const char* c ){
912  //      cout << "objname "<< objname << endl;  //      cout << "objname "<< objname << endl;
913      TString objname = c;      TString objname = c;
914      if(!objname.CompareTo("TrkLevel1"))return &trk_l1_obj;      if(!objname.CompareTo("TrkLevel1"))return &trk1_obj;
915      if(!objname.CompareTo("TrkLevel2"))return &trk_obj;      if(!objname.CompareTo("TrkLevel2"))return &trk2_obj;
916        if(!objname.CompareTo("TrkHough"))return &trkh_obj;
917            
918      return NULL;      return NULL;
919  };  };
# Line 862  TTree *PamLevel2::GetRunTree(TFile *f){ Line 972  TTree *PamLevel2::GetRunTree(TFile *f){
972  //  //
973  //--------------------------------------  //--------------------------------------
974  /**  /**
975   * Set which trees should be analysed   * Set which trees shoul be analysed
976   * @param detlist TString containing the sequence of trees required   * @param detlist TString containing the sequence of trees required
977  */  */
978  void PamLevel2::SetWhichTrees(TString detlist){  void PamLevel2::SetWhichTrees(TString detlist){
979                    
980      if(detlist.Contains("+ALL", TString::kIgnoreCase)){      if(detlist.Contains("+ALL", TString::kIgnoreCase)){
981          CAL = true;          CAL1 = true;
982          TRK = true;          CAL2 = true;
983          TRK_L1 = false;          TRK2 = true;
984            TRK1 = false;
985            TRKh = false;
986          TRG = true;          TRG = true;
987          TOF = true;          TOF = true;
988          S4  = true;          S4  = true;
# Line 878  void PamLevel2::SetWhichTrees(TString de Line 990  void PamLevel2::SetWhichTrees(TString de
990          AC  = true;          AC  = true;
991          ORB = true;          ORB = true;
992      }else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){      }else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){
993          CAL = false;          CAL1 = false;
994          TRK = false;          CAL2 = false;
995          TRK_L1 = false;          TRK2 = false;
996            TRK1 = false;
997            TRKh = false;
998          TRG = false;          TRG = false;
999          TOF = false;          TOF = false;
1000          S4  = false;          S4  = false;
# Line 889  void PamLevel2::SetWhichTrees(TString de Line 1003  void PamLevel2::SetWhichTrees(TString de
1003          ORB = false;          ORB = false;
1004      };      };
1005            
1006      if( detlist.Contains("-CAL", TString::kIgnoreCase) )CAL = false;  //  -------------------------------------------------------------------------
1007      else if( detlist.Contains("+CAL", TString::kIgnoreCase) )CAL = true;      if( detlist.Contains("CAL1", TString::kIgnoreCase) ){
1008            if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false;
1009            if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true;
1010        };
1011            
1012        if( detlist.Contains("CAL2", TString::kIgnoreCase)){
1013            if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false;
1014            if ( detlist.Contains("+CAL2", TString::kIgnoreCase) )CAL2=true;
1015        };
1016            
1017        if( detlist.Contains("+CAL", TString::kIgnoreCase) && !CAL1 && !CAL2 )CAL2=true;
1018        if( detlist.Contains("-CAL", TString::kIgnoreCase) && CAL1 && CAL2 ){
1019            CAL2=false;
1020            CAL1=false;
1021        }
1022    //  -------------------------------------------------------------------------
1023        if( detlist.Contains("TRK1", TString::kIgnoreCase) ){
1024            if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false;
1025            if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true;
1026        };
1027            
1028        if( detlist.Contains("TRK2", TString::kIgnoreCase)){
1029            if ( detlist.Contains("-TRK2", TString::kIgnoreCase) )TRK2=false;
1030            if ( detlist.Contains("+TRK2", TString::kIgnoreCase) )TRK2=true;
1031        };
1032    
1033        if( detlist.Contains("TRKh", TString::kIgnoreCase)){
1034            if ( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh=false;
1035            if ( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh=true;
1036        };
1037            
1038        if( detlist.Contains("+TRK", TString::kIgnoreCase) && !TRK1 && !TRK2 && !TRKh )TRK2=true;
1039        if( detlist.Contains("-TRK", TString::kIgnoreCase) && TRK1 && TRK2 && TRKh){
1040            TRK2=false;
1041            TRK1=false;
1042            TRKh=false;
1043        }
1044    //  -------------------------------------------------------------------------
1045    
1046    
1047            
1048      if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK = false;  //     if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK2 = false;
1049      else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK = true;  //     else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK2 = true;
1050            
1051      if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK_L1 = false;  //     if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1 = false;
1052      else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK_L1 = true;  //     else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1 = true;
1053    
1054    //     if( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh = false;
1055    //     else if( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh = true;
1056            
1057      if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false;      if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false;
1058      else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true;      else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true;
# Line 928  void PamLevel2::SetWhichTrees(TString de Line 1084  void PamLevel2::SetWhichTrees(TString de
1084   */   */
1085  Bool_t  PamLevel2::CheckLevel2File(TString name){  Bool_t  PamLevel2::CheckLevel2File(TString name){
1086                    
1087      Bool_t CAL__ok = false;          Bool_t CAL1__ok   = false;    
1088      Bool_t TRK__ok = false;          Bool_t CAL2__ok   = false;    
1089      Bool_t TRK_L1__ok = false;          Bool_t TRK2__ok   = false;    
1090      Bool_t TRG__ok = false;          Bool_t TRK1__ok   = false;    
1091      Bool_t TOF__ok = false;          Bool_t TRKh__ok   = false;    
1092      Bool_t S4__ok  = false;          Bool_t TRG__ok    = false;    
1093      Bool_t ND__ok  = false;          Bool_t TOF__ok    = false;    
1094      Bool_t AC__ok  = false;          Bool_t S4__ok     = false;    
1095      Bool_t ORB__ok = false;          Bool_t ND__ok     = false;    
1096        Bool_t AC__ok     = false;    
1097        Bool_t ORB__ok    = false;    
1098            
1099      Bool_t RUN__ok = false;      Bool_t RUN__ok    = false;
1100            
1101  //    cout << "Checking file: "<<name<<endl;      
1102    
1103        cout << "Checking file: "<<name<<endl;
1104      TFile *f = new TFile(name.Data());      TFile *f = new TFile(name.Data());
1105      if( !f || f->IsZombie() ){      if( !f || f->IsZombie() ){
1106          cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false;          cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false;
1107      }      }
1108      //   cout << "Get list of keys: "<<f<<endl;  //    cout << "Get list of keys: "<<f<<endl;
1109      TList *lk = f->GetListOfKeys();      TList *lk = f->GetListOfKeys();
1110  //      lk->Print();  //    lk->Print();
1111      TIter next(lk);      TIter next(lk);
1112      TKey *key =0;      TKey *key =0;
1113      Int_t nev =0;  
1114      Int_t nev_previous =0;      Int_t nev = 0;
1115    
1116      while( (key = (TKey*)next()) ){      while( (key = (TKey*)next()) ){
1117                    
1118          nev_previous = nev;  //      cout << key->GetName() << endl;
1119          nev = ((TTree*)f->Get(key->GetName()))->GetEntries();  //      cout << " Get tree: " << f->Get(key->GetName())<<endl;
1120          if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){  //      nev_previous = nev;
1121              cout << "File: "<< f->GetName() <<" discarded ---- "<< key->GetName() << " tree: n.entries does not match "<<nev<<" "<<nev_previous<< endl;  //      cout << " n.entries  "<< nev <<endl;
1122              return false;  //      if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){
1123          };  //          nev = ((TTree*)f->Get(key->GetName()))->GetEntries();
1124    //          cout << "File: "<< f->GetName() <<" discarded ---- "<< key->GetName() << " tree: n.entries does not match "<<nev<<" "<<nev_previous<< endl;
1125    //          return false;
1126    //      };
1127    
         if( !strcmp(key->GetName(),"Calorimeter") )CAL__ok = true;  
         if( !strcmp(key->GetName(),"Trigger"    ) )TRG__ok = true;  
         if( !strcmp(key->GetName(),"ToF"        ) )TOF__ok = true;  
         if( !strcmp(key->GetName(),"S4"         ) )S4__ok = true;  
         if( !strcmp(key->GetName(),"NeutronD"   ) )ND__ok = true;  
         if( !strcmp(key->GetName(),"Anticounter") )AC__ok = true;  
         if( !strcmp(key->GetName(),"OrbitalInfo") )ORB__ok = true;  
1128          if( !strcmp(key->GetName(),"Run"        ) )RUN__ok = true;                if( !strcmp(key->GetName(),"Run"        ) )RUN__ok = true;      
1129    
1130            //=========================================================    
1131            if( !strcmp(key->GetName(),"Trigger"    ) ){
1132                TRG__ok = true;
1133                if(TRG){
1134                    Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries();
1135                    if( nev && nevt!=nev){
1136                        cout << "File: "<< f->GetName() <<" discarded ---- Trigger tree has "<<nevt<<" events instead of "<<nev<< endl;
1137                        return false;
1138                    }
1139                    nev=nevt;
1140                }
1141            }
1142            //=========================================================    
1143            if( !strcmp(key->GetName(),"ToF"        ) ){
1144                TOF__ok = true;
1145                if(TOF){
1146                    Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries();
1147                    if( nev && nevt!=nev){
1148                        cout << "File: "<< f->GetName() <<" discarded ---- ToF tree has "<<nevt<<" events instead of "<<nev<< endl;
1149                        return false;
1150                    }
1151                    nev=nevt;
1152                }
1153            }
1154            //=========================================================  
1155            if( !strcmp(key->GetName(),"S4"         ) ){
1156                S4__ok = true;
1157                if(S4){
1158                    Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries();
1159                    if( nev && nevt!=nev){
1160                        cout << "File: "<< f->GetName() <<" discarded ---- S4 tree has "<<nevt<<" events instead of "<<nev<< endl;
1161                        return false;
1162                    }
1163                    nev=nevt;
1164                }
1165            }
1166            //=========================================================  
1167    
1168            if( !strcmp(key->GetName(),"NeutronD"   ) ){
1169                ND__ok = true;
1170                if(ND){
1171                    Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries();
1172                    if( nev && nevt!=nev){
1173                        cout << "File: "<< f->GetName() <<" discarded ---- NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl;
1174                        return false;
1175                    }
1176                    nev=nevt;
1177                }
1178            }      
1179            //=========================================================  
1180            if( !strcmp(key->GetName(),"Anticounter") ){
1181                AC__ok = true;
1182                if(AC){
1183                    Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries();
1184                    if( nev && nevt!=nev){
1185                        cout << "File: "<< f->GetName() <<" discarded ---- Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl;
1186                        return false;
1187                    }
1188                    nev=nevt;
1189                }
1190            }
1191            //=========================================================  
1192            if( !strcmp(key->GetName(),"OrbitalInfo") ){
1193                ORB__ok = true;
1194                if(ORB){
1195                    Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries();
1196                    if( nev && nevt!=nev){
1197                        cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl;
1198                        return false;
1199                    }
1200                    nev=nevt;
1201                }
1202            }
1203            //=========================================================  
1204          if( !strcmp(key->GetName(),"Tracker"    ) ){          if( !strcmp(key->GetName(),"Tracker"    ) ){
             TRK__ok = true;  
1205              TTree *T = (TTree*)f->Get("Tracker");              TTree *T = (TTree*)f->Get("Tracker");
1206                if(TRK1||TRK2||TRKh){
1207                    Int_t nevt = T->GetEntries();
1208                    if( nev && nevt!=nev){
1209                        cout << "File: "<< f->GetName() <<" discarded ---- Tracker tree has "<<nevt<<" events instead of "<<nev<< endl;
1210                        return false;
1211                    }
1212                    nev=nevt;
1213                }
1214              for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){              for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){
1215                  TString name = T->GetListOfBranches()->At(i)->GetName();                  TString name = T->GetListOfBranches()->At(i)->GetName();
1216                  if( !name.CompareTo("TrkLevel1") )TRK_L1__ok=true;                  if( !name.CompareTo("TrkLevel1") )TRK1__ok=true;
1217              };                  if( !name.CompareTo("TrkLevel2") )TRK2__ok=true;
1218                    if( !name.CompareTo("TrkHough") )TRKh__ok=true;
1219                };      
1220                T->Delete();
1221          };          };
1222                    //=========================================================  
1223            if( !strcmp(key->GetName(),"Calorimeter"    ) ){
1224                TTree *T = (TTree*)f->Get("Calorimeter");
1225                if(CAL1||CAL2){
1226                    Int_t nevt = T->GetEntries();
1227                    if( nev && nevt!=nev){
1228                        cout << "File: "<< f->GetName() <<" discarded ---- Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl;
1229                        return false;
1230                    }
1231                    nev=nevt;
1232                }
1233                for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){
1234                    TString name = T->GetListOfBranches()->At(i)->GetName();
1235                    if( !name.CompareTo("CaloLevel1") )CAL1__ok=true;
1236                    if( !name.CompareTo("CaloLevel2") )CAL2__ok=true;
1237                };    
1238                T->Delete();
1239            };      
1240    
1241      };      };
1242            
1243      lk->Delete();  
1244      f->Close();  
       
     Bool_t FLAG = true;  
1245      if(!RUN__ok) {      if(!RUN__ok) {
1246          cout << "File: "<< f->GetName() <<" discarded ---- Missing RunInfo tree"<< endl; return false;          cout << "File: "<< f->GetName() <<" discarded ---- Missing RunInfo tree"<< endl;
1247  //      FLAG = false;          return false;
     };  
     if(CAL && !CAL__ok){  
         cout << "File: "<< f->GetName() <<" discarded ---- Missing Calorimeter tree"<< endl; return false;  
 //      FLAG = false;  
     };  
     if(TRK && !TRK__ok){  
         cout << "File: "<< f->GetName() <<" discarded ---- Missing Tracker tree"<< endl; return false;  
 //      FLAG = false;  
     };  
     if(TRK_L1 && !TRK_L1__ok){  
         cout << "File: "<< f->GetName() <<" discarded ---- Missing Tracker Level1 Branch"<< endl; return false;  
 //      FLAG = false;  
     };  
     if(TRG && !TRG__ok){  
         cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; return false;  
 //      FLAG = false;  
     };  
     if(TOF && !TOF__ok){  
         cout << "File: "<< f->GetName() <<" discarded ---- Missing ToF tree"<< endl; return false;  
 //      FLAG = false;  
1248      };      };
1249      if(S4 && !S4__ok){  
1250          cout << "File: "<< f->GetName() <<" discarded ---- Missing S4 tree"<< endl; return false;      if(CAL1 && !CAL1__ok){
1251  //      FLAG = false;          cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel1 branch"<< endl;
1252            return false;
1253        };
1254        if(CAL2 && !CAL2__ok){
1255            cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel2 branch"<< endl;
1256            return false;
1257        };
1258        if(TRK2 && !TRK2__ok){
1259            cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel2 branch"<< endl;
1260            return false;
1261        };
1262        if(TRK1 && !TRK1__ok){
1263            cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel1 branch"<< endl;
1264            return false;
1265        };
1266        if(TRKh && !TRKh__ok){
1267            cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkHough branch"<< endl;
1268            return false;
1269      };      };
1270      if(ND && !ND__ok){      if(ORB && !ORB__ok){
1271          cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; return false;          cout << "File: "<< f->GetName() <<" discarded ---- Missing ORB tree"<< endl;
1272  //      FLAG = false;          return false;
1273      };      };
1274      if(AC && !AC__ok){      if(AC && !AC__ok){
1275          cout << "File: "<< f->GetName() <<" discarded ---- Missing AC tree"<< endl; return false;          cout << "File: "<< f->GetName() <<" discarded ---- Missing AC tree"<< endl;
1276  //      FLAG = false;          return false;
1277      };      };
1278      if(ORB && !ORB__ok){      if(S4 && !S4__ok){
1279          cout << "File: "<< f->GetName() <<" discarded ---- Missing ORB tree"<< endl; return false;          cout << "File: "<< f->GetName() <<" discarded ---- Missing S4 tree"<< endl;
1280  //      FLAG = false;          return false;
1281      };      };
1282            if(TOF && !TOF__ok){
1283      return FLAG;          cout << "File: "<< f->GetName() <<" discarded ---- Missing ToF tree"<< endl;
1284            return false;
1285        };
1286    
1287            if(ND && !ND__ok){
1288                cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl;
1289                return false;
1290            };
1291            if(TRG && !TRG__ok){
1292                cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl;
1293                return false;
1294            };
1295    
1296    
1297    
1298    
1299    
1300        lk->Delete();
1301        f->Close();
1302          
1303        return true;
1304                    
1305  };  };
1306    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.23