Error bars are not clear

Hello Experts,

I’m trying to add the error bars to my histogram. But I do see only the squares with black dot.
I have weighed histogram by model.Applied sumW2 option before filling the histogram.(At this stage also I see just squares)

Then I need to add separate error for my histogram.

TH1F h_model_gen   //Used 100 bins;
h_model_gen->SumW2();

//fill the histogram
h_model_gen->Fill(mass_pipi, model);
//I haven't seen error bars even in this stage(errors bars from sumW2)

//create another error histogram
error=X
h_error-> Fill(mass_pipi,error);


//Add this error histogram to my h_model_gen histogram

for(int ibin=1;ibin<=h_model_gen->GetNbinsX();ibin++){
                   error_total_1=h_mpipi_gen->GetBinError(ibin);
                   error_total =sqrt(error_total_1*error_total_1+h_error>GetBinContent(ibin));
                   h_model_gen->SetBinError(ibin,error_total);
                   
               }


h_mode_gen->Draw();

I don’t see the error bars clearly. Is that because I have 100 bins?
Please see attached

Thanks
Dil

Dear Dil,

I could not execute the peace of code you provided.

However, here are a few nodes. To draw a histogram with error bars you should do:

h_mode_gen->Draw("E");

(If you want the usual histogram lines, use hist E instead)

Here is a quick example:

TH1D *h = new TH1D("h","h",100,0,1)
TF1 *f = new TF1("f","gaus",0,1); f->SetParameters(1,0.5,0.1)
h->FillRandom("f",5000)
h->Draw("E")

Another thing to notice is that your y-axis scales is at x10^6 it could be that your errors are too small if you don’t see them properly.

Cheers,
Henrique

Hello Henrique,

Thank you for pointing me out. I guess my y axis is 10^6 and that could be the reason I don’t see clear error bars.

can you provide a reproducer we can run ?