--- PamelaLevel2/doc/examples/Loop.cpp 2006/12/11 18:29:01 1.2 +++ PamelaLevel2/doc/examples/Loop.cpp 2007/02/16 18:38:13 1.5 @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -20,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; @@ -33,7 +43,7 @@ // Functions to be provided externally //==================================== bool Select(PamLevel2*); -void CreateHistos(TFile *); +void CreateHistos(PamLevel2*, TFile *); void FillHistos(PamLevel2*); void SaveHistos(TFile *); @@ -42,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"; @@ -77,11 +84,9 @@ if( !Select(event) )return false; -// cout <TrkLevel2::ntrk()<FillCloneTrees(); if(fillHistos)FillHistos(event); + if(fillTree)event->FillCloneTrees(); return true; @@ -92,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"; @@ -111,6 +116,8 @@ //000000000000000000000000000000000000000000 //========================================== Int_t Loop(TString ddir,TString list, ULong64_t nmax, TString options, TString outfile){ + +// gObjectTable->Print(); if(options.Contains("fillTree"))fillTree=true; if(options.Contains("fillHisto"))fillHistos=true; @@ -153,6 +160,7 @@ // read input file/list // -------------------- event = new PamLevel2(); + if(DEBUG)gObjectTable->Print(); if(list.Contains(".root")){ stringstream command; command.str(""); @@ -160,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); // --------------- @@ -179,39 +190,42 @@ cout << endl<<" Start loop over events: "<< nmax<Start("event-loop"); TString current_file = ""; + 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(); + event->Clear(); // -------------- // close and exit // -------------- @@ -225,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(){