Histogram TH1D with two error bars (systematic and statistical uncertainty)

Hello everyone!

I have two histograms TH1D, containing the same information about the content of the bins but each one has different error bars, one with systematic uncertainty and the other with statistical uncertainty. What I want to do is join these two histogram into only one but now with two errors bars. I see that I can do this with TGraphMultiErrors but I want to do this for TH1D. Can I do that? It is possible? If yes, how? And when I make a fit, it will considering the statistical or systematic uncertainty??

Thank you very much!
Best regards.


I first need to understand why you want to do this. Is this for drawing or for uncertainly evaluation?

Cheers, Axel.

Hi Axel!!

Actually, is for this two case. I want to draw but before I want to make a BlastWave fit on my spectrum, maybe considering just the systematic uncertainty if I need to choose one.

If you could help me I would be very grateful!!1


OK - you already have the uncertainties separate, so your second use case should be covered, right?

For the first one, what people usually do is to create an “artificial” histogram on which they set, for each bin, the uncertainly:

TH1* histJustUsedForDrawing = (TH1*) histWithStatUncert->Clone("histJustUsedForDrawing");
for (int ibin = ...) {
  double errStat = histWithStatUncert->GetBinError(ibin);
  double errSys = histWithSysUncert->GetBinError(ibin);
  histJustUsedForDrawing->SetBinError(ibin, sqrt(errSys*errSys + errStat*errStat))

If you then draw this first and one of the others on top (histWithStatUncert->Draw("SAME")), possibly with different uncertainty “band” colors, it will show the two error “bands”.

Cheers, Axel.

It’s works, thank you very much!!!