How to find ex and ey in for error bar

HI !
I am plotting graphs with error bars. I am following examples from internet. But I can not understand how to get the ex value and ey value to have the bars. I have given some of my codes here . Thanks

Hi,
first off, you use ex and ey in the constructor, but you never define these two:

Then you have to set errors manually for every single point you have, like e.g.
g2->SetPointError(i, ex[i], ey[i]);

ooo, Thanks.
But I defined ex and ey like this;
double ex[4] = {0.0,0.0,0.0,0.0};
double ey[4] = {1, 0.5, 1, 0.5}; But clearly the bars are wrong.

Try: g2->Draw("AP"); // "AP" or "APZ"

Thanks,
but nope…the line is vanished.

What do you mean by “the error bars are wrong”? They seem perfectly fine to me…

I mean I just gave the values like double ey[4] = {1, 0.5, 1, 0.5}; .
I think I should get the errors somehow. Not like i put some values randomly.

:frowning: Nope. The line get vanished.

Yes, it is YOUR responsibility to calculate / set proper errors.

After creating histograms (and before filling them) add:

  Multiplicity->Sumw2(kTRUE);
  Tvm->Sumw2(kTRUE);
  SingleTM->Sumw2(kTRUE);
  NPT->Sumw2(kTRUE);

For your graph, you could then use something like:

x  = histo->GetMean();
ex = histo->GetMeanError();
y  = histo->GetStdDev();
ey = histo->GetStdDevError();