@@ -497,19 +497,23 @@ class ReferenceComparatorPlotImpl2D : public ReferenceComparatorPlotImpl
497497
498498ReferenceComparatorPlot::ReferenceComparatorPlot (TH1 * referenceHistogram, const std::string& outputPath, bool scaleReference, bool drawRatioOnly, const std::string& drawOption1D, const std::string& drawOption2D)
499499{
500- if (referenceHistogram->IsA () == TClass::GetClass<TH1F >() || referenceHistogram->InheritsFrom (" TH1F" )) {
500+ // histograms with integer values are promoted to floating point or double to allow correctly scaling the reference and computing the ratios
501+
502+ // 1-D histograms
503+ if (referenceHistogram->InheritsFrom (" TH1C" ) || referenceHistogram->InheritsFrom (" TH1S" ) || referenceHistogram->InheritsFrom (" TH1F" )) {
501504 mImplementation = std::make_shared<ReferenceComparatorPlotImpl1D<TH1F >>(referenceHistogram, outputPath, scaleReference, drawRatioOnly, drawOption1D);
502505 }
503506
504- if (referenceHistogram->IsA () == TClass::GetClass< TH1D >( ) || referenceHistogram->InheritsFrom (" TH1D" )) {
507+ if (referenceHistogram->InheritsFrom ( " TH1I " ) || referenceHistogram->InheritsFrom (" TH1D" )) {
505508 mImplementation = std::make_shared<ReferenceComparatorPlotImpl1D<TH1D >>(referenceHistogram, outputPath, scaleReference, drawRatioOnly, drawOption1D);
506509 }
507510
508- if (referenceHistogram->IsA () == TClass::GetClass<TH2F >() || referenceHistogram->InheritsFrom (" TH2F" )) {
511+ // 2-D histograms
512+ if (referenceHistogram->InheritsFrom (" TH2C" ) || referenceHistogram->InheritsFrom (" TH2S" ) || referenceHistogram->InheritsFrom (" TH2F" )) {
509513 mImplementation = std::make_shared<ReferenceComparatorPlotImpl2D<TH2F >>(referenceHistogram, outputPath, scaleReference, drawRatioOnly, drawOption2D);
510514 }
511515
512- if (referenceHistogram->IsA () == TClass::GetClass< TH2D >( ) || referenceHistogram->InheritsFrom (" TH2D" )) {
516+ if (referenceHistogram->InheritsFrom ( " TH2I " ) || referenceHistogram->InheritsFrom (" TH2D" )) {
513517 mImplementation = std::make_shared<ReferenceComparatorPlotImpl2D<TH2D >>(referenceHistogram, outputPath, scaleReference, drawRatioOnly, drawOption2D);
514518 }
515519}
0 commit comments