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