Error of TProfile

Hi All,

I try to set the error of a bin of a TProfile but it has way higher values than i set it to …

I do:
TProfile* h1u = new TProfile(“name”,“name”, 31, 39., 101.);
h1u->Fill(eff, rej); // e.g. fill eff=40 with rej=476.5

then I want to set an error for that bin:
h1u->SetBinError(h1u->FindBin(eff), error);

and then do a cout of some quantities:
std::cout << "Bin: " << h1u->FindBin(eff) << " Eff: " << eff << " Rej: " << rej << " ErrSet: " << error << " ErrGet: " << h1u->GetBinError(h1u->FindBin(eff)) << std::endl;

The funny thing is that the GetBinError method always gets me the bin content somehow:

Bin: 24 Eff: 86 Rej: 3.59794 ErrSet: 0.0139247 ErrGet: 3.59791
Bin: 23 Eff: 84 Rej: 4.80101 ErrSet: 0.022475 ErrGet: 4.80096
Bin: 22 Eff: 82 Rej: 6.29911 ErrSet: 0.0348176 ErrGet: 6.29901
Bin: 21 Eff: 80 Rej: 8.00397 ErrSet: 0.0508622 ErrGet: 8.00381
Bin: 20 Eff: 78 Rej: 10.0642 ErrSet: 0.0727546 ErrGet: 10.0639
Bin: 19 Eff: 76 Rej: 12.4094 ErrSet: 0.100647 ErrGet: 12.409

What am I doing wrong here? Also when I plot the profile the error is proportional to the content of the bin?

Any help is welcome
thanks
Andi

Andi,

Why are you trying to set the errors in a TProfile this way?
Use a normal TH1F, not a TProfile.
See also the class description of TProfile

Rene

Dear Rene,

I thought so that there might be something wrong with using a TProfile here.
Actually I changed back and forth between TH1F and TProfile. I have x, y data points which I have to plot and I have an error on y.

So i take a histo fill it with

Fill(eff, rej) where my y data point is just the weight then and then I set the error as before?

thanks
Andi

Andi,

You should use a TGraphErrors instead

Rene

Dear Rene,

ok I give it a try. never heard of it so far but I found it in the docu.

Cheers
Andi

Andi,

see example in tutorial gerrors2.C

Rene

Dear Rene,

now I know why i took TProfile (or TH1F). It is because i also need to divide one by the other to get a better comparisson of them nad this does not seem to be possible with TGraphErrors. Is there a way to do that similar to TProfile::Divide() or do I have to manually divide the input arrays and create a new TGrapErrors?

thanks
Andi

Andi,

In this case, do it with a TH1. You do not need a TProfile.

Rene