From 98c87d1c46a0ba81318b3e0f1f6ffda35b0cb158 Mon Sep 17 00:00:00 2001
From: Ruth Pottgen <ruth.poettgen@cern.ch>
Date: Fri, 7 Feb 2020 13:23:03 +0000
Subject: [PATCH] Merge branch '21.0-pp-reference-replacement' into '21.0'

Fixed the saveHistogramToFileSuperimposed function to rescale the data when Reference is replaced.

See merge request atlas/athena!30165

(cherry picked from commit c3e4faf8701438c9051be2f7db0511f8ee08ada8)

0e675d1d Fixed the saveHistogramToFileSuperimposed function to rescale the data when Reference is replaced.
---
 .../DataQualityUtils/src/HanOutputFile.cxx    | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/DataQuality/DataQualityUtils/src/HanOutputFile.cxx b/DataQuality/DataQualityUtils/src/HanOutputFile.cxx
index 025fc8508df..f0b1565d1db 100644
--- a/DataQuality/DataQualityUtils/src/HanOutputFile.cxx
+++ b/DataQuality/DataQualityUtils/src/HanOutputFile.cxx
@@ -1659,9 +1659,22 @@ bool HanOutputFile::saveHistogramToFileSuperimposed( std::string nameHis, std::s
       convertToGraphics(cnvsType,myC.get(),namePNG,nameJSON);
 
     } else if( h != 0 && hist2!=0){
+      // Petronel
+      double scale = 1.0;
+	    if (display.find("ScaleRef")!=std::string::npos) {
+	      scale = getScaleVal(display);
+	    } else if ( h->Integral("width") > 0.0 && hist2->Integral("width") > 0.0 && (AlgoName.find("BinContentComp")==std::string::npos) && (display.find("NoNorm")==std::string::npos) ) {
+	      scale = h->Integral("width")/hist2->Integral("width");
+	    }            
+      hist2->Scale( scale );
+	    double ymin = ( hist2->GetMinimum() < h->GetMinimum() )? hist2->GetMinimum(): h->GetMinimum(); 
+	    double ymax = ( hist2->GetMaximum() > h->GetMaximum() )? hist2->GetMaximum(): h->GetMaximum();
+      double yMargin=(ymax-ymin)*0.05;
+      h->SetAxisRange(ymin-yMargin,ymax+yMargin,"Y");
+       
       h->SetMarkerColor(1);
       h->SetFillStyle(0);
-      h->SetLineWidth(2);
+      h->SetLineWidth(2);      
       hist2->SetMarkerColor(4);
       hist2->SetLineColor(4);
       hist2->SetFillStyle(0);
@@ -1679,8 +1692,12 @@ bool HanOutputFile::saveHistogramToFileSuperimposed( std::string nameHis, std::s
       legend->SetMargin(0.15);
       legend->SetFillStyle(0);
       legend->SetBorderSize(0);
-      legend->AddEntry(h,"Data1");
-      legend->AddEntry(hist2,"Data2");
+
+    std::size_t foundN1 = run_min_LB.find_first_of("-");
+    std::size_t foundN2 = run_min_LB.find_first_of(",");
+
+      legend->AddEntry(h,("Run "+run_min_LB.substr(5,foundN1-5)).c_str());
+      legend->AddEntry(hist2,("Run "+run_min_LB.substr(foundN1+1,foundN2-foundN1-1)).c_str());
       if(hRef){
 	legend->AddEntry(hRef,"Reference");
       }
-- 
GitLab