Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:28:21

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