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