THStack and error bars

Hi experts,

I am trying to make a Data/MC comparison plot by stacking all MCs and overlaying data on the same pad. I use THStack for stacking all the MC histograms, now I want to draw summed error bar of all MCs on top of the stack plot. I tried doing this by TGraphError, but THStack doesnt support GetBinError(). I had Sumw2() setup while initializing the histograms. I also tried to add up the individual MC histogram into a new histogram to get the error, but it messed up the stack plot.

I am looking for suggestions.


I think you should do that to get the errors. THStack in only a container to group histograms together at plotting time. You should continue to plot the THStack but use the add up the individual MC histograms to get the errors.
Then you plot the Graph on top of the THStack (ie: no option A).

Yes I tried that, but somehow it is messing up THStack plots. I have attached a macro, slight modified tutorial macro. If you comment out lines 74-76 i.e. adding histograms to hfinal, ‘hs’ plots are fine, but if you add histograms to hfinal, it is changing ‘hs’. I am not sure what is happening.

Missed to attach the macro. Sorry about that, here it is.
plotter_skim.C (1.96 KB)

Ok. I got what I want. Initially I was adding all the histograms to a new histogram for getting the errors, but I could have done the same thing using TGraphError, by adding all y errors and values bin by bin for all the histograms!

Hi hari,

Can you post the macro that shows how you did this?
I am having the same problem…