File indexing completed on 2025-12-16 09:28:17
0001 #include "ComparisonCalib.h"
0002 #include <vector>
0003 #include "TROOT.h"
0004 #ifdef __APPLE__
0005 #include <unistd.h>
0006 #endif
0007 #include "TF1.h"
0008 #include "TFitResult.h"
0009 #include "TFitResultPtr.h"
0010 #include "TH1D.h"
0011 #include "TH2D.h"
0012 #include "TProfile.h"
0013 #include "TChain.h"
0014 #include "TileSpectra.h"
0015 #include "TileTrend.h"
0016 #include "CalibSummary.h"
0017 #include "CommonHelperFunctions.h"
0018 #include "PlotHelper.h"
0019
0020
0021
0022
0023
0024 bool ComparisonCalib::CheckAndOpenIO(void){
0025
0026 int matchingbranch;
0027
0028
0029
0030
0031 if(!InputListName.IsNull()){
0032
0033
0034
0035 if (expandedList == 0){
0036 std::cout << "*********************************************************" << std::endl;
0037 std::cout << "Simple reading from file list" << std::endl;
0038 std::cout << "*********************************************************" << std::endl;
0039
0040 std::cout << "reading from file list: " << InputListName.Data() << std::endl;
0041 std::fstream dummyTxt;
0042 dummyTxt.open(InputListName.Data(),std::ios::in);
0043 if(!dummyTxt.is_open()){
0044 std::cout<<"Error opening "<<InputListName.Data()<<", does the file exist?"<<std::endl;
0045 }
0046
0047
0048 std::string dummyRootName;
0049
0050 dummyTxt>>dummyRootName;
0051
0052 int goodsetup;
0053 int goodcalib;
0054 while(dummyTxt.good()){
0055 std::cout << dummyRootName.data() << std::endl;
0056
0057 TFile dummyRoot=TFile(dummyRootName.c_str(),"READ");
0058 if(dummyRoot.IsZombie()){
0059 std::cout<<"Error opening '"<<dummyRootName<<", does the file exist?"<<std::endl;
0060 return false;
0061 }
0062 dummyRoot.Close();
0063
0064 goodsetup=TsetupIn->AddFile(dummyRootName.c_str());
0065 goodcalib=TcalibIn->AddFile(dummyRootName.c_str());
0066 if(goodcalib==0){
0067 std::cout<<"Issues retrieving Calib tree from "<<dummyRootName<<", file is ignored"<<std::endl;
0068 }
0069 if(goodsetup==0){
0070 std::cout<<"Issues retrieving Setup tree from "<<dummyRootName<<", file is ignored"<<std::endl;
0071 }
0072
0073 dummyTxt>>dummyRootName;
0074 }
0075
0076
0077
0078 } else {
0079 std::cout << "You need to provide a calib file and an output of the improved muon calib in the textfile in each line" << std::endl;
0080 std::fstream dummyTxt;
0081 dummyTxt.open(InputListName.Data(),std::ios::in);
0082 if(!dummyTxt.is_open()){
0083 std::cout<<"Error opening "<<InputListName.Data()<<", does the file exist?"<<std::endl;
0084 }
0085 std::string dummyRootCalibName;
0086 std::string dummyRootHistName;
0087
0088 dummyTxt>>dummyRootCalibName >> dummyRootHistName;
0089
0090 int goodsetup;
0091 int goodcalib;
0092 while(dummyTxt.good()){
0093 std::cout << dummyRootCalibName.data() << "\t" << dummyRootHistName.data() << std::endl;
0094
0095
0096 TFile dummyRootCalib=TFile(dummyRootCalibName.c_str(),"READ");
0097 if(dummyRootCalib.IsZombie()){
0098 std::cout<<"Error opening '"<<dummyRootCalibName<<", does the file exist?"<<std::endl;
0099 return false;
0100 }
0101 dummyRootCalib.Close();
0102 TFile dummyRootHist=TFile(dummyRootHistName.c_str(),"READ");
0103 if(dummyRootHist.IsZombie()){
0104 std::cout<<"Error opening '"<<dummyRootHistName<<", does the file exist?"<<std::endl;
0105 return false;
0106 }
0107 dummyRootHist.Close();
0108
0109
0110 AddInputFile(dummyRootHistName);
0111 goodsetup=TsetupIn->AddFile(dummyRootCalibName.c_str());
0112 goodcalib=TcalibIn->AddFile(dummyRootCalibName.c_str());
0113 if(goodcalib==0){
0114 std::cout<<"Issues retrieving Calib tree from "<<dummyRootCalibName<<", file is ignored"<<std::endl;
0115 }
0116 if(goodsetup==0){
0117 std::cout<<"Issues retrieving Setup tree from "<<dummyRootCalibName<<", file is ignored"<<std::endl;
0118 }
0119
0120 dummyTxt>>dummyRootCalibName >> dummyRootHistName;
0121 }
0122 }
0123 }
0124
0125
0126
0127
0128
0129 else {
0130 std::cout << "*********************************************************" << std::endl;
0131 std::cout << "Simple reading from vector" << std::endl;
0132 std::cout << "*********************************************************" << std::endl;
0133
0134
0135 if(RootInputNames.empty()){
0136 std::cout<<"No root files, neither text list file provided"<<std::endl;
0137 return false;
0138 }
0139
0140
0141 std::vector<TString>::iterator it;
0142 int goodsetup;
0143 int goodcalib;
0144 for(it=RootInputNames.begin(); it!=RootInputNames.end(); ++it){
0145
0146 TFile dummy=TFile(it->Data(),"READ");
0147 if(dummy.IsZombie()){
0148 std::cout<<"Error opening '"<<it->Data()<<", does the file exist?"<<std::endl;
0149 return false;
0150 }
0151 dummy.Close();
0152
0153 goodsetup=TsetupIn->AddFile(it->Data());
0154 goodcalib=TcalibIn->AddFile(it->Data());
0155 if(goodcalib==0){
0156 std::cout<<"Issues retrieving Calib tree from "<<it->Data()<<", file is ignored"<<std::endl;
0157 }
0158 if(goodsetup==0){
0159 std::cout<<"Issues retrieving Setup tree from "<<it->Data()<<", file is ignored"<<std::endl;
0160 }
0161 }
0162 }
0163
0164
0165
0166 if(RootOutputName.IsNull()){
0167 return false;
0168 } else {
0169 if(!CreateOutputRootFile()){
0170 return false;
0171 }
0172 }
0173
0174
0175
0176
0177
0178 setup=Setup::GetInstance();
0179 std::cout<<"Setup add "<<setup<<std::endl;
0180 matchingbranch=TsetupIn->SetBranchAddress("setup",&rswptr);
0181 if(matchingbranch<0){
0182 std::cout<<"Error retrieving Setup info from the tree"<<std::endl;
0183 return false;
0184 }
0185 std::cout<<"Entries "<<TsetupIn->GetEntries()<<std::endl;
0186 TsetupIn->GetEntry(0);
0187 setup->Initialize(*rswptr);
0188
0189 matchingbranch=TcalibIn->SetBranchAddress("calib",&calibptr);
0190 if(matchingbranch<0){
0191 std::cout<<"Error retrieving calibration info from the tree"<<std::endl;
0192 return false;
0193 }
0194
0195 return true;
0196 }
0197
0198
0199
0200
0201 bool ComparisonCalib::ProcessCalib(void){
0202
0203
0204
0205 gSystem->Exec("mkdir -p "+OutputNameDirPlots);
0206 if (ExtPlot > 0) gSystem->Exec("mkdir -p "+OutputNameDirPlots+"/SingleLayer");
0207 StyleSettingsBasics("pdf");
0208 SetPlotStyle();
0209
0210
0211
0212
0213 bool status=true;
0214
0215 ROOT::EnableImplicitMT();
0216
0217 int entries=TcalibIn->GetEntries();
0218
0219
0220
0221
0222 std::map<int, TileTrend> trend;
0223 std::map<int, TileTrend>::iterator itrend;
0224 std::map<int, TileCalib>::const_iterator itcalib;
0225
0226 std::map<int, CalibSummary> sumCalibs;
0227 std::map<int, CalibSummary>::iterator isumCalibs;
0228
0229 double Xvalue;
0230 double Xmin= 9999.;
0231 double Xmax=-9999.;
0232 int nRun = 0;
0233
0234
0235
0236
0237 std::map<int,RunInfo> ri=readRunInfosFromFile(RunListInputName.Data(),debug,0);
0238 std::map<int,RunInfo>::iterator it;
0239
0240
0241
0242
0243 for(int ientry=0; ientry<entries;ientry++){
0244 TcalibIn->GetEntry(ientry);
0245 TsetupIn->GetEntry(ientry);
0246
0247
0248
0249 if (ientry==0) it = ri.find(calib.GetRunNumber());
0250
0251
0252
0253
0254
0255
0256
0257
0258 Int_t runNumber = calib.GetRunNumber();
0259 if(Xaxis==0){
0260 Xvalue=calib.GetRunNumber();
0261 } else if(Xaxis==1){
0262 Xvalue=calib.GetVop();
0263 } else if(Xaxis==2){
0264 Xvalue=calib.GetBeginRunTime()->GetSec();
0265 }
0266 if(Xvalue<Xmin) Xmin=Xvalue;
0267 if(Xvalue>Xmax) Xmax=Xvalue;
0268
0269
0270
0271
0272 CalibSummary aSum = CalibSummary(nRun, runNumber,calib.GetVop());
0273
0274
0275
0276
0277 TH2D* hTrigger2D = nullptr;
0278 TH2D* hHG_LMPV2D = nullptr;
0279 TH2D* hHG_LSigma2D = nullptr;
0280 TH2D* hHG_GSigma2D = nullptr;
0281 TH2D* hLG_LMPV2D = nullptr;
0282 TH2D* hLG_LSigma2D = nullptr;
0283 TH2D* hLG_GSigma2D = nullptr;
0284 TH2D* hSB_Noise2D = nullptr;
0285 TH2D* hSB_Signal2D = nullptr;
0286
0287 TFile* tempFile = nullptr;
0288 if (expandedList > 0){
0289 if (nRun < (int)RootInputNames.size()){
0290 std::cout << "reading hist file: " <<RootInputNames[nRun].Data() << " expanded list setting: " << expandedList << std::endl;
0291 tempFile = new TFile(RootInputNames[nRun].Data(),"READ");
0292
0293 if (expandedList == 1){
0294 hTrigger2D = (TH2D*)tempFile->Get("hmipTriggers");
0295 hHG_LMPV2D = (TH2D*)tempFile->Get("hspectraHGLMPVVsLayer");
0296 hHG_LSigma2D = (TH2D*)tempFile->Get("hspectraHGLSigmaVsLayer");
0297 hHG_GSigma2D = (TH2D*)tempFile->Get("hspectraHGGSigmaVsLayer");
0298 hLG_LMPV2D = (TH2D*)tempFile->Get("hspectraLGLMPVVsLayer");
0299 hLG_LSigma2D = (TH2D*)tempFile->Get("hspectraLGLSigmaVsLayer");
0300 hLG_GSigma2D = (TH2D*)tempFile->Get("hspectraLGGSigmaVsLayer");
0301 hSB_Noise2D = (TH2D*)tempFile->Get("hSuppresionNoise");
0302 hSB_Signal2D = (TH2D*)tempFile->Get("hSuppresionSignal");
0303 } else if (expandedList == 2){
0304 hTrigger2D = (TH2D*)tempFile->Get("hmipTriggers");
0305 hSB_Noise2D = (TH2D*)tempFile->Get("hSuppresionNoise");
0306 hSB_Signal2D = (TH2D*)tempFile->Get("hSuppresionSignal");
0307 }
0308 }
0309 }
0310
0311
0312
0313
0314 for(itcalib=calib.begin(); itcalib!=calib.end(); ++itcalib){
0315
0316
0317
0318
0319 int triggers = 0;
0320 double hgLMPV = 0.;
0321 double hgLSigma = 0.;
0322 double hgGSigma = 0.;
0323 double hgLMPV_E = 0.;
0324 double hgLSigma_E = 0.;
0325 double hgGSigma_E = 0.;
0326 double lgLMPV = 0.;
0327 double lgLSigma = 0.;
0328 double lgGSigma = 0.;
0329 double lgLMPV_E = 0.;
0330 double lgLSigma_E = 0.;
0331 double lgGSigma_E = 0.;
0332 double sbNoise = 0.;
0333 double sbSignal = 0.;
0334 double lghgOff = -10000.;
0335 double lghgOff_E = 0.;
0336 double hglgOff = -10000.;
0337 double hglgOff_E = 0.;
0338
0339
0340 TH1D* histCellHG = nullptr;
0341 TH1D* histCellLG = nullptr;
0342 TProfile* profCellLGHG= nullptr;
0343 TF1* fitLGHG = nullptr;
0344 TF1* fitHGLG = nullptr;
0345 if (expandedList == 1){
0346 if (ExtPlot > 1){
0347 histCellHG = (TH1D*)tempFile->Get(Form("IndividualCellsTrigg/hspectramipTriggHGCellID%i",itcalib->first));
0348 histCellLG = (TH1D*)tempFile->Get(Form("IndividualCellsTrigg/hspectramipTriggLGCellID%i",itcalib->first));
0349 profCellLGHG = (TProfile*)tempFile->Get(Form("IndividualCellsTrigg/hCoorspectramipTriggLGHGCellID%i",itcalib->first));
0350 }
0351 int layer = setup->GetLayer(itcalib->first);
0352 int chInLayer = setup->GetChannelInLayer(itcalib->first);
0353 triggers = hTrigger2D->GetBinContent(hTrigger2D->FindBin(layer,chInLayer));
0354 hgLMPV = hHG_LMPV2D->GetBinContent(hHG_LMPV2D->FindBin(layer,chInLayer));
0355 hgLMPV_E = hHG_LMPV2D->GetBinError(hHG_LMPV2D->FindBin(layer,chInLayer));
0356 hgLSigma = hHG_LSigma2D->GetBinContent(hHG_LSigma2D->FindBin(layer,chInLayer));
0357 hgLSigma_E = hHG_LSigma2D->GetBinError(hHG_LSigma2D->FindBin(layer,chInLayer));
0358 hgGSigma = hHG_GSigma2D->GetBinContent(hHG_GSigma2D->FindBin(layer,chInLayer));
0359 hgGSigma_E = hHG_GSigma2D->GetBinError(hHG_GSigma2D->FindBin(layer,chInLayer));
0360 lgLMPV = hLG_LMPV2D->GetBinContent(hLG_LMPV2D->FindBin(layer,chInLayer));
0361 lgLMPV_E = hLG_LMPV2D->GetBinError(hLG_LMPV2D->FindBin(layer,chInLayer));
0362 lgLSigma = hLG_LSigma2D->GetBinContent(hLG_LSigma2D->FindBin(layer,chInLayer));
0363 lgLSigma_E = hLG_LSigma2D->GetBinError(hLG_LSigma2D->FindBin(layer,chInLayer));
0364 lgGSigma = hLG_GSigma2D->GetBinContent(hLG_GSigma2D->FindBin(layer,chInLayer));
0365 lgGSigma_E = hLG_GSigma2D->GetBinError(hLG_GSigma2D->FindBin(layer,chInLayer));
0366 sbNoise = hSB_Noise2D->GetBinError(hSB_Noise2D->FindBin(layer,chInLayer));
0367 sbSignal = hSB_Signal2D->GetBinError(hSB_Signal2D->FindBin(layer,chInLayer));
0368 } else if (expandedList == 2){
0369 if (ExtPlot > 1){
0370 profCellLGHG = (TProfile*)tempFile->Get(Form("IndividualCells/hCoorspectramip1stLGHGCellID%i",itcalib->first));
0371 histCellHG = (TH1D*)tempFile->Get(Form("IndividualCellsTrigg/hspectramipTriggHGCellID%i",itcalib->first));
0372 histCellLG = (TH1D*)tempFile->Get(Form("IndividualCellsTrigg/hspectramipTriggLGCellID%i",itcalib->first));
0373 }
0374 fitLGHG = (TF1*)tempFile->Get(Form("IndividualCells/fcorrmip1stLGHGCellID%i",itcalib->first));
0375 fitHGLG = (TF1*)tempFile->Get(Form("IndividualCells/fcorrmip1stHGLGCellID%i",itcalib->first));
0376 int layer = setup->GetLayer(itcalib->first);
0377 int chInLayer = setup->GetChannelInLayer(itcalib->first);
0378 triggers = hTrigger2D->GetBinContent(hTrigger2D->FindBin(layer,chInLayer));
0379 sbNoise = hSB_Noise2D->GetBinError(hSB_Noise2D->FindBin(layer,chInLayer));
0380 sbSignal = hSB_Signal2D->GetBinError(hSB_Signal2D->FindBin(layer,chInLayer));
0381 if (fitLGHG){
0382 lghgOff = fitLGHG->GetParameter(0);
0383 lghgOff_E = fitLGHG->GetParError(0);
0384 }
0385 if (fitHGLG){
0386 hglgOff = fitHGLG->GetParameter(0);
0387 hglgOff_E = fitHGLG->GetParError(0);
0388 }
0389 } else if (expandedList == 3){
0390 if (ExtPlot > 1){
0391 std::cout<<"Layer Plotting: " << setup->GetLayer(itcalib->first) <<std::endl;
0392 profCellLGHG = (TProfile*)tempFile->Get(Form("IndividualCells/hCoorspectraAllTriggersLGHGCellID%i",itcalib->first));
0393 }
0394 } else if (expandedList == 4){
0395 if (ExtPlot > 1){
0396 std::cout<<"Layer Plotting: " << setup->GetLayer(itcalib->first) <<std::endl;
0397 histCellHG = (TH1D*)tempFile->Get(Form("IndividualCells/hspectrafullADCCellID%i",itcalib->first));
0398 profCellLGHG = (TProfile*)tempFile->Get(Form("IndividualCells/wafeform1DfullCellID%i",itcalib->first));
0399 std::cout << histCellHG << "\t" << profCellLGHG << std::endl;
0400 }
0401 }
0402
0403
0404
0405
0406 aSum.Fill(itcalib->second);
0407
0408
0409
0410
0411
0412 itrend=trend.find(itcalib->first);
0413 if(itrend!=trend.end()){
0414
0415 itrend->second.Fill(Xvalue,itcalib->second, (int)calib.GetRunNumber(), (double)calib.GetVop());
0416
0417 if (expandedList == 1){
0418 itrend->second.FillExtended(Xvalue,triggers, (int)calib.GetRunNumber(), histCellHG, histCellLG, profCellLGHG);
0419 itrend->second.FillMPV(Xvalue, hgLMPV, hgLMPV_E, lgLMPV, lgLMPV_E);
0420 itrend->second.FillLSigma(Xvalue, hgLSigma, hgLSigma_E, lgLSigma, lgLSigma_E);
0421 itrend->second.FillGSigma(Xvalue, hgGSigma, hgGSigma_E, lgGSigma, lgGSigma_E);
0422 itrend->second.FillSB(Xvalue, sbSignal, sbNoise);
0423 } else if (expandedList == 2){
0424 itrend->second.FillExtended(Xvalue,triggers, (int)calib.GetRunNumber(), histCellHG, histCellLG, profCellLGHG);
0425 itrend->second.FillSB(Xvalue, sbSignal, sbNoise);
0426 } else if (expandedList == 3){
0427 std::cerr<<"Run Num: " << (int)calib.GetRunNumber()<<std::endl;
0428 itrend->second.FillExtended(Xvalue,1, (int)calib.GetRunNumber(), nullptr, nullptr, profCellLGHG);
0429
0430 } else if (expandedList == 4){
0431 std::cerr<<"Run Num: " << (int)calib.GetRunNumber()<<std::endl;
0432 itrend->second.FillExtended(Xvalue,1, (int)calib.GetRunNumber(), histCellHG, nullptr, profCellLGHG);
0433 }
0434
0435 } else {
0436 TileTrend atrend=TileTrend(itcalib->first,0, expandedList);
0437
0438 atrend.Fill(Xvalue,itcalib->second, (int)calib.GetRunNumber(), (double)calib.GetVop());
0439
0440 if (expandedList == 1){
0441 atrend.FillExtended(Xvalue,triggers, (int)calib.GetRunNumber(), histCellHG, histCellLG, profCellLGHG);
0442 atrend.FillMPV(Xvalue, hgLMPV, hgLMPV_E, lgLMPV, lgLMPV_E);
0443 atrend.FillLSigma(Xvalue, hgLSigma, hgLSigma_E, lgLSigma, lgLSigma_E);
0444 atrend.FillGSigma(Xvalue, hgGSigma, hgGSigma_E, lgGSigma, lgGSigma_E);
0445 atrend.FillSB(Xvalue, sbSignal, sbNoise);
0446 } else if (expandedList == 2){
0447 atrend.FillExtended(Xvalue,triggers, (int)calib.GetRunNumber(), histCellHG, histCellLG, profCellLGHG);
0448 atrend.FillSB(Xvalue, sbSignal, sbNoise);
0449
0450 } else if (expandedList == 3){
0451 std::cout<<"Layer Filling: " << calib.GetRunNumber()<<": "<<setup->GetLayer(itcalib->first) <<std::endl;
0452 atrend.FillExtended(Xvalue,1, (int)calib.GetRunNumber(), nullptr, nullptr, profCellLGHG);
0453 } else if (expandedList == 4){
0454 std::cout<<"Layer Filling: " << calib.GetRunNumber()<<": "<<setup->GetLayer(itcalib->first) <<std::endl;
0455 atrend.FillExtended(Xvalue,1, (int)calib.GetRunNumber(), histCellHG, nullptr, profCellLGHG);
0456 }
0457
0458 trend[itcalib->first]=atrend;
0459 }
0460 }
0461
0462
0463 sumCalibs[nRun]=aSum;
0464
0465 if (expandedList){
0466 tempFile->Close();
0467 }
0468
0469 nRun++;
0470 }
0471
0472
0473
0474
0475 if (debug > 0){
0476 std::cout << "Calibs summary: "<< sumCalibs.size() << std::endl;
0477 for(isumCalibs=sumCalibs.begin(); isumCalibs!=sumCalibs.end(); ++isumCalibs){
0478 isumCalibs->second.Analyse();
0479 }
0480 }
0481
0482
0483
0484
0485 if (Xaxis == 0){
0486 Xmin= Xmin-10;
0487 Xmax= Xmax+10;
0488 } else if (Xaxis == 1){
0489 Xmin= Xmin-0.5;
0490 Xmax= Xmax+0.5;
0491 }
0492
0493 TString xaxisTitle = "";
0494 if (Xaxis==0) xaxisTitle = "Run Nr. ";
0495 else if (Xaxis==1) xaxisTitle = "V (V) ";
0496 else xaxisTitle = "date";
0497
0498 for(itrend=trend.begin(); itrend!=trend.end(); ++itrend){
0499
0500 itrend->second.Sort();
0501
0502 itrend->second.SetXAxisTitle(xaxisTitle);
0503
0504 itrend->second.Write(RootOutput);
0505 }
0506
0507
0508
0509
0510 Int_t textSizePixel = 30;
0511 Float_t textSizeRel = 0.04;
0512 TCanvas* canvas1DRunsOverlay = new TCanvas("canvas1DRunsOverlay","",0,0,1450,1300);
0513 DefaultCancasSettings( canvas1DRunsOverlay, 0.075, 0.015, 0.025, 0.09);
0514
0515 PlotCalibRunOverlay( canvas1DRunsOverlay, 0, sumCalibs, textSizeRel,
0516 Form("%s/HGPedSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second,"", debug);
0517 PlotCalibRunOverlay( canvas1DRunsOverlay, 1, sumCalibs, textSizeRel,
0518 Form("%s/HGPedWidthSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second,"", debug);
0519 PlotCalibRunOverlay( canvas1DRunsOverlay, 2, sumCalibs, textSizeRel,
0520 Form("%s/LGPedSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second,"", debug);
0521 PlotCalibRunOverlay( canvas1DRunsOverlay, 3, sumCalibs, textSizeRel,
0522 Form("%s/LGPedWidthSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second,"", debug);
0523 PlotCalibRunOverlay( canvas1DRunsOverlay, 4, sumCalibs, textSizeRel,
0524 Form("%s/HGScaleSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second,"", debug);
0525 PlotCalibRunOverlay( canvas1DRunsOverlay, 5, sumCalibs, textSizeRel,
0526 Form("%s/HGScaleWidthSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second,"", debug);
0527 PlotCalibRunOverlay( canvas1DRunsOverlay, 6, sumCalibs, textSizeRel,
0528 Form("%s/LGScaleSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second, "", debug);
0529 PlotCalibRunOverlay( canvas1DRunsOverlay, 7, sumCalibs, textSizeRel,
0530 Form("%s/LGScaleWidthSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second, "", debug);
0531 PlotCalibRunOverlay( canvas1DRunsOverlay, 8, sumCalibs, textSizeRel,
0532 Form("%s/LGHGCorr_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second, "", debug);
0533 PlotCalibRunOverlay( canvas1DRunsOverlay, 9, sumCalibs, textSizeRel,
0534 Form("%s/HGLGCorr_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second, "", debug);
0535 PlotCalibRunOverlay( canvas1DRunsOverlay, 10, sumCalibs, textSizeRel,
0536 Form("%s/LGScaleCalcSummary_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second,"", debug);
0537 PlotCalibRunOverlay( canvas1DRunsOverlay, 11, sumCalibs, textSizeRel,
0538 Form("%s/LGHGOffsetCorr_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second, "", debug);
0539 PlotCalibRunOverlay( canvas1DRunsOverlay, 12, sumCalibs, textSizeRel,
0540 Form("%s/HGLGOffsetCorr_RunOverlay.%s",OutputNameDirPlots.Data(),plotSuffix.Data()), it->second, "", debug);
0541
0542
0543 std::cout << "row max: " << setup->GetNMaxRow() << "\t column max: " << setup->GetNMaxColumn() << std::endl;
0544
0545 if (setup->GetNMaxRow()+1 == 2 && setup->GetNMaxColumn()+1 == 4){
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560 TCanvas* canvas8Panel;
0561 TPad* pad8Panel[8];
0562 Double_t topRCornerX[8];
0563 Double_t topRCornerY[8];
0564 Double_t relSize8P[8];
0565 CreateCanvasAndPadsFor8PannelTBPlot(canvas8Panel, pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel, 0.045, "", true, debug);
0566 TCanvas* canvas8PanelProf;
0567 TPad* pad8PanelProf[8];
0568 Double_t topRCornerXProf[8];
0569 Double_t topRCornerYProf[8];
0570 Double_t relSize8PProf[8];
0571 CreateCanvasAndPadsFor8PannelTBPlot(canvas8PanelProf, pad8PanelProf, topRCornerXProf, topRCornerYProf, relSize8PProf, textSizePixel, 0.045, "Prof", false, debug);
0572 int layerVerb = 5;
0573 if (expandedList == 1)layerVerb = 1;
0574
0575
0576 for (Int_t l = 0; l < setup->GetNMaxLayer()+1 && l < maxLayerPlot; l++){
0577 if (l%layerVerb == 0 && l > 0 && debug > 0)
0578 std::cout << "============================== layer " << l << " / " << setup->GetNMaxLayer() << " layers" << std::endl;
0579 if (expandedList != 3 ){
0580 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0581 trend, 0, Xmin,Xmax, l, 0,
0582 Form("%s/SingleLayer/HGped_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGPedestal",OutputNameDirPlots.Data()), it->second,ExtPlot);
0583 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0584 trend, 15, Xmin,Xmax, l, 0,
0585 Form("%s/SingleLayer/HGpedwidth_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGPedestalWidth",OutputNameDirPlots.Data()), it->second,ExtPlot);
0586 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0587 trend, 1, Xmin,Xmax, l, 0,
0588 Form("%s/SingleLayer/LGped_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGPedestal",OutputNameDirPlots.Data()), it->second,ExtPlot);
0589 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0590 trend, 16, Xmin,Xmax, l, 0,
0591 Form("%s/SingleLayer/LGpedwidth_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGPedestalWidth",OutputNameDirPlots.Data()), it->second,ExtPlot);
0592 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0593 trend, 2, Xmin,Xmax, l, 0,
0594 Form("%s/SingleLayer/HGScale_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGScale",OutputNameDirPlots.Data()), it->second,ExtPlot);
0595 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0596 trend, 3, Xmin,Xmax, l, 0,
0597 Form("%s/SingleLayer/LGScale_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGScale",OutputNameDirPlots.Data()), it->second,ExtPlot);
0598 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0599 trend, 4, Xmin,Xmax, l, 0,
0600 Form("%s/SingleLayer/LGHGCorr_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGHGCorr",OutputNameDirPlots.Data()), it->second,ExtPlot);
0601 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0602 trend, 5, Xmin,Xmax, l, 0,
0603 Form("%s/SingleLayer/HGLGCorr_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGLGCorr",OutputNameDirPlots.Data()), it->second,ExtPlot);
0604 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0605 trend, 17, Xmin,Xmax, l, 0,
0606 Form("%s/SingleLayer/LGHG_Offset_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGHGOffet",OutputNameDirPlots.Data()), it->second,ExtPlot);
0607 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0608 trend, 18, Xmin,Xmax, l, 0,
0609 Form("%s/SingleLayer/HGLG_Offset_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGLGOffet",OutputNameDirPlots.Data()), it->second,ExtPlot);
0610 }
0611 if (expandedList == 1){
0612 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0613 trend, 9, Xmin,Xmax, l, 0,
0614 Form("%s/SingleLayer/HG_LandMPV_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGLandMPV",OutputNameDirPlots.Data()), it->second,ExtPlot);
0615 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0616 trend, 10, Xmin,Xmax, l, 0,
0617 Form("%s/SingleLayer/LG_LandMPV_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGLandMPV",OutputNameDirPlots.Data()), it->second,ExtPlot);
0618 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0619 trend, 11, Xmin,Xmax, l, 0,
0620 Form("%s/SingleLayer/HG_LandSigma_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGLandSigma",OutputNameDirPlots.Data()), it->second,ExtPlot);
0621 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0622 trend, 12, Xmin,Xmax, l, 0,
0623 Form("%s/SingleLayer/LG_LandSigma_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGLandSigma",OutputNameDirPlots.Data()), it->second,ExtPlot);
0624 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0625 trend, 13, Xmin,Xmax, l, 0,
0626 Form("%s/SingleLayer/HG_GaussSigma_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendHGGaussSigma",OutputNameDirPlots.Data()), it->second,ExtPlot);
0627 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0628 trend, 14, Xmin,Xmax, l, 0,
0629 Form("%s/SingleLayer/LG_GaussSigma_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendLGGaussSigma",OutputNameDirPlots.Data()), it->second,ExtPlot);
0630 }
0631 if (expandedList == 1 || expandedList == 2 ){
0632 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0633 trend, 6, Xmin,Xmax, l, 0,
0634 Form("%s/SingleLayer/MuonTriggers_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendMuonTriggers",OutputNameDirPlots.Data()), it->second,ExtPlot);
0635 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0636 trend, 7, Xmin,Xmax, l, 0,
0637 Form("%s/SingleLayer/SBSignal_MuonTriggers_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendSBSignal_MuonTriggers",OutputNameDirPlots.Data()), it->second,ExtPlot);
0638 PlotTrending8MLayer( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0639 trend, 8, Xmin,Xmax, l, 0,
0640 Form("%s/SingleLayer/SBNoise_MuonTriggers_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/TrendSBNoise_MuonTriggers",OutputNameDirPlots.Data()), it->second,ExtPlot);
0641 }
0642 }
0643
0644 if (ExtPlot > 1){
0645 std::cout<< "plotting individual distribution per run overlayed" << std::endl;
0646 for (Int_t l = 0; l < setup->GetNMaxLayer()+1 && l < maxLayerPlot; l++){
0647 if (l%layerVerb == 0 && l > 0 && debug > 0)
0648 std::cout << "============================== layer " << l << " / " << setup->GetNMaxLayer() << " layers" << std::endl;
0649 if (expandedList == 1 || expandedList == 2 ){
0650 PlotRunOverlay8MLayer ( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0651 trend, nRun, 0, -15,850, l, 0,
0652 Form("%s/SingleLayer/MuonTriggers_HGDist_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonHGDist",OutputNameDirPlots.Data()), it->second,ExtPlot);
0653 PlotRunOverlay8MLayer ( canvas8Panel,pad8Panel, topRCornerX, topRCornerY, relSize8P, textSizePixel,
0654 trend, nRun, 1, -10,210, l, 0,
0655 Form("%s/SingleLayer/MuonTriggers_LGDist_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonLGDist",OutputNameDirPlots.Data()), it->second,ExtPlot);
0656 }
0657 if (expandedList > 0 ){
0658 PlotRunOverlayProfile8MLayer (canvas8PanelProf,pad8PanelProf, topRCornerXProf, topRCornerYProf, relSize8PProf, textSizePixel,
0659 trend, nRun,-20, 340, -20, 3900, l, 0,
0660 Form("%s/SingleLayer/MuonTriggers_LGHGCorr_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonLGHGCorr",OutputNameDirPlots.Data()), it->second,ExtPlot);
0661 }
0662 }
0663 }
0664 } else if (setup->GetNMaxRow()+1 == 1 && setup->GetNMaxColumn()+1 == 2){
0665
0666
0667
0668
0669
0670
0671
0672
0673
0674
0675
0676 TCanvas* canvas2Panel;
0677 TPad* pad2Panel[2];
0678 Double_t topRCornerX[2];
0679 Double_t topRCornerY[2];
0680 Int_t textSizePixel = 30;
0681 Double_t relSizeP[2];
0682 CreateCanvasAndPadsFor2PannelTBPlot(canvas2Panel, pad2Panel, topRCornerX, topRCornerY, relSizeP, textSizePixel);
0683
0684 TCanvas* canvas2PanelProf;
0685 TPad* pad2PanelProf[2];
0686 Double_t topRCornerXProf[2];
0687 Double_t topRCornerYProf[2];
0688 Double_t relSizePProf[2];
0689 CreateCanvasAndPadsFor2PannelTBPlot(canvas2PanelProf, pad2PanelProf, topRCornerXProf, topRCornerYProf, relSizePProf, textSizePixel, 0.075, "Prof", false);
0690 int layerVerb = 5;
0691 if (expandedList == 1)layerVerb = 1;
0692
0693 if (ExtPlot > 1){
0694 std::cout<< "plotting individual distribution per run overlayed" << std::endl;
0695 for (Int_t l = 0; l < setup->GetNMaxLayer()+1 && l < maxLayerPlot; l++){
0696 if (l%layerVerb == 0 && l > 0 && debug > 0)
0697 std::cout << "============================== layer " << l << " / " << setup->GetNMaxLayer() << " layers" << std::endl;
0698 if (expandedList == 1 || expandedList == 2 || expandedList == 4){
0699 PlotRunOverlay2MLayer ( canvas2Panel,pad2Panel, topRCornerX, topRCornerY, relSizeP, textSizePixel,
0700 trend, nRun, 0, -15,850, l, 0,
0701 Form("%s/SingleLayer/MuonTriggers_HGDist_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonHGDist",OutputNameDirPlots.Data()), it->second,ExtPlot);
0702 }
0703 if (expandedList == 1 || expandedList == 2 ){
0704 PlotRunOverlay2MLayer ( canvas2Panel,pad2Panel, topRCornerX, topRCornerY, relSizeP, textSizePixel,
0705 trend, nRun, 1, -10,210, l, 0,
0706 Form("%s/SingleLayer/MuonTriggers_LGDist_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonLGDist",OutputNameDirPlots.Data()), it->second,ExtPlot);
0707 }
0708 if (expandedList > 0 ){
0709 Int_t maxComp = 3900;
0710 Double_t maxX = 340;
0711 if (GetIsHGCROC()){
0712 maxComp = 1048;
0713 maxX = 500000;
0714 }
0715 PlotRunOverlayProfile2MLayer (canvas2PanelProf,pad2PanelProf, topRCornerXProf, topRCornerYProf, relSizePProf, textSizePixel,
0716 trend, nRun,-20, 340, -20, maxComp, l, 0,
0717 Form("%s/SingleLayer/MuonTriggers_LGHGCorr_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonLGHGCorr",OutputNameDirPlots.Data()), it->second,ExtPlot);
0718 }
0719 }
0720 }
0721
0722 } else if (setup->GetNMaxRow()+1 == 1 && setup->GetNMaxColumn()+1 == 1){
0723
0724
0725
0726
0727 TCanvas* canvasLayer = new TCanvas("canvasLayer","",0,0,620,600);
0728 DrawCanvasSettings( canvasLayer,0.125, 0.01, 0.03, 0.1);
0729 Double_t topRCornerX = 0.95;
0730 Double_t topLCornerX = 0.165;
0731 Double_t topRCornerY = 0.99;
0732 Int_t textSizePixel = 30;
0733 Double_t relSizeP = 30./620;
0734
0735 TCanvas* canvasLayerProf = new TCanvas("canvasLayerProf","",0,0,620,600);
0736 DrawCanvasSettings( canvasLayerProf,0.138, 0.08, 0.03, 0.1);
0737 Double_t topRCornerXProf = 0.175;
0738 Double_t topLCornerXProf = 0.89;
0739 Double_t topRCornerYProf = 0.95;
0740 Double_t relSizePProf = 30./620;
0741 int layerVerb = 5;
0742 if (expandedList == 1)layerVerb = 1;
0743
0744 if (ExtPlot > 1){
0745 std::cout<< "plotting individual distribution per run overlayed" << std::endl;
0746 for (Int_t l = 0; l < setup->GetNMaxLayer()+1 && l < maxLayerPlot; l++){
0747 if (l%layerVerb == 0 && l > 0 && debug > 0)
0748 std::cout << "============================== layer " << l << " / " << setup->GetNMaxLayer() << " layers" << std::endl;
0749 if (expandedList == 1 || expandedList == 2){
0750 PlotRunOverlay1MLayer ( canvasLayer, topRCornerX, topLCornerX, topRCornerY, relSizeP, textSizePixel,
0751 trend, nRun, 0, -15,310, l, 0,
0752 Form("%s/SingleLayer/MuonTriggers_HGDist_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonHGDist",OutputNameDirPlots.Data()), it->second,ExtPlot);
0753 PlotRunOverlay1MLayer ( canvasLayer,topRCornerX, topLCornerX, topRCornerY, relSizeP, textSizePixel,
0754 trend, nRun, 1, -10,210, l, 0,
0755 Form("%s/SingleLayer/MuonTriggers_LGDist_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonLGDist",OutputNameDirPlots.Data()), it->second,ExtPlot);
0756 }
0757 if ( expandedList == 4){
0758 PlotRunOverlay1MLayer ( canvasLayer, topRCornerX, topLCornerX, topRCornerY, relSizeP, textSizePixel,
0759 trend, nRun, 0, -15,310, l, 0,
0760 Form("%s/SingleLayer/MaxAdc_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonHGDist",OutputNameDirPlots.Data()), it->second,ExtPlot,true);
0761 }
0762 if (expandedList > 0 ){
0763 Int_t maxComp = 3900;
0764 Double_t maxX = 340;
0765 if (GetIsHGCROC()){
0766 maxComp = 250;
0767 maxX = 450000;
0768 }
0769 PlotRunOverlayProfile1MLayer (canvasLayerProf, topRCornerXProf, topLCornerXProf, topRCornerYProf, relSizePProf, textSizePixel,
0770 trend, nRun,-20, maxX, -20, maxComp, l, 0,
0771 Form("%s/SingleLayer/MuonTriggers_LGHGCorr_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonLGHGCorr",OutputNameDirPlots.Data()), it->second,ExtPlot);
0772 PlotRunOverlayProfile1MLayer (canvasLayerProf, topRCornerXProf, topLCornerXProf, topRCornerYProf, relSizePProf, textSizePixel,
0773 trend, nRun,-20, maxX, -0.01, 0.05, l, 0,
0774 Form("%s/SingleLayer/MuonTriggers_LGHGCorrScaled_Layer%02d.%s" ,OutputNameDirPlots.Data(), l, plotSuffix.Data()),Form("%s/OverlayMuonLGHGCorr",OutputNameDirPlots.Data()), it->second,ExtPlot, true);
0775 }
0776 }
0777 }
0778 }
0779 return status;
0780 }
0781
0782
0783
0784
0785
0786 bool ComparisonCalib::CreateOutputRootFile(void){
0787 if(Overwrite){
0788 RootOutput=new TFile(RootOutputName.Data(),"RECREATE");
0789 } else{
0790 RootOutput = new TFile(RootOutputName.Data(),"CREATE");
0791 }
0792 if(RootOutput->IsZombie()){
0793 std::cout<<"Error opening '"<<RootOutput<<"'no reachable path? Exist without force mode to overwrite?..."<<std::endl;
0794 return false;
0795 }
0796 return true;
0797 }