From 880b4b1d7495d8fb8e9e4ca4bae1f69d38b9572d Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Tue, 3 Jun 2008 06:46:00 +0000 Subject: [PATCH] From Philippe: In TH1::Merge add support for merging histograms where bin labels are set and not all bins or same bins have a label set. This fixes the report: http://root.cern.ch/phpBB2/viewtopic.php?t=5767 git-svn-id: http://root.cern.ch/svn/root/trunk@24108 27541ba8-7e3a-0410-8455-c3a389f83636 --- hist/hist/src/TH1.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hist/hist/src/TH1.cxx b/hist/hist/src/TH1.cxx index ec87033da1e..1cf9d0c59a7 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -4985,13 +4985,19 @@ Long64_t TH1::Merge(TCollection *li) ix = fXaxis.FindBin(h->GetXaxis()->GetBinCenter(binx)); } else { const char* label=h->GetXaxis()->GetBinLabel(binx); - if (!label) label=""; - ix = fXaxis.FindBin(label); + if (!label || label[0]==0) { + ix = fXaxis.FindBin(h->GetXaxis()->GetBinCenter(binx)); + } else { + ix = fXaxis.FindBin(label); + if (ix==-1) ix = fXaxis.FindBin(h->GetXaxis()->GetBinCenter(binx)); + } } - if (ix >= 0) AddBinContent(ix,cu); - if (fSumw2.fN) { - Double_t error1 = h->GetBinError(binx); - fSumw2.fArray[ix] += error1*error1; + if (ix >= 0) { + AddBinContent(ix,cu); + if (fSumw2.fN) { + Double_t error1 = h->GetBinError(binx); + fSumw2.fArray[ix] += error1*error1; + } } } } -- GitLab