/[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.55 by pam-fi, Wed Nov 14 11:14:28 2007 UTC revision 1.56 by pam-fi, Tue Nov 20 18:16:30 2007 UTC
# Line 386  PamLevel2::PamLevel2(){ Line 386  PamLevel2::PamLevel2(){
386   */   */
387  PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){  PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){
388      Initialize();      Initialize();
389      GetPamTree(GetListOfLevel2Files(ddir,list),detlist);      TList*  listf = GetListOfLevel2Files(ddir,list);
390      GetRunTree(GetListOfLevel2Files(ddir,list));      GetPamTree(listf,detlist);
391        GetRunTree(listf);
392  };  };
393    
394  /**  /**
# Line 399  PamLevel2::PamLevel2(TString ddir,TStrin Line 400  PamLevel2::PamLevel2(TString ddir,TStrin
400   */   */
401  PamLevel2::PamLevel2(TString ddir,TString list){  PamLevel2::PamLevel2(TString ddir,TString list){
402      Initialize();      Initialize();
403      GetPamTree(GetListOfLevel2Files(ddir,list),"");      TList*  listf = GetListOfLevel2Files(ddir,list);
404      GetRunTree(GetListOfLevel2Files(ddir,list));      GetPamTree(listf,"");
405        GetRunTree(listf);
406  };  };
407    
408    
# Line 426  void PamLevel2::Initialize(){ Line 428  void PamLevel2::Initialize(){
428      run_obj   = 0;//new GL_RUN();      run_obj   = 0;//new GL_RUN();
429      soft_obj   = 0;// Emiliano      soft_obj   = 0;// Emiliano
430      irun = -1LL;      irun = -1LL;
431        irunt = -1LL;
432      runfirstentry = 0LL;      runfirstentry = 0LL;
433      runlastentry = 0LL;      runlastentry = 0LL;
434    
# Line 448  void PamLevel2::Initialize(){ Line 451  void PamLevel2::Initialize(){
451    
452      totdltime[0] = 0LL;      totdltime[0] = 0LL;
453      totdltime[1] = 0LL;      totdltime[1] = 0LL;
454        totdltime[2] = 0LL;
455    
456      host = "mysql://localhost/pamelaprod";      host = "mysql://localhost/pamelaprod";
457      user = "anonymous";      user = "anonymous";
# Line 575  void PamLevel2::Delete(){ Line 579  void PamLevel2::Delete(){
579      if(run_tree_clone)run_tree_clone->Delete();;      if(run_tree_clone)run_tree_clone->Delete();;
580      if(sel_tree_clone)sel_tree_clone->Delete();;      if(sel_tree_clone)sel_tree_clone->Delete();;
581            
582        if(irunoffset) delete [] irunoffset;
583    
584  };  };
585    
# Line 691  void PamLevel2::Reset(){ Line 696  void PamLevel2::Reset(){
696      run_obj   = 0;//new GL_RUN();      run_obj   = 0;//new GL_RUN();
697      soft_obj   = 0;// Emiliano      soft_obj   = 0;// Emiliano
698      irun = -1;      irun = -1;
699        irunt = -1;
700      runfirstentry = 0ULL;      runfirstentry = 0ULL;
701      runlastentry = 0ULL;          runlastentry = 0ULL;    
702      //      //
703      totdltime[0] = 0LL;      totdltime[0] = 0LL;
704      totdltime[1] = 0LL;      totdltime[1] = 0LL;
705        totdltime[2] = 0LL;
706      //      //
707  };  };
708    
# Line 1730  TTree *PamLevel2::GetPamTree(TFile *f, T Line 1737  TTree *PamLevel2::GetPamTree(TFile *f, T
1737    
1738      TTree *L = (TTree*)f->Get("SelectionList");      TTree *L = (TTree*)f->Get("SelectionList");
1739      if(L && SELLI==1) {      if(L && SELLI==1) {
 //      L->SetBranchAddress("RunEntry",&irun);  
 //      cout << "SelectionList: set branch address RunEntry"<<endl;  
 //      L->SetBranchAddress("EventEntry",&irunentry);  
 //      cout << "SelectionList: set branch address EventEntry"<<endl;  
 //      if(!Trout)Trout=O;  
 //      else Trout->AddFriend("SelectionList");  
1740          cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemented!!!!"<<endl;          cout << " TTree *PamLevel2::GetPamTree(TFile, TString) >>> SelectionList not implemented!!!!"<<endl;
1741          sel_tree = 0;          sel_tree = 0;
1742      }else{      }else{
# Line 1919  TChain *PamLevel2::GetPamTree(TList *fl, Line 1920  TChain *PamLevel2::GetPamTree(TList *fl,
1920            
1921      TChain *Trout =0;      TChain *Trout =0;
1922    
1923            // -------------------------------------------
1924        // set flags to include/exclude trees/branches
1925        // -------------------------------------------
1926      if( detlist.Contains("+AUTO", TString::kIgnoreCase) ) {      if( detlist.Contains("+AUTO", TString::kIgnoreCase) ) {
1927          if( fl->GetEntries()>0 ){          if( fl->GetEntries()>0 ){
1928              cout << "+AUTO"<<endl;              cout << "+AUTO"<<endl;
1929              TFile *fprimo = new TFile( fl->At(0)->GetName() );              TFile *fprimo = new TFile( fl->At(0)->GetName() );
1930              GetWhichTrees(fprimo);              GetWhichTrees(fprimo);
1931                fprimo->Close();// AAAAARGGGGGHHHHH!!!!!!! non commentare questa riga, altrimenti si incasina il TChain
1932              fprimo->Delete();              fprimo->Delete();
1933          }          }
1934      };      };
1935      SetWhichTrees(detlist);          SetWhichTrees(detlist);    
1936    
1937    
1938        // -------------------------------------------
1939  //    if( !detlist.IsNull() )SetWhichTrees(detlist);      // build chains
1940  //          // -------------------------------------------
1941      TChain *T = 0;            TChain *T = 0;      
1942      TChain *C = 0;      TChain *C = 0;
1943      TChain *O = 0;      TChain *O = 0;
# Line 1977  TChain *PamLevel2::GetPamTree(TList *fl, Line 1981  TChain *PamLevel2::GetPamTree(TList *fl,
1981          };          };
1982      };      };
1983            
1984      cout << "done chain \n";      cout << "done chains\n";
1985      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1986    
1987  //    UInt_t *found=0;  
1988        // -------------------------------------------
1989        // make friends
1990        // -------------------------------------------
1991    
1992  // Tracker  // Tracker
1993        cout << "Friends: "<<endl;
1994      if(T && (TRK2||TRK1||TRKh)) {      if(T && (TRK2||TRK1||TRKh)) {
 //      if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2"));  
 //      if(TRK2)cout << "Tracker      : set branch address TrkLevel2"<<endl;  
 //      if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1"));  
 //      if(TRK1)cout << "Tracker      : set branch address TrkLevel1"<<endl;  
 //      if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough"));  
 //      if(TRKh)cout << "Tracker      : set branch address TrkHough"<<endl;  
1995          if(!Trout)Trout=T;          if(!Trout)Trout=T;
1996          else Trout->AddFriend("Tracker");          else Trout->AddFriend("Tracker");
1997      }else{  //      cout << "+Tacker"<<endl;
 //        cout << "Tracker      : missing tree"<<endl;  
1998      };      };
1999      // Calorimeter      // Calorimeter
2000      if(C && (CAL2||CAL1)) {      if(C && (CAL2||CAL1)) {
 //        if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2"));  
 //        if(CAL2)cout << "Calorimeter  : set branch address CaloLevel2"<<endl;  
 //        if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1"));  
 //        if(CAL1)cout << "Calorimeter  : set branch address CaloLevel1"<<endl;  
2001          if(!Trout)Trout=C;          if(!Trout)Trout=C;
2002          else Trout->AddFriend("Calorimeter");          else Trout->AddFriend("Calorimeter");
2003      }else{  //      cout << "+Calorimeter"<<endl;
 //        cout << "Calorimeter  : missing tree"<<endl;  
2004      };      };
2005      // ToF          // ToF    
2006      if(O && TOF) {      if(O && TOF) {
 //        O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2"));  
 //        cout << "ToF          : set branch address ToFLevel2"<<endl;  
2007          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2008          else Trout->AddFriend("ToF");          else Trout->AddFriend("ToF");
2009      }else{  //      cout << "+ToF"<<endl;
 //        cout << "ToF         : missing tree"<<endl;  
2010      };      };
2011      // Trigger      // Trigger
2012      if(R && TRG) {      if(R && TRG) {
 //        R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2"));  
 //        cout << "Trigger      : set branch address TrigLevel2"<<endl;  
2013          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2014          else Trout->AddFriend("Trigger");          else Trout->AddFriend("Trigger");
2015      }else{  //      cout << "+Trigger"<<endl;
 //        cout << "Trigger      : missing tree"<<endl;  
2016      };      };
2017      // S4      // S4
2018      if(S && S4) {      if(S && S4) {
 //        S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2"));  
 //        cout << "S4           : set branch address S4Level2"<<endl;  
2019          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2020          else Trout->AddFriend("S4");          else Trout->AddFriend("S4");
2021      }else{  //      cout << "+S4"<<endl;
 //        cout << "S4           : missing tree"<<endl;  
2022      };      };
2023      // Neutron Detector      // Neutron Detector
2024      if(N && ND) {      if(N && ND) {
 //        N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2"));  
 //        cout << "NeutronD     : set branch address NDLevel2"<<endl;  
2025          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2026          else Trout->AddFriend("NeutronD");          else Trout->AddFriend("NeutronD");
2027      }else{  //      cout << "+NeutronD"<<endl;
 //        cout << "NeutronD     : missing tree"<<endl;  
2028      };      };
2029      // Anticounters      // Anticounters
2030      if(A && AC) {      if(A && AC) {
 //        A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2"));  
 //        cout << "Anticounter  : set branch address AcLevel2"<<endl;  
2031          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2032          else Trout->AddFriend("Anticounter");          else Trout->AddFriend("Anticounter");
2033      }else{  //      cout << "+Anticounter"<<endl;
 //        cout << "Anticounter  : missing tree"<<endl;  
2034      };      };
2035      // Orbital Info      // Orbital Info
2036      if(B && ORB) {      if(B && ORB) {
 //      B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo"));  
 //      cout << "OrbitalInfo  : set branch address OrbitalInfo"<<endl;  
2037          if(!Trout)Trout=O;          if(!Trout)Trout=O;
2038          else Trout->AddFriend("OrbitalInfo");          else Trout->AddFriend("OrbitalInfo");
2039      }else{  //      cout << "+OrbitalInfo"<<endl;
 //      cout << "OrbitalInfo  : missing tree"<<endl;  
2040      };      };
2041      // GPamela      // GPamela
2042      if(G && GP) {      if(G && GP) {
         if(!gp_obj)gp_obj = new GPamela();  
 //      ------------------------------------  
 //      ATTENZIONE!!!  
 //      non so per quale arcano motivo,  
 //      per l'albero di gpamela il branch address lo devo settare  
 //      DOPO aver fatto friend  
 //      FGRRRVZZZZUTSALKJMSLKJ!!!  
 //      ------------------------------------  
 //      gp_obj->SetBranchAddress(G); //ho dovuto fare in maniera diversa dagli altri  
 //      cout << "h20          : set branch address GPamela "<<endl;  
2043          if(!Trout)Trout=G;          if(!Trout)Trout=G;
2044          else Trout->AddFriend("h20");          else Trout->AddFriend("h20");
2045      }else{  //      cout << "+h20"<<endl;
 //      cout << "h20          : missing tree"<<endl;  
2046      };      };
2047    
2048  //  =====================================  //  =====================================
# Line 2082  TChain *PamLevel2::GetPamTree(TList *fl, Line 2050  TChain *PamLevel2::GetPamTree(TList *fl,
2050  //  =====================================  //  =====================================
2051      SetBranchAddress(Trout);      SetBranchAddress(Trout);
2052    
2053    
2054    //  ------------------------------------
2055    //  finally handle selection trees...
2056    //  (it is not friend of pamela tree)
2057    //  ------------------------------------
2058    
2059      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;      cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
2060    
2061      // Selection List      // Selection List
2062      if(L && SELLI==1) {      if(L && SELLI==1) {
2063          cout<<">>> Found selection-list <<<"<<endl;          cout<<">>> Found selection-list <<<"<<endl;
2064  //      L->SetBranchAddress("RunEntry",&irun);  //      L->SetBranchAddress("RunEntry",&irun);
2065          L->SetBranchAddress("RunEntry",&irun);          L->SetBranchAddress("RunEntry",&irunt);//NEWNEW
2066          cout << "SelectionList: set branch address RunEntry"<<endl;          cout << "SelectionList: set branch address RunEntry"<<endl;
2067          L->SetBranchAddress("EventEntry",&irunentry);          L->SetBranchAddress("EventEntry",&irunentry);
2068          cout << "SelectionList: set branch address EventEntry"<<endl;          cout << "SelectionList: set branch address EventEntry"<<endl;
2069          sel_tree = L;          sel_tree = L;
2070  //      if(!Trout)Trout=O;  //      if(!Trout)Trout=O;
2071  //      else Trout->AddFriend("SelectionList");  //      else Trout->AddFriend("SelectionList");
2072          cout << "----------------------------------------------------" <<endl;          cout << "+SelectionList"<<endl;
2073            cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
2074      }else{      }else{
2075  //      cout << "SelectionList  : missing tree"<<endl;  //      cout << "SelectionList  : missing tree"<<endl;
2076          if(L)L->Delete();          if(L)L->Delete();
2077      };      };
       
 //    cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl;  
   
 //      ------------------------------------  
 //      ATTENZIONE!!!  
 //      non so per quale arcano motivo,  
 //      per l'albero di gpamela il branch address lo devo settare  
 //      DOPO aver fatto friend  
 //      FGRRRVZZZZUTSALKJMSLKJ!!!  
 //      ------------------------------------  
 //     cout << G << " --- "<<GP <<endl;  
 //     if(G && GP) {      
 //      gp_obj->SetBranchAddress(Trout); //ho dovuto fare in maniera diversa dagli altri  
 //      cout << "h20          : set branch address GPamela "<<endl;  
 //     }else{  
 //      cout << "h20          : missing tree"<<endl;  
 //     };  
