/[PAMELA software]/PamelaLevel2/doc/examples/Loop.cpp
ViewVC logotype

Diff of /PamelaLevel2/doc/examples/Loop.cpp

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

revision 1.3 by pam-fi, Wed Jan 3 13:28:49 2007 UTC revision 1.4 by pam-fi, Mon Jan 15 11:51:39 2007 UTC
# Line 21  using namespace std; Line 21  using namespace std;
21  //===================================  //===================================
22  // global variables  // global variables
23  //===================================  //===================================
24    Bool_t    DEBUG;
25    TString   DIR;
26    TString   LIST;
27    TString   OPTIONS;
28    ULong64_t MAXEV;
29    TString   OUTFILE;
30    
31  PamLevel2 *event = NULL;  PamLevel2 *event = NULL;
32  TChain    *tree  = NULL;  TChain    *tree  = NULL;
33  TFile     *outfh = NULL;  TFile     *outfh = NULL;
# Line 52  bool Begin(){ Line 59  bool Begin(){
59          return 0;          return 0;
60      }      }
61      fieldpath.Append("/trk-param/field_param-0/");      fieldpath.Append("/trk-param/field_param-0/");
62      event->LoadField(fieldpath.Data());      event->GetTrkLevel2()->LoadField(fieldpath.Data());
63    
64    
65      //------------------------------      //------------------------------
# Line 78  bool Process(int iev){ Line 85  bool Process(int iev){
85    
86            
87      if( !Select(event) )return false;      if( !Select(event) )return false;
 //    cout <<event->TrkLevel2::ntrk()<<endl;  
   
88    
89      if(fillTree)event->FillCloneTrees();      if(fillTree)event->FillCloneTrees();
90      if(fillHistos)FillHistos(event);      if(fillHistos)FillHistos(event);
# Line 156  Int_t Loop(TString ddir,TString list, UL Line 161  Int_t Loop(TString ddir,TString list, UL
161  //  read input file/list  //  read input file/list
162  //  --------------------  //  --------------------
163      event = new PamLevel2();      event = new PamLevel2();
164        if(DEBUG)gObjectTable->Print();
165      if(list.Contains(".root")){      if(list.Contains(".root")){
166          stringstream command;          stringstream command;
167          command.str("");          command.str("");
# Line 166  Int_t Loop(TString ddir,TString list, UL Line 172  Int_t Loop(TString ddir,TString list, UL
172      }else{            }else{      
173          tree  = event->GetPamTree(ddir,list,options);          tree  = event->GetPamTree(ddir,list,options);
174      };      };
175    //    gObjectTable->Print();
176      tree->SetCacheSize(0);      tree->SetCacheSize(0);
177    
178  //  ---------------  //  ---------------
# Line 182  Int_t Loop(TString ddir,TString list, UL Line 189  Int_t Loop(TString ddir,TString list, UL
189            
190      cout << endl<<" Start loop over events:  "<< nmax<<endl;      cout << endl<<" Start loop over events:  "<< nmax<<endl;
191      Int_t ntrk = 0;      Int_t ntrk = 0;
192        Int_t ncls = 0;
193      Int_t sel  = 0;      Int_t sel  = 0;
194      Int_t get  = 0;      Int_t get  = 0;
195      TBenchmark *benchmark = new TBenchmark();      TBenchmark *benchmark = new TBenchmark();
196      benchmark->Start("event-loop");      benchmark->Start("event-loop");
197            
198      TString current_file = "";      TString current_file = "";
199  //    gObjectTable->Print();      if(DEBUG)gObjectTable->Print();
200      for(ULong64_t iev=0; iev<nmax; iev++){      for(ULong64_t iev=0; iev<nmax; iev++){
201                    
202          event->Clear();          event->Clear();
# Line 196  Int_t Loop(TString ddir,TString list, UL Line 204  Int_t Loop(TString ddir,TString list, UL
204              get++;              get++;
205              if( Process(iev) ){              if( Process(iev) ){
206                  sel++;                  sel++;
                 if(event->TrkLevel2::ntrk() >0)ntrk++;    
207              }              }
208              if(current_file.CompareTo(tree->GetFile()->GetName())){              if(current_file.CompareTo(tree->GetFile()->GetName())){
209                  current_file=tree->GetFile()->GetName();                  current_file=tree->GetFile()->GetName();
210                  cout << iev<< " -> "<< current_file << endl;                  cout << iev<< " -> "<< current_file << endl;
 //          cout << tree->GetFile()->GetName() << endl;  
211              };              };
 //          if( fillTree && !(sel%10000) )  
 //          if(event->TrkLevel2::ntrk() >0)ntrk++;        
212          }else{          }else{
213              cout << "Chain entry "<<iev<<" -- ERROR --"<<endl;              cout << "Chain entry "<<iev<<" -- ERROR --"<<endl;
214          };          };
215  //      if(!(iev%100))cout << iev << endl;          if( !(iev%5000) && DEBUG)gObjectTable->Print();
216            
217      };      };
218      benchmark->Show("event-loop");      benchmark->Show("event-loop");
219      cout << sel <<" selected events over "<<get;      cout << sel <<" selected events over "<<get;
220      if(get)cout<<" ("<< 100*sel/get<<"%)"<<endl;      if(get)cout<<" ("<< 100*sel/get<<"%)"<<endl;
221  //    cout << "Fitted tracks: "<<ntrk<<endl;      if(DEBUG)gObjectTable->Print();
222  //    gObjectTable->Print();      event->Clear();
223  //  --------------  //  --------------
224  //  close and exit  //  close and exit
225  //  --------------  //  --------------
# Line 229  Int_t Loop(TString ddir,TString list, UL Line 233  Int_t Loop(TString ddir,TString list, UL
233    
234  #if !defined(__CINT__)  #if !defined(__CINT__)
235    
236  // input parameters  // // input parameters
237  Bool_t    DEBUG;  // Bool_t    DEBUG;
238  TString   DIR;  // TString   DIR;
239  TString   LIST;  // TString   LIST;
240  TString   OPTIONS;  // TString   OPTIONS;
241  ULong64_t MAXEV;  // ULong64_t MAXEV;
242  TString   OUTFILE;  // TString   OUTFILE;
243    
244  void usage(){  void usage(){
245    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23