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

**URL:** <https://root-forum.cern.ch/t/histogram-th1d-with-two-error-bars-systematic-and-statistical-uncertainty/46079>\
**Category:** Newbie\
**Created:** [July 29, 2021, 8:08pm UTC](https://root-forum.cern.ch/t/histogram-th1d-with-two-error-bars-systematic-and-statistical-uncertainty/46079 "2021-07-29T20:08:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrramos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/b77776/32.png) [@rrramos](https://root-forum.cern.ch/u/rrramos)\
**Post date:** [July 29, 2021, 8:08pm UTC](https://root-forum.cern.ch/t/histogram-th1d-with-two-error-bars-systematic-and-statistical-uncertainty/46079/1 "2021-07-29T20:08:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [July 29, 2021, 8:37pm UTC](https://root-forum.cern.ch/t/histogram-th1d-with-two-error-bars-systematic-and-statistical-uncertainty/46079/2 "2021-07-29T20:37:34Z")

</div>

Hi,

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

Cheers, Axel.

---

<div class="post-metadata">

**Author:** ![rrramos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/b77776/32.png) [@rrramos](https://root-forum.cern.ch/u/rrramos)\
**Post date:** [July 29, 2021, 9:58pm UTC](https://root-forum.cern.ch/t/histogram-th1d-with-two-error-bars-systematic-and-statistical-uncertainty/46079/3 "2021-07-29T21:58:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [July 29, 2021, 10:07pm UTC](https://root-forum.cern.ch/t/histogram-th1d-with-two-error-bars-systematic-and-statistical-uncertainty/46079/4 "2021-07-29T22:07:45Z")

</div>

Hi,

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:

```c++
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.

---

<div class="post-metadata">

**Author:** ![rrramos](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/b77776/32.png) [@rrramos](https://root-forum.cern.ch/u/rrramos)\
**Post date:** [July 31, 2021, 4:50pm UTC](https://root-forum.cern.ch/t/histogram-th1d-with-two-error-bars-systematic-and-statistical-uncertainty/46079/5 "2021-07-31T16:50:46Z")

</div>

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