Hi,
I’m having quite a hard time trying to draw several objects on the same TPad. These objects are a THStack collection, a TH1D object and another TH1D…
I want to draw the THStack at the bottom of the graphics order, followed by one of the TH1D objects, and then the other. The final TH1D object is drawn with errorbars (“E”), this represents my data, and the other TH1D is simply a sum of all the objects in my THStack. (Total MC.)
I am aware that I cannot use anything to do with THStack->GetX/Yaxis() before drawing as the axis do not exist for THStack until they are drawn. (I don’t fully understand this.)
For example I can do
TH1D->GetYaxis()->SetRangeUser(...)
but not
THStack->GetYaxis()->SetRangeUser(...)
until THStack->Draw() is called.
Additionally, I don’t understand the difference between SetRangeUser()
and SetMaximum()
or SetMinimum()
. Which of these should I be using as a drawing option to set the axis range on a plot? Or does it not matter and they do the same thing?
So my problem is this: I do not know how to set the axis limits of the THStack before drawing the other objects.
I tried drawing the “total MC” first using the drawing option “axis”, however my code then crashed later on. (I haven’t figured out why yet. The crash happens when I call TCanvas->SaveAs()
I believe. Not 100% sure aboutt this yet.)
Any help/advice would be appreciated.
So to summarize, I want to
- draw THStack
- draw TH1D with option “hist”
- draw TH1D with option “E”
- do this such that my axis range is fixed between (for example) 0 and 1000
How does ROOT want me to that?