File indexing completed on 2025-12-16 09:28:19
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 "EventDisplay.h"
0023
0024
0025
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<<"-d [0-n] switch on debug info with debug level 0 to n"<<std::endl;
0032 std::cout<<"-F fff set plot extension explicitly, default is pdf "<<std::endl;
0033 std::cout<<"-i uuu Input file in root format"<<std::endl;
0034 std::cout<<"-c Switches on to display HGCROC testbeam data: ADC"<<std::endl;
0035 std::cout<<"-p Switches on to display HGCROC testbeam data: ADC - pedestal"<<std::endl;
0036 std::cout<<"-o Switches on to display HGCROC testbeam data: TOT"<<std::endl;
0037 std::cout<<"-P zzz Plots directory path"<<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<<"-e setting event number to plot, default: 0" <<std::endl;
0041 std::cout<<"-N setting number of events to plot, default:1"<<std::endl;
0042 std::cout<<"-M plot only muon triggered events"<<std::endl;
0043 std::cout<<"-t qqqqq minumum number of hit tiles to generate a plot"<<std::endl;
0044 std::cout<<"Examples:"<<std::endl;
0045 std::cout<<exe<<" -Q (-f) -P plotDir/ -i input.root"<<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 EventDisplay EvtDisplay;
0055 int c;
0056 while((c=getopt(argc,argv,"F:P:r:d:i:y:e:N:cpohMt:"))!=-1){
0057 switch(c){
0058 case 'd':
0059 std::cout<<"enable debug " << optarg <<std::endl;
0060 EvtDisplay.EnableDebug(atoi(optarg));
0061 break;
0062 case 'F':
0063 std::cout<<"DataPrep: Set Plot extension to: "<< optarg<<std::endl;
0064 EvtDisplay.SetPlotExtension(optarg);
0065 break;
0066 case 'i':
0067 std::cout<<"Root input file is: "<<optarg<<std::endl;
0068 EvtDisplay.SetRootInput(Form("%s",optarg));
0069 break;
0070 case 'P':
0071 std::cout<<"Outputdir plots to be saved in: "<<optarg<<std::endl;
0072 EvtDisplay.SetPlotOutputDir(Form("%s",optarg));
0073 break;
0074 case 'r':
0075 std::cout<<"run list file from: "<<optarg<<std::endl;
0076 EvtDisplay.SetRunListInput(Form("%s",optarg));
0077 break;
0078 case 'y':
0079 std::cout<<"Setting year externally: "<<optarg<<std::endl;
0080 EvtDisplay.SetYear(atoi(optarg));
0081 break;
0082 case 'e':
0083 std::cout<<"Setting event to plot: " << optarg << std::endl;
0084 EvtDisplay.SetEventToPlot(atoi(optarg));
0085 break;
0086 case 'N':
0087 std::cout<<"Setting how many events to plot: "<<optarg<<std::endl;
0088 EvtDisplay.SetNumberOfEventsToPlot(atoi(optarg));
0089 break;
0090 case 'c':
0091 std::cout<<"Switching to plotting HGCROC testbeam data."<<std::endl;
0092 std::cout<<"Plotting ADC"<<std::endl;
0093 EvtDisplay.PlotHGCROC_ADCData();
0094 break;
0095 case 'p':
0096 std::cout<<"Switching to plotting HGCROC testbeam data."<<std::endl;
0097 std::cout<<"Plotting (ADC - pedestal)"<<std::endl;
0098 EvtDisplay.PlotHGCROC_ADCwPedData();
0099 break;
0100 case 'o':
0101 std::cout<<"Switching to plotting HGCROC testbeam data."<<std::endl;
0102 std::cout<<"Plotting TOT"<<std::endl;
0103 EvtDisplay.PlotHGCROC_TOTData();
0104 break;
0105 case 'M':
0106 std::cout<<"Plot only muon-triggered events in the range"<<std::endl;
0107 EvtDisplay.PlotMuonTriggeredEvents(true);
0108 break;
0109 case 't':
0110 std::cout<<"Requiring minimum number of hit tiles: " << optarg << std::endl;
0111 EvtDisplay.SetMinTilesHit(atoi(optarg));
0112 break;
0113 case '?':
0114 std::cout<<"Option "<<optarg <<" not supported, will be ignored "<<std::endl;
0115 break;
0116 case 'h':
0117 PrintHelp(argv[0]);
0118 return 0;
0119 }
0120 }
0121 if(!EvtDisplay.CheckAndOpenIO()){
0122 std::cout<<"Check input and configurations, inconsistency or error with I/O detected"<<std::endl;
0123 PrintHelp(argv[0]);
0124 return -1;
0125 }
0126
0127 EvtDisplay.Process();
0128 std::cout<<"Exiting"<<std::endl;
0129 return 0;
0130 }