Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-03 07:50:47

0001 #include <iostream>
0002 #include <fstream>
0003 #include <vector>
0004 #include <map>
0005 #include <utility>
0006 #include <ctype.h>
0007 #include <stdio.h>
0008 #include <stdlib.h>
0009 #include <unistd.h> // Add for use on Mac OS -> Same goes for Analyses.cc
0010 #include "TString.h"
0011 #include "TFile.h"
0012 #include "TTree.h"
0013 #include "TCanvas.h"
0014 #include "TF1.h"
0015 #include "TH1D.h"
0016 #include "TObjArray.h"
0017 #include "TObjString.h"
0018 
0019 #include "Setup.h"
0020 #include "Calib.h"
0021 #include "Event.h"
0022 #include "Tile.h"
0023 #include "HGCROC.h"
0024 #include "Caen.h"
0025 #include "DataAnalysis.h"
0026 
0027 void PrintHelp(char* exe){
0028   std::cout<<"Usage:"<<std::endl;
0029   std::cout<<exe<<" [-option (arguments)]"<<std::endl;
0030   std::cout<<"Options:"<<std::endl;
0031   std::cout<<"-a       printing calib object to file (using name of output root or calib root file ending in txt)"<<std::endl;
0032   std::cout<<"-d [0-n] switch on debug info with debug level 0 to n"<<std::endl;
0033   std::cout<<"-f       Force to write output if already exist"<<std::endl;
0034   std::cout<<"-F fff   set plot extension explicitly, default is pdf "<<std::endl;
0035   std::cout<<"-i uuu   Input file in root format"<<std::endl;
0036   std::cout<<"-n nnn Input the maximum number of events you would like to run"<<std::endl;
0037   std::cout<<"-o vvv   Output file name "<<std::endl;
0038   std::cout<<"-O kkk   Output Histos saved in"<<std::endl;
0039   std::cout<<"-P zzz   Plots directory path"<<std::endl;
0040   std::cout<<"-Q       Run basic QA routine"<<std::endl;
0041   std::cout<<"-r rrr   Name of run list file  2024 PS TB [../configs/DataTakingDB_202409_CAEN.csv] "<<std::endl;
0042   std::cout<<"-y yyyy  setting year externally to narrow parameters"<<std::endl;
0043   std::cout<<"-t       Create Deltatime histos (Use -M and -m for Max and min)"<<std::endl;
0044   std::cout<<"Examples:"<<std::endl;
0045   std::cout<<exe<<" -Q (-f) -P plotDir/ -O OutputHist.root -i input.root (-f to overwrite existing output)"<<std::endl;
0046 }
0047   
0048 
0049 int main(int argc, char* argv[]){
0050   if(argc<4) {
0051     PrintHelp(argv[0]);
0052     return 0;
0053   }
0054   DataAnalysis AnAnalysis;
0055   int c;
0056   while((c=getopt(argc,argv,"ad:e:fF:hi:n:o:O:P:qQr:y:tM:m:L:l:"))!=-1){
0057     switch(c){
0058     case 'a':
0059       std::cout<<"printing calib object to file"<<std::endl;
0060       AnAnalysis.IsCalibSaveToFile(true);
0061       break;
0062     case 'd':
0063       std::cout<<"enable debug " << optarg <<std::endl;
0064       AnAnalysis.EnableDebug(atoi(optarg));
0065       break;
0066     case 'e':
0067       std::cout<<"enabling extended plotting: "<< optarg<<std::endl;
0068       AnAnalysis.SetExtPlotting(atoi(optarg));
0069       break;
0070     case 'f':
0071       std::cout<<"If output already exists it will be overwritten"<<std::endl;
0072       AnAnalysis.CanOverWrite(true);
0073       break;
0074     case 'F':
0075       std::cout<<"DataPrep: Set Plot extension to: "<< optarg<<std::endl;
0076       AnAnalysis.SetPlotExtension(optarg);
0077       break;      
0078     case 'i':
0079       std::cout<<"Root input file is: "<<optarg<<std::endl;
0080       AnAnalysis.SetRootInput(Form("%s",optarg));
0081       break;
0082     case 'n':
0083       std::cout<<"Maximum number of events is changed to "<<optarg<<std::endl;
0084       AnAnalysis.SetMaximumEvents(atoi(optarg));
0085       break;
0086     case 'o':
0087       std::cout<<"Output to be saved in: "<<optarg<<std::endl;
0088       AnAnalysis.SetRootOutput(Form("%s",optarg));
0089       break;
0090     case 'O':
0091       std::cout<<"Output  Histsto be saved in: "<<optarg<<std::endl;
0092       AnAnalysis.SetRootOutputHists(Form("%s",optarg));
0093       break;
0094     case 'P':
0095       std::cout<<"Outputdir plots to be saved in: "<<optarg<<std::endl;
0096       AnAnalysis.SetPlotOutputDir(Form("%s",optarg));
0097       break;
0098     case 'q':
0099       std::cout<<"running very simple QA"<<std::endl;
0100       AnAnalysis.IsToSimpleRunQA(true);
0101       break;
0102     case 'Q':
0103       std::cout<<"running QA"<<std::endl;
0104       AnAnalysis.IsToRunQA(true);
0105       break;
0106     case 'r':
0107       std::cout<<"run list file from: "<<optarg<<std::endl;
0108       AnAnalysis.SetRunListInput(Form("%s",optarg));
0109       break;
0110     case 'y':
0111       std::cout<<"Setting year externally: "<<optarg<<std::endl;
0112       AnAnalysis.SetYear(atoi(optarg));
0113       break;
0114     case '?':
0115       std::cout<<"Option "<<optarg <<" not supported, will be ignored "<<std::endl;
0116       break;
0117     case 't':
0118       std::cout<<"Making DeltaTime Histos"<<std::endl;
0119       AnAnalysis.SetDeltaTimePlotting(true);
0120       break;
0121     case 'M':
0122       std::cout<<"Setting max for DeltaTime histos"<<std::endl;
0123       AnAnalysis.SetTimeMax(atoi(optarg));
0124       break;
0125     case 'm':
0126       std::cout<<"Setting min for DeltaTime histos"<<std::endl;
0127       AnAnalysis.SetTimeMin(atoi(optarg));
0128       break;
0129     case 'L':
0130       std::cout<<"Setting max percent for DeltaTime histos"<<std::endl;
0131       AnAnalysis.SetPercentMax(atoi(optarg));
0132       break;
0133     case 'l':
0134       std::cout<<"Setting min percent for DeltaTime histos"<<std::endl;
0135       AnAnalysis.SetPercentMin(atoi(optarg));
0136       break;    
0137     case 'h':
0138       PrintHelp(argv[0]);
0139       return 0;
0140     }
0141   }
0142   if(!AnAnalysis.CheckAndOpenIO()){
0143     std::cout<<"Check input and configurations, inconsistency or error with I/O detected"<<std::endl;
0144     PrintHelp(argv[0]);
0145     return -1;
0146   }
0147 
0148   AnAnalysis.Process();
0149   std::cout<<"Exiting"<<std::endl;
0150   return 0;
0151 }