--- PamelaLevel2/doc/examples/Loop.cpp 2007/01/15 11:51:39 1.4 +++ PamelaLevel2/doc/examples/Loop.cpp 2007/02/16 18:38:13 1.5 @@ -30,9 +30,11 @@ 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; @@ -41,7 +43,7 @@ // Functions to be provided externally //==================================== bool Select(PamLevel2*); -void CreateHistos(TFile *); +void CreateHistos(PamLevel2*, TFile *); void FillHistos(PamLevel2*); void SaveHistos(TFile *); @@ -50,27 +52,24 @@ //========================================== bool Begin(){ - //------------------------ - // load magnetic field - //------------------------ - TString fieldpath = gSystem->Getenv("PAM_CALIB"); - if(fieldpath.IsNull()){ - cout << " **ERROR** : No PAMELA environment variables defined "<GetTrkLevel2()->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"; @@ -86,8 +85,8 @@ if( !Select(event) )return false; - if(fillTree)event->FillCloneTrees(); if(fillHistos)FillHistos(event); + if(fillTree)event->FillCloneTrees(); return true; @@ -98,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"; @@ -169,8 +168,10 @@ 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); @@ -200,21 +201,26 @@ 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 << "%%%% "<GetFile()->GetName())){ current_file=tree->GetFile()->GetName(); - cout << iev<< " -> "<< current_file << endl; + cout < "<< current_file << endl; }; }else{ cout << "Chain entry "<Print(); + + if( !(iev%1000) )cout <<"|"; }; + cout <Show("event-loop"); cout << sel <<" selected events over "<