# Plot Calculated Errors in an existing Histogram

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++

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

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.

Yes, sorry that’s what I meant! I have edited my post.

1 Like

Thank you, Get back to you shortly.

@jonas Sorry for the late reply. I was adding few others into my code. The technique works perfectly fine. Thank You.