// #include #include // #include #include #include #include #include #include #include #include #include // #include // using namespace std; //=================================== // global variables //=================================== Bool_t DEBUG; Bool_t MATRIX; TString DIR; TString LIST; TString I_OPTIONS; TString O_OPTIONS; ULong64_t MINEV; ULong64_t MAXEV; TString OUTFILE; PamLevel2 *event = NULL; TFile *outfh = NULL; //==================================== // Functions to be provided externally //==================================== bool Select(PamLevel2*); void CreateHistos(PamLevel2*, TString); void FindAverage(PamLevel2*,int); void FindMatrix(PamLevel2*,int); void SaveHistos(); void CalculateAverage(); //========================================== //000000000000000000000000000000000000000000 //========================================== bool Begin(TString outfile){ //------------------------------ // create output histos/trees //------------------------------ CreateHistos(event,outfile); cout << "\nBegin() - done\n\n"; return 1; } //========================================== //000000000000000000000000000000000000000000 //========================================== bool Process1(int iev){ if( !Select(event) )return false; if ( MATRIX ){ FindMatrix(event,iev); } else { FindAverage(event,iev); }; return true; } //========================================== //000000000000000000000000000000000000000000 //========================================== bool Finish(){ SaveHistos(); cout << "Finish() - done\n"; return 1; } //========================================== //000000000000000000000000000000000000000000 //========================================== Int_t Loop(TString ddir,TString list, ULong64_t nmax, ULong64_t nmin, TString ioptions, TString ooptions, TString outfile){ // ------------------- // create output files // ------------------- TTree::SetMaxTreeSize(1000*Long64_t(2000000000)); //m 070308 + dimensione oltre la quale divide il file di uscita: 2TB // -------------------- // read input file/list // -------------------- event = new PamLevel2(ddir,list,ioptions); // tree->SetCacheSize(0); // --------------- // initializations // --------------- if( !Begin(outfile) )return 0;; // ----------------- // loop over events // ----------------- ULong64_t nevents = event->GetEntries(); if(!nmax)nmax = numeric_limits::max(); if(nevents < nmax)nmax=nevents; nmax=nmax-nmin; cout << endl<<" Start loop over events: "<< nmax <Clear(); if( event->GetEntry(iev) ){ Process1(iev); }else{ cout << "Chain entry "<Clear(); // -------------- // close and exit // -------------- Finish(); return 0; } ///////////////////////////////////////////////////////////////// void usage(){ cout << "------------------------------------------------------------"< inlcude(exclude) all default level1/level2 trees and branches \n " ; cout << " +(-)TRK1 +(-)TRK2 +(-)CAL1 +(-)CAL2 +(-)TOF +(-)TRG +(-)ND +(-)S4 +(-)ORB --> inlcude(exclude) level1/level2 trees and branches \n" ; cout << " +TRK0 +CAL0 +TOF0 --> include level0 branches \n" ; cout << "-output-options [ options ] - options: \n"; cout << " fillHistos --> create an output file with histograms \n"; cout << " fillTree --> create an output file with trees storing the selected events \n "; cout << " == NB == "< inlcude(exclude) all trees and branches \n " ; cout << " +(-)TRK1 +(-)TRK2 +(-)CAL1 +(-)CAL2 +(-)TOF +(-)TRG +(-)ND +(-)S4 +(-)ORB --> inlcude(exclude) trees and branches \n" ; cout << "------------------------------------------------------------"<1){ if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") ){ usage(); return(1); }; // ----------------------- // Read input parameters // ----------------------- DEBUG = false; MATRIX = false; DIR = gSystem->WorkingDirectory(); LIST = ""; OUTFILE = ""; I_OPTIONS = "+AUTO "; O_OPTIONS = "fillHistos"; MAXEV = 0; MINEV = 0; for (int i = 1; i < argc; i++){ // -----------------------------------------------------// if (!strcmp(argv[i], "-processFile")){ if (++i >= argc) throw -1; LIST = argv[i]; cout << "processFile "<= argc) throw -1; DIR = argv[i]; cout << "processDir "<= argc) throw -1; OUTFILE = argv[i]; cout << "outputFile "<= argc) throw -1; MINEV = atoi(argv[i]); cout << "FirstEvent "<= argc) throw -1; MAXEV = atoi(argv[i]); cout << "NumEvents "<= argc) throw -1; I_OPTIONS = argv[i]; if( I_OPTIONS.Contains("[") ){ do{ if (++i >= argc) throw -1; I_OPTIONS.Append(argv[i]); }while(!I_OPTIONS.Contains("]")); }else cout << "wrong option format --> ignoring " << endl; } // -----------------------------------------------------// else if (!strcmp(argv[i], "-output-options")){ if (++i >= argc) throw -1; O_OPTIONS = argv[i]; if( O_OPTIONS.Contains("[") ){ do{ if (++i >= argc) throw -1; O_OPTIONS.Append(argv[i]); }while(!O_OPTIONS.Contains("]")); }else cout << "wrong option format --> ignoring " << endl; } // -----------------------------------------------------// else if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-g")){ DEBUG = true; continue; } // else if (!strcmp(argv[i], "-matrix")){ MATRIX = true; continue; } // -----------------------------------------------------// else{ cout << "Unidentified input parameter. Ignored."<< endl; }; }; }else{ usage(); return(1); }; // ----------------------- // Check input parameters // ----------------------- return(0); }; // int main(int argc, char **argv) { if( HandleInputPar(argc,argv) )return(1); cout << "INPUT OPTIONS "<