--- PamelaLevel2/doc/examples/Loop.cpp 2007/01/03 13:28:49 1.3 +++ PamelaLevel2/doc/examples/Loop.cpp 2007/02/16 18:38:13 1.5 @@ -21,11 +21,20 @@ //=================================== // global variables //=================================== +Bool_t DEBUG; +TString DIR; +TString LIST; +TString OPTIONS; +ULong64_t MAXEV; +TString OUTFILE; + PamLevel2 *event = NULL; TChain *tree = NULL; +TChain *runt = NULL; TFile *outfh = NULL; TFile *outft = NULL; TTree *otree = NULL; +GL_RUN *run = NULL; bool fillTree = false; bool fillHistos = false; @@ -34,7 +43,7 @@ // Functions to be provided externally //==================================== bool Select(PamLevel2*); -void CreateHistos(TFile *); +void CreateHistos(PamLevel2*, TFile *); void FillHistos(PamLevel2*); void SaveHistos(TFile *); @@ -43,27 +52,24 @@ //========================================== bool Begin(){ - //------------------------ - // load magnetic field - //------------------------ - TString fieldpath = gSystem->Getenv("PAM_CALIB"); - if(fieldpath.IsNull()){ - cout << " **ERROR** : No PAMELA environment variables defined "<LoadField(fieldpath.Data()); - +// //------------------------ +// // load magnetic field +// //------------------------ +// TString fieldpath = gSystem->Getenv("PAM_CALIB"); +// if(fieldpath.IsNull()){ +// cout << " **ERROR** : No PAMELA environment variables defined "<GetTrkLevel2()->LoadField(fieldpath.Data()); +// === non c'e` piu` bisogno //------------------------------ // create output histos/trees //------------------------------ - if(fillHistos) CreateHistos(outfh); - if(fillTree){ -// outft->cd(); -// event->CreateCloneTrees(tree,outft); - event->CreateCloneTrees(outft); - } + if(fillHistos) CreateHistos(event,outfh); + if(fillTree)event->CreateCloneTrees(outft); + // gDirectory->ls(); cout << "\nBegin() - done\n\n"; @@ -78,11 +84,9 @@ if( !Select(event) )return false; -// cout <TrkLevel2::ntrk()<FillCloneTrees(); if(fillHistos)FillHistos(event); + if(fillTree)event->FillCloneTrees(); return true; @@ -93,15 +97,15 @@ bool Finish(){ + if(fillHistos){ + SaveHistos(outfh); + outfh->Close(); + } if(fillTree){ outft->cd(); event->WriteCloneTrees(); outft->Close(); } - if(fillHistos){ - SaveHistos(outfh); - outfh->Close(); - } cout << "Finish() - done\n"; @@ -156,6 +160,7 @@ // read input file/list // -------------------- event = new PamLevel2(); + if(DEBUG)gObjectTable->Print(); if(list.Contains(".root")){ stringstream command; command.str(""); @@ -163,9 +168,12 @@ cout << command.str().c_str() << endl; gSystem->Exec(command.str().c_str()); tree = event->GetPamTree(ddir,"list-temp.txt",options); + runt = event->GetRunTree(ddir,"list-temp.txt"); }else{ tree = event->GetPamTree(ddir,list,options); + runt = event->GetRunTree(ddir,list); }; +// gObjectTable->Print(); tree->SetCacheSize(0); // --------------- @@ -182,40 +190,42 @@ cout << endl<<" Start loop over events: "<< nmax<Start("event-loop"); TString current_file = ""; -// gObjectTable->Print(); + if(DEBUG)gObjectTable->Print(); for(ULong64_t iev=0; ievClear(); - if( tree->GetEntry(iev) ){ +// if( tree->GetEntry(iev) ){ + if( event->GetEntry(iev) ){ //<<< new feature get++; if( Process(iev) ){ + cout << "%%%% "<TrkLevel2::ntrk() >0)ntrk++; } if(current_file.CompareTo(tree->GetFile()->GetName())){ current_file=tree->GetFile()->GetName(); - cout << iev<< " -> "<< current_file << endl; -// cout << tree->GetFile()->GetName() << endl; + cout < "<< current_file << endl; }; -// if( fillTree && !(sel%10000) ) -// if(event->TrkLevel2::ntrk() >0)ntrk++; }else{ cout << "Chain entry "<Print(); + if( !(iev%1000) )cout <<"|"; + }; + cout <Show("event-loop"); cout << sel <<" selected events over "<Print(); + if(DEBUG)gObjectTable->Print(); + event->Clear(); // -------------- // close and exit // -------------- @@ -229,13 +239,13 @@ #if !defined(__CINT__) -// input parameters -Bool_t DEBUG; -TString DIR; -TString LIST; -TString OPTIONS; -ULong64_t MAXEV; -TString OUTFILE; +// // input parameters +// Bool_t DEBUG; +// TString DIR; +// TString LIST; +// TString OPTIONS; +// ULong64_t MAXEV; +// TString OUTFILE; void usage(){