File indexing completed on 2025-12-16 09:28:20
0001 #ifndef PLOTTHELPER_H
0002 #define PLOTTHELPER_H
0003
0004 #include "TLegend.h"
0005 #include "TAxis.h"
0006 #include "TColor.h"
0007 #include "TCanvas.h"
0008 #include "TLine.h"
0009 #include "TBox.h"
0010 #include "TPad.h"
0011 #include "TFrame.h"
0012 #include "TLatex.h"
0013 #include "TGraph.h"
0014 #include "TGraphErrors.h"
0015 #include "TGraphAsymmErrors.h"
0016 #include "TGaxis.h"
0017 #include "TSystem.h"
0018 #include "TStyle.h"
0019 #include <TH3.h>
0020 #include "TileSpectra.h"
0021 #include "TileTrend.h"
0022 #include "CalibSummary.h"
0023 #include "AnaSummary.h"
0024 #include "CommonHelperFunctions.h"
0025 #include "PlotHelper_general.h"
0026 #include "PlotHelper_8MLayer.h"
0027 #include "PlotHelper_2MLayer.h"
0028 #include "PlotHelper_1MLayer.h"
0029
0030
0031
0032 void PlotSimple2D( TCanvas* canvas2D,
0033 TH2* hist, double maxy, double maxx,
0034 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0035 int labelOpt = 1, Bool_t hasNeg = kFALSE, TString drwOpt ="colz",
0036 bool blegAbove = false, TString additionalLabel = ""
0037 ){
0038 canvas2D->cd();
0039 SetStyleHistoTH2ForGraphs( hist, hist->GetXaxis()->GetTitle(), hist->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.9, 1.05);
0040 hist->GetZaxis()->SetLabelSize(0.85*textSizeRel);
0041 hist->GetZaxis()->SetTitleOffset(1.06);
0042 hist->GetZaxis()->SetTitleSize(textSizeRel);
0043
0044
0045 if (maxy > -10000)hist->GetYaxis()->SetRangeUser(hist->GetYaxis()->GetBinCenter(1)-0.1,maxy+0.1);
0046 if (maxx > -10000)hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetBinCenter(1)-0.1,maxx+0.1);
0047 if (!hasNeg)
0048 hist->GetZaxis()->SetRangeUser(hist->GetMinimum(0),hist->GetMaximum());
0049 else
0050 hist->GetZaxis()->SetRangeUser(hist->GetMinimum(),hist->GetMaximum());
0051
0052 if (((TString)hist->GetZaxis()->GetTitle()).Contains("counts")){
0053 gStyle->SetPaintTextFormat(".0f");
0054 std::cout << "entered counts case" << std::endl;
0055 } else {
0056 gStyle->SetPaintTextFormat(".3f");
0057 }
0058 hist->DrawCopy(drwOpt.Data());
0059
0060 if (!blegAbove)
0061 DrawLatex(0.85, 0.92, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0062 else
0063 DrawLatex(0.92, 0.97, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0064
0065 if (additionalLabel.CompareTo("") != 0){
0066 if (!blegAbove)
0067 DrawLatex(0.11, 0.92, additionalLabel, false, 0.85*textSizeRel, 42);
0068 else
0069 DrawLatex(0.08, 0.97, additionalLabel, false, 0.85*textSizeRel, 42);
0070 }
0071 if (((TString)hist->GetXaxis()->GetTitle()).Contains("cell ID")){
0072 std::cout << "entered cell ID" << std::endl;
0073 if (maxx > -10000)
0074 DrawLines(hist->GetXaxis()->GetBinCenter(1)-0.1, maxx+0.1,0., 0., 5, kGray+1, 10);
0075 else
0076 DrawLines(hist->GetXaxis()->GetBinCenter(1)-0.1,hist->GetXaxis()->GetBinCenter(hist->GetNbinsX()-1)+0.1,0., 0., 5, kGray+1, 10);
0077 }
0078 canvas2D->SaveAs(nameOutput.Data());
0079 }
0080
0081
0082
0083
0084 void PlotSimple2D( TCanvas* canvas2D,
0085 TH2* hist, double miny, double maxy, double maxx,
0086 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0087 int labelOpt = 1, Bool_t hasNeg = kFALSE, TString drwOpt ="colz",
0088 bool blegAbove = false, TString additionalLabel = ""
0089 ){
0090 canvas2D->cd();
0091 SetStyleHistoTH2ForGraphs( hist, hist->GetXaxis()->GetTitle(), hist->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.9, 1.05);
0092 hist->GetZaxis()->SetLabelSize(0.85*textSizeRel);
0093 hist->GetZaxis()->SetTitleOffset(1.06);
0094 hist->GetZaxis()->SetTitleSize(textSizeRel);
0095
0096
0097 if (miny > -10000 && maxy > -10000)hist->GetYaxis()->SetRangeUser(miny-0.1,maxy+0.1);
0098 if (maxx > -10000)hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetBinCenter(1)-0.1,maxx+0.1);
0099 if (!hasNeg)
0100 hist->GetZaxis()->SetRangeUser(hist->GetMinimum(0),hist->GetMaximum());
0101 else
0102 hist->GetZaxis()->SetRangeUser(hist->GetMinimum(),hist->GetMaximum());
0103
0104 if (((TString)hist->GetZaxis()->GetTitle()).Contains("counts")){
0105 gStyle->SetPaintTextFormat(".0f");
0106 std::cout << "entered counts case" << std::endl;
0107 } else {
0108 gStyle->SetPaintTextFormat(".3f");
0109 }
0110 hist->DrawCopy(drwOpt.Data());
0111
0112 if (!blegAbove)
0113 DrawLatex(0.85, 0.92, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0114 else
0115 DrawLatex(0.92, 0.97, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0116
0117 if (additionalLabel.CompareTo("") != 0){
0118 if (!blegAbove)
0119 DrawLatex(0.11, 0.92, additionalLabel, false, 0.85*textSizeRel, 42);
0120 else
0121 DrawLatex(0.08, 0.97, additionalLabel, false, 0.85*textSizeRel, 42);
0122 }
0123
0124 if (((TString)hist->GetXaxis()->GetTitle()).Contains("cell ID")){
0125 std::cout << "entered cell ID" << std::endl;
0126 if (maxx > -10000)
0127 DrawLines(hist->GetXaxis()->GetBinCenter(1)-0.1, maxx+0.1,0., 0., 5, kGray+1, 10);
0128 else
0129 DrawLines(hist->GetXaxis()->GetBinCenter(1)-0.1,hist->GetXaxis()->GetBinCenter(hist->GetNbinsX()-1)+0.1,0., 0., 5, kGray+1, 10);
0130 }
0131 canvas2D->SaveAs(nameOutput.Data());
0132 }
0133
0134
0135
0136
0137 void Plot2DWithGraph( TCanvas* canvas2D,
0138 TH2* hist, TGraphErrors* graph, double maxy, double maxx,
0139 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0140 int labelOpt = 1, Bool_t hasNeg = kFALSE, TString drwOpt ="colz",
0141 bool blegAbove = false, TString additionalLabel = ""
0142 ){
0143 canvas2D->cd();
0144
0145 SetStyleHistoTH2ForGraphs( hist, hist->GetXaxis()->GetTitle(), hist->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.9, 1.05);
0146 hist->GetZaxis()->SetLabelSize(0.85*textSizeRel);
0147 hist->GetZaxis()->SetTitleOffset(1.06);
0148 hist->GetZaxis()->SetTitleSize(textSizeRel);
0149
0150
0151 if (canvas2D->GetLogy() == 1){
0152 if (maxy > -10000)hist->GetYaxis()->SetRangeUser(0.05,maxy+0.1);
0153 } else {
0154 if (maxy > -10000)hist->GetYaxis()->SetRangeUser(hist->GetYaxis()->GetBinCenter(1)-0.1,maxy+0.1);
0155 }
0156 if (maxx > -10000)hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetBinCenter(1)-0.1,maxx+0.1);
0157 if (!hasNeg)
0158 hist->GetZaxis()->SetRangeUser(hist->GetMinimum(0),hist->GetMaximum());
0159 else
0160 hist->GetZaxis()->SetRangeUser(hist->GetMinimum(),hist->GetMaximum());
0161
0162 if (((TString)hist->GetZaxis()->GetTitle()).Contains("counts")){
0163 gStyle->SetPaintTextFormat(".0f");
0164 std::cout << "entered counts case" << std::endl;
0165 } else {
0166 gStyle->SetPaintTextFormat(".3f");
0167 }
0168 hist->DrawCopy(drwOpt.Data());
0169
0170 if (graph){
0171 SetMarkerDefaultsTGraphErr( graph, 24, 2, kGray+1,kGray+1, 3, kFALSE, 0, kFALSE);
0172 graph->Draw("same,pe");
0173 }
0174 if (!blegAbove){
0175 DrawLatex(0.835, 0.935, Form("#it{#bf{LFHCal TB:} %s}",GetStringFromRunInfo(currRunInfo,7).Data()), true, textSizeRel, 42);
0176 DrawLatex(0.835, 0.90, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0177 DrawLatex(0.835, 0.865, Form("%s",GetStringFromRunInfo(currRunInfo,8).Data()), true, 0.85*textSizeRel, 42);
0178 }
0179 else
0180 DrawLatex(0.92, 0.97, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0181
0182 if (additionalLabel.CompareTo("") != 0){
0183 if (!blegAbove)
0184 DrawLatex(0.11, 0.92, additionalLabel, false, 0.85*textSizeRel, 42);
0185 else
0186 DrawLatex(0.08, 0.97, additionalLabel, false, 0.85*textSizeRel, 42);
0187 }
0188 if (((TString)hist->GetXaxis()->GetTitle()).Contains("cell ID")){
0189 if (maxx > -10000)
0190 DrawLines(hist->GetXaxis()->GetBinCenter(1)-0.1, maxx+0.1,0., 0., 5, kGray+1, 10);
0191 else
0192 DrawLines(hist->GetXaxis()->GetBinCenter(1)-0.1,hist->GetXaxis()->GetBinCenter(hist->GetNbinsX()-1)+0.1,0., 0., 5, kGray+1, 10);
0193 }
0194 canvas2D->SaveAs(nameOutput.Data());
0195 }
0196
0197
0198
0199
0200 void PlotSimple1D( TCanvas* canvas2D,
0201 TH1* hist, Int_t maxy, Int_t maxx,
0202 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0203 int labelOpt = 1,
0204 TString additionalLabel = ""
0205 ){
0206 canvas2D->cd();
0207 SetStyleHistoTH1ForGraphs( hist, hist->GetXaxis()->GetTitle(), hist->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.9, 1.05);
0208
0209 SetMarkerDefaults(hist, 20, 1, kBlue+1, kBlue+1, kFALSE);
0210
0211
0212 if (maxy > -10000)hist->GetYaxis()->SetRangeUser(-0.5,maxy+0.1);
0213 if (maxx > -10000)hist->GetXaxis()->SetRangeUser(-0.5,maxx+0.1);
0214
0215 hist->Draw("p,e");
0216
0217 DrawLatex(0.95, 0.92, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0218 if (additionalLabel.CompareTo("") != 0){
0219 DrawLatex(0.95, 0.92-textSizeRel, additionalLabel, true, 0.85*textSizeRel, 42);
0220 }
0221 canvas2D->SaveAs(nameOutput.Data());
0222 }
0223
0224
0225
0226
0227 void PlotContamination1D( TCanvas* canvas2D,
0228 TH1* histAll, TH1* histMuon, TH1* histPrim, Int_t maxy, Int_t maxx,
0229 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0230 int labelOpt = 1,
0231 TString additionalLabel = ""
0232 ){
0233 canvas2D->cd();
0234 SetStyleHistoTH1ForGraphs( histAll, histAll->GetXaxis()->GetTitle(), histAll->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.9, 1.05);
0235
0236 SetMarkerDefaults(histAll, 20, 1, kBlue+1, kBlue+1, kFALSE);
0237
0238
0239 if (maxy > -10000)histAll->GetYaxis()->SetRangeUser(-0.5,maxy+0.1);
0240 if (maxx > -10000)histAll->GetXaxis()->SetRangeUser(0.5,maxx+0.1);
0241
0242 histAll->Draw("p,e");
0243 SetMarkerDefaults(histMuon, 25, 1, kGray+1, kGray+1, kFALSE);
0244 histMuon->Draw("p,e,same");
0245 SetMarkerDefaults(histPrim, 24, 1, kRed+1, kRed+1, kFALSE);
0246 histPrim->Draw("p,e,same");
0247
0248
0249 DrawLatex(0.95, 0.92, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0250 if (additionalLabel.CompareTo("") != 0){
0251 DrawLatex(0.95, 0.92-textSizeRel, additionalLabel, true, 0.85*textSizeRel, 42);
0252 }
0253
0254 TLegend* legend = GetAndSetLegend2( 0.11, 0.93-3*textSizeRel, 0.4, 0.93,0.85*textSizeRel, 1, "", 42,0.1);
0255 legend->AddEntry(histAll, "no evt. selection", "p");
0256 legend->AddEntry(histMuon, "muon events", "p");
0257 legend->AddEntry(histPrim, "remaining events", "p");
0258 legend->Draw();
0259
0260 canvas2D->SaveAs(nameOutput.Data());
0261 }
0262
0263
0264
0265
0266
0267 void PlotLayerOverlay( TCanvas* canvas2D,
0268 TH1D** histLayer, Float_t maxy, Float_t maxx, Float_t meanLayer, int maxLayer,
0269 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0270 int labelOpt = 1,
0271 TString additionalLabel = "", bool frebin = true
0272 ){
0273 canvas2D->cd();
0274 canvas2D->SetLogy(1);
0275
0276 SetStyleHistoTH1ForGraphs( histLayer[0], histLayer[0]->GetXaxis()->GetTitle(), histLayer[0]->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.9, 1.05);
0277
0278
0279 TString title = histLayer[0]->GetXaxis()->GetTitle();
0280 bool Exaxis = false;
0281 bool Posxaxis = false;
0282 bool NCellsxaxis = false;
0283 if (title.Contains("E_{layer}"))
0284 Exaxis = true;
0285 if (title.Contains("(cm)"))
0286 Posxaxis = true;
0287 if (title.Contains("N_{cells,layer}"))
0288 NCellsxaxis = true;
0289
0290 if (maxy > -10000 )
0291 histLayer[0]->GetYaxis()->SetRangeUser(1,maxy);
0292 if (maxx > -10000 && !Posxaxis){
0293 std::cout << "resetting x range: 0 - " << maxx << std::endl;
0294 histLayer[0]->GetXaxis()->SetRange(1,histLayer[0]->GetXaxis()->FindBin(maxx)+1);
0295 } else if (maxx > -10000 && Posxaxis){
0296 histLayer[0]->GetXaxis()->SetRange(histLayer[0]->GetXaxis()->FindBin(-maxx)-1,histLayer[0]->GetXaxis()->FindBin(maxx)+1);
0297 }
0298 histLayer[0]->DrawCopy("axis");
0299
0300 Setup* setup = Setup::GetInstance();
0301
0302 TLegend* legend = nullptr;
0303 Int_t lineBottom = (2+8);
0304 if (!(setup->GetNMaxLayer()+1 == 64))
0305 lineBottom = (2+4);
0306 else if ( setup->GetNMaxLayer()+1 == 64 && (NCellsxaxis || Posxaxis))
0307 lineBottom = (2+5);
0308
0309 if (setup->GetNMaxLayer()+1 == 64 && (NCellsxaxis || Posxaxis )){
0310 legend = GetAndSetLegend2( 0.11, 0.93-lineBottom*0.85*textSizeRel, 0.95, 0.93-2*0.85*textSizeRel,0.75*textSizeRel, 15, Form("Layer, #LTlayer#GT = %.2f",meanLayer), 42,0.4);
0311 } else if (setup->GetNMaxLayer()+1 == 64 ){
0312 legend = GetAndSetLegend2( 0.4, 0.93-lineBottom*0.85*textSizeRel, 0.95, 0.93-2*0.85*textSizeRel,0.75*textSizeRel, 8, Form("Layer, #LTlayer#GT = %.2f",meanLayer), 42,0.4);
0313 } else {
0314 legend = GetAndSetLegend2( 0.4, 0.93-lineBottom*0.85*textSizeRel, 0.95, 0.93-2*0.85*textSizeRel,0.75*textSizeRel, 5, Form("Layer, #LTlayer#GT = %.2f",meanLayer), 42,0.2);
0315 }
0316 for (int l = 0; l< setup->GetNMaxLayer()+1; l++){
0317 if (Exaxis & frebin)histLayer[l]->Rebin(4);
0318 SetLineDefaults(histLayer[l], GetColorLayer(l), 4, GetLineStyleLayer(l));
0319 histLayer[l]->Draw("same,hist");
0320 if (maxLayer == l)
0321 legend->AddEntry(histLayer[l],Form("#bf{%d}",l),"l");
0322 else
0323 legend->AddEntry(histLayer[l],Form("%d",l),"l");
0324 }
0325 histLayer[0]->DrawCopy("axis,same");
0326 legend->Draw();
0327
0328 DrawLatex(0.95, 0.92, Form("#it{#bf{LFHCal TB:} %s}",GetStringFromRunInfo(currRunInfo,7).Data()), true, 0.85*textSizeRel, 42);
0329 DrawLatex(0.95, 0.885, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0330 if (additionalLabel.CompareTo("") != 0){
0331 DrawLatex(0.95, 0.885-textSizeRel, additionalLabel, true, 0.85*textSizeRel, 42);
0332 }
0333 if ( setup->GetNMaxLayer()+1 == 64 && (NCellsxaxis || Posxaxis))
0334 lineBottom--;
0335 DrawLatex(0.95, 0.935-(lineBottom+1)*0.85*textSizeRel, "#bf{bold #} indicates max layer", true, 0.75*textSizeRel, 42);
0336
0337 canvas2D->SaveAs(nameOutput.Data());
0338 }
0339
0340
0341
0342
0343
0344 void PlotSimple2DZRange( TCanvas* canvas2D,
0345 TH2* hist, Int_t maxy, Int_t maxx, double minZ, double maxZ,
0346 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0347 int labelOpt = 1, TString drwOpt ="colz",
0348 bool blegAbove = false, TString additionalLabel = ""
0349 ){
0350 canvas2D->cd();
0351 SetStyleHistoTH2ForGraphs( hist, hist->GetXaxis()->GetTitle(), hist->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.9, 1.05);
0352 hist->GetZaxis()->SetLabelSize(0.85*textSizeRel);
0353 hist->GetZaxis()->SetTitleOffset(1.06);
0354 hist->GetZaxis()->SetTitleSize(textSizeRel);
0355
0356
0357 if (maxy > -10000)hist->GetYaxis()->SetRangeUser(-0.5,maxy+0.1);
0358 if (maxx > -10000)hist->GetXaxis()->SetRangeUser(0.5,maxx+0.1);
0359 hist->GetZaxis()->SetRangeUser(minZ,maxZ);
0360
0361 if (((TString)hist->GetZaxis()->GetTitle()).Contains("counts")){
0362 gStyle->SetPaintTextFormat(".0f");
0363 std::cout << "entered counts case" << std::endl;
0364 } else {
0365 gStyle->SetPaintTextFormat(".3f");
0366 }
0367 hist->Draw(drwOpt.Data());
0368
0369 if (!blegAbove)
0370 DrawLatex(0.85, 0.92, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0371 else
0372 DrawLatex(0.92, 0.97, GetStringFromRunInfo(currRunInfo,labelOpt), true, 0.85*textSizeRel, 42);
0373
0374 if (additionalLabel.CompareTo("") != 0){
0375 if (!blegAbove)
0376 DrawLatex(0.11, 0.92, additionalLabel, false, 0.85*textSizeRel, 42);
0377 else
0378 DrawLatex(0.08, 0.97, additionalLabel, false, 0.85*textSizeRel, 42);
0379 }
0380 canvas2D->SaveAs(nameOutput.Data());
0381 }
0382
0383
0384
0385
0386
0387 void PlotMipWithFitsSingleTile (TCanvas* canvasSingleTile, Double_t topRCornerX, Double_t topRCornerY, Double_t relSize, Int_t textSizePixel,
0388 std::map<int,TileSpectra> spectra, std::map<int,TileSpectra> spectraTrigg,
0389 bool isHG, Double_t xPMin, Double_t xPMax, Double_t scaleYMax,
0390 int cellID, TString nameOutput, RunInfo currRunInfo){
0391
0392 Double_t maxY = 0;
0393 std::map<int, TileSpectra>::iterator ithSpectra;
0394 std::map<int, TileSpectra>::iterator ithSpectraTrigg;
0395
0396 Setup* setupT = Setup::GetInstance();
0397 int row = setupT->GetRow(cellID);
0398 int col = setupT->GetColumn(cellID);
0399 int lay = setupT->GetLayer(cellID);
0400 int mod = setupT->GetModule(cellID);
0401
0402 ithSpectra=spectra.find(cellID);
0403 ithSpectraTrigg=spectraTrigg.find(cellID);
0404 if(ithSpectra==spectra.end()){
0405 std::cout << "WARNING: skipping cell ID: " << cellID << "\t row " << row << "\t column " << col << "\t layer " << lay << "\t module " << mod << std::endl;
0406 return;
0407 }
0408 TH1D* tempHist = nullptr;
0409 if (isHG){
0410 tempHist = ithSpectra->second.GetHG();
0411 } else {
0412 tempHist = ithSpectra->second.GetLG();
0413 }
0414 if (maxY < FindLargestBin1DHist(tempHist, xPMin , xPMax)) maxY = FindLargestBin1DHist(tempHist, xPMin , xPMax);
0415
0416
0417 canvasSingleTile->cd();
0418 canvasSingleTile->SetLogy();
0419
0420 double noiseWidth = 0;
0421 if (isHG){
0422 noiseWidth = ithSpectra->second.GetCalib()->PedestalSigH;
0423 } else {
0424 noiseWidth = ithSpectra->second.GetCalib()->PedestalSigL;
0425 }
0426 SetStyleHistoTH1ForGraphs( tempHist, tempHist->GetXaxis()->GetTitle(), tempHist->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.1, 510, 510, 43, 63);
0427 SetMarkerDefaults(tempHist, 20, 1.8, kBlue+1, kBlue+1, kFALSE);
0428 tempHist->GetXaxis()->SetRangeUser(xPMin,xPMax);
0429 tempHist->GetYaxis()->SetRangeUser(0.7,scaleYMax*maxY);
0430
0431 tempHist->Draw("pe");
0432 short bctemp = ithSpectra->second.GetCalib()->BadChannel;
0433 if (bctemp != -64 && bctemp < 3){
0434 Color_t boxCol = kGray;
0435 if (bctemp == 1)
0436 boxCol = kGray+1;
0437 else if (bctemp == 0)
0438 boxCol = kGray+2;
0439 TBox* badChannelArea = CreateBox(boxCol, xPMin, 0.7, xPMax,scaleYMax*maxY, 1001 );
0440 badChannelArea->Draw();
0441 tempHist->Draw("same,axis");
0442 tempHist->Draw("same,pe");
0443 }
0444
0445 TH1D* tempHistT = nullptr;
0446
0447 if (isHG){
0448 tempHistT = ithSpectraTrigg->second.GetHG();
0449 } else {
0450 tempHistT = ithSpectraTrigg->second.GetLG();
0451 }
0452 SetMarkerDefaults(tempHistT, 24, 1.8, kRed+1, kRed+1, kFALSE);
0453 tempHistT->Draw("same,pe");
0454
0455 double lineHeight = 1.05*relSize;
0456 DrawLatex(topRCornerX, topRCornerY-1*lineHeight, Form("#it{#bf{LFHCal TB}}: #it{%s}",GetStringFromRunInfo(currRunInfo, 6).Data()), true, relSize, 42);
0457 DrawLatex(topRCornerX, topRCornerY-2*lineHeight, GetStringFromRunInfo(currRunInfo, 1), true,relSize, 42);
0458 DrawLatex(topRCornerX, topRCornerY-3*lineHeight, Form("cell %d: row %d col %d layer %d", cellID, row, col, lay), true, relSize, 42);
0459
0460 TF1* fit = nullptr;
0461 bool isTrigFit = false;
0462 double maxFit = 0;
0463 if (isHG){
0464 fit = ithSpectraTrigg->second.GetSignalModel(1);
0465 if (!fit){
0466 fit = ithSpectra->second.GetSignalModel(1);
0467 if (fit){
0468 maxFit = ithSpectra->second.GetCalib()->ScaleH;
0469 }
0470 } else {
0471 isTrigFit = true;
0472 maxFit = ithSpectraTrigg->second.GetCalib()->ScaleH;
0473 }
0474 } else {
0475 fit = ithSpectraTrigg->second.GetSignalModel(0);
0476 if (!fit){
0477 fit = ithSpectra->second.GetSignalModel(0);
0478 if (fit){
0479 maxFit = ithSpectra->second.GetCalib()->ScaleL;
0480 }
0481 } else {
0482 isTrigFit = true;
0483 maxFit = ithSpectraTrigg->second.GetCalib()->ScaleL;
0484 }
0485 }
0486 if (fit){
0487 if (isTrigFit)
0488 SetStyleFit(fit , 0, 2000, 20, 3, kRed+3);
0489 else
0490 SetStyleFit(fit , 0, 2000, 20, 7, kBlue+3);
0491 fit->Draw("same");
0492 TLegend* legend = GetAndSetLegend2( topRCornerX-9*relSize, topRCornerY-6*lineHeight, topRCornerX-0.04, topRCornerY-3.2*lineHeight,0.85*textSizePixel, 1, "", 43,0.1);
0493 if (isTrigFit)
0494 legend->AddEntry(fit, "Landau-Gauss fit, trigg.", "l");
0495 else
0496 legend->AddEntry(fit, "Landau-Gauss fit", "l");
0497 legend->AddEntry((TObject*)0, Form("#scale[0.8]{L MPV = %2.2f #pm %2.2f}",fit->GetParameter(1), fit->GetParError(1) ) , " ");
0498 legend->AddEntry((TObject*)0, Form("#scale[0.8]{Max = %2.2f}", maxFit ) , " ");
0499 legend->Draw();
0500 DrawLines(maxFit, maxFit,0.7, scaleYMax*maxY/10, 15, kRed+3, 7);
0501 }
0502
0503 DrawLines(noiseWidth*3, noiseWidth*3,0.7, scaleYMax*maxY, 8, kGray+1, 10);
0504 DrawLines(noiseWidth*5, noiseWidth*5,0.7, scaleYMax*maxY, 8, kGray+1, 6);
0505
0506 canvasSingleTile->SaveAs(nameOutput.Data());
0507 }
0508
0509
0510
0511
0512
0513 void EventDisplayWithSliceHighlighted( TH3F* h3All, TH1D* h1XAll, TH1D* h1YAll, TH1D* h1ZAll,
0514 TH3F* h3LocTrigg, TH1D* h1XLocTrigg, TH1D* h1YLocTrigg, TH1D* h1ZLocTrigg,
0515 TH3F* h3Remain, TH1D* h1XRemain, TH1D* h1YRemain, TH1D* h1ZRemain,
0516 Int_t evtNr, Float_t etot, Float_t maxE,
0517 Float_t maxEX, Float_t maxEY, Float_t maxEZ, bool ktrigg,
0518 RunInfo currRunInfo, TString outputName, TString suffix = "pdf"
0519 ){
0520 Double_t textSizeRel = 0.035;
0521 Double_t textSizeSubpad = 0.06;
0522
0523 TCanvas* canvas3D2 = new TCanvas("canvas3D2","",0,0,1400,750);
0524
0525 TPad* padEvt[4];
0526 padEvt[0] = new TPad("pad_0", "", 0, 0, 0.75, 0.9,-1, -1, -2);
0527 padEvt[1] = new TPad("pad_1", "", 0.75, 0.66, 1, 1,-1, -1, -2);
0528 padEvt[2] = new TPad("pad_2", "", 0.75, 0.33, 1, 0.66,-1, -1, -2);
0529 padEvt[3] = new TPad("pad_3", "", 0.75, 0., 1., 0.33,-1, -1, -2);
0530
0531 DefaultPadSettings( padEvt[0], 0.04, 0.02, 0.0, 0.1);
0532 padEvt[0]->SetFillStyle(4000);
0533 padEvt[0]->SetLineStyle(0);
0534 DefaultPadSettings( padEvt[1], 0.12, 0.015, 0.02, 0.12);
0535 padEvt[1]->SetFillStyle(4000);
0536 padEvt[1]->SetLineStyle(0);
0537 DefaultPadSettings( padEvt[2], 0.12, 0.015, 0.02, 0.12);
0538 padEvt[2]->SetFillStyle(4000);
0539 padEvt[2]->SetLineStyle(0);
0540 DefaultPadSettings( padEvt[3], 0.12, 0.015, 0.02, 0.12);
0541 padEvt[3]->SetFillStyle(4000);
0542 padEvt[3]->SetLineStyle(0);
0543
0544 canvas3D2->Draw();
0545 canvas3D2->cd();
0546
0547 DrawLatex(0.01, 0.95, Form("#it{#bf{LFHCal TB}}: #it{%s}",GetStringFromRunInfo(currRunInfo, 6).Data()), false, textSizeRel, 42);
0548 DrawLatex(0.01, 0.92, GetStringFromRunInfo(currRunInfo, 1), false, 0.85*textSizeRel, 42);
0549 if(ktrigg) DrawLatex(0.01, 0.89, Form("Event %d, muon triggered",evtNr), false, 0.85*textSizeRel, 42);
0550 else DrawLatex(0.01, 0.89, Form("Event %d",evtNr), false, 0.85*textSizeRel, 42);
0551 DrawLatex(0.01, 0.86, Form("#it{E}_{tot} = %.2f mip eq/tile", etot), false, 0.85*textSizeRel, 42);
0552 DrawLatex(0.01, 0.83, Form("#it{E}_{max,cell} = %.2f mip eq/tile", maxE), false, 0.85*textSizeRel, 42);
0553
0554 padEvt[0]->Draw();
0555 padEvt[0]->cd();
0556 padEvt[0]->SetTheta(50);
0557 padEvt[0]->SetPhi(40);
0558
0559 SetStyleHistoTH3ForGraphs(h3All, "#it{z} (cm) ", " #it{x} (cm)","#it{y} (cm)", 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 1.5, 1.3, 0.7, 510, 505, 502);
0560 h3All->GetXaxis()->SetLabelOffset(-0.004);
0561 h3All->GetYaxis()->SetLabelOffset(-0.002);
0562 SetStyleHistoTH3ForGraphs(h3LocTrigg, "#it{z} (cm) ", "#it{x} (cm)","#it{y} (cm)", 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 1.5, 1.6, 0.6, 510, 505, 502);
0563 SetStyleHistoTH3ForGraphs(h3Remain, "#it{z} (cm) ", "#it{x} (cm)","#it{y} (cm)", 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 1.5, 1.6, 0.6, 510, 505, 502);
0564 h3All->SetMaximum(maxE);
0565 h3All->SetLineColor(kBlack);
0566 h3All->Draw("box");
0567 h3Remain->SetMaximum(maxE);
0568 h3Remain->SetLineColor(kBlue+1);
0569 h3Remain->Draw("box,same,X+,Y+,Z+");
0570 h3LocTrigg->SetMaximum(maxE);
0571 h3LocTrigg->SetLineColor(kRed+1);
0572 h3LocTrigg->SetFillColorAlpha(kRed+1, 0.5);
0573 h3LocTrigg->Draw("BOX3,same");
0574
0575 canvas3D2->cd();
0576 padEvt[1]->Draw();
0577 padEvt[1]->cd();
0578 SetStyleHistoTH1ForGraphs( h1XAll, "#it{x} (cm)", "#it{E} (mip eq./tile)", 0.85*textSizeSubpad, textSizeSubpad, 0.85*textSizeSubpad, textSizeSubpad,0.9, 0.9);
0579 SetMarkerDefaults(h1XAll, 24, 1, kBlack, kBlack, kFALSE);
0580 SetMarkerDefaults(h1XLocTrigg, 20, 0.8, kRed+1, kRed+1, kFALSE);
0581 SetMarkerDefaults(h1XRemain, 34, 0.8, kBlue+1, kBlue+1, kFALSE);
0582 h1XAll->GetYaxis()->SetRangeUser(0.,1.1*maxEX);
0583 h1XAll->Draw("pe");
0584 h1XLocTrigg->Draw("pe,same");
0585 h1XRemain->Draw("pe,same");
0586 canvas3D2->cd();
0587 padEvt[2]->Draw();
0588 padEvt[2]->cd();
0589 SetStyleHistoTH1ForGraphs( h1YAll, "#it{y} (cm)", "#it{E} (mip eq./tile)", 0.85*textSizeSubpad, textSizeSubpad, 0.85*textSizeSubpad, textSizeSubpad,0.9, 0.9);
0590 SetMarkerDefaults(h1YAll, 24, 1, kBlack, kBlack, kFALSE);
0591 SetMarkerDefaults(h1YLocTrigg, 20, 0.8, kRed+1, kRed+1, kFALSE);
0592 SetMarkerDefaults(h1YRemain, 34, 0.8, kBlue+1, kBlue+1, kFALSE);
0593 h1YAll->GetYaxis()->SetRangeUser(0.,1.1*maxEY);
0594 h1YAll->Draw("pe");
0595 h1YLocTrigg->Draw("pe,same");
0596 h1YRemain->Draw("pe,same");
0597
0598 canvas3D2->cd();
0599 padEvt[3]->Draw();
0600 padEvt[3]->cd();
0601 SetStyleHistoTH1ForGraphs( h1ZAll, "#it{z} (cm)", "#it{E} (mip eq./tile)", 0.85*textSizeSubpad, textSizeSubpad, 0.85*textSizeSubpad, textSizeSubpad,0.9, 0.9);
0602 SetMarkerDefaults(h1ZAll, 24, 1, kBlack, kBlack, kFALSE);
0603 SetMarkerDefaults(h1ZLocTrigg, 20, 0.8, kRed+1, kRed+1, kFALSE);
0604 SetMarkerDefaults(h1ZRemain, 34, 0.8, kBlue+1, kBlue+1, kFALSE);
0605 h1ZAll->GetYaxis()->SetRangeUser(0.,1.1*maxEZ);
0606 h1ZAll->Draw("pe");
0607 h1ZLocTrigg->Draw("pe,same");
0608 h1ZRemain->Draw("pe,same");
0609
0610 canvas3D2->cd();
0611 TLegend* legend = GetAndSetLegend2( 0.6, 0.89, 0.75, 0.97, 0.85*textSizeRel, 1, "", 42, 0.2);
0612 legend->AddEntry(h1ZAll, "all cells", "pl");
0613 legend->AddEntry(h1ZLocTrigg, "local #mu triggered", "pl");
0614 legend->AddEntry(h1ZRemain, "remaining cells", "pl");
0615 legend->Draw();
0616
0617 canvas3D2->SaveAs( Form("%s%06i.%s", outputName.Data(), evtNr, suffix.Data()));
0618
0619 delete padEvt[0];
0620 delete padEvt[1];
0621 delete padEvt[2];
0622 delete padEvt[3];
0623 delete legend;
0624 delete canvas3D2;
0625 return;
0626 }
0627
0628
0629
0630
0631 void EventDisplayWithSlice( TH3F* h3All, TH1D* h1XAll, TH1D* h1YAll, TH1D* h1ZAll,
0632 Int_t evtNr, Float_t etot, Float_t maxE,
0633 Float_t maxEX, Float_t maxEY, Float_t maxEZ, bool ktrigg,
0634 RunInfo currRunInfo, TString outputName, TString suffix = "pdf"
0635 ){
0636 Double_t textSizeRel = 0.035;
0637 Double_t textSizeSubpad = 0.06;
0638
0639 TCanvas* canvas3D2 = new TCanvas("canvas3D2","",0,0,1400,750);
0640
0641 TPad* padEvt[4];
0642 padEvt[0] = new TPad("pad_0", "", 0, 0, 0.75, 0.9,-1, -1, -2);
0643 padEvt[1] = new TPad("pad_1", "", 0.75, 0.66, 1, 1,-1, -1, -2);
0644 padEvt[2] = new TPad("pad_2", "", 0.75, 0.33, 1, 0.66,-1, -1, -2);
0645 padEvt[3] = new TPad("pad_3", "", 0.75, 0., 1., 0.33,-1, -1, -2);
0646
0647 DefaultPadSettings( padEvt[0], 0.04, 0.02, 0.0, 0.1);
0648 padEvt[0]->SetFillStyle(4000);
0649 padEvt[0]->SetLineStyle(0);
0650 DefaultPadSettings( padEvt[1], 0.12, 0.015, 0.02, 0.12);
0651 padEvt[1]->SetFillStyle(4000);
0652 padEvt[1]->SetLineStyle(0);
0653 DefaultPadSettings( padEvt[2], 0.12, 0.015, 0.02, 0.12);
0654 padEvt[2]->SetFillStyle(4000);
0655 padEvt[2]->SetLineStyle(0);
0656 DefaultPadSettings( padEvt[3], 0.12, 0.015, 0.02, 0.12);
0657 padEvt[3]->SetFillStyle(4000);
0658 padEvt[3]->SetLineStyle(0);
0659
0660 canvas3D2->Draw();
0661 canvas3D2->cd();
0662
0663 DrawLatex(0.01, 0.95, Form("#it{#bf{LFHCal TB}}: #it{%s}",GetStringFromRunInfo(currRunInfo, 6).Data()), false, textSizeRel, 42);
0664 DrawLatex(0.01, 0.92, GetStringFromRunInfo(currRunInfo, 1), false, 0.85*textSizeRel, 42);
0665 if(ktrigg) DrawLatex(0.01, 0.89, Form("Event %d, muon triggered",evtNr), false, 0.85*textSizeRel, 42);
0666 else DrawLatex(0.01, 0.89, Form("Event %d",evtNr), false, 0.85*textSizeRel, 42);
0667 DrawLatex(0.01, 0.86, Form("#it{E}_{tot} = %.2f mip eq/tile", etot), false, 0.85*textSizeRel, 42);
0668 DrawLatex(0.01, 0.83, Form("#it{E}_{max,cell} = %.2f mip eq/tile", maxE), false, 0.85*textSizeRel, 42);
0669
0670 padEvt[0]->Draw();
0671 padEvt[0]->cd();
0672 padEvt[0]->SetTheta(50);
0673 padEvt[0]->SetPhi(40);
0674
0675 SetStyleHistoTH3ForGraphs(h3All, "#it{z} (cm) ", " #it{x} (cm)","#it{y} (cm)", 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 0.65*textSizeRel,0.85*textSizeRel, 1.5, 1.3, 0.7, 510, 505, 502);
0676 h3All->GetXaxis()->SetLabelOffset(-0.004);
0677 h3All->GetYaxis()->SetLabelOffset(-0.002);
0678 h3All->SetMaximum(maxE);
0679 h3All->SetFillColor(kBlue+1);
0680 h3All->SetLineColor(kBlue+1);
0681 h3All->Draw("box1");
0682
0683 canvas3D2->cd();
0684 padEvt[1]->Draw();
0685 padEvt[1]->cd();
0686 SetStyleHistoTH1ForGraphs( h1XAll, "#it{x} (cm)", "#it{E} (mip eq./tile)", 0.85*textSizeSubpad, textSizeSubpad, 0.85*textSizeSubpad, textSizeSubpad,0.9, 0.9);
0687 SetMarkerDefaults(h1XAll, 24, 1, kBlue+1, kBlue+1, kFALSE);
0688 h1XAll->GetYaxis()->SetRangeUser(0.,1.1*maxEX);
0689 h1XAll->Draw("pe");
0690 canvas3D2->cd();
0691
0692 padEvt[2]->Draw();
0693 padEvt[2]->cd();
0694 SetStyleHistoTH1ForGraphs( h1YAll, "#it{y} (cm)", "#it{E} (mip eq./tile)", 0.85*textSizeSubpad, textSizeSubpad, 0.85*textSizeSubpad, textSizeSubpad,0.9, 0.9);
0695 SetMarkerDefaults(h1YAll, 24, 1, kBlue+1, kBlue+1, kFALSE);
0696 h1YAll->GetYaxis()->SetRangeUser(0.,1.1*maxEY);
0697 h1YAll->Draw("pe");
0698
0699 canvas3D2->cd();
0700 padEvt[3]->Draw();
0701 padEvt[3]->cd();
0702 SetStyleHistoTH1ForGraphs( h1ZAll, "#it{z} (cm)", "#it{E} (mip eq./tile)", 0.85*textSizeSubpad, textSizeSubpad, 0.85*textSizeSubpad, textSizeSubpad,0.9, 0.9);
0703 SetMarkerDefaults(h1ZAll, 24, 1, kBlue+1, kBlue+1, kFALSE);
0704 h1ZAll->GetYaxis()->SetRangeUser(0.,1.1*maxEZ);
0705 h1ZAll->Draw("pe");
0706
0707 canvas3D2->cd();
0708 canvas3D2->SaveAs( Form("%s%06i.%s", outputName.Data(), evtNr, suffix.Data()));
0709
0710 delete padEvt[0];
0711 delete padEvt[1];
0712 delete padEvt[2];
0713 delete padEvt[3];
0714 delete canvas3D2;
0715 return;
0716 }
0717
0718
0719
0720
0721 void PlotCalibRunOverlay( TCanvas* canvas2D, Int_t option,
0722 std::map<int, CalibSummary> sumRuns,
0723 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0724
0725 TString additionalLabel = "", int debug = 0
0726 ){
0727
0728 Double_t minY = 0;
0729 Double_t maxY = 0;
0730 Double_t minX = 9999;
0731 Double_t maxX = 0;
0732 bool isSameVoltage = true;
0733 double commanVoltage = 0;
0734
0735 std::map<int, CalibSummary>::iterator itrun;
0736 Int_t nruns = 0;
0737 for(itrun=sumRuns.begin(); itrun!=sumRuns.end(); ++itrun){
0738 TH1D* tempH = nullptr;
0739 if (option==0) tempH = itrun->second.GetHGped();
0740 else if (option==1) tempH = itrun->second.GetHGpedwidth();
0741 else if (option==2) tempH = itrun->second.GetLGped();
0742 else if (option==3) tempH = itrun->second.GetLGpedwidth();
0743 else if (option==4) tempH = itrun->second.GetHGScale();
0744 else if (option==5) tempH = itrun->second.GetHGScalewidth();
0745 else if (option==6) tempH = itrun->second.GetLGScale();
0746 else if (option==7) tempH = itrun->second.GetLGScalewidth();
0747 else if (option==8) tempH = itrun->second.GetLGHGcorr();
0748 else if (option==9) tempH = itrun->second.GetHGLGcorr();
0749 else if (option==10) tempH = itrun->second.GetLGScaleCalc();
0750 else if (option==11) tempH = itrun->second.GetLGHGOffcorr();
0751 else if (option==12) tempH = itrun->second.GetHGLGOffcorr();
0752 if (maxY < tempH->GetMaximum()) maxY = tempH->GetMaximum();
0753 if ( maxX < FindLastBinXAboveMin(tempH)) maxX = FindLastBinXAboveMin(tempH);
0754 if ( minX > FindFirstBinXAboveMin(tempH)) minX = FindFirstBinXAboveMin(tempH);
0755 if (nruns==0){
0756 commanVoltage = itrun->second.GetVoltage();
0757 } else {
0758 if (commanVoltage != itrun->second.GetVoltage()) isSameVoltage = false;
0759 }
0760 nruns++;
0761 }
0762
0763
0764 TString label2 = Form("Common V_{op} = %2.1f V", commanVoltage);
0765 canvas2D->cd();
0766
0767 TH1D* histos[30];
0768 if (debug > 0){
0769 if (nruns > 30) std::cout << "more than 30 runs are included in this, only 30 will be plotted, currently " << nruns << "\t runs were requested" << std::endl;
0770 else std::cout << nruns << " will be plotted" << std::endl;
0771 }
0772 double lineBottom = 6;
0773 if (nruns < 6) lineBottom = 1;
0774 else if (nruns < 11) lineBottom = 2;
0775 else if (nruns < 16) lineBottom = 3;
0776 else if (nruns < 21) lineBottom = 4;
0777 else if (nruns < 26) lineBottom = 5;
0778 TLegend* legend = GetAndSetLegend2( 0.55, 0.88-lineBottom*textSizeRel, 0.95, 0.88,
0779 0.85*textSizeRel, 5, "",42,0.35);;
0780 int currRun = 0;
0781 for(itrun=sumRuns.begin(); (itrun!=sumRuns.end()) && (currRun < 30); ++itrun){
0782 histos[currRun] = nullptr;
0783 if (option==0) histos[currRun] = itrun->second.GetHGped();
0784 else if (option==1) histos[currRun] = itrun->second.GetHGpedwidth();
0785 else if (option==2) histos[currRun] = itrun->second.GetLGped();
0786 else if (option==3) histos[currRun] = itrun->second.GetLGpedwidth();
0787 else if (option==4) histos[currRun] = itrun->second.GetHGScale();
0788 else if (option==5) histos[currRun] = itrun->second.GetHGScalewidth();
0789 else if (option==6) histos[currRun] = itrun->second.GetLGScale();
0790 else if (option==7) histos[currRun] = itrun->second.GetLGScalewidth();
0791 else if (option==8) histos[currRun] = itrun->second.GetLGHGcorr();
0792 else if (option==9) histos[currRun] = itrun->second.GetHGLGcorr();
0793 else if (option==10) histos[currRun] = itrun->second.GetLGScaleCalc();
0794 else if (option==11) histos[currRun] = itrun->second.GetLGHGOffcorr();
0795 else if (option==12) histos[currRun] = itrun->second.GetHGLGOffcorr();
0796 SetStyleHistoTH1ForGraphs( histos[currRun], histos[currRun]->GetXaxis()->GetTitle(), histos[currRun]->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.95, 1.02);
0797 SetLineDefaults(histos[currRun], GetColorLayer(currRun), 4, GetLineStyleLayer(currRun));
0798 if(currRun == 0){
0799 histos[currRun]->GetXaxis()->SetRangeUser(minX-5*histos[currRun]->GetBinWidth(1),maxX+5*histos[currRun]->GetBinWidth(1));
0800 histos[currRun]->GetYaxis()->SetRangeUser(minY,maxY*1.1);
0801 histos[currRun]->Draw("hist");
0802 } else {
0803 histos[currRun]->Draw("same,hist");
0804 }
0805 legend->AddEntry(histos[currRun],Form("%d",itrun->first),"l");
0806 currRun++;
0807 }
0808 histos[0]->DrawCopy("axis,same");
0809 legend->Draw();
0810
0811 DrawLatex(0.95, 0.92, Form("#it{#bf{LFHCal TB:} %s}",GetStringFromRunInfo(currRunInfo,7).Data()), true, 0.85*textSizeRel, 42);
0812 DrawLatex(0.95, 0.885, GetStringFromRunInfo(currRunInfo,8), true, 0.85*textSizeRel, 42);
0813 if (isSameVoltage)
0814 DrawLatex(0.95, 0.88-0.5*0.85*textSizeRel-lineBottom*textSizeRel , label2, true, 0.85*textSizeRel, 42);
0815
0816 canvas2D->SaveAs(nameOutput.Data());
0817 }
0818
0819
0820
0821
0822 void PlotAnalysisComparison( TCanvas* canvas2D, Int_t option,
0823 std::map<int, AnaSummary> sumRuns,
0824 Float_t textSizeRel, TString nameOutput, RunInfo currRunInfo,
0825
0826 TString additionalLabel = "", int debug = 0
0827 ){
0828
0829 Double_t minY = 0.1;
0830 Double_t maxY = 0;
0831 Double_t minX = 9999;
0832 Double_t maxX = 0;
0833 bool isSameVoltage = true;
0834 double commanVoltage = 0;
0835
0836 std::map<int, AnaSummary>::iterator itrun;
0837 Int_t nruns = 0;
0838 for(itrun=sumRuns.begin(); itrun!=sumRuns.end(); ++itrun){
0839 TH1D* tempH;
0840 if (option==0) tempH = itrun->second.GetDeltaTime();
0841 if (maxY < tempH->GetMaximum()) maxY = tempH->GetMaximum();
0842 if ( maxX < FindLastBinXAboveMin(tempH)) maxX = FindLastBinXAboveMin(tempH);
0843 if ( minX > FindFirstBinXAboveMin(tempH)) minX = FindFirstBinXAboveMin(tempH);
0844 if (nruns==0){
0845 commanVoltage = itrun->second.GetVoltage();
0846 } else {
0847 if (commanVoltage != itrun->second.GetVoltage()) isSameVoltage = false;
0848 }
0849 nruns++;
0850 }
0851
0852
0853 TString label2 = Form("Common V_{op} = %2.1f V", commanVoltage);
0854 canvas2D->cd();
0855 TH1D* histos[30];
0856 if (debug > 0){
0857 if (nruns > 30) std::cout << "more than 30 runs are included in this, only 30 will be plotted, currently " << nruns << "\t runs were requested" << std::endl;
0858 else std::cout << nruns << " will be plotted" << std::endl;
0859 }
0860 double lineBottom = 6;
0861 if (nruns < 6) lineBottom = 1;
0862 else if (nruns < 11) lineBottom = 2;
0863 else if (nruns < 16) lineBottom = 3;
0864 else if (nruns < 21) lineBottom = 4;
0865 else if (nruns < 26) lineBottom = 5;
0866 TLegend* legend = GetAndSetLegend2( 0.55, 0.88-lineBottom*textSizeRel, 0.95, 0.88,
0867 0.85*textSizeRel, 5, "",42,0.35);;
0868 int currRun = 0;
0869 for(itrun=sumRuns.begin(); (itrun!=sumRuns.end()) && (currRun < 30); ++itrun){
0870 histos[currRun] = nullptr;
0871 if (option==0) histos[currRun] = itrun->second.GetDeltaTime();
0872
0873 SetStyleHistoTH1ForGraphs( histos[currRun], histos[currRun]->GetXaxis()->GetTitle(), histos[currRun]->GetYaxis()->GetTitle(), 0.85*textSizeRel, textSizeRel, 0.85*textSizeRel, textSizeRel,0.95, 1.02);
0874 SetLineDefaults(histos[currRun], GetColorLayer(currRun), 4, GetLineStyleLayer(currRun));
0875 if(currRun == 0){
0876 histos[currRun]->GetXaxis()->SetRangeUser(minX-5*histos[currRun]->GetBinWidth(1),maxX+5*histos[currRun]->GetBinWidth(1));
0877 histos[currRun]->GetYaxis()->SetRangeUser(minY,maxY*1.1);
0878 histos[currRun]->Draw("hist");
0879
0880 } else {
0881 histos[currRun]->Draw("same,hist");
0882
0883 }
0884 legend->AddEntry(histos[currRun],Form("%d",itrun->second.GetRunNumber()),"l");
0885 currRun++;
0886 }
0887 histos[0]->DrawCopy("axis,same");
0888 legend->Draw();
0889
0890 DrawLatex(0.95, 0.92, Form("#it{#bf{LFHCal TB:} %s}",GetStringFromRunInfo(currRunInfo,7).Data()), true, 0.85*textSizeRel, 42);
0891 DrawLatex(0.95, 0.885, GetStringFromRunInfo(currRunInfo,8), true, 0.85*textSizeRel, 42);
0892 if (isSameVoltage)
0893 DrawLatex(0.95, 0.88-0.5*0.85*textSizeRel-lineBottom*textSizeRel , label2, true, 0.85*textSizeRel, 42);
0894
0895 canvas2D->SaveAs(nameOutput.Data());
0896 }
0897
0898 #endif