2078    
2079    //  --------------------------------------------
2080    //  return the pamela chain with all the friends
2081    //  --------------------------------------------
2082    
2083      pam_tree = Trout;      pam_tree = Trout;
2084            
# Line 2210  void PamLevel2::SetBranchAddress(TTree * Line 2171  void PamLevel2::SetBranchAddress(TTree *
2171          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2172          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2173      };      };
     // SelectionList  
     if(SELLI==1) {  
 //      t->SetBranchAddress("RunEntry", &irun);  
         t->SetBranchAddress("RunEntry", &irun);  
         cout << "SelectionList: set branch address RunEntry"<<endl;  
         t->SetBranchAddress("EventEntry", &irunentry);  
         cout << "SelectionList: set branch address EventEntry"<<endl;  
     };  
2174            
2175  }  }
2176  /**  /**
# Line 2301  void PamLevel2::SetBranchAddress(TChain Line 2254  void PamLevel2::SetBranchAddress(TChain
2254          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2255      };      };
2256      // SelectionList      // SelectionList
2257      if(SELLI==1) {  //     if(SELLI==1){
2258  //      t->SetBranchAddress("RunEntry", &irun);  //      t->SetBranchAddress("RunEntry",&irunt);//NEWNEW
2259          t->SetBranchAddress("RunEntry", &irun);  //      cout << "SelectionList: set branch address RunEntry"<<endl;
2260          cout << "SelectionList: set branch address RunEntry"<<endl;  //      t->SetBranchAddress("EventEntry",&irunentry);
2261          t->SetBranchAddress("EventEntry", &irunentry);  //      cout << "SelectionList: set branch address EventEntry"<<endl;
2262          cout << "SelectionList: set branch address EventEntry"<<endl;          
2263      };  //     }
2264        
2265  }  }
2266    
2267    
# Line 2349  TChain *PamLevel2::GetRunTree(TList *fl) Line 2302  TChain *PamLevel2::GetRunTree(TList *fl)
2302          cout << "Run         : set branch address RunInfo"<<endl;          cout << "Run         : set branch address RunInfo"<<endl;
2303          R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano          R->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano
2304          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano
2305    
2306            irunoffset = new int[R->GetNtrees()];
2307            cout << "----------------------------------------------------"<<endl;
2308            cout << "irun\t | ";
2309            cout << "tree\t |";
2310    //      cout << "offset\t |";
2311            cout << "RUN\t";
2312            cout << "FRAG\t";
2313            cout << "NEVENTS\t";
2314            cout << "absolute time\t\t\t";
2315            cout << "on-board time";
2316            cout<<endl;
2317            for (Int_t ii=0; ii<R->GetEntries(); ii++){
2318                R->GetEntry(ii);
2319                cout << ii<< "\t | ";
2320                cout << R->GetTreeNumber()<< "\t |";
2321    //          cout << R->GetChainOffset()<< "\t |";
2322                cout <<GetRunInfo()->ID<<"\t";
2323                cout <<GetRunInfo()->ID_RUN_FRAG<<"\t";
2324                cout <<GetRunInfo()->NEVENTS<< "\t";
2325                cout <<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME <<"\t";
2326                cout <<GetRunInfo()->RUNHEADER_OBT<<" <---> "<<GetRunInfo()->RUNTRAILER_OBT<<"\t";
2327                cout <<endl;
2328                irunoffset[R->GetTreeNumber()]=R->GetChainOffset();
2329            }
2330            cout << "----------------------------------------------------"<<endl;
2331    
2332    
2333    
2334      }else{      }else{
2335          delete R;          delete R;
2336          R=0;          R=0;
# Line 2384  TTree *PamLevel2::GetRunTree(TFile *f){ Line 2366  TTree *PamLevel2::GetRunTree(TFile *f){
2366          cout << "Run         : set branch address RunInfo"<<endl;          cout << "Run         : set branch address RunInfo"<<endl;
2367          T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano          T->SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano
2368          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano
2369    
2370      }      }
2371    
2372      run_tree = (TChain*)T;      run_tree = (TChain*)T;
# Line 2452  Bool_t PamLevel2::UpdateRunInfo(TChain * Line 2435  Bool_t PamLevel2::UpdateRunInfo(TChain *
2435                 abstime <= GetRunInfo()->RUNTRAILER_TIME)                 abstime <= GetRunInfo()->RUNTRAILER_TIME)
2436              ){              ){
2437              irun = -1LL;              irun = -1LL;
2438                irunt = -1LL;
2439              runfirstentry = 0LL;              runfirstentry = 0LL;
2440              runlastentry = -1LL;              runlastentry = -1LL;
2441          };          };
# Line 2537  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2521  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2521        
2522      Int_t oldrun = irun; // store current run index      Int_t oldrun = irun; // store current run index
2523    
2524        // -----------------------------------------------------------------------
2525        // the first time the routine is called, set run search from the beginning
2526        // -----------------------------------------------------------------------
2527    
2528        if ( irun < 0 ){
2529            irun = 0LL;
2530            irunt = 0LL;
2531            irunentry = 0;
2532            prevshift = 0;
2533            run_tree->GetEntry(irun);
2534            if( !GetOrbitalInfo() )cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated "<<endl;
2535        };      
2536        // ---------------------------------------------------------------
2537        // retrieve OBT and absolute time of the event
2538        // ---------------------------------------------------------------
2539        ULong64_t abstime = 0LL;
2540        ULong64_t obt     = 0LL;
2541        if( GetOrbitalInfo() ){
2542            abstime = GetOrbitalInfo()->absTime;
2543            obt     = GetOrbitalInfo()->OBT;
2544    //      cout << " ABS >>> "<<abstime<<" OBT >>> "<<obt<<" "<<endl;
2545        }else{
2546            abstime = GetRunInfo()->RUNHEADER_TIME;
2547            obt     = GetRunInfo()->RUNHEADER_OBT;
2548        }
2549    //    cout << ISGP << " "<<abstime<<endl;
2550        // ---------------------------------------------------------------
2551        // the absolute time is necessary to relate the event with the run
2552        // ---------------------------------------------------------------
2553    //     if( !GetOrbitalInfo() && !ISGP ){
2554    //      cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;
2555    //      return(false);
2556    //     }
2557        // -----------------------------------------------------------------------
2558        // if it is simulation, assign abstime by hand (temporaneo!!!)
2559        // -----------------------------------------------------------------------
2560    //     if(ISGP){
2561    //      abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
2562    //      obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO
2563    //     }
2564        
2565    
2566      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2567      // if it is a full file (not preselected)      // if it is a full file (not preselected)
2568      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2569      if(SELLI==0){      if(SELLI==0){
2570    
2571          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2572          // increment dead and live-time counters          // increment dead and live-time counters
2573            // (only when reading a file not preselected)
2574          // ---------------------------------------------------------------          // ---------------------------------------------------------------
2575          if( GetTrigLevel2() ){          if(SELLI==0){
2576              totdltime[0]+=GetTrigLevel2()->dltime[0];              if( GetTrigLevel2() ){
2577              totdltime[1]+=GetTrigLevel2()->dltime[1];                  totdltime[0]+=GetTrigLevel2()->dltime[0];
2578                    totdltime[1]+=GetTrigLevel2()->dltime[1];
2579                }
2580                totdltime[2]++;
2581          }          }
         totdltime[2]++;  
   
2582  //      cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl;  //      cout << setw(10)<<totdltime[0]<<setw(10)<<totdltime[1]<<setw(10)<<totdltime[2]<<endl;
2583    
2584          // ---------------------------------------------------------------  //      // ---------------------------------------------------------------
2585          // retrieve OBT and absolute time of the event  //      // retrieve OBT and absolute time of the event
2586          // ---------------------------------------------------------------  //      // ---------------------------------------------------------------
2587          ULong64_t abstime = 0;  //      ULong64_t abstime = 0;
2588          ULong64_t obt     = 0;  //      ULong64_t obt     = 0;
2589          if( GetOrbitalInfo() ){  //      if( GetOrbitalInfo() ){
2590              abstime = GetOrbitalInfo()->absTime;  //          abstime = GetOrbitalInfo()->absTime;
2591              obt     = GetOrbitalInfo()->OBT;  //          obt     = GetOrbitalInfo()->OBT;
2592          }  //      }
2593          // ---------------------------------------------------------------  //      // ---------------------------------------------------------------
2594          // the absolute time is necessary to relate the event with the run  //      // the absolute time is necessary to relate the event with the run
2595          // ---------------------------------------------------------------  //      // ---------------------------------------------------------------
2596          if( !GetOrbitalInfo() && !ISGP ){  //      if( !GetOrbitalInfo() && !ISGP ){
2597              cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;  //          cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- ERROR -- missing OrbitalInfo "<<endl;
2598              return(false);  //          return(false);
2599          }  //      }
2600                
2601          // -----------------------------------------------------------------------  //      // -----------------------------------------------------------------------
2602          // the first time the routine is called, set run search from the beginning  //      // the first time the routine is called, set run search from the beginning
2603          // -----------------------------------------------------------------------  //      // -----------------------------------------------------------------------
2604          if ( irun < 0 ){  //      if ( irun < 0 ){
2605              irun = 0LL;  //          irun = 0LL;
2606              irunentry = 0;  //          irunt = 0LL;
2607              prevshift = 0;  //          irunentry = 0;
2608              run_tree->GetEntry(irun);  //          prevshift = 0;
2609    //          run_tree->GetEntry(irun);
2610              if( ISGP && run_tree->GetEntries()!=1 ){  
2611                  cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl;  //          if( ISGP && run_tree->GetEntries()!=1 ){
2612                  cout << "** WARNING ** run will not be updated"<<endl;  //              cout << "** WARNING ** simulated files are assumed to have 1 single run, not "<< run_tree->GetEntries() << endl;
2613              }  //              cout << "** WARNING ** run will not be updated"<<endl;
2614          };        //          }
2615    //      };      
2616    
2617          // -----------------------------------------------------------------------  //      // -----------------------------------------------------------------------
2618          // if it is simulation, assign abstime by hand (temporaneo!!!)  //      // if it is simulation, assign abstime by hand (temporaneo!!!)
2619          // -----------------------------------------------------------------------  //      // -----------------------------------------------------------------------
2620          if(ISGP){  //      if(ISGP){
2621              abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO  //          abstime = GetRunInfo()->RUNHEADER_TIME; // BARBATRUCCO
2622              obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO  //          obt     = GetRunInfo()->RUNHEADER_OBT; // BARBATRUCCO
2623          }  //      }
2624          //          //
2625          bool fromfirst = true; // first loop over runs          bool fromfirst = true; // first loop over runs
2626    
# Line 2624  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2653  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2653              // -----------------------------------------              // -----------------------------------------
2654              // store dead and live-time of previous run              // store dead and live-time of previous run
2655              // -----------------------------------------              // -----------------------------------------
2656              if(fromfirst){  //          if(SELLI==0){
2657                  if(oldrun==irun){                  if(fromfirst){
2658                      /// decrement counters                      if(oldrun==irun){
2659                      if( GetTrigLevel2()){                          /// decrement counters
2660                          totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time                          if( GetTrigLevel2()){
2661                          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time                              totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time
2662                                totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time
2663                            }
2664                            totdltime[2]--;                              //event counter
2665                            cout << endl;
2666                            cout << "n.events     : "<<totdltime[2]<<endl;
2667                            cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;
2668                            cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;          
2669                        }else{
2670                            totdltime[0]=0;//live-time
2671                            totdltime[1]=0;//dead-time
2672                            totdltime[2]=0;                             //event counter
2673                            cout << " *** JUMP RUN *** irun "<<irun<<endl;
2674                      }                      }
2675                      totdltime[2]--;                              //event counter                      /// add an entry
2676                      cout << endl;                      if(run_tree_clone)
2677                      cout << "n.events     : "<<totdltime[2]<<endl;                          if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())
2678                      cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;                              run_tree_clone->GetBranch("DeadLiveTime")->Fill();
2679                      cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;                            /// reset counters
2680                  }else{                      if( GetTrigLevel2() ){
2681                      totdltime[0]=0;//live-time                          totdltime[0]=GetTrigLevel2()->dltime[0];//live-time
2682                      totdltime[1]=0;//dead-time                          totdltime[1]=0;                         //dead-time
2683                      totdltime[2]=0;                             //event counter                      }
2684                      cout << " *** JUMP RUN *** irun "<<irun<<endl;                      totdltime[2]=1;                             //event counter
                 }  
                 /// add an entry  
                 if(run_tree_clone)  
                     if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())  
                         run_tree_clone->GetBranch("DeadLiveTime")->Fill();  
                 /// reset counters  
                 if( GetTrigLevel2() ){  
                     totdltime[0]=GetTrigLevel2()->dltime[0];//live-time  
                     totdltime[1]=0;                         //dead-time  
2685                  }                  }
2686                  totdltime[2]=1;                             //event counter  //          }
             }  
   
2687    
2688              irun++;              irun++;        
2689              // ------------------------------------              // ------------------------------------
2690              // if the end of run tree is reached...              // if the end of run tree is reached...
2691              // ------------------------------------              // ------------------------------------
# Line 2683  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2713  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2713              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;              if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift;
2714              irunentry = 0;              irunentry = 0;
2715              prevshift = 0;                        prevshift = 0;          
2716              run_tree->GetEntry(irun);                    run_tree->GetEntry(irun);
2717                irunt = irun - irunoffset[run_tree->GetTreeNumber()];
2718              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){              if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){
2719                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;                  cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<<irun<<"  has RUNHEADER_OBT>=RUNTRAILER_OBT " <<endl;
2720                  cout << "                                                            (NB!! in this case some events are assigned to a wrong run)"<<endl;                  cout << "                                                            (NB!! in this case some events are assigned to a wrong run)"<<endl;
# Line 2706  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2737  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2737    
2738    
2739    
 //      // -----------------------------------------  
 //      // store dead and live-time of previous run  
 //      // -----------------------------------------  
 //      // --------------------------------------------------------------  
 //      // if the run is empty, fill the dead-live time branch with zeros  
 //      // --------------------------------------------------------------  
 //      /// if some runs have been jumped, fill with zeros  
 //      if(irun-oldrun>1){  
 //          ULong64_t  temp[3];  
 //          temp[0]=totdltime[0];  
 //          temp[1]=totdltime[1];  
 //          temp[2]=totdltime[2];  
 //          for(int i=oldrun+1; i<irun; irun++){  
 //              totdltime[0]=0;  
 //              totdltime[1]=0;  
 //              totdltime[2]=0;  
 //              cout << " ** JUMPED RUN **"<<endl;  
 //              if(run_tree_clone)  
 //                  if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())  
 //                      run_tree_clone->GetBranch("DeadLiveTime")->Fill();  
 //          }  
 //          totdltime[0]=temp[0];  
 //          totdltime[1]=temp[1];  
 //          totdltime[2]=temp[2];  
 //      }  
 //      /// decrement counters  
 //      if( GetTrigLevel2() ){  
 //          totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time  
 //          totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time  
 //      }  
 //      totdltime[2]--;                              //event counter  
 //      /// add an entry  
 //      if(irun>0 ){  
 //          cout << endl;  
 //          cout << "n.events     : "<<totdltime[2]<<endl;  
 //          cout << "RUN LIVE-TIME: "<<totdltime[0]*0.16<<" ms"<<endl;  
 //          cout << "RUN DEAD-TIME: "<<totdltime[1]*0.01<<" ms"<<endl;        
 //          if(run_tree_clone)  
 //              if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries())  
 //                  run_tree_clone->GetBranch("DeadLiveTime")->Fill();  
 //      }  
 //      /// reset counters  
 //      if( GetTrigLevel2() ){  
 //          totdltime[0]=GetTrigLevel2()->dltime[0];//live-time  
 //          totdltime[1]=0;                         //dead-time  
 //      }  
 //      totdltime[2]=1;                             //event counter  
           
2740    
2741          // --------------------------------------          // --------------------------------------
2742          // ---> exit with TRUE          // ---> exit with TRUE
# Line 2776  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2759  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2759      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2760      // if it is a preselected file (there is SelectionList)      // if it is a preselected file (there is SelectionList)
2761      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-      // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
2762        // irun  = run entry relative to the chain
2763        // irunt = run entry relative to the tree
2764      if(SELLI==1){            if(SELLI==1){      
2765          sel_tree->GetEntry(iev);          sel_tree->GetEntry(iev);// read irunt from SelectionList
2766            irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW
2767          if(irun != oldrun){          if(irun != oldrun){
2768              run_tree->GetEntry(irun);              run_tree->GetEntry(irun);
2769                // check if the time is ok (with merged files it is not...)
2770                // if not loop over run and look for the proper entry
2771                bool SECONDO_GIRO=false;
2772                while (
2773                    (
2774                        (
2775                            !(abstime >= GetRunInfo()->RUNHEADER_TIME &&    // check on absolute time (s)
2776                              abstime <= GetRunInfo()->RUNTRAILER_TIME)
2777                            ||
2778                            !(obt >= GetRunInfo()->RUNHEADER_OBT &&         // additional check on OBT (ms)
2779                              obt <= GetRunInfo()->RUNTRAILER_OBT)
2780                            )
2781                        || GetRunInfo()->NEVENTS==0
2782                        )
2783    //              && irun < run_tree->GetEntries()
2784                    ){
2785                    cout << " (test) ";
2786                    cout << " tree "<<sel_tree->GetTreeNumber();
2787                    cout << " irunt "<<irunt;
2788                    cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2789                    cout << " abs "<<abstime;
2790                    cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2791                    cout << " obt "<<obt;
2792                    cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2793                    cout << " *** JUMP RUN *** irun "<<irun;
2794    //              if(!SECONDO_GIRO)cout << " (don't worry)";
2795    //              else             cout << " (start worring...)";
2796                    cout << endl;
2797                    irun++;
2798                    irunoffset[sel_tree->GetTreeNumber()]++;
2799                    if(irun == run_tree->GetEntries() && SECONDO_GIRO){
2800                        cout << " ...grrrvzzkhhhajsdkj!!!! "<<endl;
2801                        return false;
2802                    }
2803                    if(irun == run_tree->GetEntries()){
2804                        SECONDO_GIRO=true;
2805                        irun=0;
2806                        irunoffset[sel_tree->GetTreeNumber()]=0;
2807                    }
2808                    run_tree->GetEntry(irun);
2809                }
2810    
2811                cout << " (test) ";
2812                cout << " tree "<<sel_tree->GetTreeNumber();
2813                cout << " irunt "<<irunt;
2814                cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2815                cout << " abs "<<abstime;
2816                cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2817                cout << " obt "<<obt;
2818                cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2819                cout << endl;
2820              cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;              cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;
2821                cout << endl;
2822              prevshift = 0;              prevshift = 0;
2823              return true;              return true;
2824          }          }
# Line 2813  void PamLevel2::SetWhichTrees(TString de Line 2851  void PamLevel2::SetWhichTrees(TString de
2851      if( detlist.Contains("+ALL", TString::kIgnoreCase)){      if( detlist.Contains("+ALL", TString::kIgnoreCase)){
2852    
2853          cout << " ======================================================== "<<endl;          cout << " ======================================================== "<<endl;
2854          cout << "                       (( WARNING ))                      "<< endl;          cout << "                       (( WARNING ))                      "<<endl;
2855          cout << " The meaning of the option +ALL has changed!!             "<<endl;          cout << " The meaning of the option +ALL has changed!!             "<<endl;
2856          cout << " Now it includes really all (level0+level1+level2+gpamela)"<<endl;          cout << " Now it includes really all (level0+level1+level2+gpamela)"<<endl;
2857          cout << " and the file is discarded if it does not contain all     "<<endl;          cout << " and the file is discarded if it does not contain         "<<endl;
2858          cout << " trees or level0 files are not available!!                "<<endl;          cout << " all trees or  if level0 files are not available!!        "<<endl;
2859          cout << " ======================================================== "<<endl;          cout << " ======================================================== "<<endl;
2860                            
2861          CAL0 = true;          CAL0 = true;
# Line 2927  void PamLevel2::SetWhichTrees(TString de Line 2965  void PamLevel2::SetWhichTrees(TString de
2965      if( detlist.Contains("-GP", TString::kIgnoreCase) )GP = false;      if( detlist.Contains("-GP", TString::kIgnoreCase) )GP = false;
2966      else if( detlist.Contains("+GP", TString::kIgnoreCase) )GP = true;      else if( detlist.Contains("+GP", TString::kIgnoreCase) )GP = true;
2967    
2968      cout<< "Set detector list from input --> ";      cout<< "tree/branch list from input --> ";
2969      if(TRK0)cout<<"TRK0 ";      if(TRK0)cout<<"TRK0 ";
2970      if(TRK1)cout<<"TRK1 ";      if(TRK1)cout<<"TRK1 ";
2971      if(TRK2)cout<<"TRK2 ";      if(TRK2)cout<<"TRK2 ";
# Line 3106  void  PamLevel2::GetWhichTrees(TFile* f) Line 3144  void  PamLevel2::GetWhichTrees(TFile* f)
3144            
3145  //    delete lk;  //    delete lk;
3146    
3147      cout<< "Get detector list from input file --> ";      cout<< "tree/branch list from file  --> ";
3148      if(TRK1)cout<<"TRK1 ";      if(TRK1)cout<<"TRK1 ";
3149      if(TRK2)cout<<"TRK2 ";      if(TRK2)cout<<"TRK2 ";
3150      if(TRKh)cout<<"TRKH ";      if(TRKh)cout<<"TRKH ";
# Line 3154  Bool_t  PamLevel2::CheckLevel2File(TStri Line 3192  Bool_t  PamLevel2::CheckLevel2File(TStri
3192            
3193      Bool_t SELLI__ok  = false;      Bool_t SELLI__ok  = false;
3194    
3195      cout << "Checking file: "<<name<<endl;  //    cout << "Checking file: "<<name<<endl;
3196      TFile *f = new TFile(name.Data());      TFile *f = new TFile(name.Data());
3197      if( !f || f->IsZombie() ){      if( !f || f->IsZombie() ){
3198          cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false;          cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false;
# Line 3506  void PamLevel2::CreateCloneTrees(TFile * Line 3544  void PamLevel2::CreateCloneTrees(TFile *
3544      // ------------------      // ------------------
3545      // replicate run tree      // replicate run tree
3546      // ------------------      // ------------------
3547      cout << "----------------------------------------------------"<<endl;  //    cout << "----------------------------------------------------"<<endl;
3548      cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl;  //    cout << "irun\t | RUN\t NEVENTS\t absolute time"<<endl;
3549      for (Int_t i=0; i<run_tree->GetEntries(); i++){      for (Int_t i=0; i<run_tree->GetEntries(); i++){
3550          run_tree->GetEntry(i);          run_tree->GetEntry(i);
3551          cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl;  //      cout << i<< "\t | "<<GetRunInfo()->ID<<"\t "<<GetRunInfo()->NEVENTS<< "\t "<<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME<<endl;
3552          run_tree_clone->Fill();          run_tree_clone->Fill();
3553      }      }
3554      cout << "----------------------------------------------------"<<endl;      cout << "----------------------------------------------------"<<endl;
# Line 3524  void PamLevel2::CreateCloneTrees(TFile * Line 3562  void PamLevel2::CreateCloneTrees(TFile *
3562    
3563      sel_tree_clone = new TTree("SelectionList","List of selected events ");      sel_tree_clone = new TTree("SelectionList","List of selected events ");
3564  //    sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");  //    sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");
3565      sel_tree_clone->Branch("RunEntry",&irun,"runentry/L");      sel_tree_clone->Branch("RunEntry",&irunt,"runentry/L");//NEWNEW
3566      sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L");      sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L");
3567            
3568    
# Line 3702  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3740  Int_t PamLevel2::GetEntry(Long64_t iee){
3740          return 0;          return 0;
3741      }      }
3742    
 //    cout << " gp_obj->P0 "<<gp_obj->P0<<endl;  
3743      //      //
3744      // ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0.      // ... that's way I put it here. Notice that nothing change in the code (is backward compatible) since in any case you return with 0.
3745      // in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not      // in theory one would like to return 1 if run is not loaded but now I don't have the will to add that 2 lines of code and it is not

Legend:
Removed from v.1.55  
changed lines
  Added in v.1.56

  ViewVC Help
Powered by ViewVC 1.1.23