File indexing completed on 2026-08-05 08:29:04
0001 #include <iostream>
0002 #include <fstream>
0003 #include <vector>
0004 #include <map>
0005 #include <utility>
0006 #include <string>
0007 #include <ctype.h>
0008 #include <stdio.h>
0009 #include <stdlib.h>
0010 #include <unistd.h>
0011 #ifdef __APPLE__
0012 #include <unistd.h>
0013 #endif
0014 #include "TString.h"
0015 #include "TFile.h"
0016 #include "TTree.h"
0017 #include "TCanvas.h"
0018 #include "TF1.h"
0019 #include "TH1D.h"
0020 #include "TObjArray.h"
0021 #include "TObjString.h"
0022
0023 #include "Setup.h"
0024 #include "Calib.h"
0025 #include "Event.h"
0026 #include "Tile.h"
0027 #include "HGCROC.h"
0028 #include "Caen.h"
0029 #include "ComparisonWaveform.h"
0030
0031 void PrintHelp(char* exe){
0032 std::cout<<"Usage:"<<std::endl;
0033 std::cout<<exe<<" [-option (arguments)]"<<std::endl;
0034 std::cout<<"Options:"<<std::endl;
0035 std::cout<<"-c ccc list of cell to be plotted separately"<<std::endl;
0036 std::cout<<"-d [0-3] Debugging mode"<<std::endl;
0037 std::cout<<"-e [0-1] extended plotting"<<std::endl;
0038 std::cout<<"-E [1-X] histo reading options for expanded file list"<<std::endl;
0039 std::cout<<"-f Force to write output if already exist"<<std::endl;
0040 std::cout<<"-F fff set explicit plot extension explicitly, default is pdf "<<std::endl;
0041 std::cout<<"-H switch to HGCROC output" << std::endl;
0042 std::cout<<"-i uuu Input file list"<<std::endl;
0043 std::cout<<"-I uuu expanded input file list"<<std::endl;
0044 std::cout<<"-L [1-63]restrict max layer plotting"<<std::endl;
0045 std::cout<<"-o vvv Output file name (mandatory)"<<std::endl;
0046 std::cout<<"-O kkk Output directory name for plots (mandatory)"<<std::endl;
0047 std::cout<<"-r rrr Name of run list file 2024 PS TB [../configs/DataTakingDB_202409_CAEN.csv] "<<std::endl;
0048 std::cout<<"-R Trending plots versus run #"<<std::endl;
0049 std::cout<<"-V Trending plots versus Vop"<<std::endl;
0050
0051 std::cout<<"-h this help"<<std::endl<<std::endl;
0052 std::cout<<"Examples:"<<std::endl;
0053 std::cout<<exe<<" (-f) -o TrendingOutput.root -i input_list.txt (-f to overwrite existing output)"<<std::endl;
0054 std::cout<<exe<<" (-f) -o TrendingOutput.root InputName*.root InputName2.root (-f to overwrite existing output)"<<std::endl;
0055 }
0056
0057
0058 int main(int argc, char* argv[]){
0059 if(argc<4) {
0060 PrintHelp(argv[0]);
0061 return 0;
0062 }
0063 std::vector<std::string> RootRegexp;
0064 std::vector<std::string>::iterator it;
0065 for(int i=1; i<argc; i++){
0066 RootRegexp.push_back(argv[i]);
0067 }
0068 ComparisonWaveform CompAnalysis;
0069 CompAnalysis.SetIsHGCROC(true);
0070
0071 int c;
0072 while((c=getopt(argc,argv,"c:d:e:E:fF:i:I:L:o:O:r:RVth"))!=-1){
0073 switch(c){
0074 case 'c':
0075 std::cout<<"Compare: set list of cells for detailed plotting " << optarg <<std::endl;
0076 CompAnalysis.SetCellList(optarg);
0077 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-c");
0078 RootRegexp.erase(it);
0079 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0080 RootRegexp.erase(it);
0081 break;
0082 case 'd':
0083 std::cout<<"Compare: enable debug " << optarg <<std::endl;
0084 CompAnalysis.EnableDebug(atoi(optarg));
0085 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-d");
0086 RootRegexp.erase(it);
0087 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0088 RootRegexp.erase(it);
0089 break;
0090 case 'e':
0091 std::cout<<"Compare: enabling extended plotting"<<std::endl;
0092 CompAnalysis.SetExtPlotting(atoi(optarg));
0093 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-e");
0094 RootRegexp.erase(it);
0095 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0096 RootRegexp.erase(it);
0097 break;
0098 case 'E':
0099 std::cout<<"Compare: set histo reading option"<<std::endl;
0100 CompAnalysis.ExpandedList(atoi(optarg));
0101 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-E");
0102 RootRegexp.erase(it);
0103 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0104 RootRegexp.erase(it);
0105 break;
0106 case 'f':
0107 std::cout<<"Compare: If output already exists it will be overwritten"<<std::endl;
0108 CompAnalysis.CanOverWrite(true);
0109 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-f");
0110 RootRegexp.erase(it);
0111 break;
0112 case 'F':
0113 std::cout<<"Compare: Set Plot extension to: "<< optarg<<std::endl;
0114 CompAnalysis.SetPlotExtension(optarg);
0115 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-F");
0116 RootRegexp.erase(it);
0117 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0118 RootRegexp.erase(it);
0119 break;
0120 case 'i':
0121 std::cout<<"Compare: Root input file is: "<<optarg<<std::endl;
0122 CompAnalysis.SetInputList(Form("%s",optarg));
0123 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-i");
0124 RootRegexp.erase(it);
0125 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0126 RootRegexp.erase(it);
0127 break;
0128 case 'I':
0129 std::cout<<"Compare: Expanded Root input file is: "<<optarg<<std::endl;
0130 CompAnalysis.SetInputList(Form("%s",optarg));
0131 if (CompAnalysis.GetExpandedList() == 0){
0132 CompAnalysis.ExpandedList(1);
0133 }
0134 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-I");
0135 RootRegexp.erase(it);
0136 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0137 RootRegexp.erase(it);
0138 break;
0139 case 'L':
0140 std::cout<<"Compare: restrict max layer plotting: "<<optarg<<std::endl;
0141 CompAnalysis.SetMaxPlotLayer(atoi(optarg));
0142 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-L");
0143 RootRegexp.erase(it);
0144 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0145 RootRegexp.erase(it);
0146 break;
0147 case 'o':
0148 std::cout<<"Compare: Output to be saved in: "<<optarg<<std::endl;
0149 CompAnalysis.SetRootOutput(Form("%s",optarg));
0150 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-o");
0151 RootRegexp.erase(it);
0152 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0153 RootRegexp.erase(it);
0154 break;
0155 case 'O':
0156 std::cout<<"Compare: Outputdir plots to be saved in: "<<optarg<<std::endl;
0157 CompAnalysis.SetPlotOutputDir(Form("%s",optarg));
0158 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-O");
0159 RootRegexp.erase(it);
0160 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0161 RootRegexp.erase(it);
0162 break;
0163 case 'r':
0164 std::cout<<"Compare: run list file from: "<<optarg<<std::endl;
0165 CompAnalysis.SetRunListInput(Form("%s",optarg));
0166 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-r");
0167 RootRegexp.erase(it);
0168 it=std::find(RootRegexp.begin(),RootRegexp.end(),Form("%s",optarg));
0169 RootRegexp.erase(it);
0170 break;
0171 case 'R':
0172 std::cout<<"Compare: Trending plots versus run #"<<std::endl;
0173 CompAnalysis.SetTrendingAxis(0);
0174 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-R");
0175 RootRegexp.erase(it);
0176 break;
0177 case 'V':
0178 std::cout<<"Compare: Trending plots versus Vop"<<std::endl;
0179 CompAnalysis.SetTrendingAxis(1);
0180 it=std::find(RootRegexp.begin(),RootRegexp.end(),"-V");
0181 RootRegexp.erase(it);
0182 break;
0183 case '?':
0184 std::cout<<"Option "<<optarg <<" not supported, will be ignored "<<std::endl;
0185 break;
0186 case 'h':
0187 PrintHelp(argv[0]);
0188 return 0;
0189 }
0190 }
0191 std::cout<<"begin extra list"<<std::endl;
0192 for(it=RootRegexp.begin(); it!=RootRegexp.end(); ++it){
0193 std::cout<<*it<<std::endl;
0194 CompAnalysis.AddInputFile(*it);
0195 }
0196 std::cout<<"end extra list"<<std::endl;
0197 if(!CompAnalysis.CheckAndOpenIO()){
0198 std::cout<<"Check input and configurations, inconsistency or error with I/O detected"<<std::endl;
0199 PrintHelp(argv[0]);
0200 return -1;
0201 }
0202
0203 CompAnalysis.ProcessWaveformCompare();
0204
0205 std::cout<<"Exiting"<<std::endl;
0206
0207 return 0;
0208 }