Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-04 09:27:01

0001 #ifndef PLOTTHELPER_2MLAYER_H
0002 #define PLOTTHELPER_2MLAYER_H
0003 
0004   // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0005   // dedicated class for all 8M layer plotting functions
0006   // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0007 
0008 //   //__________________________________________________________________________________________________________
0009 //   // Plot Trigger Primitive with Fits for Full layer
0010 //   //__________________________________________________________________________________________________________
0011 //   void PlotTriggerPrimWithFits8MLayer (TCanvas* canvas2Panel, TPad* pads[8], Double_t* topRCornerX,  Double_t* topRCornerY, 
0012 //                                          Double_t* relSizeP, Int_t textSizePixel, 
0013 //                                          std::map<int,TileSpectra> spectra, Setup* setupT, 
0014 //                                          double avMip, double facLow, double facHigh,
0015 //                                          Double_t xPMin, Double_t xPMax, Double_t scaleYMax, 
0016 //                                          int layer, int mod,  TString nameOutput, RunInfo currRunInfo){
0017 //                                   
0018 //     Double_t maxY = 0;
0019 //     std::map<int, TileSpectra>::iterator ithSpectra;
0020 //     std::map<int, TileSpectra>::iterator ithSpectraTrigg;
0021 //     
0022 //     int nRow = setupT->GetNMaxRow()+1;
0023 //     int nCol = setupT->GetNMaxColumn()+1;
0024 //     int skipped = 0;
0025 //     for (int r = 0; r < nRow; r++){
0026 //       for (int c = 0; c < nCol; c++){
0027 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0028 //         ithSpectra=spectra.find(tempCellID);
0029 //         if(ithSpectra==spectra.end()){
0030 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0031 //           continue;
0032 //         } 
0033 //         TH1D* tempHist = ithSpectra->second.GetTriggPrim();
0034 //         if (maxY < FindLargestBin1DHist(tempHist, xPMin , xPMax)) maxY = FindLargestBin1DHist(tempHist, xPMin , xPMax);
0035 //       }  
0036 //     }
0037 // 
0038 //     for (int r = 0; r < nRow; r++){
0039 //       for (int c = 0; c < nCol; c++){
0040 //         canvas2Panel->cd();
0041 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0042 //         int p = setupT->GetChannelInLayer(tempCellID);
0043 //         pads[p]->Draw();
0044 //         pads[p]->cd();
0045 //         pads[p]->SetLogy();
0046 //         ithSpectra=spectra.find(tempCellID);
0047 //         if(ithSpectra==spectra.end()){
0048 //           skipped++;
0049 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0050 //           pads[p]->Clear();
0051 //           pads[p]->Draw();
0052 //           if (p ==7 ){
0053 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-2.*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0054 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-3.*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0055 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4.*relSizeP[p], "Trigger primitives", true, 0.85*relSizeP[p], 42);
0056 //           }
0057 //           continue;
0058 //         } 
0059 //         TH1D* tempHist = ithSpectra->second.GetTriggPrim();
0060 //         SetStyleHistoTH1ForGraphs( tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.1, 510, 510, 43, 63);  
0061 //         SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);   
0062 //         tempHist->GetXaxis()->SetRangeUser(xPMin,xPMax);
0063 //         tempHist->GetYaxis()->SetRangeUser(0.7,scaleYMax*maxY);
0064 //         
0065 //         tempHist->Draw("pe");
0066 //         short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0067 //         if (bctemp != -64 && bctemp < 3){
0068 //           Color_t boxCol = kGray;
0069 //           if (bctemp == 1)
0070 //             boxCol = kGray+1;
0071 //           else if (bctemp == 0)
0072 //             boxCol = kGray+2;
0073 //           TBox* badChannelArea =  CreateBox(boxCol, xPMin, 0.7, xPMax,scaleYMax*maxY, 1001 );
0074 //           badChannelArea->Draw();
0075 //           tempHist->Draw("same,axis");
0076 //           tempHist->Draw("same,pe");
0077 //         }
0078 // 
0079 //         TString label           = Form("row %d col %d", r, c);
0080 //         if (p == 7){
0081 //           label = Form("row %d col %d layer %d", r, c, layer);
0082 //         }
0083 //         TLatex *labelChannel    = new TLatex(topRCornerX[p]-0.045,topRCornerY[p]-1.2*relSizeP[p],label);
0084 //         SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,31);
0085 //         labelChannel->Draw();  
0086 //       
0087 //         TBox* triggArea =  CreateBox(kBlue-8, avMip*facLow, 0.7, avMip*facHigh,scaleYMax*maxY, 1001 );
0088 //         triggArea->Draw();
0089 //         
0090 //         DrawLines(avMip*facLow, avMip*facLow,0.7, scaleYMax*maxY, 1, 1, 7);
0091 //         DrawLines(avMip*facHigh, avMip*facHigh,0.7, scaleYMax*maxY, 1, 1, 7);
0092 //         tempHist->Draw("same,axis");
0093 //         tempHist->Draw("same,pe");
0094 //         
0095 //         if (p ==7 ){
0096 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-2.*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0097 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-3.*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0098 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4.*relSizeP[p], "Trigger primitives", true, 0.85*relSizeP[p], 42);
0099 //         }
0100 //       }
0101 //     }
0102 //     if (skipped < 6)
0103 //       canvas2Panel->SaveAs(nameOutput.Data());
0104 //   }
0105 //     
0106   //__________________________________________________________________________________________________________
0107   // Plot Noise with Fits for Full layer
0108   //__________________________________________________________________________________________________________
0109   void PlotNoiseWithFits2MLayer (TCanvas* canvas2Panel, TPad* pads[8], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
0110                                   std::map<int,TileSpectra> spectra, Setup* setupT, bool isHG, 
0111                                   Double_t xPMin, Double_t xPMax, Double_t scaleYMax, int layer, int mod,  TString nameOutput, RunInfo currRunInfo){
0112                                   
0113     Double_t maxY = 0;
0114     std::map<int, TileSpectra>::iterator ithSpectra;
0115     
0116     int nCol = setupT->GetNMaxColumn()+1;
0117     int skipped = 0;
0118     for (int c = 0; c < nCol; c++){
0119       int tempCellID = setupT->GetCellID(0,c, layer, mod);
0120       ithSpectra=spectra.find(tempCellID);
0121       if(ithSpectra==spectra.end()){
0122         std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << 0 << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0123         skipped++;
0124         continue;
0125       } 
0126       TH1D* tempHist = nullptr;
0127       if (isHG){
0128         tempHist = ithSpectra->second.GetHG();
0129       } else {
0130         tempHist = ithSpectra->second.GetLG();
0131       }
0132       if (maxY < FindLargestBin1DHist(tempHist, xPMin , xPMax)) maxY = FindLargestBin1DHist(tempHist, xPMin , xPMax);
0133     }  
0134     
0135     for (int c = 0; c < nCol; c++){
0136       canvas2Panel->cd();
0137       int tempCellID = setupT->GetCellID(0,c, layer, mod);
0138       pads[c]->Draw();
0139       pads[c]->cd();
0140       pads[c]->SetLogy();
0141       ithSpectra=spectra.find(tempCellID);
0142       if(ithSpectra==spectra.end()){
0143         std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << 0 << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0144         pads[c]->Clear();
0145         pads[c]->Draw();
0146         if (c ==1 ){
0147           DrawLatex(topRCornerX[c]-0.04, topRCornerY[c]-4*0.85*relSizeP[c]-1.4*relSizeP[c], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[c], 42);
0148           DrawLatex(topRCornerX[c]-0.04, topRCornerY[c]-4*0.85*relSizeP[c]-2.2*relSizeP[c], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[c], 42);
0149         }
0150         continue;
0151       } 
0152       TH1D* tempHist = nullptr;
0153       if (isHG){
0154           tempHist = ithSpectra->second.GetHG();
0155       } else {
0156           tempHist = ithSpectra->second.GetLG();
0157       }
0158       SetStyleHistoTH1ForGraphs( tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.1, 510, 510, 43, 63);  
0159       SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);   
0160       tempHist->GetXaxis()->SetRangeUser(xPMin,xPMax);
0161       tempHist->GetYaxis()->SetRangeUser(0.7,scaleYMax*maxY);
0162       
0163       tempHist->Draw("pe");
0164       short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0165       if (bctemp != -64 && bctemp < 3){
0166         Color_t boxCol = kGray;
0167         if (bctemp == 1)
0168           boxCol = kGray+1;
0169         else if (bctemp == 0)
0170           boxCol = kGray+2;
0171         TBox* badChannelArea =  CreateBox(boxCol, xPMin, 0.7, xPMax,scaleYMax*maxY, 1001 );
0172         badChannelArea->SetFillColorAlpha(boxCol, 0.35);
0173         badChannelArea->Draw();
0174         tempHist->Draw("same,axis");
0175         tempHist->Draw("same,pe");
0176       }
0177       
0178       TString label           = Form("col %d", c);
0179       if (c == 1){
0180         label = Form("col %d layer %d", c, layer);
0181       }
0182       TLatex *labelChannel    = new TLatex(topRCornerX[c]-0.04,topRCornerY[c]-1.2*relSizeP[c],label);
0183       SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,31);
0184 
0185       
0186       TF1* fit = nullptr;
0187       if (isHG){
0188         fit = ithSpectra->second.GetBackModel(1);
0189       } else {
0190         fit = ithSpectra->second.GetBackModel(0);  
0191       }
0192       if (fit){
0193         SetStyleFit(fit , xPMin, xPMax, 7, 7, kBlack);
0194         fit->Draw("same");
0195         TLegend* legend = GetAndSetLegend2( topRCornerX[c]-8*relSizeP[c], topRCornerY[c]-4*0.85*relSizeP[c]-0.4*relSizeP[c], topRCornerX[c]-0.04, topRCornerY[c]-0.6*relSizeP[c],0.85*textSizePixel, 1, label, 43,0.2);
0196         legend->AddEntry(fit, "Gauss noise fit", "l");
0197         legend->AddEntry((TObject*)0, Form("#mu = %2.2f #pm %2.2f",fit->GetParameter(1), fit->GetParError(1) ) , " ");
0198         legend->AddEntry((TObject*)0, Form("#sigma = %2.2f #pm %2.2f",fit->GetParameter(2), fit->GetParError(2) ) , " ");
0199         legend->Draw();
0200           
0201       } else {
0202         labelChannel->Draw();  
0203       }
0204     
0205       if (xPMin < -5) DrawLines(0, 0,0.7, scaleYMax*maxY, 2, kGray+1, 10);  
0206     
0207       if (c ==1 ){
0208         DrawLatex(topRCornerX[c]-0.04, topRCornerY[c]-4*0.85*relSizeP[c]-1.4*relSizeP[c], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[c], 42);
0209         DrawLatex(topRCornerX[c]-0.04, topRCornerY[c]-4*0.85*relSizeP[c]-2.2*relSizeP[c], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[c], 42);
0210       }
0211     }
0212     if (skipped < 2)
0213       canvas2Panel->SaveAs(nameOutput.Data());
0214   }
0215 //   
0216 //   
0217 //   //__________________________________________________________________________________________________________
0218 //   // Plot Noise extracted from collision data
0219 //   //__________________________________________________________________________________________________________
0220 //   void PlotNoiseAdvWithFits8MLayer (TCanvas* canvas2Panel, TPad* pads[8], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
0221 //                                       std::map<int,TileSpectra> spectra, std::map<int,TileSpectra> spectraTrigg, bool isHG, 
0222 //                                       Double_t xPMin, Double_t xPMax, Double_t scaleYMax, int layer, int mod,  TString nameOutput, RunInfo currRunInfo){
0223 //                                   
0224 //     Double_t maxY = 0;
0225 //     std::map<int, TileSpectra>::iterator ithSpectra;
0226 //     std::map<int, TileSpectra>::iterator ithSpectraTrigg;
0227 //     
0228 //     Setup* setupT = Setup::GetInstance();
0229 //     int nRow = setupT->GetNMaxRow()+1;
0230 //     int nCol = setupT->GetNMaxColumn()+1;
0231 //     int skipped = 0;
0232 //     for (int r = 0; r < nRow; r++){
0233 //       for (int c = 0; c < nCol; c++){
0234 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0235 //         ithSpectra=spectra.find(tempCellID);
0236 //         if(ithSpectra==spectra.end()){
0237 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0238 //           continue;
0239 //         } 
0240 //         TH1D* tempHist = nullptr;
0241 //         if (isHG){
0242 //           tempHist = ithSpectra->second.GetHG();
0243 //         } else {
0244 //           tempHist = ithSpectra->second.GetLG();
0245 //         }
0246 //         if (maxY < FindLargestBin1DHist(tempHist, xPMin , xPMax)) maxY = FindLargestBin1DHist(tempHist, xPMin , xPMax);
0247 //       }  
0248 //     }
0249 //     for (int r = 0; r < nRow; r++){
0250 //       for (int c = 0; c < nCol; c++){
0251 //         canvas2Panel->cd();
0252 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0253 //         int p = setupT->GetChannelInLayer(tempCellID);
0254 //         pads[p]->Draw();
0255 //         pads[p]->cd();
0256 //         pads[p]->SetLogy();
0257 //         ithSpectra=spectra.find(tempCellID);
0258 //         if(ithSpectra==spectra.end()){
0259 //           skipped++;
0260 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0261 //           pads[p]->Clear();
0262 //           pads[p]->Draw();
0263 //           if (p ==7 ){
0264 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0265 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0266 //           }
0267 //           continue;
0268 //         } 
0269 //         ithSpectraTrigg=spectraTrigg.find(tempCellID);
0270 //         TH1D* tempHist = nullptr;
0271 //         if (isHG){
0272 //             tempHist = ithSpectra->second.GetHG();
0273 //         } else {
0274 //             tempHist = ithSpectra->second.GetLG();
0275 //         }
0276 //         SetStyleHistoTH1ForGraphs( tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.1, 510, 510, 43, 63);  
0277 //         SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);   
0278 //         tempHist->GetXaxis()->SetRangeUser(xPMin,xPMax);
0279 //         tempHist->GetYaxis()->SetRangeUser(0.7,scaleYMax*maxY);
0280 //         
0281 //         tempHist->Draw("pe");
0282 //         short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0283 //         if (bctemp != -64 && bctemp < 3){
0284 //           Color_t boxCol = kGray;
0285 //           if (bctemp == 1)
0286 //             boxCol = kGray+1;
0287 //           else if (bctemp == 0)
0288 //             boxCol = kGray+2;
0289 //           TBox* badChannelArea =  CreateBox(boxCol, xPMin, 0.7, xPMax,scaleYMax*maxY, 1001 );
0290 //           badChannelArea->Draw();
0291 //           tempHist->Draw("same,axis");
0292 //           tempHist->Draw("same,pe");
0293 //         }
0294 //         
0295 //         TH1D* tempHistT = nullptr;
0296 //         if (isHG){
0297 //             tempHistT = ithSpectraTrigg->second.GetHG();
0298 //         } else {
0299 //             tempHistT = ithSpectraTrigg->second.GetLG();
0300 //         }
0301 //         SetMarkerDefaults(tempHistT, 24, 1, kRed+1, kRed+1, kFALSE);   
0302 //         tempHistT->Draw("same,pe");
0303 //         
0304 //         TString label           = Form("row %d col %d", r, c);
0305 //         if (p == 7){
0306 //           label = Form("row %d col %d layer %d", r, c, layer);
0307 //         }
0308 //         TLatex *labelChannel    = new TLatex(topRCornerX[p]-0.045,topRCornerY[p]-1.2*relSizeP[p],label);
0309 //         SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,31);
0310 // 
0311 //         
0312 //         TF1* fit            = nullptr;
0313 //         bool isTrigFit      = false;
0314 //         if (isHG){
0315 //           fit = ithSpectraTrigg->second.GetBackModel(1);
0316 //           if (!fit){
0317 //               fit = ithSpectra->second.GetBackModel(1);
0318 //               
0319 //           } else {
0320 //               isTrigFit = true;
0321 //           }
0322 //         } else {
0323 //           fit = ithSpectraTrigg->second.GetBackModel(0);
0324 //           if (!fit){
0325 //               fit = ithSpectra->second.GetBackModel(0);
0326 //           } else {
0327 //               isTrigFit = true;
0328 //           }  
0329 //         }
0330 //         if (fit){
0331 //           if (isTrigFit)
0332 //             SetStyleFit(fit , 0, 2000, 7, 3, kRed+3);
0333 //           else 
0334 //             SetStyleFit(fit , 0, 2000, 7, 7, kBlue+3);  
0335 //           fit->Draw("same");
0336 //           TLegend* legend = GetAndSetLegend2( topRCornerX[p]-10*relSizeP[p], topRCornerY[p]-4*0.85*relSizeP[p]-0.4*relSizeP[p], topRCornerX[p]-0.04, topRCornerY[p]-0.6*relSizeP[p],0.85*textSizePixel, 1, label, 43,0.1);
0337 //           if (isTrigFit)
0338 //             legend->AddEntry(fit, "Gauss noise fit, trigg.", "l");
0339 //           else 
0340 //             legend->AddEntry(fit, "Gauss noise fit", "l");  
0341 //           legend->AddEntry((TObject*)0, Form("#mu = %2.2f #pm %2.2f",fit->GetParameter(1), fit->GetParError(1) ) , " ");
0342 //           legend->AddEntry((TObject*)0, Form("#sigma = %2.2f #pm %2.2f",fit->GetParameter(2), fit->GetParError(2) ) , " ");
0343 //           legend->Draw();
0344 //         } else {
0345 //           labelChannel->Draw();  
0346 //         }
0347 //       
0348 //         DrawLines(0, 0,0.7, scaleYMax*maxY, 2, kGray+1, 10);  
0349 //         if (p ==7 ){
0350 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0351 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0352 //         }
0353 //       
0354 //       }
0355 //     }
0356 //     if (skipped < 6)
0357 //       canvas2Panel->SaveAs(nameOutput.Data());
0358 //   }  
0359 //   
0360 //   //__________________________________________________________________________________________________________
0361 //   // Plot Mip with Fits for Full layer
0362 //   //__________________________________________________________________________________________________________
0363 //   void PlotMipWithFits8MLayer (TCanvas* canvas2Panel, TPad* pads[8], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
0364 //                                   std::map<int,TileSpectra> spectra, std::map<int,TileSpectra> spectraTrigg, Setup* setupT, bool isHG, 
0365 //                                   Double_t xPMin, Double_t xPMax, Double_t scaleYMax, int layer, int mod,  TString nameOutput, RunInfo currRunInfo){
0366 //                                   
0367 //     Double_t maxY = 0;
0368 //     std::map<int, TileSpectra>::iterator ithSpectra;
0369 //     std::map<int, TileSpectra>::iterator ithSpectraTrigg;
0370 //     
0371 //     int nRow = setupT->GetNMaxRow()+1;
0372 //     int nCol = setupT->GetNMaxColumn()+1;
0373 //     int skipped = 0;
0374 //     for (int r = 0; r < nRow; r++){
0375 //       for (int c = 0; c < nCol; c++){
0376 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0377 //         ithSpectra=spectra.find(tempCellID);
0378 //         if(ithSpectra==spectra.end()){
0379 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0380 //           continue;
0381 //         } 
0382 //         TH1D* tempHist = nullptr;
0383 //         if (isHG){
0384 //           tempHist = ithSpectra->second.GetHG();
0385 //         } else {
0386 //           tempHist = ithSpectra->second.GetLG();
0387 //         }
0388 //         if (maxY < FindLargestBin1DHist(tempHist, xPMin , xPMax)) maxY = FindLargestBin1DHist(tempHist, xPMin , xPMax);
0389 //       }  
0390 //     }
0391 //     
0392 //     for (int r = 0; r < nRow; r++){
0393 //       for (int c = 0; c < nCol; c++){
0394 //         canvas2Panel->cd();
0395 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0396 //         int p = setupT->GetChannelInLayer(tempCellID);
0397 //         pads[p]->Draw();
0398 //         pads[p]->cd();
0399 //         pads[p]->SetLogy();
0400 //         ithSpectra=spectra.find(tempCellID);
0401 //         if(ithSpectra==spectra.end()){
0402 //           skipped++;
0403 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0404 //           pads[p]->Clear();
0405 //           pads[p]->Draw();
0406 //           if (p ==7 ){
0407 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0408 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0409 //           }          
0410 //           continue;
0411 //         } 
0412 //         ithSpectraTrigg=spectraTrigg.find(tempCellID);
0413 //         TH1D* tempHist = nullptr;
0414 //         double noiseWidth = 0;
0415 //         if (isHG){
0416 //             tempHist = ithSpectra->second.GetHG();
0417 //             noiseWidth = ithSpectra->second.GetCalib()->PedestalSigH;
0418 //         } else {
0419 //             tempHist = ithSpectra->second.GetLG();
0420 //             noiseWidth = ithSpectra->second.GetCalib()->PedestalSigL;
0421 //         }
0422 //         SetStyleHistoTH1ForGraphs( tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.1, 510, 510, 43, 63);  
0423 //         SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);   
0424 //         tempHist->GetXaxis()->SetRangeUser(xPMin,xPMax);
0425 //         tempHist->GetYaxis()->SetRangeUser(0.7,scaleYMax*maxY);
0426 //         
0427 //         tempHist->Draw("pe");
0428 //         short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0429 //         if (bctemp != -64 && bctemp < 3){
0430 //           Color_t boxCol = kGray;
0431 //           if (bctemp == 1)
0432 //             boxCol = kGray+1;
0433 //           else if (bctemp == 0)
0434 //             boxCol = kGray+2;
0435 //           TBox* badChannelArea =  CreateBox(boxCol, xPMin, 0.7, xPMax,scaleYMax*maxY, 1001 );
0436 //           badChannelArea->Draw();
0437 //           tempHist->Draw("same,axis");
0438 //           tempHist->Draw("same,pe");
0439 //         }
0440 //         
0441 //         TH1D* tempHistT = nullptr;
0442 //         
0443 //         if (isHG){
0444 //             tempHistT = ithSpectraTrigg->second.GetHG();
0445 //         } else {
0446 //             tempHistT = ithSpectraTrigg->second.GetLG();
0447 //         }
0448 //         SetMarkerDefaults(tempHistT, 24, 1, kRed+1, kRed+1, kFALSE);   
0449 //         tempHistT->Draw("same,pe");
0450 //         
0451 //         TString label           = Form("row %d col %d", r, c);
0452 //         if (p == 7){
0453 //           label = Form("row %d col %d layer %d", r, c, layer);
0454 //         }
0455 //         TLatex *labelChannel    = new TLatex(topRCornerX[p]-0.045,topRCornerY[p]-1.2*relSizeP[p],label);
0456 //         SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,31);
0457 // 
0458 //         
0459 //         TF1* fit            = nullptr;
0460 //         bool isTrigFit      = false;
0461 //         double maxFit       = 0;
0462 //         if (isHG){
0463 //           fit = ithSpectraTrigg->second.GetSignalModel(1);
0464 //           if (!fit){
0465 //               fit = ithSpectra->second.GetSignalModel(1);
0466 //               if (fit){
0467 //                 maxFit = ithSpectra->second.GetCalib()->ScaleH;
0468 //               }
0469 //           } else {
0470 //               isTrigFit = true;
0471 //               maxFit = ithSpectraTrigg->second.GetCalib()->ScaleH;
0472 //           }
0473 //         } else {
0474 //           fit = ithSpectraTrigg->second.GetSignalModel(0);
0475 //           if (!fit){
0476 //               fit = ithSpectra->second.GetSignalModel(0);
0477 //               if (fit){
0478 //                 maxFit = ithSpectra->second.GetCalib()->ScaleL;
0479 //               }
0480 //           } else {
0481 //               isTrigFit = true;
0482 //               maxFit = ithSpectraTrigg->second.GetCalib()->ScaleL;
0483 //           }  
0484 //         }
0485 //         if (fit){
0486 //           if (isTrigFit)
0487 //             SetStyleFit(fit , 0, 2000, 7, 3, kRed+3);
0488 //           else 
0489 //             SetStyleFit(fit , 0, 2000, 7, 7, kBlue+3);  
0490 //           fit->Draw("same");
0491 //           TLegend* legend = GetAndSetLegend2( topRCornerX[p]-10*relSizeP[p], topRCornerY[p]-4*0.85*relSizeP[p]-0.4*relSizeP[p], topRCornerX[p]-0.04, topRCornerY[p]-0.6*relSizeP[p],0.85*textSizePixel, 1, label, 43,0.1);
0492 //           if (isTrigFit)
0493 //             legend->AddEntry(fit, "Landau-Gauss fit, trigg.", "l");
0494 //           else 
0495 //             legend->AddEntry(fit, "Landau-Gauss fit", "l");  
0496 //           legend->AddEntry((TObject*)0, Form("#scale[0.8]{L MPV = %2.2f #pm %2.2f}",fit->GetParameter(1), fit->GetParError(1) ) , " ");
0497 //           legend->AddEntry((TObject*)0, Form("#scale[0.8]{Max = %2.2f}", maxFit ) , " ");
0498 //           legend->Draw();
0499 //           DrawLines(maxFit, maxFit,0.7, scaleYMax*maxY/10, 5, kRed+3, 7);  
0500 //         } else {
0501 //           labelChannel->Draw();  
0502 //         }
0503 //       
0504 //         DrawLines(noiseWidth*3, noiseWidth*3,0.7, scaleYMax*maxY, 2, kGray+1, 10);  
0505 //         DrawLines(noiseWidth*5, noiseWidth*5,0.7, scaleYMax*maxY, 2, kGray+1, 6);  
0506 //       
0507 //         if (p ==7 ){
0508 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0509 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0510 //         }
0511 //       }
0512 //     }
0513 //     if (skipped < 6)
0514 //       canvas2Panel->SaveAs(nameOutput.Data());
0515 //   }
0516 // 
0517 //   //__________________________________________________________________________________________________________
0518 //   // Plot Spectra with Fits for Full layer
0519 //   //__________________________________________________________________________________________________________
0520 //   void PlotSpectra8MLayer (TCanvas* canvas2Panel, TPad* pads[8], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
0521 //                                   std::map<int,TileSpectra> spectra, int isHG, 
0522 //                                   Double_t xPMin, Double_t xPMax, Double_t scaleYMax, int layer, int mod,  TString nameOutput, RunInfo currRunInfo){
0523 //                                   
0524 //     Double_t maxY = 0;
0525 //     std::map<int, TileSpectra>::iterator ithSpectra;
0526 //     Setup* setupT = Setup::GetInstance();
0527 //     
0528 //     int nRow = setupT->GetNMaxRow()+1;
0529 //     int nCol = setupT->GetNMaxColumn()+1;
0530 //     int skipped = 0;
0531 //     for (int r = 0; r < nRow; r++){
0532 //       for (int c = 0; c < nCol; c++){
0533 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0534 //         ithSpectra=spectra.find(tempCellID);
0535 //         if(ithSpectra==spectra.end()){
0536 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0537 //           continue;
0538 //         } 
0539 //         TH1D* tempHist = nullptr;
0540 //         if (isHG == 0){
0541 //           tempHist = ithSpectra->second.GetHG();
0542 //         } else if (isHG == 1){
0543 //           tempHist = ithSpectra->second.GetLG();
0544 //         } else {
0545 //           tempHist = ithSpectra->second.GetComb();
0546 //         }
0547 //         if (maxY < FindLargestBin1DHist(tempHist, xPMin , xPMax)) maxY = FindLargestBin1DHist(tempHist, xPMin , xPMax);
0548 //       }  
0549 //     }
0550 //     
0551 //     for (int r = 0; r < nRow; r++){
0552 //       for (int c = 0; c < nCol; c++){
0553 //         canvas2Panel->cd();
0554 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0555 //         int p = setupT->GetChannelInLayer(tempCellID);
0556 //         pads[p]->Draw();
0557 //         pads[p]->cd();
0558 //         pads[p]->SetLogy();
0559 //         ithSpectra=spectra.find(tempCellID);
0560 //         if(ithSpectra==spectra.end()){
0561 //           skipped++;
0562 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0563 //           pads[p]->Clear();
0564 //           pads[p]->Draw();
0565 //           if (p ==7 ){
0566 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0567 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0568 //           }          
0569 //           continue;
0570 //         } 
0571 //         TH1D* tempHist = nullptr;
0572 //         double noiseWidth = 0;
0573 //         if (isHG == 0){
0574 //             tempHist = ithSpectra->second.GetHG();
0575 //             noiseWidth = ithSpectra->second.GetCalib()->PedestalSigH;
0576 //         } else if (isHG == 1){
0577 //             tempHist = ithSpectra->second.GetLG();
0578 //             noiseWidth = ithSpectra->second.GetCalib()->PedestalSigL;
0579 //         } else {
0580 //             tempHist = ithSpectra->second.GetComb();
0581 //         }
0582 //         SetStyleHistoTH1ForGraphs( tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.1, 510, 510, 43, 63);  
0583 //         SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);   
0584 //         tempHist->GetXaxis()->SetRangeUser(xPMin,xPMax);
0585 //         tempHist->GetYaxis()->SetRangeUser(0.7,scaleYMax*maxY);
0586 //         
0587 //         tempHist->Draw("pe");
0588 //         short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0589 //         if (bctemp != -64 && bctemp < 3){
0590 //           Color_t boxCol = kGray;
0591 //           if (bctemp == 1)
0592 //             boxCol = kGray+1;
0593 //           else if (bctemp == 0)
0594 //             boxCol = kGray+2;
0595 //           TBox* badChannelArea =  CreateBox(boxCol, xPMin, 0.7, xPMax,scaleYMax*maxY, 1001 );
0596 //           badChannelArea->Draw();
0597 //           tempHist->Draw("same,axis");
0598 //           tempHist->Draw("same,pe");
0599 //         }
0600 //                 
0601 //         TString label           = Form("row %d col %d", r, c);
0602 //         if (p == 7){
0603 //           label = Form("row %d col %d layer %d", r, c, layer);
0604 //         }
0605 //         TLatex *labelChannel    = new TLatex(topRCornerX[p]-0.045,topRCornerY[p]-1.2*relSizeP[p],label);
0606 //         SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,31);
0607 //         labelChannel->Draw();  
0608 //       
0609 //         if (isHG < 2){
0610 //           DrawLines(noiseWidth*3, noiseWidth*3,0.7, scaleYMax*maxY, 2, kGray+1, 10);  
0611 //           DrawLines(noiseWidth*5, noiseWidth*5,0.7, scaleYMax*maxY, 2, kGray+1, 6);  
0612 //         } else {
0613 //           DrawLines(0.3, 0.3, 0.7, scaleYMax*maxY, 2, kGray+1, 10);  
0614 //         }
0615 //         if (p ==7 ){
0616 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeP[p], 42);
0617 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeP[p], 42);
0618 //         }
0619 //       }
0620 //     }
0621 //     if (skipped < 6)
0622 //       canvas2Panel->SaveAs(nameOutput.Data());
0623 //   }
0624 //   
0625 //   //__________________________________________________________________________________________________________
0626 //   // Plot Corr with Fits for Full layer
0627 //   //__________________________________________________________________________________________________________
0628 //   void PlotCorrWithFits8MLayer (TCanvas* canvas2Panel, TPad* pads[8], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
0629 //                                   std::map<int,TileSpectra> spectra, int option, 
0630 //                                   Double_t xPMin, Double_t xPMax, Double_t maxY, int layer, int mod,  TString nameOutput, RunInfo currRunInfo){
0631 //                                   
0632 //     Setup* setupT = Setup::GetInstance();
0633 //     
0634 //     std::map<int, TileSpectra>::iterator ithSpectra;    
0635 //     int nRow = setupT->GetNMaxRow()+1;
0636 //     int nCol = setupT->GetNMaxColumn()+1;
0637 //     int skipped = 0;
0638 //     
0639 //     for (int r = 0; r < nRow; r++){
0640 //       for (int c = 0; c < nCol; c++){
0641 //         canvas2Panel->cd();
0642 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0643 //         int p = setupT->GetChannelInLayer(tempCellID);
0644 //         pads[p]->Draw();
0645 //         pads[p]->SetLogy(0);
0646 //         pads[p]->cd();
0647 //         
0648 //         ithSpectra=spectra.find(tempCellID);
0649 //         if(ithSpectra==spectra.end()){
0650 //           skipped++;
0651 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0652 //           pads[p]->Clear();
0653 //           pads[p]->Draw();
0654 //           if (p ==7 ){
0655 //             DrawLatex(topRCornerX[p]+0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), false, 0.85*relSizeP[p], 42);
0656 //             DrawLatex(topRCornerX[p]+0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), false, 0.85*relSizeP[p], 42);
0657 //           }
0658 //         continue;
0659 //         } 
0660 //         TProfile* tempProfile = nullptr;
0661 //         if (option == 1 || option == 2){
0662 //             tempProfile = ithSpectra->second.GetHGLGcorr();
0663 //         } else {
0664 //             tempProfile = ithSpectra->second.GetLGHGcorr();
0665 //         }
0666 //         if (!tempProfile) continue;
0667 //         TH1D* dummyhist = new TH1D("dummyhist", "", tempProfile->GetNbinsX(), tempProfile->GetXaxis()->GetXmin(), tempProfile->GetXaxis()->GetXmax());
0668 //         SetStyleHistoTH1ForGraphs( dummyhist, tempProfile->GetXaxis()->GetTitle(), tempProfile->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.5, 510, 510, 43, 63);  
0669 // 
0670 // 
0671 //         // SetStyleTProfile( tempProfile, tempProfile->GetXaxis()->GetTitle(), tempProfile->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.1, 510, 510, 43, 63);  
0672 //         SetMarkerDefaultsProfile(tempProfile, 20, 1, kBlue+1, kBlue+1);   
0673 //         Int_t maxX = 3900;        
0674 //         if (option == 0 || option == 2 )
0675 //           maxX = 340;
0676 //         if (option == 2){
0677 //           dummyhist->GetYaxis()->SetRangeUser(-maxY,maxY);
0678 //           dummyhist->GetXaxis()->SetRangeUser(xPMin,maxX);
0679 //         } else {
0680 //           dummyhist->GetYaxis()->SetRangeUser(0,maxY);
0681 //           dummyhist->GetXaxis()->SetRangeUser(0,maxX);
0682 //         }
0683 //         
0684 //         
0685 //         dummyhist->Draw("axis");
0686 // 
0687 //         short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0688 //         if (bctemp != -64 && bctemp < 3){
0689 //           Color_t boxCol = kGray;
0690 //           if (bctemp == 1)
0691 //             boxCol = kGray+1;
0692 //           else if (bctemp == 0)
0693 //             boxCol = kGray+2;
0694 //           TBox* badChannelArea =  CreateBox(boxCol, 0, 0, maxX,maxY, 1001 );
0695 //           badChannelArea->Draw();
0696 //           dummyhist->Draw("axis,same");
0697 //         }
0698 // 
0699 //         tempProfile->Draw("pe, same");
0700 //                 
0701 //         TString label           = Form("row %d col %d", r, c);
0702 //         if (p == 7){
0703 //           label = Form("row %d col %d layer %d", r, c, layer);
0704 //         }
0705 //         TLatex *labelChannel    = new TLatex(topRCornerX[p]+0.045,topRCornerY[p]-1.2*relSizeP[p],label);
0706 //         SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,11);
0707 // 
0708 //         
0709 //         TF1* fit            = nullptr;
0710 //         if (option == 1 ){
0711 //           fit = ithSpectra->second.GetCorrModel(1);
0712 //         } else if (option == 0 ){
0713 //           fit = ithSpectra->second.GetCorrModel(0);
0714 //         }
0715 //         if (fit){
0716 //           Double_t rangeFit[2] = {0,0};
0717 //           fit->GetRange(rangeFit[0], rangeFit[1]);
0718 //           SetStyleFit(fit , rangeFit[0], rangeFit[1], 7, 3, kRed+3);
0719 //           fit->Draw("same");
0720 //           TLegend* legend = GetAndSetLegend2( topRCornerX[p]+0.045, topRCornerY[p]-4*0.85*relSizeP[p]-0.4*relSizeP[p], topRCornerX[p]+6*relSizeP[p], topRCornerY[p]-0.6*relSizeP[p],0.85*textSizePixel, 1, label, 43,0.1);
0721 //           legend->AddEntry(fit, "linear fit, trigg.", "l");
0722 //           legend->AddEntry((TObject*)0, Form("#scale[0.8]{b = %2.3f #pm %2.4f}",fit->GetParameter(0), fit->GetParError(0) ) , " ");
0723 //           legend->AddEntry((TObject*)0, Form("#scale[0.8]{a = %2.3f #pm %2.4f}",fit->GetParameter(1), fit->GetParError(1) ) , " ");
0724 //           legend->Draw();
0725 //         } else {
0726 //           labelChannel->Draw();  
0727 //         }
0728 //       
0729 //         if (option == 2){
0730 //          DrawLines(xPMin,maxX,0, 0, 2, kGray+1, 10);   
0731 //         }
0732 //         if (p ==7 ){
0733 //           DrawLatex(topRCornerX[p]+0.045, topRCornerY[p]-4*0.85*relSizeP[p]-1.4*relSizeP[p], GetStringFromRunInfo(currRunInfo, 2), false, 0.85*relSizeP[p], 42);
0734 //           DrawLatex(topRCornerX[p]+0.045, topRCornerY[p]-4*0.85*relSizeP[p]-2.2*relSizeP[p], GetStringFromRunInfo(currRunInfo, 3), false, 0.85*relSizeP[p], 42);
0735 //         }
0736 //       }
0737 //     }
0738 //     if (skipped < 6)
0739 //       canvas2Panel->SaveAs(nameOutput.Data());
0740 //   }
0741 // 
0742   //__________________________________________________________________________________________________________
0743   // Plot Corr with Fits for Full layer 2D
0744   //__________________________________________________________________________________________________________
0745   void PlotCorr2D2MLayer (TCanvas* canvas2Panel, TPad* pads[2], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
0746                                   std::map<int,TileSpectra> spectra, 
0747                                   Double_t xPMin, Double_t xPMax, Double_t maxY, int layer, int mod,  TString nameOutput, RunInfo currRunInfo){
0748                                   
0749     Setup* setupT = Setup::GetInstance();
0750     
0751     std::map<int, TileSpectra>::iterator ithSpectra;    
0752     int nCol = setupT->GetNMaxColumn()+1;
0753     int skipped = 0;
0754     ReadOut::Type rotype = ReadOut::Type::Undef;
0755     
0756     for (int c = 0; c < nCol; c++){
0757       canvas2Panel->cd();
0758       int tempCellID = setupT->GetCellID(0,c, layer, mod);
0759       pads[c]->Draw();
0760       pads[c]->SetLogy(0);
0761       pads[c]->SetLogz(1);
0762       pads[c]->cd();
0763       
0764       Int_t offset = 1;
0765       
0766       ithSpectra=spectra.find(tempCellID);
0767       if(ithSpectra==spectra.end()){
0768         skipped++;
0769         std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << 0 << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0770         pads[c]->Clear();
0771         pads[c]->Draw();
0772         if (c == 1 ){
0773           DrawLatex(topRCornerX[c]+0.045, topRCornerY[c]-offset*0.85*relSizeP[c]-1.4*relSizeP[c], GetStringFromRunInfo(currRunInfo, 2), false, 0.85*relSizeP[c], 42);
0774           DrawLatex(topRCornerX[c]+0.045, topRCornerY[c]-offset*0.85*relSizeP[c]-2.2*relSizeP[c], GetStringFromRunInfo(currRunInfo, 3), false, 0.85*relSizeP[c], 42);
0775         }
0776         continue;
0777       } else {
0778         rotype = ithSpectra->second.GetROType();
0779       }
0780       TProfile* tempProfile = ithSpectra->second.GetLGHGcorr();
0781       TH2D* temp2D          = ithSpectra->second.GetCorr();
0782       if (!tempProfile) continue;
0783       SetStyleHistoTH2ForGraphs( temp2D, temp2D->GetXaxis()->GetTitle(), temp2D->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.5, 510, 510, 43, 63);  
0784       SetMarkerDefaultsProfile(tempProfile, 24, 0.7, kRed+2, kRed+2);   
0785       
0786       temp2D->GetYaxis()->SetRangeUser(-10,maxY);
0787       temp2D->GetXaxis()->SetRangeUser(0,xPMax);
0788       temp2D->Draw("col");
0789 
0790       short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0791       if (bctemp != -64 && bctemp < 3){
0792         Color_t boxCol = kGray;
0793         if (bctemp == 1)
0794           boxCol = kGray+1;
0795         else if (bctemp == 0)
0796           boxCol = kGray+2;
0797         TBox* badChannelArea =  CreateBox(boxCol, 0, 0, xPMax,maxY, 1001 );
0798         badChannelArea->Draw();
0799         temp2D->Draw("axis,same");
0800       }
0801 
0802       TString xTit = temp2D->GetXaxis()->GetTitle();
0803       if (xTit.Contains("ample") != 0){
0804         tempProfile->Draw("pe, same");
0805       } 
0806         
0807       TString label           = Form("col %d", c);
0808       if (c == 1){
0809         label = Form("col %d layer %d", c, layer);
0810       }
0811       TLatex *labelChannel    = new TLatex(topRCornerX[c]+0.045,topRCornerY[c]-1.2*relSizeP[c],label);
0812       SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,11);
0813 
0814       TF1* fit            = ithSpectra->second.GetCorrModel(0);
0815       if (rotype == ReadOut::Type::Hgcroc)
0816         fit            = ithSpectra->second.GetCorrModel(1);
0817       if (fit){
0818         offset=4;
0819         Double_t rangeFit[2] = {0,0};
0820         fit->GetRange(rangeFit[0], rangeFit[1]);
0821         SetStyleFit(fit , rangeFit[0], rangeFit[1], 7, 3, kRed+3);
0822         fit->Draw("same");
0823         TLegend* legend = nullptr;
0824         if (rotype == ReadOut::Type::Caen){
0825           legend = GetAndSetLegend2( topRCornerX[c]+0.045, topRCornerY[c]-4*0.85*relSizeP[c]-0.4*relSizeP[c], topRCornerX[c]+6*relSizeP[c], topRCornerY[c]-0.6*relSizeP[c],0.85*textSizePixel, 1, label, 43,0.1);
0826           legend->AddEntry(fit, "linear fit, trigg.", "l");
0827           legend->AddEntry((TObject*)0, Form("#scale[0.8]{b = %2.3f #pm %2.4f}",fit->GetParameter(0), fit->GetParError(0) ) , " ");
0828           legend->AddEntry((TObject*)0, Form("#scale[0.8]{a = %2.3f #pm %2.4f}",fit->GetParameter(1), fit->GetParError(1) ) , " ");
0829         } else {
0830           legend = GetAndSetLegend2( topRCornerX[c]+0.045, topRCornerY[c]-3*0.85*relSizeP[c]-0.4*relSizeP[c], topRCornerX[c]+6*relSizeP[c], topRCornerY[c]-0.6*relSizeP[c],0.85*textSizePixel, 1, label, 43,0.1);
0831           legend->AddEntry(fit, "const fit", "l");
0832           legend->AddEntry((TObject*)0, Form("#scale[0.8]{a = %2.3f #pm %2.4f}",fit->GetParameter(0), fit->GetParError(0) ) , " ");   
0833         }
0834         legend->Draw();
0835       } else {
0836         labelChannel->Draw();  
0837       }
0838     
0839       if (c ==1 ){
0840         DrawLatex(topRCornerX[c]+0.045, topRCornerY[c]-offset*0.85*relSizeP[c]-1.4*relSizeP[c], GetStringFromRunInfo(currRunInfo, 2), false, 0.85*relSizeP[c], 42);
0841         DrawLatex(topRCornerX[c]+0.045, topRCornerY[c]-offset*0.85*relSizeP[c]-2.2*relSizeP[c], GetStringFromRunInfo(currRunInfo, 3), false, 0.85*relSizeP[c], 42);
0842       }
0843     }
0844     if (skipped < 2)
0845       canvas2Panel->SaveAs(nameOutput.Data());
0846   }
0847 //   
0848 //   //__________________________________________________________________________________________________________
0849 //   // Plot Corr with Fits for Full layer
0850 //   //__________________________________________________________________________________________________________
0851 //   void PlotTrending8MLayer (TCanvas* canvas2Panel, TPad* pads[8], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
0852 //                               std::map<int,TileTrend> trending, int optionTrend, 
0853 //                               Double_t xPMin, Double_t xPMax, int layer, int mod,  TString nameOutput, TString nameOutputSummary, RunInfo currRunInfo, Int_t  detailedPlot = 1){
0854 //                                   
0855 //     Setup* setupT = Setup::GetInstance();
0856 //     
0857 //     std::map<int, TileTrend>::iterator ithTrend;    
0858 //     int nRow = setupT->GetNMaxRow()+1;
0859 //     int nCol = setupT->GetNMaxColumn()+1;
0860 //     int skipped = 0;
0861 //     bool isSameVoltage    = true;
0862 //     double commanVoltage  = 0;
0863 //     
0864 //     Double_t minY = 9999;
0865 //     Double_t maxY = 0.;
0866 //     
0867 //     for (int r = 0; r < nRow; r++){
0868 //       for (int c = 0; c < nCol; c++){
0869 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0870 //         ithTrend=trending.find(tempCellID);
0871 //         if (optionTrend == 0){
0872 //           if(minY>ithTrend->second.GetMinHGped()) minY=ithTrend->second.GetMinHGped();
0873 //           if(maxY<ithTrend->second.GetMaxHGped()) maxY=ithTrend->second.GetMaxHGped();
0874 //         } else if (optionTrend == 1){
0875 //           if(minY>ithTrend->second.GetMinLGped()) minY=ithTrend->second.GetMinLGped();
0876 //           if(maxY<ithTrend->second.GetMaxLGped()) maxY=ithTrend->second.GetMaxLGped();
0877 //         } else if (optionTrend == 2){
0878 //           if(minY>ithTrend->second.GetMinHGscale()) minY=ithTrend->second.GetMinHGscale();
0879 //           if(maxY<ithTrend->second.GetMaxHGscale()) maxY=ithTrend->second.GetMaxHGscale();
0880 //         } else if (optionTrend == 3){
0881 //           if(minY>ithTrend->second.GetMinLGscale()) minY=ithTrend->second.GetMinLGscale();
0882 //           if(maxY<ithTrend->second.GetMaxLGscale()) maxY=ithTrend->second.GetMaxLGscale();
0883 //         } else if (optionTrend == 4){
0884 //           if(minY>ithTrend->second.GetMinLGHGcorr()) minY=ithTrend->second.GetMinLGHGcorr();
0885 //           if(maxY<ithTrend->second.GetMaxLGHGcorr()) maxY=ithTrend->second.GetMaxLGHGcorr();
0886 //         } else if (optionTrend == 5){
0887 //           if(minY>ithTrend->second.GetMinHGLGcorr()) minY=ithTrend->second.GetMinHGLGcorr();
0888 //           if(maxY<ithTrend->second.GetMaxHGLGcorr()) maxY=ithTrend->second.GetMaxHGLGcorr();          
0889 //         } else if (optionTrend == 6){
0890 //           if(minY>ithTrend->second.GetMinTrigg()) minY=ithTrend->second.GetMinTrigg();
0891 //           if(maxY<ithTrend->second.GetMaxTrigg()) maxY=ithTrend->second.GetMaxTrigg();          
0892 //         } else if (optionTrend == 7){
0893 //           if(minY>ithTrend->second.GetMinSBSignal()) minY=ithTrend->second.GetMinSBSignal();
0894 //           if(maxY<ithTrend->second.GetMaxSBSignal()) maxY=ithTrend->second.GetMaxSBSignal();          
0895 //         } else if (optionTrend == 8){
0896 //           if(minY>ithTrend->second.GetMinSBNoise()) minY=ithTrend->second.GetMinSBNoise();
0897 //           if(maxY<ithTrend->second.GetMaxSBNoise()) maxY=ithTrend->second.GetMaxSBNoise();          
0898 //         } else if (optionTrend == 9){
0899 //           if(minY>ithTrend->second.GetMinHGMPV()) minY=ithTrend->second.GetMinHGMPV();
0900 //           if(maxY<ithTrend->second.GetMaxHGMPV()) maxY=ithTrend->second.GetMaxHGMPV();          
0901 //         } else if (optionTrend == 10){
0902 //           if(minY>ithTrend->second.GetMinLGMPV()) minY=ithTrend->second.GetMinLGMPV();
0903 //           if(maxY<ithTrend->second.GetMaxLGMPV()) maxY=ithTrend->second.GetMaxLGMPV();          
0904 //         } else if (optionTrend == 11){
0905 //           if(minY>ithTrend->second.GetMinHGLSigma()) minY=ithTrend->second.GetMinHGLSigma();
0906 //           if(maxY<ithTrend->second.GetMaxHGLSigma()) maxY=ithTrend->second.GetMaxHGLSigma();          
0907 //         } else if (optionTrend == 12){
0908 //           if(minY>ithTrend->second.GetMinLGLSigma()) minY=ithTrend->second.GetMinLGLSigma();
0909 //           if(maxY<ithTrend->second.GetMaxLGLSigma()) maxY=ithTrend->second.GetMaxLGLSigma();          
0910 //         } else if (optionTrend == 13){
0911 //           if(minY>ithTrend->second.GetMinHGGSigma()) minY=ithTrend->second.GetMinHGGSigma();
0912 //           if(maxY<ithTrend->second.GetMaxHGGSigma()) maxY=ithTrend->second.GetMaxHGGSigma();          
0913 //         } else if (optionTrend == 14){
0914 //           if(minY>ithTrend->second.GetMinLGGSigma()) minY=ithTrend->second.GetMinLGGSigma();
0915 //           if(maxY<ithTrend->second.GetMaxLGGSigma()) maxY=ithTrend->second.GetMaxLGGSigma();          
0916 //         } else if (optionTrend == 15){
0917 //           if(minY>ithTrend->second.GetMinHGpedwidth()) minY=ithTrend->second.GetMinHGpedwidth();
0918 //           if(maxY<ithTrend->second.GetMaxHGpedwidth()) maxY=ithTrend->second.GetMaxHGpedwidth();          
0919 //         } else if (optionTrend == 16){
0920 //           if(minY>ithTrend->second.GetMinLGpedwidth()) minY=ithTrend->second.GetMinLGpedwidth();
0921 //           if(maxY<ithTrend->second.GetMaxLGpedwidth()) maxY=ithTrend->second.GetMaxLGpedwidth();          
0922 //         } else if (optionTrend == 17){
0923 //           if(minY>ithTrend->second.GetMinLGHGOffset()) minY=ithTrend->second.GetMinLGHGOffset();
0924 //           if(maxY<ithTrend->second.GetMaxLGHGOffset()) maxY=ithTrend->second.GetMaxLGHGOffset();          
0925 //         } else if (optionTrend == 18){
0926 //           if(minY>ithTrend->second.GetMinHGLGOffset()) minY=ithTrend->second.GetMinHGLGOffset();
0927 //           if(maxY<ithTrend->second.GetMaxHGLGOffset()) maxY=ithTrend->second.GetMaxHGLGOffset();          
0928 //         }
0929 //         for (int rc = 0; rc < ithTrend->second.GetNRuns() && rc < 30; rc++ ){
0930 //           if (r == 0 && c == 0){
0931 //             if (rc == 0){
0932 //               commanVoltage = ithTrend->second.GetVoltage(rc);
0933 //             } else {
0934 //               if (commanVoltage != ithTrend->second.GetVoltage(rc))  isSameVoltage = false;
0935 //             }
0936 //           }
0937 //         }
0938 //       }
0939 //     }
0940 //     if (minY == 9999 && maxY == 0.){
0941 //       std::cout <<"Something went wrong! No ranges set for layer " <<  layer << " \t trend plotting option: " << optionTrend << "\t ABORTING!" << std::endl;
0942 //       return;
0943 //     }
0944 //     // prep for log scale
0945 //     if (optionTrend == 6){ 
0946 //       if (minY ==0 ) minY = 1;
0947 //       else minY = minY/5.;
0948 //       maxY= maxY*5.;
0949 //     } else if (optionTrend == 17 || optionTrend == 18 ){ 
0950 //       minY = 1.1*minY;
0951 //       maxY = 2*maxY;      
0952 //     } else {
0953 //       minY = 0.9*minY;
0954 //       maxY = 1.1*maxY;      
0955 //     }
0956 //     for (int r = 0; r < nRow; r++){
0957 //       for (int c = 0; c < nCol; c++){
0958 //         
0959 //         canvas2Panel->cd();
0960 //         int tempCellID = setupT->GetCellID(r,c, layer, mod);
0961 //         int p = setupT->GetChannelInLayer(tempCellID);
0962 // 
0963 //         TString label           = Form("row %d col %d", r, c);
0964 //         TString label2          = Form("Common V_{op} = %2.1f V", commanVoltage);
0965 //         if (p == 7){
0966 //           label = Form("row %d col %d layer %d", r, c, layer);
0967 //         }
0968 // 
0969 //         pads[p]->Draw();
0970 //         
0971 //         if (optionTrend == 6){ 
0972 //           pads[p]->SetLogy(1);
0973 //         } else {
0974 //           pads[p]->SetLogy(0);          
0975 //         }
0976 // 
0977 //         pads[p]->cd();
0978 //         ithTrend=trending.find(tempCellID);
0979 //         if(ithTrend==trending.end()){
0980 //           skipped++;
0981 //           std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t row " << r << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
0982 //           pads[p]->Clear();
0983 //           pads[p]->Draw();
0984 //           if (p ==4 ){
0985 //             TString lab1 = Form("#it{#bf{LFHCal TB:}} %s", GetStringFromRunInfo(currRunInfo, 9).Data());
0986 //             TString lab2 = GetStringFromRunInfo(currRunInfo, 8);
0987 //             TString lab3 = GetStringFromRunInfo(currRunInfo, 10);
0988 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p]-1*0.85*relSizeP[p], lab1, true, 0.85*textSizePixel, 43);
0989 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p]-2*0.85*relSizeP[p], lab2, true, 0.85*textSizePixel, 43);
0990 //             DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p]-3*0.85*relSizeP[p], lab3, true, 0.85*textSizePixel, 43);
0991 //           }
0992 //           continue;
0993 //         } 
0994 //         TGraphErrors* tempGraph = nullptr;
0995 //         if (optionTrend == 0)       tempGraph = ithTrend->second.GetHGped();
0996 //         else if (optionTrend == 1)  tempGraph = ithTrend->second.GetLGped();
0997 //         else if (optionTrend == 2)  tempGraph = ithTrend->second.GetHGScale();            
0998 //         else if (optionTrend == 3)  tempGraph = ithTrend->second.GetLGScale();
0999 //         else if (optionTrend == 4)  tempGraph = ithTrend->second.GetLGHGcorr();
1000 //         else if (optionTrend == 5)  tempGraph = ithTrend->second.GetHGLGcorr();
1001 //         else if (optionTrend == 6)  tempGraph = ithTrend->second.GetTrigger();
1002 //         else if (optionTrend == 7)  tempGraph = ithTrend->second.GetSBSignal();
1003 //         else if (optionTrend == 8)  tempGraph = ithTrend->second.GetSBNoise();
1004 //         else if (optionTrend == 9)  tempGraph = ithTrend->second.GetHGLMPV();
1005 //         else if (optionTrend == 10) tempGraph = ithTrend->second.GetLGLMPV();
1006 //         else if (optionTrend == 11) tempGraph = ithTrend->second.GetHGLSigma();
1007 //         else if (optionTrend == 12) tempGraph = ithTrend->second.GetLGLSigma();
1008 //         else if (optionTrend == 13) tempGraph = ithTrend->second.GetHGGSigma();
1009 //         else if (optionTrend == 14) tempGraph = ithTrend->second.GetLGGSigma();
1010 //         else if (optionTrend == 15) tempGraph = ithTrend->second.GetHGpedwidth();
1011 //         else if (optionTrend == 16) tempGraph = ithTrend->second.GetLGpedwidth();
1012 //         else if (optionTrend == 17) tempGraph = ithTrend->second.GetLGHGOff();
1013 //         else if (optionTrend == 18) tempGraph = ithTrend->second.GetHGLGOff();
1014 //         if (!tempGraph) continue;
1015 //         TH1D* dummyhist = new TH1D("dummyhist", "", 100, xPMin, xPMax);
1016 //         SetStyleHistoTH1ForGraphs( dummyhist, tempGraph->GetXaxis()->GetTitle(), tempGraph->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.5, 510, 510, 43, 63);  
1017 //         // if (optionTrend == 6)std::cout << "\t" << tempGraph->GetXaxis()->GetTitle() << "\t" << tempGraph->GetYaxis()->GetTitle() << std::endl;
1018 //         SetMarkerDefaultsTGraphErr(tempGraph, 20, 1, kBlue+1, kBlue+1);   
1019 //         dummyhist->GetYaxis()->SetRangeUser(minY,maxY);
1020 //         dummyhist->Draw("axis");
1021 //         tempGraph->Draw("pe, same");
1022 //                 
1023 //         DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p], label, true, 0.85*textSizePixel, 43);
1024 //         if (isSameVoltage && p == 7){
1025 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p]-1*0.85*relSizeP[p], label2, true, 0.85*textSizePixel, 43);
1026 //         }
1027 //         if (p ==4 ){
1028 //           TString lab1 = Form("#it{#bf{LFHCal TB:}} %s", GetStringFromRunInfo(currRunInfo, 9).Data());
1029 //           TString lab2 = GetStringFromRunInfo(currRunInfo, 8);
1030 //           TString lab3 = GetStringFromRunInfo(currRunInfo, 10);
1031 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p]-1*0.85*relSizeP[p], lab1, true, 0.85*textSizePixel, 43);
1032 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p]-2*0.85*relSizeP[p], lab2, true, 0.85*textSizePixel, 43);
1033 //           DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeP[p]-3*0.85*relSizeP[p], lab3, true, 0.85*textSizePixel, 43);
1034 //         }
1035 //       }
1036 //     }
1037 //     if (skipped < 8){
1038 //       if(detailedPlot) canvas2Panel->SaveAs(nameOutput.Data());
1039 //       if (layer == 0) canvas2Panel->Print(Form("%s.pdf[",nameOutputSummary.Data()));
1040 //       canvas2Panel->Print(Form("%s.pdf",nameOutputSummary.Data()));
1041 //       if (layer == setupT->GetNMaxLayer()) canvas2Panel->Print(Form("%s.pdf]",nameOutputSummary.Data()));
1042 //     }
1043 //   }
1044 //   
1045 //   //__________________________________________________________________________________________________________
1046 //   // Plot Run overlay for all 8 tiles for all runs available
1047 //   //__________________________________________________________________________________________________________
1048   void PlotRunOverlay2MLayer (TCanvas* canvas2Panel, TPad* pads[2], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
1049                               std::map<int,TileTrend> trending, int nruns, int optionTrend, 
1050                               Double_t xPMin, Double_t xPMax, int layer, int mod,  TString nameOutput, TString nameOutputSummary, RunInfo currRunInfo, Int_t detailedPlot = 1){
1051                                   
1052     Setup* setupT = Setup::GetInstance();
1053     
1054     std::map<int, TileTrend>::iterator ithTrend;    
1055     int nCol = setupT->GetNMaxColumn()+1;
1056     int skipped = 0;
1057     
1058     Double_t maxY         = 0.;
1059     Double_t minY         = 9999.;
1060     bool isSameVoltage    = true;
1061     double commanVoltage  = 0;
1062     for (int c = 0; c < nCol; c++){
1063       int tempCellID = setupT->GetCellID(0,c, layer, mod);
1064       ithTrend=trending.find(tempCellID);
1065       if (optionTrend == 0){      // HG
1066         if(maxY<ithTrend->second.GetMaxHGSpec()) maxY=ithTrend->second.GetMaxHGSpec();
1067         if(minY>ithTrend->second.GetMinHGSpec()) minY=ithTrend->second.GetMinHGSpec();
1068       } else if (optionTrend == 1){   //LG
1069         if(maxY<ithTrend->second.GetMaxLGSpec()) maxY=ithTrend->second.GetMaxLGSpec();
1070         if(minY>ithTrend->second.GetMinLGSpec()) minY=ithTrend->second.GetMinLGSpec();
1071       } 
1072       
1073       for (int rc = 0; rc < ithTrend->second.GetNRuns() && rc < 30; rc++ ){
1074         if (c == 0){
1075           if (rc == 0){
1076             commanVoltage = ithTrend->second.GetVoltage(rc);
1077           } else {
1078             if (commanVoltage != ithTrend->second.GetVoltage(rc))  isSameVoltage = false;
1079           }
1080         }
1081       }
1082     }
1083     if (maxY == 0 && minY == 9999.){
1084       std::cout <<"Something went wrong! No ranges set for layer " <<  layer << " \t trend plotting option: " << optionTrend << "\t ABORTING!" << std::endl;
1085       return;
1086     }
1087     maxY = 3*maxY;
1088     TH1D* histos[30];
1089 
1090     double lineBottom  = (1.4+6);
1091     if (nruns < 6) lineBottom = (1.4+1);
1092     else if (nruns < 11) lineBottom = (1.4+2);
1093     else if (nruns < 16) lineBottom = (1.4+3);
1094     else if (nruns < 21) lineBottom = (1.4+4);
1095     else if (nruns < 26) lineBottom = (1.4+5);
1096     TLegend* legend = nullptr;
1097   
1098     for (int c = 0; c < nCol; c++){
1099       canvas2Panel->cd();
1100       int tempCellID = setupT->GetCellID(0,c, layer, mod);
1101       pads[c]->Draw();
1102       pads[c]->cd();
1103       pads[c]->SetLogy(1);
1104       ithTrend=trending.find(tempCellID);
1105 
1106       TString label           = Form("col %d", c);
1107       TString label2          = Form("Common V_{op} = %2.1f V", commanVoltage);
1108       if ( c == 1 ){
1109         label = Form("col %d layer %d", c, layer);
1110       }
1111       if(ithTrend==trending.end()){
1112         skipped++;
1113         std::cout << "WARNING: skipping cell ID: " << tempCellID << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
1114         pads[c]->Clear();
1115         pads[c]->Draw();
1116         if (c == 0 ){
1117           TString lab1 = Form("#it{#bf{LFHCal TB:}} %s", GetStringFromRunInfo(currRunInfo, 9).Data());
1118           TString lab2 = GetStringFromRunInfo(currRunInfo, 8);
1119           TString lab3 = GetStringFromRunInfo(currRunInfo, 10);
1120           DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c]-1*0.85*relSizeP[c], lab1, true, 0.85*textSizePixel, 43);
1121           DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c]-2*0.85*relSizeP[c], lab2, true, 0.85*textSizePixel, 43);
1122           DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c]-3*0.85*relSizeP[c], lab3, true, 0.85*textSizePixel, 43);
1123         }
1124         
1125         DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c], label, true, 0.85*textSizePixel, 43);
1126         continue;
1127       } 
1128 
1129       if ( c == 1 ){
1130         double startLegY  = topRCornerY[c]-lineBottom*relSizeP[c];
1131         double endLegY    = topRCornerY[c]-1.4*relSizeP[c];
1132         legend = GetAndSetLegend2(  0.3, startLegY, topRCornerX[c]-0.045/2, endLegY,
1133                                     0.85*textSizePixel, 5, "",43,0.25);
1134       }
1135       
1136       for (int rc = 0; rc < ithTrend->second.GetNRuns() && rc < 30; rc++ ){
1137         int tmpRunNr = ithTrend->second.GetRunNr(rc);
1138         histos[rc] = nullptr;
1139         if (tmpRunNr != -1) {
1140           if (optionTrend == 0){      // HG
1141             histos[rc] = ithTrend->second.GetHGTriggRun(ithTrend->second.GetRunNr(rc));
1142           } else if (optionTrend == 1){      // LG
1143             histos[rc] = ithTrend->second.GetLGTriggRun(ithTrend->second.GetRunNr(rc));
1144           }
1145         }
1146         if (histos[rc]){
1147           SetStyleHistoTH1ForGraphs( histos[rc], histos[rc]->GetXaxis()->GetTitle(), histos[rc]->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.95, 1.3,  510, 510, 43, 63);  
1148           SetLineDefaults(histos[rc], GetColorLayer(rc), 2, GetLineStyleLayer(rc));   
1149           if(rc == 0){
1150             histos[rc]->GetXaxis()->SetRangeUser(xPMin,xPMax);
1151             histos[rc]->GetYaxis()->SetRangeUser(minY,maxY);
1152             histos[rc]->Draw("hist");
1153           } else {
1154             histos[rc]->Draw("same,hist");
1155           }
1156           if(c == 1) legend->AddEntry(histos[rc],Form("%d",tmpRunNr),"l");
1157         }
1158       }
1159       if (histos[0]) histos[0]->Draw("axis,same");                
1160       
1161       // labeling inside the panels & legend drawing 
1162       DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c], label, true, 0.85*textSizePixel, 43);
1163       if (isSameVoltage && c == 1){
1164         DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-(lineBottom+0.5)*relSizeP[c], label2, true, 0.85*textSizePixel, 43);
1165       }
1166       
1167       if (c == 1) legend->Draw();
1168       if (c == 0 ){
1169         TString lab1 = Form("#it{#bf{LFHCal TB:}} %s", GetStringFromRunInfo(currRunInfo, 9).Data());
1170         TString lab2 = GetStringFromRunInfo(currRunInfo, 8);
1171         TString lab3 = GetStringFromRunInfo(currRunInfo, 10);
1172         DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c]-1*0.85*relSizeP[c], lab1, true, 0.85*textSizePixel, 43);
1173         DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c]-2*0.85*relSizeP[c], lab2, true, 0.85*textSizePixel, 43);
1174         DrawLatex(topRCornerX[c]-0.045, topRCornerY[c]-1.2*relSizeP[c]-3*0.85*relSizeP[c], lab3, true, 0.85*textSizePixel, 43);
1175       }
1176     }
1177     if (skipped < 2){
1178       if(detailedPlot) canvas2Panel->SaveAs(nameOutput.Data());
1179       if (layer == 0) canvas2Panel->Print(Form("%s.pdf[",nameOutputSummary.Data()));
1180       canvas2Panel->Print(Form("%s.pdf",nameOutputSummary.Data()));
1181       if (layer == setupT->GetNMaxLayer()) canvas2Panel->Print(Form("%s.pdf]",nameOutputSummary.Data()));
1182     }
1183   }
1184 
1185   //__________________________________________________________________________________________________________
1186   // Plot Run overlay for all 8 tiles for all runs available
1187   //__________________________________________________________________________________________________________
1188   void PlotRunOverlayProfile2MLayer (TCanvas* canvas2Panel, TPad* pads[2], Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSizeP, Int_t textSizePixel, 
1189                                       std::map<int,TileTrend> trending, int nruns,
1190                                       Double_t xPMin, Double_t xPMax, Double_t yPMin, Double_t yPMax,  int layer, int mod,  TString nameOutput, TString nameOutputSummary, RunInfo currRunInfo, Int_t detailedPlot = 1){
1191                                   
1192     Setup* setupT = Setup::GetInstance();
1193     
1194     std::map<int, TileTrend>::iterator ithTrend;    
1195     int nRow = setupT->GetNMaxRow()+1;
1196     int nCol = setupT->GetNMaxColumn()+1;
1197     int skipped = 0;
1198     
1199     bool isSameVoltage    = true;
1200     double commanVoltage  = 0;
1201     for (int c = 0; c < nCol; c++){
1202       int tempCellID = setupT->GetCellID(0,c, layer, mod);
1203       ithTrend=trending.find(tempCellID);
1204       for (int rc = 0; rc < ithTrend->second.GetNRuns() && rc < 30; rc++ ){
1205         if (c == 0){
1206           if (rc == 0){
1207             commanVoltage = ithTrend->second.GetVoltage(rc);
1208           } else {
1209             if (commanVoltage != ithTrend->second.GetVoltage(rc))  isSameVoltage = false;
1210           }
1211         }
1212       }
1213     }
1214     TProfile* profs[30];
1215 
1216     double lineBottom  = (1.4+6);
1217     if (nruns < 6) lineBottom = (1.4+1);
1218     else if (nruns < 11) lineBottom = (1.4+2);
1219     else if (nruns < 16) lineBottom = (1.4+3);
1220     else if (nruns < 21) lineBottom = (1.4+4);
1221     else if (nruns < 26) lineBottom = (1.4+5);
1222     TLegend* legend = nullptr;
1223     
1224     for (int c = 0; c < nCol; c++){
1225       canvas2Panel->cd();
1226       int tempCellID = setupT->GetCellID(0,c, layer, mod);
1227       pads[c]->Draw();
1228       pads[c]->cd();
1229       pads[c]->SetLogy(0);
1230       ithTrend=trending.find(tempCellID);
1231 
1232       TString label           = Form("col %d", c);
1233       TString label2          = Form("Common V_{op} = %2.1f V", commanVoltage);
1234       if (c == 1){
1235         label = Form(" col %d layer %d", c, layer);
1236       }
1237       
1238       // Double_t yPosStart = topRCornerY[c]-1.2*relSizeP[c];
1239       Double_t yPosStart = topRCornerY[c];
1240       if(ithTrend==trending.end()){
1241         skipped++;
1242         std::cout << "WARNING: skipping cell ID: " << tempCellID  << "\t column " << c << "\t layer " << layer << "\t module " << mod << std::endl;
1243         pads[c]->Clear();
1244         pads[c]->Draw();
1245         if (c == 0 ){
1246           TString lab1 = Form("#it{#bf{LFHCal TB:}} %s", GetStringFromRunInfo(currRunInfo, 9).Data());
1247           TString lab2 = GetStringFromRunInfo(currRunInfo, 8);
1248           TString lab3 = GetStringFromRunInfo(currRunInfo, 10);
1249           DrawLatex(topRCornerX[c]+0.045, yPosStart-1*0.85*relSizeP[c], lab1, false, 0.85*textSizePixel, 43);
1250           DrawLatex(topRCornerX[c]+0.045, yPosStart-2*0.85*relSizeP[c], lab2, false, 0.85*textSizePixel, 43);
1251           DrawLatex(topRCornerX[c]+0.045, yPosStart-3*0.85*relSizeP[c], lab3, false, 0.85*textSizePixel, 43);
1252         }
1253         
1254         DrawLatex(topRCornerX[c]+0.045, yPosStart, label, false, 0.85*textSizePixel, 43);
1255         continue;
1256       } 
1257 
1258       if (c == 1 ){
1259         double startLegY  = yPosStart+1.2*relSizeP[c] -lineBottom*relSizeP[c];
1260         double endLegY    = yPosStart+1.2*relSizeP[c] -1.4*relSizeP[c];
1261         legend = GetAndSetLegend2(  topRCornerX[c]+0.045/2, startLegY, 0.7, endLegY,
1262                                     0.85*textSizePixel, 5, "",43,0.25);
1263       }
1264       
1265       TH1D* dummyhist;
1266       for (int rc = 0; rc < ithTrend->second.GetNRuns() && rc < 30; rc++ ){
1267         int tmpRunNr = ithTrend->second.GetRunNr(rc);
1268         profs[rc] = nullptr;
1269         if (tmpRunNr != -1) {
1270           profs[rc] = ithTrend->second.GetLGHGTriggRun(ithTrend->second.GetRunNr(rc));
1271           std::cout << profs[rc] << std::endl;
1272         }
1273         if (profs[rc]){
1274           if (rc == 0){
1275             dummyhist = new TH1D("dummyhist", "", profs[rc]->GetNbinsX(), profs[rc]->GetXaxis()->GetXmin(), profs[rc]->GetXaxis()->GetXmax());
1276             SetStyleHistoTH1ForGraphs( dummyhist, profs[rc]->GetXaxis()->GetTitle(), profs[rc]->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.5, 510, 510, 43, 63);  
1277             dummyhist->GetXaxis()->SetRangeUser(xPMin,xPMax);
1278             dummyhist->GetYaxis()->SetRangeUser(yPMin,yPMax);
1279             dummyhist->Draw("axis");
1280           }
1281 
1282           SetLineDefaults(profs[rc], GetColorLayer(rc), 2, GetLineStyleLayer(rc));   
1283           profs[rc]->SetMarkerStyle(24);
1284           profs[rc]->Draw("same,pe");
1285           if(c == 1) legend->AddEntry(profs[rc],Form("%d",tmpRunNr),"p");
1286         }
1287       }
1288       if (dummyhist) dummyhist->Draw("axis,same");                
1289       
1290       // labeling inside the panels & legend drawing 
1291       DrawLatex(topRCornerX[c]+0.045, yPosStart, label, false, 0.85*textSizePixel, 43);
1292       if (isSameVoltage && c == 1){
1293         DrawLatex(topRCornerX[c]+0.045, yPosStart+1.2*relSizeP[c]-(lineBottom+0.5)*relSizeP[c], label2, false, 0.85*textSizePixel, 43);
1294       }
1295       
1296       if (c == 1 ) legend->Draw();
1297       if (c == 0 ){
1298         TString lab1 = Form("#it{#bf{LFHCal TB:}} %s", GetStringFromRunInfo(currRunInfo, 9).Data());
1299         TString lab2 = GetStringFromRunInfo(currRunInfo, 8);
1300         TString lab3 = GetStringFromRunInfo(currRunInfo, 10);
1301         DrawLatex(topRCornerX[c]+0.045, yPosStart-1*0.85*relSizeP[c], lab1, false, 0.85*textSizePixel, 43);
1302         DrawLatex(topRCornerX[c]+0.045, yPosStart-2*0.85*relSizeP[c], lab2, false, 0.85*textSizePixel, 43);
1303         DrawLatex(topRCornerX[c]+0.045, yPosStart-3*0.85*relSizeP[c], lab3, false, 0.85*textSizePixel, 43);
1304       }
1305     }
1306     
1307     if (skipped < 2){
1308       if(detailedPlot) canvas2Panel->SaveAs(nameOutput.Data());
1309       if (layer == 0) canvas2Panel->Print(Form("%s.pdf[",nameOutputSummary.Data()));
1310       canvas2Panel->Print(Form("%s.pdf",nameOutputSummary.Data()));
1311       if (layer == setupT->GetNMaxLayer()) canvas2Panel->Print(Form("%s.pdf]",nameOutputSummary.Data()));
1312     }
1313   }
1314   
1315 #endif
1316