Is it possible to have the errors for a weighted histogram store the number of entries (ie the bin contents of the unweighted histogram) instead of the sum of the square of the weights? This way the error can be the the (sum of the weights)/sqrt(number of entries). (ie the fractional error of the unweighted histogram times the bin contents.)
For the case of a constant weight I believe these two cases are the same, but if the weight for each event varies, then (I think) they are different.
This is called a profile histogram. See class TProfile
It seems to me that the profile histogram will store the information I need, but displays the average weight not the sum of the weights. I just want to have a normal histogram (displaying the sum of the weights in each bin), with the errors set to the (sum of the weights)/sqrt(number of entries).
To do this with either TH1F or TProfile, it seems I would need to create 2 objects. In the case of TH1F one to keep track of the sum of the weights, and one to keep track of the number of entries. Or the TProfile and a TH1D to hold the projection and errors(calculated from the TProfile H(j)/sqrt(L(j))) to be displayed.
I am probably just being dense here, but there has to be some easier solution. I have a lot of histogram in my code, and Id hate to have to double up on each one.
I don’t think the error you are requesting is statistically correct, but if you want to have this, as Rene mentioned, you need to fill a TProfile which has all the information.
You can get the equivalent histogram a TProfile using the new option "W"
and then you need just to replace its errors as follow:
TH1D * h1 = profile->ProjectionX("h1","W");
for (int i = 1; i < =h1->GetXaxis()->GetNbins(); ++i)
h1->SetBinError( i, sqrt( profile->GetBinEntries(i) ) );