File indexing completed on 2026-11-20 09:33:52
0001 #ifndef PLOTHELPER_FOCALFEB_H
0002 #define PLOTHELPER_FOCALFEB_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 inline void PlotTriggerPrimFoCalFEB (TCanvas* canvasFEB, TPad** pads,
0024 Double_t* topRCornerX, Double_t* topRCornerY,
0025 Double_t* relSizeFEB, Int_t textSizePixel,
0026 std::map<int,TileSpectra> spectra,
0027 double avMip, double facLow, double facHigh,
0028 Double_t xPMin, Double_t xPMax, Double_t scaleYMax,
0029 int mod, TString nameOutput, RunInfo currRunInfo){
0030
0031 Setup* setupT = Setup::GetInstance();
0032 Double_t maxY = 0;
0033 std::map<int, TileSpectra>::iterator ithSpectra;
0034 int nRow = 4;
0035 int nCol = 8;
0036 int skipped = 0;
0037 bool found = false;
0038 TH1D* dummyHist = nullptr;
0039
0040 for (int r = 0; r < nRow; ++r){
0041 for (int c = 0; c < nCol; ++c){
0042 int row = 3 - r;
0043 int tempCellID = setupT->GetCellID(row, c, 0, mod);
0044 ithSpectra = spectra.find(tempCellID);
0045 if (ithSpectra == spectra.end()) continue;
0046 TH1D* tempHist = ithSpectra->second.GetTriggPrim();
0047 if (tempHist && maxY < FindLargestBin1DHist(tempHist, xPMin, xPMax))
0048 maxY = FindLargestBin1DHist(tempHist, xPMin, xPMax);
0049 if (!found && tempHist){
0050 dummyHist = new TH1D("dummyTempFoCalFEB", "", tempHist->GetNbinsX(),
0051 tempHist->GetBinCenter(1)-tempHist->GetBinWidth(1),
0052 tempHist->GetBinCenter(tempHist->GetNbinsX())+tempHist->GetBinWidth(tempHist->GetNbinsX()));
0053 SetStyleHistoTH1ForGraphs(dummyHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(),
0054 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0055 0.9, 1.1, 510, 510, 43, 63);
0056 dummyHist->SetBinContent(dummyHist->FindBin(0), 0.5);
0057 dummyHist->SetDirectory(0);
0058 found = true;
0059 }
0060 }
0061 }
0062
0063 for (int r = 0; r < nRow; ++r){
0064 for (int c = 0; c < nCol; ++c){
0065 canvasFEB->cd();
0066 int row = 3 - r;
0067 int tempCellID = setupT->GetCellID(row, c, 0, mod);
0068 int p = setupT->GetChannelInLayer(tempCellID);
0069 pads[p]->Draw();
0070 pads[p]->cd();
0071 pads[p]->SetLogy();
0072 ithSpectra = spectra.find(tempCellID);
0073
0074 TString label = Form("row %d col %d", row, c);
0075 TLatex *labelChannel = new TLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeFEB[p], label);
0076 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0077
0078 if (ithSpectra == spectra.end()){
0079 skipped++;
0080 pads[p]->Clear();
0081 pads[p]->Draw();
0082 if (dummyHist){
0083 TH1D* dummyHist2 = (TH1D*)dummyHist->Clone("dummyTemp2FoCalFEB");
0084 dummyHist2->GetYaxis()->SetRangeUser(0.7, scaleYMax*maxY);
0085 dummyHist2->GetXaxis()->SetRangeUser(xPMin, xPMax);
0086 SetStyleHistoTH1ForGraphs(dummyHist2, dummyHist2->GetXaxis()->GetTitle(), dummyHist2->GetYaxis()->GetTitle(),
0087 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0088 0.9, 1.1, 510, 510, 43, 63);
0089 dummyHist2->Draw("");
0090 }
0091 labelChannel->Draw();
0092 if (p == 31){
0093 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-2.*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0094 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-3.*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0095 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4.*relSizeFEB[p], "Trigger primitives", true, 0.85*relSizeFEB[p], 42);
0096 }
0097 continue;
0098 }
0099
0100 TH1D* tempHist = ithSpectra->second.GetTriggPrim();
0101 SetStyleHistoTH1ForGraphs(tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(),
0102 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0103 0.9, 1.1, 510, 510, 43, 63);
0104 SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);
0105 tempHist->GetXaxis()->SetRangeUser(xPMin, xPMax);
0106 tempHist->GetYaxis()->SetRangeUser(0.7, scaleYMax*maxY);
0107
0108 tempHist->Draw("pe");
0109 DrawCorrectBadChannelBox(ithSpectra->second.GetCalib()->BadChannel, xPMin, 0, xPMax, maxY);
0110 tempHist->Draw("same,axis");
0111 tempHist->Draw("same,pe");
0112
0113 labelChannel->Draw();
0114
0115 TBox* triggArea = CreateBox(kBlue-8, avMip*facLow, 0.7, avMip*facHigh, scaleYMax*maxY, 1001);
0116 triggArea->Draw();
0117 DrawLines(avMip*facLow, avMip*facLow, 0.7, scaleYMax*maxY, 1, 1, 7);
0118 DrawLines(avMip*facHigh, avMip*facHigh, 0.7, scaleYMax*maxY, 1, 1, 7);
0119 tempHist->Draw("same,axis");
0120 tempHist->Draw("same,pe");
0121
0122 if (p == 31){
0123 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-2.*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0124 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-3.*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0125 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-4.*relSizeFEB[p], "Trigger primitives", true, 0.85*relSizeFEB[p], 42);
0126 }
0127 }
0128 }
0129
0130 if (skipped < 8)
0131 canvasFEB->SaveAs(nameOutput.Data());
0132 }
0133
0134
0135
0136
0137 inline void PlotNoiseWithFitsFoCalFEB (TCanvas* canvasFEB, TPad** pads,
0138 Double_t* topRCornerX, Double_t* topRCornerY, Double_t* relSizeFEB,
0139 Int_t textSizePixel, std::map<int,TileSpectra> spectra, int option,
0140 Double_t xPMin, Double_t xPMax, Double_t scaleYMax,
0141 int mod, TString nameOutput, RunInfo currRunInfo){
0142
0143 Double_t maxY = 0;
0144 std::map<int, TileSpectra>::iterator ithSpectra;
0145 Setup* setupT = Setup::GetInstance();
0146
0147 int nRow = 4;
0148 int nCol = 8;
0149 int skipped = 0;
0150 for (int r = 0; r < nRow; ++r){
0151 for (int c = 0; c < nCol; ++c){
0152 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0153 ithSpectra = spectra.find(tempCellID);
0154 if (ithSpectra == spectra.end()){
0155 skipped++;
0156 continue;
0157 }
0158 TH1D* tempHist = nullptr;
0159 if (option == 0) tempHist = ithSpectra->second.GetHG();
0160 else if (option == 1) tempHist = ithSpectra->second.GetLG();
0161 else if (option == 2) tempHist = ithSpectra->second.GetTOA();
0162 else if (option == 3) tempHist = ithSpectra->second.GetTOT();
0163 if (tempHist && maxY < FindLargestBin1DHist(tempHist, xPMin, xPMax))
0164 maxY = FindLargestBin1DHist(tempHist, xPMin, xPMax);
0165 }
0166 }
0167
0168 for (int r = 0; r < nRow; ++r){
0169 for (int c = 0; c < nCol; ++c){
0170 canvasFEB->cd();
0171 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0172 int p = setupT->GetChannelInLayer(tempCellID);
0173 pads[p]->Draw();
0174 pads[p]->cd();
0175 pads[p]->SetLogy();
0176 ithSpectra = spectra.find(tempCellID);
0177 if (ithSpectra == spectra.end()){
0178 pads[p]->Clear();
0179 pads[p]->Draw();
0180 if (p == 31){
0181 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-4*0.85*relSizeFEB[p]-1.4*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0182 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-4*0.85*relSizeFEB[p]-2.2*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0183 }
0184 continue;
0185 }
0186
0187 TH1D* tempHist = nullptr;
0188 if (option == 0) tempHist = ithSpectra->second.GetHG();
0189 else if (option == 1) tempHist = ithSpectra->second.GetLG();
0190 else if (option == 2) tempHist = ithSpectra->second.GetTOA();
0191 else if (option == 3) tempHist = ithSpectra->second.GetTOT();
0192
0193 SetStyleHistoTH1ForGraphs(tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(),
0194 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0195 0.9, 1.1, 510, 510, 43, 63);
0196 SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);
0197 tempHist->GetXaxis()->SetRangeUser(xPMin, xPMax);
0198 tempHist->GetYaxis()->SetRangeUser(0.7, scaleYMax*maxY);
0199
0200 tempHist->Draw("pe");
0201 short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0202 if (bctemp != -64 && bctemp < 3){
0203 Color_t boxCol = kGray;
0204 if (bctemp == 1) boxCol = kGray+1;
0205 else if (bctemp == 0) boxCol = kGray+2;
0206 TBox* badChannelArea = CreateBox(boxCol, xPMin, 0.7, xPMax, scaleYMax*maxY, 1001);
0207 badChannelArea->SetFillColorAlpha(boxCol, 0.35);
0208 badChannelArea->Draw();
0209 tempHist->Draw("same,axis");
0210 tempHist->Draw("same,pe");
0211 }
0212
0213 TString label = Form("row %d col %d", r, c);
0214 TLatex *labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
0215 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0216
0217 TF1* fit = nullptr;
0218 if (option == 0) fit = ithSpectra->second.GetBackModel(1);
0219 else if (option == 1) fit = ithSpectra->second.GetBackModel(0);
0220 if (fit){
0221 SetStyleFit(fit, xPMin, xPMax, 7, 7, kBlack);
0222 fit->Draw("same");
0223 TLegend* legend = GetAndSetLegend2(topRCornerX[p]-8*relSizeFEB[p], topRCornerY[p]-4*0.85*relSizeFEB[p]-0.4*relSizeFEB[p],
0224 topRCornerX[p]-0.04, topRCornerY[p]-0.6*relSizeFEB[p], 0.85*textSizePixel, 1, label, 43, 0.2);
0225 legend->AddEntry(fit, "Gauss noise fit", "l");
0226 legend->AddEntry((TObject*)0, Form("#mu = %2.2f #pm %2.2f", fit->GetParameter(1), fit->GetParError(1)), " ");
0227 legend->AddEntry((TObject*)0, Form("#sigma = %2.2f #pm %2.2f", fit->GetParameter(2), fit->GetParError(2)), " ");
0228 legend->Draw();
0229 } else {
0230 labelChannel->Draw();
0231 }
0232
0233 if (xPMin < -5) DrawLines(0, 0, 0.7, scaleYMax*maxY, 2, kGray+1, 10);
0234 if (p == 31){
0235 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-4*0.85*relSizeFEB[p]-1.4*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0236 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-4*0.85*relSizeFEB[p]-2.2*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0237 }
0238 }
0239 }
0240
0241 if (skipped < 32)
0242 canvasFEB->SaveAs(nameOutput.Data());
0243 }
0244
0245
0246
0247
0248 inline void PlotSpectraFoCalFEB (TCanvas* canvasFEB, TPad** pads,
0249 Double_t* topRCornerX, Double_t* topRCornerY, Double_t* relSizeFEB,
0250 Int_t textSizePixel, std::map<int,TileSpectra> spectra, int option,
0251 Double_t xPMin, Double_t xPMax, Double_t scaleYMax,
0252 int mod, TString nameOutput, RunInfo currRunInfo){
0253
0254 Setup* setupT = Setup::GetInstance();
0255 Double_t maxY = 0;
0256 std::map<int, TileSpectra>::iterator ithSpectra;
0257 int nRow = 4;
0258 int nCol = 8;
0259 int skipped = 0;
0260
0261 for (int r = 0; r < nRow; ++r){
0262 for (int c = 0; c < nCol; ++c){
0263 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0264 ithSpectra = spectra.find(tempCellID);
0265 if (ithSpectra == spectra.end()) continue;
0266 TH1D* tempHist = nullptr;
0267 if (option == 0) tempHist = ithSpectra->second.GetHG();
0268 else if (option == 1) tempHist = ithSpectra->second.GetLG();
0269 else if (option == 2) tempHist = ithSpectra->second.GetComb();
0270 else if (option == 3) tempHist = ithSpectra->second.GetTOA();
0271 else if (option == 4) tempHist = ithSpectra->second.GetTOT();
0272 if (tempHist && maxY < FindLargestBin1DHist(tempHist, xPMin, xPMax))
0273 maxY = FindLargestBin1DHist(tempHist, xPMin, xPMax);
0274 }
0275 }
0276
0277 for (int r = 0; r < nRow; ++r){
0278 for (int c = 0; c < nCol; ++c){
0279 canvasFEB->cd();
0280 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0281 int p = setupT->GetChannelInLayer(tempCellID);
0282 pads[p]->Draw();
0283 pads[p]->cd();
0284 pads[p]->SetLogy();
0285 ithSpectra = spectra.find(tempCellID);
0286 if (ithSpectra == spectra.end()){
0287 skipped++;
0288 pads[p]->Clear();
0289 pads[p]->Draw();
0290 continue;
0291 }
0292
0293 TH1D* tempHist = nullptr;
0294 if (option == 0) tempHist = ithSpectra->second.GetHG();
0295 else if (option == 1) tempHist = ithSpectra->second.GetLG();
0296 else if (option == 2) tempHist = ithSpectra->second.GetComb();
0297 else if (option == 3) tempHist = ithSpectra->second.GetTOA();
0298 else if (option == 4) tempHist = ithSpectra->second.GetTOT();
0299
0300 SetStyleHistoTH1ForGraphs(tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(),
0301 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0302 0.9, 1.1, 510, 510, 43, 63);
0303 SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);
0304 tempHist->GetXaxis()->SetRangeUser(xPMin, xPMax);
0305 tempHist->GetYaxis()->SetRangeUser(0.7, scaleYMax*maxY);
0306
0307 tempHist->Draw("pe");
0308 short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0309 if (bctemp != -64 && bctemp < 3){
0310 Color_t boxCol = kGray;
0311 if (bctemp == 1) boxCol = kGray+1;
0312 else if (bctemp == 0) boxCol = kGray+2;
0313 TBox* badChannelArea = CreateBox(boxCol, xPMin, 0.7, xPMax, scaleYMax*maxY, 1001);
0314 badChannelArea->SetFillColorAlpha(boxCol, 0.35);
0315 badChannelArea->Draw();
0316 tempHist->Draw("same,axis");
0317 tempHist->Draw("same,pe");
0318 }
0319
0320 TString label = Form("row %d col %d", r, c);
0321 TLatex *labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
0322 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0323 labelChannel->Draw();
0324
0325 if (p == 31){
0326 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-2.4*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0327 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-3.6*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0328 }
0329 }
0330 }
0331
0332 if (skipped < 32)
0333 canvasFEB->SaveAs(nameOutput.Data());
0334 }
0335
0336
0337
0338
0339
0340
0341
0342
0343 inline void PlotNoiseAdvWithFitsFoCalFEB (TCanvas* canvasFEB, TPad** pads,
0344 Double_t* topRCornerX, Double_t* topRCornerY, Double_t* relSizeFEB,
0345 Int_t textSizePixel, std::map<int,TileSpectra> spectra,
0346 std::map<int,TileSpectra> spectraTrigg, bool opt,
0347 Double_t xPMin, Double_t xPMax, Double_t scaleYMax,
0348 int mod, TString nameOutput, RunInfo currRunInfo){
0349 Setup* setupT = Setup::GetInstance();
0350 Double_t maxY = 0;
0351 std::map<int, TileSpectra>::iterator ithSpectra;
0352 std::map<int, TileSpectra>::iterator ithSpectraTrigg;
0353 int nRow = 4;
0354 int nCol = 8;
0355 int skipped = 0;
0356
0357 for (int r = 0; r < nRow; ++r){
0358 for (int c = 0; c < nCol; ++c){
0359 int row = 3 - r;
0360 int tempCellID = setupT->GetCellID(row, c, 0, mod);
0361 ithSpectra = spectra.find(tempCellID);
0362 if (ithSpectra == spectra.end()) continue;
0363 TH1D* tempHist = (opt ? ithSpectra->second.GetHG() : ithSpectra->second.GetLG());
0364 if (tempHist && maxY < FindLargestBin1DHist(tempHist, xPMin, xPMax))
0365 maxY = FindLargestBin1DHist(tempHist, xPMin, xPMax);
0366 }
0367 }
0368
0369 for (int r = 0; r < nRow; ++r){
0370 for (int c = 0; c < nCol; ++c){
0371 canvasFEB->cd();
0372 int row = 3 - r;
0373 int tempCellID = setupT->GetCellID(row, c, 0, mod);
0374 int p = setupT->GetChannelInLayer(tempCellID);
0375 pads[p]->Draw();
0376 pads[p]->cd();
0377 pads[p]->SetLogy();
0378
0379 ithSpectra = spectra.find(tempCellID);
0380 if (ithSpectra == spectra.end()){
0381 skipped++;
0382 pads[p]->Clear();
0383 pads[p]->Draw();
0384 continue;
0385 }
0386
0387 ithSpectraTrigg = spectraTrigg.find(tempCellID);
0388 if (ithSpectraTrigg == spectraTrigg.end()){
0389 skipped++;
0390 pads[p]->Clear();
0391 pads[p]->Draw();
0392 continue;
0393 }
0394
0395 TH1D* tempHist = (opt ? ithSpectra->second.GetHG() : ithSpectra->second.GetLG());
0396 TH1D* tempHistT = (opt ? ithSpectraTrigg->second.GetHG() : ithSpectraTrigg->second.GetLG());
0397 if (!tempHist) continue;
0398
0399 SetStyleHistoTH1ForGraphs(tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(),
0400 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0401 0.9, 1.1, 510, 510, 43, 63);
0402 SetMarkerDefaults(tempHist, 20, 1, kBlue+1, kBlue+1, kFALSE);
0403 tempHist->GetXaxis()->SetRangeUser(xPMin, xPMax);
0404 tempHist->GetYaxis()->SetRangeUser(0.7, scaleYMax*maxY);
0405 tempHist->Draw("pe");
0406
0407 if (tempHistT){
0408 SetMarkerDefaults(tempHistT, 24, 1, kRed+1, kRed+1, kFALSE);
0409 tempHistT->Draw("same,pe");
0410 }
0411
0412 TString label = Form("row %d col %d", row, c);
0413 TLatex* labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
0414 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0415 labelChannel->Draw();
0416
0417 DrawLines(0, 0, 0.7, scaleYMax*maxY, 2, kGray+1, 10);
0418 if (p == 31){
0419 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-2.4*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0420 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-3.6*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0421 }
0422 }
0423 }
0424
0425 if (skipped < 32)
0426 canvasFEB->SaveAs(nameOutput.Data());
0427 }
0428
0429
0430
0431
0432 inline void Plot3SpectraOverlayFoCalFEB (TCanvas* canvasFEB, TPad** pads,
0433 Double_t* topRCornerX, Double_t* topRCornerY, Double_t* relSizeFEB,
0434 Int_t textSizePixel, std::map<int,TileSpectra> spectra,
0435 std::map<int,TileSpectra> spectraTrigg,
0436 std::map<int,TileSpectra> spectraNoise,
0437 bool opt, Double_t xPMin, Double_t xPMax, Double_t scaleYMax,
0438 int mod, TString nameOutput, RunInfo currRunInfo){
0439 Setup* setupT = Setup::GetInstance();
0440 Double_t maxY = 0;
0441 std::map<int, TileSpectra>::iterator ithSpectra;
0442 int nRow = 4;
0443 int nCol = 8;
0444 int skipped = 0;
0445
0446 for (int r = 0; r < nRow; ++r){
0447 for (int c = 0; c < nCol; ++c){
0448 int row = 3 - r;
0449 int tempCellID = setupT->GetCellID(row, c, 0, mod);
0450 ithSpectra = spectra.find(tempCellID);
0451 if (ithSpectra == spectra.end()) continue;
0452 TH1D* tempHist = (opt ? ithSpectra->second.GetHG() : ithSpectra->second.GetLG());
0453 if (tempHist && maxY < FindLargestBin1DHist(tempHist, xPMin, xPMax))
0454 maxY = FindLargestBin1DHist(tempHist, xPMin, xPMax);
0455 }
0456 }
0457
0458 for (int r = 0; r < nRow; ++r){
0459 for (int c = 0; c < nCol; ++c){
0460 canvasFEB->cd();
0461 int row = 3 - r;
0462 int tempCellID = setupT->GetCellID(row, c, 0, mod);
0463 int p = setupT->GetChannelInLayer(tempCellID);
0464 pads[p]->Draw();
0465 pads[p]->cd();
0466 pads[p]->SetLogy();
0467
0468 ithSpectra = spectra.find(tempCellID);
0469 if (ithSpectra == spectra.end()){
0470 skipped++;
0471 pads[p]->Clear();
0472 pads[p]->Draw();
0473 continue;
0474 }
0475
0476 TH1D* tempHist = (opt ? ithSpectra->second.GetHG() : ithSpectra->second.GetLG());
0477 if (!tempHist) continue;
0478
0479 SetStyleHistoTH1ForGraphs(tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(),
0480 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0481 0.9, 1.1, 510, 510, 43, 63);
0482 SetMarkerDefaults(tempHist, 24, 1, kGray+1, kGray+1, kFALSE);
0483 tempHist->GetXaxis()->SetRangeUser(xPMin, xPMax);
0484 tempHist->GetYaxis()->SetRangeUser(0.7, scaleYMax*maxY);
0485 tempHist->Draw("pe");
0486
0487 std::map<int, TileSpectra>::iterator ithTrigg = spectraTrigg.find(tempCellID);
0488 if (ithTrigg != spectraTrigg.end()){
0489 TH1D* histTrig = (opt ? ithTrigg->second.GetHG() : ithTrigg->second.GetLG());
0490 if (histTrig){
0491 SetMarkerDefaults(histTrig, 20, 1, kRed+1, kRed+1, kFALSE);
0492 histTrig->Draw("same,pe");
0493 }
0494 }
0495
0496 std::map<int, TileSpectra>::iterator ithNoise = spectraNoise.find(tempCellID);
0497 if (ithNoise != spectraNoise.end()){
0498 TH1D* histNoise = (opt ? ithNoise->second.GetHG() : ithNoise->second.GetLG());
0499 if (histNoise){
0500 SetMarkerDefaults(histNoise, 24, 1, kBlue+1, kBlue+1, kFALSE);
0501 histNoise->Draw("same,pe");
0502 }
0503 }
0504
0505 TString label = Form("row %d col %d", row, c);
0506 TLatex* labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
0507 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0508 labelChannel->Draw();
0509
0510 DrawLines(0, 0, 0.7, scaleYMax*maxY, 2, kGray+1, 10);
0511 if (p == 31){
0512 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-2.4*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0513 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-3.6*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0514 }
0515 }
0516 }
0517
0518 if (skipped < 32)
0519 canvasFEB->SaveAs(nameOutput.Data());
0520 }
0521
0522
0523
0524
0525 inline void PlotCorrWithFitsFoCalFEB (TCanvas* canvasFEB, TPad** pads, Double_t* topRCornerX, Double_t* topRCornerY,
0526 Double_t* relSizeFEB, Int_t textSizePixel, std::map<int,TileSpectra> spectra,
0527 int option, Double_t xPMin, Double_t xPMax, Double_t maxY,
0528 int mod, TString nameOutput, RunInfo currRunInfo){
0529 Setup* setupT = Setup::GetInstance();
0530 std::map<int, TileSpectra>::iterator ithSpectra;
0531 int nRow = 4;
0532 int nCol = 8;
0533 int skipped = 0;
0534
0535 for (int r = 0; r < nRow; ++r){
0536 for (int c = 0; c < nCol; ++c){
0537 canvasFEB->cd();
0538 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0539 int p = setupT->GetChannelInLayer(tempCellID);
0540 pads[p]->Draw();
0541 pads[p]->SetLogy(0);
0542 pads[p]->cd();
0543
0544 ithSpectra = spectra.find(tempCellID);
0545 if (ithSpectra == spectra.end()){
0546 skipped++;
0547 pads[p]->Clear();
0548 pads[p]->Draw();
0549 continue;
0550 }
0551
0552 TProfile* tempProfile = nullptr;
0553 if (option == 1 || option == 2)
0554 tempProfile = ithSpectra->second.GetHGLGcorr();
0555 else
0556 tempProfile = ithSpectra->second.GetLGHGcorr();
0557 if (!tempProfile) continue;
0558
0559 TH1D* dummyhist = new TH1D("dummyhistFoCalFEB", "", tempProfile->GetNbinsX(), tempProfile->GetXaxis()->GetXmin(), tempProfile->GetXaxis()->GetXmax());
0560 SetStyleHistoTH1ForGraphs(dummyhist, tempProfile->GetXaxis()->GetTitle(), tempProfile->GetYaxis()->GetTitle(),
0561 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0562 0.9, 1.5, 510, 510, 43, 63);
0563 Int_t maxX = 3900;
0564 if (option == 0 || option == 2) maxX = 340;
0565 dummyhist->GetYaxis()->SetRangeUser(0, maxY);
0566 dummyhist->GetXaxis()->SetRangeUser(0, maxX);
0567 dummyhist->Draw("axis");
0568 DrawCorrectBadChannelBox(ithSpectra->second.GetCalib()->BadChannel, xPMin, 0, xPMax, maxY);
0569 tempProfile->Draw("pe,same");
0570
0571 TString label = Form("row %d col %d", r, c);
0572 TLatex* labelChannel = new TLatex(topRCornerX[p]+0.045, topRCornerY[p]-1.2*relSizeFEB[p], label);
0573 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 11);
0574
0575 TF1* fit = nullptr;
0576 if (option == 1) fit = ithSpectra->second.GetCorrModel(1);
0577 else if (option == 0) fit = ithSpectra->second.GetCorrModel(0);
0578 if (fit){
0579 Double_t rangeFit[2] = {0, 0};
0580 fit->GetRange(rangeFit[0], rangeFit[1]);
0581 SetStyleFit(fit, rangeFit[0], rangeFit[1], 7, 3, kRed+3);
0582 fit->Draw("same");
0583 } else {
0584 labelChannel->Draw();
0585 }
0586
0587 if (p == 31){
0588 DrawLatex(topRCornerX[p]+0.045, topRCornerY[p]-2.4*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), false, 0.85*relSizeFEB[p], 42);
0589 DrawLatex(topRCornerX[p]+0.045, topRCornerY[p]-3.6*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), false, 0.85*relSizeFEB[p], 42);
0590 }
0591 }
0592 }
0593
0594 if (skipped < 32)
0595 canvasFEB->SaveAs(nameOutput.Data());
0596 }
0597
0598
0599
0600
0601 inline void PlotCorr2DFoCalFEB (TCanvas* canvasFEB, TPad** pads, Double_t* topRCornerX, Double_t* topRCornerY,
0602 Double_t* relSizeFEB, Int_t textSizePixel, std::map<int,TileSpectra> spectra,
0603 int option, Double_t xPMin, Double_t xPMax, Double_t minY, Double_t maxY,
0604 int mod, TString nameOutput, RunInfo currRunInfo, bool noCalib = 0, int triggCh = -1){
0605 Setup* setupT = Setup::GetInstance();
0606 std::map<int, TileSpectra>::iterator ithSpectra;
0607 int nRow = 4;
0608 int nCol = 8;
0609 int skipped = 0;
0610
0611 for (int r = 0; r < nRow; ++r){
0612 for (int c = 0; c < nCol; ++c){
0613 canvasFEB->cd();
0614 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0615 int p = setupT->GetChannelInLayer(tempCellID);
0616 pads[p]->Draw();
0617 pads[p]->SetLogy(0);
0618 pads[p]->SetLogz(1);
0619 pads[p]->cd();
0620
0621 ithSpectra = spectra.find(tempCellID);
0622 if (ithSpectra == spectra.end()){
0623 skipped++;
0624 pads[p]->Clear();
0625 pads[p]->Draw();
0626 continue;
0627 }
0628
0629 TH2D* temp2D = nullptr;
0630 TProfile* tempProfile = nullptr;
0631 if (option == 0){
0632 tempProfile = ithSpectra->second.GetLGHGcorr();
0633 temp2D = ithSpectra->second.GetCorr();
0634 } else if (option == 1){
0635 temp2D = ithSpectra->second.GetCorr();
0636 } else if (option == 2){
0637 tempProfile = ithSpectra->second.GetTOAADC();
0638 temp2D = ithSpectra->second.GetCorrTOAADC();
0639 }
0640
0641 if (temp2D){
0642 SetStyleHistoTH2ForGraphs(temp2D, temp2D->GetXaxis()->GetTitle(), temp2D->GetYaxis()->GetTitle(),
0643 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0644 0.9, 1.5, 510, 510, 43, 63);
0645 temp2D->GetYaxis()->SetRangeUser(minY, maxY);
0646 temp2D->GetXaxis()->SetRangeUser(xPMin, xPMax);
0647 temp2D->Draw("col");
0648 } else if (tempProfile){
0649 TH1D* dummyhist = new TH1D("dummyhistFoCalFEB2D", "", tempProfile->GetNbinsX(), tempProfile->GetXaxis()->GetXmin(), tempProfile->GetXaxis()->GetXmax());
0650 SetStyleHistoTH1ForGraphs(dummyhist, tempProfile->GetXaxis()->GetTitle(), tempProfile->GetYaxis()->GetTitle(),
0651 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,
0652 0.9, 1.5, 510, 510, 43, 63);
0653 dummyhist->GetXaxis()->SetRangeUser(xPMin, xPMax);
0654 dummyhist->GetYaxis()->SetRangeUser(minY, maxY);
0655 dummyhist->Draw("axis");
0656 }
0657
0658 if (tempProfile)
0659 tempProfile->Draw("pe,same");
0660
0661 TString label = Form("row %d col %d", r, c);
0662 TLatex* labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
0663 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0664 labelChannel->Draw();
0665
0666 if (p == 31){
0667 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-2.4*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSizeFEB[p], 42);
0668 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-3.6*relSizeFEB[p], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSizeFEB[p], 42);
0669 }
0670 }
0671 }
0672
0673 if (skipped < 32)
0674 canvasFEB->SaveAs(nameOutput.Data());
0675 }
0676
0677
0678
0679
0680 inline void PlotTrendingFoCalFEB (TCanvas* canvasFEB, TPad** pads, Double_t* topRCornerX, Double_t* topRCornerY,
0681 Double_t* relSizeFEB, Int_t textSizePixel, std::map<int,TileTrend> trending,
0682 int optionTrend, Double_t xPMin, Double_t xPMax, Double_t minY, Double_t maxY,
0683 int isSameVoltage, double commonVoltage, int mod, TString nameOutput,
0684 TString nameOutputSummary, RunInfo currRunInfo, Int_t detailedPlot = 1){
0685 Setup* setupT = Setup::GetInstance();
0686 std::map<int, TileTrend>::iterator ithTrend;
0687 int nRow = 4;
0688 int nCol = 8;
0689 int skipped = 0;
0690
0691 ithTrend=trending.begin();
0692
0693 TGraphErrors* tempGraph3= nullptr;
0694 TGraphErrors* tempGraph32= nullptr;
0695 if (optionTrend != 19 && optionTrend != 20 && optionTrend != 50 ){
0696 tempGraph3 = ithTrend->second.GetTrendingBasedOnOption(optionTrend);
0697 } else if (optionTrend == 19){
0698 tempGraph3 = ithTrend->second.GetTrendingBasedOnOption(0);
0699 tempGraph32 = ithTrend->second.GetTrendingBasedOnOption(1);
0700 } else if (optionTrend == 20){
0701 tempGraph3 = ithTrend->second.GetTrendingBasedOnOption(15);
0702 tempGraph32 = ithTrend->second.GetTrendingBasedOnOption(16);
0703 } else if (optionTrend == 50){
0704 tempGraph3 = ithTrend->second.GetTrendingBasedOnOption(30);
0705 tempGraph32 = ithTrend->second.GetTrendingBasedOnOption(32);
0706 }
0707 if (!tempGraph3){
0708 std::cout << "No graphs for this option available: "<< optionTrend << std::endl;
0709 return;
0710 }
0711 TString yAxisT = tempGraph3->GetYaxis()->GetTitle();
0712 if (tempGraph32){
0713 yAxisT.ReplaceAll("(arb. units)","");
0714 yAxisT = yAxisT+", "+tempGraph32->GetYaxis()->GetTitle();
0715 }
0716
0717
0718 TH1D* dummyhist = new TH1D("dummyhistFoCalFEBTrend", "", 100, xPMin, xPMax);
0719 SetStyleHistoTH1ForGraphs(dummyhist, tempGraph3->GetXaxis()->GetTitle(), yAxisT, 0.85*textSizePixel, textSizePixel,
0720 0.85*textSizePixel, textSizePixel, 0.9, 1.3, 510, 510, 43, 63);
0721 dummyhist->GetYaxis()->SetRangeUser(minY, maxY);
0722
0723
0724 TString lab1 = Form("#it{#bf{%s TB:}} %s", (currRunInfo.detector).Data(), GetStringFromRunInfo(currRunInfo, 9).Data());
0725 TString lab2 = GetStringFromRunInfo(currRunInfo, 8);
0726 TString lab3 = GetStringFromRunInfo(currRunInfo, 10);
0727
0728 for (int r = 0; r < nRow; ++r){
0729 for (int c = 0; c < nCol; ++c){
0730 canvasFEB->cd();
0731 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0732 int p = setupT->GetChannelInLayer(tempCellID);
0733
0734 TString label = Form("row %d col %d", r, c);
0735 TString labelAsic = Form("a %d ch %d",setupT->GetROunit(tempCellID) , setupT->GetROchannel(tempCellID));
0736 TString label2 = Form("Common V_{op} = %2.1f V", commonVoltage);
0737 if (isSameVoltage > 1)
0738 label2 = label2+Form(",%s", (GetSpeciesStringFromPDG(currRunInfo.pdg).Data()));
0739 if (isSameVoltage > 2)
0740 label2 = label2+Form(", Run %d", currRunInfo.runNr);
0741
0742 pads[p]->Draw();
0743 pads[p]->cd();
0744 if (optionTrend == 6)
0745 pads[p]->SetLogy(1);
0746 else
0747 pads[p]->SetLogy(0);
0748
0749 ithTrend = trending.find(tempCellID);
0750 if (ithTrend == trending.end()){
0751 skipped++;
0752 pads[p]->Clear();
0753 pads[p]->Draw();
0754 dummyhist->Draw("axis");
0755 continue;
0756 }
0757
0758 TGraphErrors* tempGraph = nullptr;
0759 TGraphErrors* tempGraph2 = nullptr;
0760 TF1* fit = nullptr;
0761 if (optionTrend != 19 && optionTrend != 20 && optionTrend != 50 ){
0762 tempGraph = ithTrend->second.GetTrendingBasedOnOption(optionTrend);
0763 } else if (optionTrend == 19){
0764 tempGraph = ithTrend->second.GetTrendingBasedOnOption(0);
0765 tempGraph2 = ithTrend->second.GetTrendingBasedOnOption(1);
0766 } else if (optionTrend == 20){
0767 tempGraph = ithTrend->second.GetTrendingBasedOnOption(15);
0768 tempGraph2 = ithTrend->second.GetTrendingBasedOnOption(16);
0769 } else if (optionTrend == 50){
0770 tempGraph = ithTrend->second.GetTrendingBasedOnOption(30);
0771 tempGraph2 = ithTrend->second.GetTrendingBasedOnOption(32);
0772 }
0773 if (optionTrend == 2){
0774 fit = ithTrend->second.GetHGScaleFit();
0775 } else if (optionTrend == 3){
0776 fit = ithTrend->second.GetLGScaleFit();
0777 }
0778
0779 if (!tempGraph) continue;
0780 SetMarkerDefaultsTGraphErr(tempGraph, 20, 1, kBlue+1, kBlue+1);
0781
0782
0783 dummyhist->Draw("axis");
0784
0785 if (fit){
0786 SetLineDefaultsTF1(fit, kRed+2, 2, 3);
0787 fit->Draw("same");
0788 }
0789
0790 tempGraph->Draw("pe,same");
0791 if (tempGraph2){
0792 SetMarkerDefaultsTGraphErr(tempGraph2, 25, 1, kRed+1, kRed+1);
0793 tempGraph2->Draw("pe, same");
0794 }
0795
0796 TLatex* labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
0797 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0798 labelChannel->Draw();
0799 TLatex* labelChannelAsic = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-2.*relSizeFEB[p], labelAsic);
0800 SetStyleTLatex(labelChannelAsic, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
0801 labelChannelAsic->Draw();
0802
0803 if (p == 31){
0804 DrawLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p]-2*0.85*relSizeFEB[p], label2, true, 0.85*textSizePixel, 43);
0805 }
0806 if (p == 24){
0807 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeFEB[p]-2*0.85*relSizeFEB[p], lab1, true, 0.85*textSizePixel, 43);
0808 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeFEB[p]-3*0.85*relSizeFEB[p], lab2, true, 0.85*textSizePixel, 43);
0809 DrawLatex(topRCornerX[p]-0.045, topRCornerY[p]-1.2*relSizeFEB[p]-4*0.85*relSizeFEB[p], lab3, true, 0.85*textSizePixel, 43);
0810
0811 if (tempGraph2 ){
0812 double startLegY = topRCornerY[p]-1.2*relSizeFEB[p]-4.5*0.85*relSizeFEB[p];
0813 double endLegY = topRCornerY[p]-1.2*relSizeFEB[p]-5.5*0.85*relSizeFEB[p];
0814 TLegend* legend = nullptr;
0815 if (currRunInfo.readout == "CAEN" && optionTrend != 50){
0816 legend = GetAndSetLegend2( 0.7, startLegY, topRCornerX[p]-0.045/2, endLegY,
0817 0.85*textSizePixel, 2, "",43,0.22);
0818 legend->AddEntry(tempGraph, "HG", "p");
0819 legend->AddEntry(tempGraph2, "LG", "p");
0820 } else if (optionTrend != 50){
0821 legend = GetAndSetLegend2( 0.3, startLegY, topRCornerX[p]-0.045/2, endLegY,
0822 0.85*textSizePixel, 2, "",43,0.12);
0823 legend->AddEntry(tempGraph, "0th sample", "p");
0824 legend->AddEntry(tempGraph2, "waveform fit", "p");
0825 } else {
0826 legend = GetAndSetLegend2( 0.3, startLegY, topRCornerX[p]-0.045/2, endLegY,
0827 0.85*textSizePixel, 2, "",43,0.12);
0828 legend->AddEntry(tempGraph, "ADC max", "p");
0829 legend->AddEntry(tempGraph2, "TOT", "p");
0830 }
0831 legend->Draw();
0832 }
0833 }
0834 }
0835 }
0836
0837 if (skipped < 32)
0838 canvasFEB->SaveAs(nameOutput.Data());
0839 }
0840
0841
0842
0843
0844 inline void PlotRunOverlayFoCalFEB (TCanvas* canvasFEB, TPad** pads, Double_t* topRCornerX, Double_t* topRCornerY,
0845 Double_t* relSizeFEB, Int_t textSizePixel, std::map<int,TileTrend> trending,
0846 int nruns, int optionTrend, Double_t xPMin, Double_t xPMax, int mod,
0847 TString nameOutput, TString nameOutputSummary, RunInfo commonRunInfo,
0848 Int_t detailedPlot = 1){
0849 Setup* setupT = Setup::GetInstance();
0850 std::map<int, TileTrend>::iterator ithTrend;
0851 int nRow = 4;
0852 int nCol = 8;
0853 int skipped = 0;
0854
0855
0856 bool isSameRun = false;
0857 int altStyle = 0;
0858 if (commonRunInfo.runNr != -10000){
0859 isSameRun = true;
0860 altStyle = 1;
0861 }
0862 if (commonRunInfo.pdg != -10000)
0863 altStyle = 1;
0864 bool isSameVoltage = false;
0865 double commonVoltage = 0;
0866 if (commonRunInfo.vop != -10000.){
0867 isSameVoltage = true;
0868 commonVoltage = commonRunInfo.vop;
0869 }
0870 Int_t nSameSettings = 0;
0871 if (commonRunInfo.rf > -1) nSameSettings++;
0872 if (commonRunInfo.cf > -1) nSameSettings++;
0873 if (commonRunInfo.cfcomp > -1) nSameSettings++;
0874 if (commonRunInfo.cc > -1) nSameSettings++;
0875 if (commonRunInfo.vop > -1) nSameSettings++;
0876
0877 double lineBottom = (2.4+5);
0878 if (nruns < 6) lineBottom = (2.4);
0879 else if (nruns < 11) lineBottom = (2.4+1);
0880 else if (nruns < 16) lineBottom = (2.4+2);
0881 else if (nruns < 21) lineBottom = (2.4+3);
0882 else if (nruns < 26) lineBottom = (2.4+4);
0883 if (nSameSettings == 4) lineBottom++;
0884 TLegend* legend = nullptr;
0885
0886 Double_t maxY = 0.;
0887 Double_t minY = 9999.;
0888 for (int r = 0; r < nRow; r++){
0889 for (int c = 0; c < nCol; c++){
0890 int tempCellID = setupT->GetCellID(r,c, 0, mod);
0891 int p = setupT->GetChannelInLayer(tempCellID);
0892 ithTrend=trending.find(tempCellID);
0893 if (ithTrend==trending.end()) continue;
0894 if (optionTrend == 0){
0895 if(maxY<ithTrend->second.GetMaxHGSpec()) maxY=ithTrend->second.GetMaxHGSpec();
0896 if(minY>ithTrend->second.GetMinHGSpec()) minY=ithTrend->second.GetMinHGSpec();
0897 } else if (optionTrend == 1){
0898 if(maxY<ithTrend->second.GetMaxLGSpec()) maxY=ithTrend->second.GetMaxLGSpec();
0899 if(minY>ithTrend->second.GetMinLGSpec()) minY=ithTrend->second.GetMinLGSpec();
0900 } else if (optionTrend == 2){
0901 if(maxY<ithTrend->second.GetMaxTOT()) maxY=ithTrend->second.GetMaxTOTSpec();
0902 if(minY>ithTrend->second.GetMinTOT()) minY=ithTrend->second.GetMinTOTSpec();
0903 } else if (optionTrend == 3){
0904 if(maxY<ithTrend->second.GetMaxTOASpec()) maxY=ithTrend->second.GetMaxTOASpec();
0905 if(minY>ithTrend->second.GetMinTOASpec()) minY=ithTrend->second.GetMinTOASpec();
0906 }
0907 }
0908 }
0909 std::cout << " minY: " << minY << "\t maxY: " << maxY << std::endl;
0910
0911 TH1D* histos[30];
0912
0913 for (int r = 0; r < nRow; ++r){
0914 for (int c = 0; c < nCol; ++c){
0915 canvasFEB->cd();
0916 int tempCellID = setupT->GetCellID(r, c, 0, mod);
0917 int p = setupT->GetChannelInLayer(tempCellID);
0918 pads[p]->Draw();
0919 pads[p]->cd();
0920 pads[p]->SetLogy(1);
0921
0922 ithTrend = trending.find(tempCellID);
0923 if (ithTrend == trending.end()){
0924 skipped++;
0925 pads[p]->Clear();
0926 pads[p]->Draw();
0927 continue;
0928 }
0929
0930 if (p == 31 ){
0931 double startLegY = topRCornerY[p]-lineBottom*relSizeFEB[p];
0932 double endLegY = topRCornerY[p]-2.4*relSizeFEB[p];
0933 TString header = "";
0934 double width = 0.9;
0935 if (nSameSettings == 4){
0936
0937 if (commonRunInfo.rf < 0)
0938 header = "RF (k#Omega)";
0939 if (commonRunInfo.cf < 0) header = "CF (fF)";
0940 if (commonRunInfo.cfcomp < 0) header = "CF_{comp} (fF)";
0941 if (commonRunInfo.cc < 0) header = "CC";
0942 if (commonRunInfo.vop < 0) header = "V_{op} (V)";
0943 }
0944 legend = GetAndSetLegend2( 0.045, startLegY, width, endLegY,
0945 0.85*textSizePixel, 5, "",43,0.25);
0946 }
0947
0948 int maxRC = ithTrend->second.GetNRuns();
0949 if (maxRC > 30) maxRC = 30;
0950 int first = maxRC-1;
0951 bool firstFound = false;
0952 for (int rc = maxRC-1; rc > -1 ; rc-- ){
0953 int tmpRunNr = ithTrend->second.GetRunNr(rc);
0954 histos[rc] = nullptr;
0955 if (tmpRunNr != -1 && !isSameRun) {
0956 if (optionTrend == 0){
0957 histos[rc] = ithTrend->second.GetHGTriggRun(ithTrend->second.GetRunNr(rc));
0958 } else if (optionTrend == 1){
0959 histos[rc] = ithTrend->second.GetLGTriggRun(ithTrend->second.GetRunNr(rc));
0960 } else if (optionTrend == 2){
0961 histos[rc] = ithTrend->second.GetTOTHistRun(ithTrend->second.GetRunNr(rc));
0962 } else if (optionTrend == 3){
0963 histos[rc] = ithTrend->second.GetTOAHistRun(ithTrend->second.GetRunNr(rc));
0964 }
0965 } else if (isSameRun && tmpRunNr != -1){
0966 if (optionTrend == 0){
0967 histos[rc] = ithTrend->second.GetHGTriggRun(rc);
0968 } else if (optionTrend == 1){
0969 histos[rc] = ithTrend->second.GetLGTriggRun(rc);
0970 } else if (optionTrend == 2){
0971 histos[rc] = ithTrend->second.GetTOTHistRun(rc);
0972 } else if (optionTrend == 3){
0973 histos[rc] = ithTrend->second.GetTOAHistRun(rc);
0974 }
0975 }
0976
0977 if (histos[rc] && histos[rc]->GetEntries() > 0){
0978 if (!firstFound && histos[rc]->GetEntries() > 0){
0979 first = rc;
0980 firstFound = true;
0981 }
0982 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);
0983 SetLineDefaults(histos[rc], GetColorLayer(rc), 2, GetLineStyleLayer(rc));
0984 if (histos[rc]->GetEntries() > 0) {
0985 if(rc == first){
0986 histos[rc]->GetXaxis()->SetRangeUser(xPMin,xPMax);
0987 histos[rc]->GetYaxis()->SetRangeUser(minY,maxY);
0988 histos[rc]->Draw("hist");
0989 } else {
0990 histos[rc]->Draw("same,hist");
0991 }
0992 }
0993 if(p == 31) legend->AddEntry(histos[rc],ithTrend->second.GetLabel(rc),"l");
0994 }
0995 }
0996 if (firstFound && histos[first]) histos[first]->Draw("axis,same");
0997
0998 TString label = Form("row %d col %d", r, c);
0999 TString labelAsic = Form("a %d ch %d",setupT->GetROunit(tempCellID) , setupT->GetROchannel(tempCellID));
1000
1001 TLatex* labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
1002 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
1003 labelChannel->Draw();
1004 TLatex* labelChannelAsic = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-2.*relSizeFEB[p], labelAsic);
1005 SetStyleTLatex(labelChannelAsic, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
1006 labelChannelAsic->Draw();
1007 if (p == 31)
1008 legend->Draw();
1009 }
1010 }
1011
1012 if (skipped < 32)
1013 canvasFEB->SaveAs(nameOutput.Data());
1014 }
1015
1016
1017
1018
1019 inline void PlotRunOverlayProfileFoCalFEB (TCanvas* canvasFEB, TPad** pads, Double_t* topRCornerX, Double_t* topRCornerY,
1020 Double_t* relSizeFEB, Int_t textSizePixel, std::map<int,TileTrend> trending,
1021 int nruns, int option, Double_t xPMin, Double_t xPMax,
1022 Double_t yPMin, Double_t yPMax, int mod, TString nameOutput,
1023 TString nameOutputSummary, RunInfo commonRunInfo,
1024 Int_t detailedPlot = 1, bool scaleInt = false){
1025 Setup* setupT = Setup::GetInstance();
1026 std::map<int, TileTrend>::iterator ithTrend;
1027 int nRow = 4;
1028 int nCol = 8;
1029 int skipped = 0;
1030
1031
1032 bool isSameRun = false;
1033 int altStyle = 0;
1034 if (commonRunInfo.runNr != -10000){
1035 isSameRun = true;
1036 altStyle = 1;
1037 }
1038 if (commonRunInfo.pdg != -10000)
1039 altStyle = 1;
1040 bool isSameVoltage = false;
1041 double commonVoltage = 0;
1042 if (commonRunInfo.vop != -10000.){
1043 isSameVoltage = true;
1044 commonVoltage = commonRunInfo.vop;
1045 }
1046
1047 Int_t nSameSettings = 0;
1048 if (commonRunInfo.rf > -1) nSameSettings++;
1049 if (commonRunInfo.cf > -1) nSameSettings++;
1050 if (commonRunInfo.cfcomp > -1) nSameSettings++;
1051 if (commonRunInfo.cc > -1) nSameSettings++;
1052 if (commonRunInfo.vop > -1) nSameSettings++;
1053
1054 TProfile* profs[30];
1055
1056 double lineBottom = (2.4+5);
1057 if (nruns < 6) lineBottom = (2.4);
1058 else if (nruns < 11) lineBottom = (2.4+1);
1059 else if (nruns < 16) lineBottom = (2.4+2);
1060 else if (nruns < 21) lineBottom = (2.4+3);
1061 else if (nruns < 26) lineBottom = (2.4+4);
1062 if (nSameSettings == 4) lineBottom++;
1063 TLegend* legend = nullptr;
1064
1065
1066 for (int r = 0; r < nRow; ++r){
1067 for (int c = 0; c < nCol; ++c){
1068 canvasFEB->cd();
1069 int tempCellID = setupT->GetCellID(r, c, 0, mod);
1070
1071
1072 int p = setupT->GetChannelInLayer(tempCellID);
1073 pads[p]->Draw();
1074 pads[p]->cd();
1075 pads[p]->SetLogy(0);
1076
1077 ithTrend = trending.find(tempCellID);
1078 if (ithTrend == trending.end()){
1079 skipped++;
1080 pads[p]->Clear();
1081 pads[p]->Draw();
1082 continue;
1083 }
1084
1085 if (p == 31 ){
1086 double startLegY = topRCornerY[p]-lineBottom*relSizeFEB[p];
1087 double endLegY = topRCornerY[p]-2.4*relSizeFEB[p];
1088 TString header = "";
1089 double width = 0.9;
1090 if (nSameSettings == 4){
1091
1092 if (commonRunInfo.rf < 0)
1093 header = "RF (k#Omega)";
1094 if (commonRunInfo.cf < 0) header = "CF (fF)";
1095 if (commonRunInfo.cfcomp < 0) header = "CF_{comp} (fF)";
1096 if (commonRunInfo.cc < 0) header = "CC";
1097 if (commonRunInfo.vop < 0) header = "V_{op} (V)";
1098 }
1099 legend = GetAndSetLegend2( 0.045, startLegY, width, endLegY,
1100 0.85*textSizePixel, 5, "",43,0.25);
1101 }
1102
1103 TH1D* dummyhist = nullptr;
1104 for (int rc = 0; rc < ithTrend->second.GetNRuns() && rc < 30; rc++ ){
1105 int tmpRunNr = ithTrend->second.GetRunNr(rc);
1106 profs[rc] = nullptr;
1107 if (tmpRunNr != -1) {
1108 if (option == 0)
1109 profs[rc] = ithTrend->second.GetLGHGTriggRun(ithTrend->second.GetRunNr(rc));
1110 else if (option == 1)
1111 profs[rc] = ithTrend->second.GetWave1DRun(ithTrend->second.GetRunNr(rc));
1112 else if (option == 2)
1113 profs[rc] = ithTrend->second.GetTOARun(ithTrend->second.GetRunNr(rc));
1114 else if (option == 3)
1115 profs[rc] = ithTrend->second.GetTOTRun(ithTrend->second.GetRunNr(rc));
1116 if (scaleInt && profs[rc] != nullptr) profs[rc]->Scale(1/profs[rc]->Integral());
1117 }
1118 if (profs[rc]){
1119 if (rc == 0){
1120 TString yTitle = profs[rc]->GetYaxis()->GetTitle();
1121 if (scaleInt && profs[rc] != nullptr) yTitle = Form("%s/ integral", yTitle.Data());
1122 dummyhist = new TH1D(Form("dummyhist_%d_%d_%d",option, mod,p), "", profs[rc]->GetNbinsX(), profs[rc]->GetXaxis()->GetXmin(), profs[rc]->GetXaxis()->GetXmax());
1123 dummyhist->SetDirectory(0);
1124 SetStyleHistoTH1ForGraphs( dummyhist, profs[rc]->GetXaxis()->GetTitle(), profs[rc]->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.3, 510, 510, 43, 63);
1125 dummyhist->GetXaxis()->SetRangeUser(xPMin,xPMax);
1126 dummyhist->GetYaxis()->SetRangeUser(yPMin,yPMax);
1127 dummyhist->Draw("axis");
1128 }
1129
1130 SetLineDefaults(profs[rc], GetColorLayer(rc, altStyle), 2, GetLineStyleLayer(rc, altStyle));
1131 profs[rc]->SetMarkerStyle(GetMarkerLayer(rc));
1132 profs[rc]->Draw("same,pe");
1133 if(p == 31){
1134 TString labelLegend = ithTrend->second.GetLabel(rc);
1135 if (nSameSettings == 4){
1136 if (commonRunInfo.vop < 0) labelLegend = Form("%.1f",(double)ithTrend->second.GetVoltage(rc));
1137 if (commonRunInfo.rf < 0) labelLegend = Form("%.1f",ReturnRFValue(ithTrend->second.GetRF(rc)));
1138 if (commonRunInfo.cf < 0) labelLegend = Form("%.0f",ReturnCFValue(ithTrend->second.GetCF(rc)));
1139 if (commonRunInfo.cfcomp < 0) labelLegend = Form("%.0f",ReturnCFCompValue(ithTrend->second.GetCFComp(rc)));
1140 if (commonRunInfo.cc < 0) labelLegend = Form("%.0f",ReturnCCValue(ithTrend->second.GetCC(rc)));
1141 }
1142 legend->AddEntry(profs[rc],labelLegend.Data(),"p");
1143 }
1144
1145
1146 }
1147 }
1148 if (dummyhist) dummyhist->Draw("axis,same");
1149
1150 TString label = Form("row %d col %d", r, c);
1151 TString labelAsic = Form("a %d ch %d",setupT->GetROunit(tempCellID) , setupT->GetROchannel(tempCellID));
1152 TLatex* labelChannel = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-1.2*relSizeFEB[p], label);
1153 SetStyleTLatex(labelChannel, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
1154 labelChannel->Draw();
1155 TLatex* labelChannelAsic = new TLatex(topRCornerX[p]-0.04, topRCornerY[p]-2.*relSizeFEB[p], labelAsic);
1156 SetStyleTLatex(labelChannelAsic, 0.85*textSizePixel, 4, 1, 43, kTRUE, 31);
1157 labelChannelAsic->Draw();
1158
1159 if (p == 31)
1160 legend->Draw();
1161 }
1162 }
1163
1164 if (skipped < 32)
1165 canvasFEB->SaveAs(nameOutput.Data());
1166 }
1167
1168
1169
1170
1171 inline void PlotMipWithFitsFoCalFEB (TCanvas* canvasFEB, TPad** pads, Double_t* topRCornerX, Double_t* topRCornerY,
1172 Double_t* relSizeFEB, Int_t textSizePixel, std::map<int,TileSpectra> spectra,
1173 std::map<int,TileSpectra> spectraTrigg, int opt, Double_t xPMin, Double_t xPMax,
1174 Double_t scaleYMax, int mod, TString nameOutput, RunInfo currRunInfo){
1175 PlotNoiseAdvWithFitsFoCalFEB(canvasFEB, pads, topRCornerX, topRCornerY, relSizeFEB, textSizePixel,
1176 spectra, spectraTrigg, opt == 1, xPMin, xPMax, scaleYMax, mod, nameOutput, currRunInfo);
1177 }
1178
1179 #endif