Skip to content

Commit

Permalink
[Common] support varibale bins in reference comparator output
Browse files Browse the repository at this point in the history
The changes allow to properly display histograms with variable bin
sizes in the output of the reference comparator task.
The variable bins support is introduced by using the `Clone()`
function to instantiate the internal histograms.
  • Loading branch information
aferrero2707 committed Sep 25, 2024
1 parent 396984b commit 1c9f72b
Showing 1 changed file with 17 additions and 36 deletions.
53 changes: 17 additions & 36 deletions Modules/Common/src/ReferenceComparatorPlot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,9 @@ class ReferenceComparatorPlotImpl1D : public ReferenceComparatorPlotImpl

// histogram from the current run
mPadHist->cd();
mPlot = std::make_shared<HIST>((canvasName + "_hist").c_str(), "",
referenceHistogram->GetXaxis()->GetNbins(),
referenceHistogram->GetXaxis()->GetXmin(),
referenceHistogram->GetXaxis()->GetXmax());
mPlot.reset((HIST*)referenceHistogram->Clone((canvasName + "_hist").c_str()));
mPlot->Reset();
mPlot->SetTitle("");
mPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mPlot->GetXaxis()->SetLabelSize(labelSize);
mPlot->GetXaxis()->SetTitleSize(labelSize);
Expand All @@ -211,20 +210,18 @@ class ReferenceComparatorPlotImpl1D : public ReferenceComparatorPlotImpl
mPlot->Draw(drawOption.c_str());

// histogram from the reference run
mReferencePlot = std::make_shared<HIST>((canvasName + "_hist_ref").c_str(), "",
referenceHistogram->GetXaxis()->GetNbins(),
referenceHistogram->GetXaxis()->GetXmin(),
referenceHistogram->GetXaxis()->GetXmax());
mReferencePlot.reset((HIST*)referenceHistogram->Clone((canvasName + "_hist_ref").c_str()));
mReferencePlot->Reset();
mReferencePlot->SetTitle("");
mReferencePlot->SetLineColor(kBlue);
mReferencePlot->SetOption((drawOption + "SAME").c_str());
mReferencePlot->Draw((drawOption + "SAME").c_str());

// histogram with current/reference ratio
mPadHistRatio->cd();
mRatioPlot = std::make_shared<HIST>((canvasName + "_hist_ratio").c_str(), "",
referenceHistogram->GetXaxis()->GetNbins(),
referenceHistogram->GetXaxis()->GetXmin(),
referenceHistogram->GetXaxis()->GetXmax());
mRatioPlot.reset((HIST*)referenceHistogram->Clone((canvasName + "_hist_ratio").c_str()));
mRatioPlot->Reset();
mRatioPlot->SetTitle("");
if (drawRatioOnly) {
mRatioPlot->SetTitle(referenceHistogram->GetTitle());
mRatioPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
Expand Down Expand Up @@ -369,14 +366,8 @@ class ReferenceComparatorPlotImpl2D : public ReferenceComparatorPlotImpl

// histogram from the current run
mPadHist->cd();
mPlot = std::make_shared<HIST>((canvasName + "_hist").c_str(),
referenceHistogram->GetTitle(),
referenceHistogram->GetXaxis()->GetNbins(),
referenceHistogram->GetXaxis()->GetXmin(),
referenceHistogram->GetXaxis()->GetXmax(),
referenceHistogram->GetYaxis()->GetNbins(),
referenceHistogram->GetYaxis()->GetXmin(),
referenceHistogram->GetYaxis()->GetXmax());
mPlot.reset((HIST*)referenceHistogram->Clone((canvasName + "_hist").c_str()));
mPlot->Reset();
mPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mPlot->GetYaxis()->SetTitle(referenceHistogram->GetYaxis()->GetTitle());
mPlot->SetStats(0);
Expand All @@ -385,14 +376,9 @@ class ReferenceComparatorPlotImpl2D : public ReferenceComparatorPlotImpl

// histogram from the reference run
mPadHistRef->cd();
mReferencePlot = std::make_shared<HIST>((canvasName + "_hist_ref").c_str(),
TString::Format("%s (reference)", referenceHistogram->GetTitle()),
referenceHistogram->GetXaxis()->GetNbins(),
referenceHistogram->GetXaxis()->GetXmin(),
referenceHistogram->GetXaxis()->GetXmax(),
referenceHistogram->GetYaxis()->GetNbins(),
referenceHistogram->GetYaxis()->GetXmin(),
referenceHistogram->GetYaxis()->GetXmax());
mReferencePlot.reset((HIST*)referenceHistogram->Clone((canvasName + "_hist_ref").c_str()));
mReferencePlot->Reset();
mReferencePlot->SetTitle(TString::Format("%s (reference)", referenceHistogram->GetTitle()));
mReferencePlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mReferencePlot->GetYaxis()->SetTitle(referenceHistogram->GetYaxis()->GetTitle());
mReferencePlot->SetStats(0);
Expand All @@ -401,14 +387,9 @@ class ReferenceComparatorPlotImpl2D : public ReferenceComparatorPlotImpl

// histogram with current/reference ratio
mPadHistRatio->cd();
mRatioPlot = std::make_shared<HIST>((canvasName + "_hist_ratio").c_str(),
TString::Format("%s (ratio)", referenceHistogram->GetTitle()),
referenceHistogram->GetXaxis()->GetNbins(),
referenceHistogram->GetXaxis()->GetXmin(),
referenceHistogram->GetXaxis()->GetXmax(),
referenceHistogram->GetYaxis()->GetNbins(),
referenceHistogram->GetYaxis()->GetXmin(),
referenceHistogram->GetYaxis()->GetXmax());
mRatioPlot.reset((HIST*)referenceHistogram->Clone((canvasName + "_hist_ratio").c_str()));
mRatioPlot->Reset();
mRatioPlot->SetTitle(TString::Format("%s (ratio)", referenceHistogram->GetTitle()));
mRatioPlot->GetXaxis()->SetTitle(referenceHistogram->GetXaxis()->GetTitle());
mRatioPlot->GetYaxis()->SetTitle(referenceHistogram->GetYaxis()->GetTitle());
if (!drawRatioOnly) {
Expand Down

0 comments on commit 1c9f72b

Please sign in to comment.