/[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.58 by pam-fi, Tue Nov 27 19:34:08 2007 UTC revision 1.61 by pam-fi, Thu Apr 3 14:39:51 2008 UTC
# Line 492  void PamLevel2::Initialize(){ Line 492  void PamLevel2::Initialize(){
492    
493      ISGP = false;      ISGP = false;
494    
495        DBG = false;
496    
497      tsorted=0;      tsorted=0;
498      timage=0;      timage=0;
499            
# Line 1520  PamTrack *PamLevel2::GetTrack(int it){ Line 1522  PamTrack *PamLevel2::GetTrack(int it){
1522   */   */
1523  PamTrack *PamLevel2::GetTrackImage(int it){  PamTrack *PamLevel2::GetTrackImage(int it){
1524    
 //     if(!trk2_obj) return 0;  
   
 // //  *-*-*-*-*-*-*-*-*-*-*-*-*  
 //     SortTracks("+CAL+TOF");  
 // //  *-*-*-*-*-*-*-*-*-*-*-*-*  
 // //    if(!sorted_tracks)return 0;  
 //     if(sorted_tracks.IsEmpty())return 0;  
       
 //     PamTrack *image = 0;  
       
 //     if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){  
 //      TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it);  
 //      if( temp->HasImage() ){  
 //          TrkTrack   *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo());  
 //          image = GetPamTrackAlong(t);  
 //      }else{  
 //          cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl;  
 //      };  
 //     }else{  
 //      cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<trk2_obj->TrkLevel2::GetNTracks()<<")"<<endl;  
 //     };  
       
 //     return image;  
   
   
1525  //  *-*-*-*-*-*-*-*-*-*-*-*-*  //  *-*-*-*-*-*-*-*-*-*-*-*-*
1526      SortTracks();      SortTracks();
1527  //  *-*-*-*-*-*-*-*-*-*-*-*-*  //  *-*-*-*-*-*-*-*-*-*-*-*-*
# Line 2168  void PamLevel2::SetBranchAddress(TTree * Line 2145  void PamLevel2::SetBranchAddress(TTree *
2145      if(GP) {      if(GP) {
2146  //      GetPointerTo("GPamela");  //      GetPointerTo("GPamela");
2147          if(!gp_obj)gp_obj = new GPamela();          if(!gp_obj)gp_obj = new GPamela();
2148          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri  //      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2149    // //   t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2150            if(SELLI) t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2151            else      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2152    
2153          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2154      };      };
2155            
# Line 2250  void PamLevel2::SetBranchAddress(TChain Line 2231  void PamLevel2::SetBranchAddress(TChain
2231      if(GP) {      if(GP) {
2232  //      GetPointerTo("GPamela");  //      GetPointerTo("GPamela");
2233          if(!gp_obj)gp_obj = new GPamela();          if(!gp_obj)gp_obj = new GPamela();
2234          gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri          if(SELLI) t->SetBranchAddress("GPamela", GetPointerTo("GPamela"));
2235            else      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2236    //      gp_obj->SetBranchAddress(t); //ho dovuto fare in maniera diversa dagli altri
2237          cout << "h20          : set branch address GPamela "<<endl;          cout << "h20          : set branch address GPamela "<<endl;
2238      };      };
2239      // SelectionList      // SelectionList
# Line 2283  TChain *PamLevel2::GetRunTree(TList *fl) Line 2266  TChain *PamLevel2::GetRunTree(TList *fl)
2266          return run_tree;          return run_tree;
2267      };        };  
2268      //      //
2269    
2270    
2271      TChain *R = new TChain("Run");      TChain *R = new TChain("Run");
2272            
2273      // loop over files and create chains              // loop over files and create chains        
# Line 2295  TChain *PamLevel2::GetRunTree(TList *fl) Line 2280  TChain *PamLevel2::GetRunTree(TList *fl)
2280              R->Add(name);              R->Add(name);
2281          };          };
2282      }      }
2283        
2284    
2285      if(R->GetNtrees()){      if(RUN && R->GetNtrees()){
2286            
2287          R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));          R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));
2288          cout << "Run         : set branch address RunInfo"<<endl;          cout << "Run         : set branch address RunInfo"<<endl;
# Line 2304  TChain *PamLevel2::GetRunTree(TList *fl) Line 2290  TChain *PamLevel2::GetRunTree(TList *fl)
2290          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano          cout << "Software    : set branch address SoftInfo"<<endl; // Emiliano
2291    
2292          irunoffset = new int[R->GetNtrees()];          irunoffset = new int[R->GetNtrees()];
2293          cout << "----------------------------------------------------"<<endl;          if(DBG){
2294          cout << "irun\t | ";              cout << "----------------------------------------------------"<<endl;
2295          cout << "tree\t |";              cout << "irun\t | ";
2296                cout << "tree\t |";
2297  //      cout << "offset\t |";  //      cout << "offset\t |";
2298          cout << "RUN\t";              cout << "RUN\t";
2299          cout << "FRAG\t";              cout << "FRAG\t";
2300          cout << "NEVENTS\t";              cout << "NEVENTS\t";
2301          cout << "absolute time\t\t\t";              cout << "absolute time\t\t\t";
2302          cout << "on-board time";              cout << "on-board time";
2303          cout<<endl;              cout<<endl;
2304            }
2305          for (Int_t ii=0; ii<R->GetEntries(); ii++){          for (Int_t ii=0; ii<R->GetEntries(); ii++){
2306              R->GetEntry(ii);              R->GetEntry(ii);
2307              cout << ii<< "\t | ";              if(DBG){
2308              cout << R->GetTreeNumber()<< "\t |";                  cout << ii<< "\t | ";
2309                    cout << R->GetTreeNumber()<< "\t |";
2310  //          cout << R->GetChainOffset()<< "\t |";  //          cout << R->GetChainOffset()<< "\t |";
2311              cout <<GetRunInfo()->ID<<"\t";                  cout <<GetRunInfo()->ID<<"\t";
2312              cout <<GetRunInfo()->ID_RUN_FRAG<<"\t";                  cout <<GetRunInfo()->ID_RUN_FRAG<<"\t";
2313              cout <<GetRunInfo()->NEVENTS<< "\t";                  cout <<GetRunInfo()->NEVENTS<< "\t";
2314              cout <<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME <<"\t";                  cout <<GetRunInfo()->RUNHEADER_TIME<<" <---> "<<GetRunInfo()->RUNTRAILER_TIME <<"\t";
2315              cout <<GetRunInfo()->RUNHEADER_OBT<<" <---> "<<GetRunInfo()->RUNTRAILER_OBT<<"\t";                  cout <<GetRunInfo()->RUNHEADER_OBT<<" <---> "<<GetRunInfo()->RUNTRAILER_OBT<<"\t";
2316              cout <<endl;                  cout <<endl;
2317                }
2318              irunoffset[R->GetTreeNumber()]=R->GetChainOffset();              irunoffset[R->GetTreeNumber()]=R->GetChainOffset();
2319          }          }
2320            cout << "N.run = "<<R->GetEntries()<<endl;
2321          cout << "----------------------------------------------------"<<endl;          cout << "----------------------------------------------------"<<endl;
2322    
2323    
   
