Ankur
August 15, 2022, 10:39am
1
I plotted the histogram given below:
h221=(TH1D*)f->Get("hrate_all_rule0");
I calculated the errors (not the one produced by GetBinError, default by ROOT ) for the above histogram and stored them in:
TH1D *errACP0NH_295 =(TH1D*)sumACP0NH_295->Clone("errACP0NH_295");
Now I want to call the BinContent from ** errACP0NH_295 * and plot as vertical error bars for the histogram h221 on the same pad.
How should I do it?
ROOT Version: 6.24/02
Platform: Focal Release 20.04
Compiler: C++
jonas
August 15, 2022, 11:05am
2
Hi @Ankur ,
In this case, you have to explicitly set the errors of h221
to be the content of errACP0NH_2095
:
for(int i=0 ; i <= h221->GetNbinsX() ; i++){
h221->SetBinError(i, errACP0NH_2095->GetBinContent(i));
}
If you don’t want to modify the original histogram, you can create a Clone()
of it.
Hope this helps!
Jonas
Ankur
August 15, 2022, 11:15am
4
Thank you @jonas for your reply. Before proceeding, let me confirm if you mean errACP0NH_2095->GetBinContent
instead of errACP0NH_2095->GetBinError(i)
? My idea is that the errors for h221 are calculated and stored in errACP0NH_2095 .
jonas
August 15, 2022, 11:15am
5
Yes, sorry that’s what I meant! I have edited my post.
1 Like
Ankur
August 15, 2022, 11:16am
6
Thank you, Get back to you shortly.
Ankur
August 22, 2022, 8:33am
7
@jonas Sorry for the late reply. I was adding few others into my code. The technique works perfectly fine. Thank You.