Getting a scaled NEntries after a cut in histogram

Hi,

i want to obtain the scaled number of events which passed a certain cut. I do this:

Ztaue_NOMINAL->Draw(“electrons_pt”,“4000normWeighttotalWeight*(electrons_pt>30)”)
If i then retrieve the histogram:
TH1F * he = (TH1F*)gPad->GetPrimitive(“htemp”)

he->GetEntries() is giving the unscaled number of events (nEvents which passed the cut, but are not multiplied with 4000normWeighttotalWeight)

he->GetSumOfWeights();
gives me a number which seems correct.

Is it ok to get the scaled number of events which passed a cut like this or is there a better way?

Thanks.

Hi,

Yes, TH1::GetSumOfWeights returns the total sum of the weights in your histogram which in your case corresponds to the scaled (weighted) number of entries.
In case of a weighted histogram GetEntries returns something not very significative statistically. You might be instead interested in GetEffectiveEntries() which is obtained from the ratio of the square of the sum of weights with the sum of the weights square

Lorenzo