2324      }else{      }else{
2325          delete R;          delete R;
2326          R=0;          R=0;
2327      }      }
2328        
2329    
2330      run_tree = R;      run_tree = R;
2331    
# Line 2784  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2775  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2775                      )                      )
2776  //              && irun < run_tree->GetEntries()  //              && irun < run_tree->GetEntries()
2777                  ){                  ){
2778                  cout << " (test) ";  
2779                  cout << " tree "<<sel_tree->GetTreeNumber();                  if(DBG){
2780                  cout << " irunt "<<irunt;                      cout << " (test) ";
2781                  cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];                      cout << " tree "<<sel_tree->GetTreeNumber();
2782                  cout << " abs "<<abstime;                      cout << " irunt "<<irunt;
2783                  cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;                      cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2784                  cout << " obt "<<obt;                      cout << " abs "<<abstime;
2785                  cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;                      cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2786                  cout << " *** JUMP RUN *** irun "<<irun;                      cout << " obt "<<obt;
2787                        cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2788                        cout << " *** JUMP RUN *** irun "<<irun;
2789  //              if(!SECONDO_GIRO)cout << " (don't worry)";  //              if(!SECONDO_GIRO)cout << " (don't worry)";
2790  //              else             cout << " (start worring...)";  //              else             cout << " (start worring...)";
2791                  cout << endl;                      cout << endl;
2792                    }
2793  //              irun++;  //              irun++;
2794                  irunoffset[sel_tree->GetTreeNumber()]++;                  irunoffset[sel_tree->GetTreeNumber()]++;
2795                  irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW                            irun = irunt + irunoffset[sel_tree->GetTreeNumber()];//NEWNEW          
# Line 2814  Bool_t PamLevel2::UpdateRunInfo(Long64_t Line 2808  Bool_t PamLevel2::UpdateRunInfo(Long64_t
2808                  run_tree->GetEntry(irun);                  run_tree->GetEntry(irun);
2809              }              }
2810    
2811              cout << " (test) ";  
2812              cout << " tree "<<sel_tree->GetTreeNumber();              if(DBG){
2813              cout << " irunt "<<irunt;                  cout << " (test) ";
2814              cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];                  cout << " tree "<<sel_tree->GetTreeNumber();
2815              cout << " abs "<<abstime;                  cout << " irunt "<<irunt;
2816              cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;                  cout << " offset "<<irunoffset[sel_tree->GetTreeNumber()];
2817              cout << " obt "<<obt;                  cout << " abs "<<abstime;
2818              cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;                  cout <<" >> "<<GetRunInfo()->RUNHEADER_TIME<<" "<<GetRunInfo()->RUNTRAILER_TIME;
2819              cout << endl;                  cout << " obt "<<obt;
2820              cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" irun "<<irun<<endl;                  cout <<" >> "<<GetRunInfo()->RUNHEADER_OBT<<" "<<GetRunInfo()->RUNTRAILER_OBT;
2821                }
2822              cout << endl;              cout << endl;
2823                cout << endl << " ))))) UPDATE RUN INFO (((((  @iev "<<iev<<" run "<<GetRunInfo()->ID<<" (run-entry "<<irun<<")"<<endl;
2824    //          cout << endl;
2825              prevshift = 0;              prevshift = 0;
2826              return true;              return true;
2827          }          }
# Line 3031  void  PamLevel2::GetWhichTrees(TFile* f) Line 3028  void  PamLevel2::GetWhichTrees(TFile* f)
3028            
3029      RUN    = false;      RUN    = false;
3030                    
3031      cout << "Checking file: "<<f->GetName()<<endl;  //    cout << "Checking file: "<<f->GetName()<<endl;
3032      if( !f || f->IsZombie() ){      if( !f || f->IsZombie() ){
3033          cout << "File: "<< f->GetName() <<" Non valid root file"<< endl;          cout << "File: "<< f->GetName() <<" Non valid root file"<< endl;
3034          return;          return;
# Line 3406  Bool_t  PamLevel2::CheckLevel2File(TStri Line 3403  Bool_t  PamLevel2::CheckLevel2File(TStri
3403    
3404    
3405      if(!RUN__ok) {      if(!RUN__ok) {
3406          cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl;          cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree (NB: RUN infos will not be updated)"<< endl;
3407  //      return false;          RUN = false;
3408      };      };
3409    
3410      if(CAL1 && !CAL1__ok){      if(CAL1 && !CAL1__ok){
# Line 3530  void PamLevel2::CreateCloneTrees(TFile * Line 3527  void PamLevel2::CreateCloneTrees(TFile *
3527    
3528    
3529  //  if the pointer is null, create a default file  //  if the pointer is null, create a default file
3530        if(!run_tree)return;
3531    
3532      if(!ofile){      if(!ofile){
3533          cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl;          cout << "void PamLevel2::CreateCloneTrees(TFile*) -- WARNING -- Creating file: clone-tree.root "<<endl;
# Line 3751  Int_t PamLevel2::GetEntry(Long64_t iee){ Line 3749  Int_t PamLevel2::GetEntry(Long64_t iee){
3749      // 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
3750      // a problem if you don't check the return code of getentry.      // a problem if you don't check the return code of getentry.
3751      //      //
3752      if(!run_tree ){      if(!RUN || !run_tree ){
3753          if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1?          if ( TRK0 || CAL0 || TOF0 || RUN ) { //forse cosi` va bene per tornare 1?
3754              cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl;              cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- run tree not loaded"<<endl;
3755              return 0;              return 0;
# Line 4022  Int_t PamLevel2::GetYodaEntry(){ Line 4020  Int_t PamLevel2::GetYodaEntry(){
4020   */   */
4021  Bool_t PamLevel2::SetDBConnection(){  Bool_t PamLevel2::SetDBConnection(){
4022    
4023      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(DBG){
4024      cout<<"Connecting to DB"<<endl;          cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
4025      cout<<"HOST "<<host<<endl;          cout<<"Connecting to DB"<<endl;
4026      cout<<"USER "<<user<<endl;          cout<<"HOST "<<host<<endl;
4027      cout<<"PSW  "<<psw<<endl;          cout<<"USER "<<user<<endl;
4028            cout<<"PSW  "<<psw<<endl;
4029        }
4030      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
4031      if( !dbc )return false;      if( !dbc )return false;
4032      if( !dbc->IsConnected() )return false;          if( !dbc->IsConnected() )return false;    
# Line 4034  Bool_t PamLevel2::SetDBConnection(){ Line 4034  Bool_t PamLevel2::SetDBConnection(){
4034      myquery.str("");  // EMILIANO      myquery.str("");  // EMILIANO
4035      myquery << "SET time_zone='+0:00'";  // EMILIANO      myquery << "SET time_zone='+0:00'";  // EMILIANO
4036      dbc->Query(myquery.str().c_str());  // EMILIANO      dbc->Query(myquery.str().c_str());  // EMILIANO
4037      cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;      if(DBG)cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
4038      return true;      return true;
4039    
4040  }  }

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.61

  ViewVC Help
Powered by ViewVC 1.1.23