Jen
October 10, 2023, 9:08pm
1
Hi,
I have a question about filling the TGraphAsymmErrors object.
I set a gsyst to plot the statistic uncertainty band of h1. I set the code as:

```
gsyst = ROOT.TGraphAsymmErrors(h1)
for j in range (1,gsyst.GetN()+1):
total_unc = 0
total_unc += pow(h1.GetBinErrorj), 2)
total_unc = sqrt(total_unc)
gsyst.SetPointEYlow(j-1, total_unc)
gsyst.SetPointEYhigh(j-1, total_unc)
gsyst.Draw("E2same")
```

What I am not sure is should I fill the gsyst with j or j-1? I mean should it be:

```
gsyst.SetPointEYlow(j, total_unc)
gsyst.SetPointEYhigh(j, total_unc)
```

or

```
gsyst.SetPointEYlow(j-1, total_unc)
gsyst.SetPointEYhigh(j-1, total_unc)
```

Cheers,
Jen

Danilo
October 11, 2023, 4:54am
2
Dear Jen,

Welcome back to the ROOT Forum.
The first point of graphs, including TGraphAsymmErrors, is always indexed with zero.

Cheers,
D

Jen
October 16, 2023, 4:15pm
3
do you mean I should use
gsyst.SetPointEYlow(j-1, total_unc)

?

And for h1 histogram, the first point is indexed with zero or one?

couet
October 17, 2023, 6:33am
4
`TGraphXXX`

classes deal with C++ vectors. So they are indexed from `0`

to `N-1`

if they have `N`

entries. In your example if `j`

starts at 1 and you want to index the first entry of your `TGraph`

, yes, in that case, you should use `j-1`

.

Histogram classes deal with bins. If your histogram has `N`

bins they are numbered from `1`

to `N`

1 Like

system
Closed
November 13, 2023, 12:29pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.