How to get weighted mean from histogram?

Hello,

I fill histograms with weights: TH1->Fill(,);

When I fill with weights the mean value of the x-axis displayed in the stats box is the same as without the weights. How can I have it display a weighted mean value?

Thanks,

Mark

Could you send the shortest possible RUNNING script reproducing this problem?
and indicate which version of ROOT?

Rene

[quote=“brun”]Could you send the shortest possible RUNNING script reproducing this problem?
and indicate which version of ROOT?

Rene[/quote]

I attached a macro that shows the problem. I played around a bit and the problem goes away if I use positive weights. However I need to use weights that are always +/- 1 and the -ve weights dont get taken into account when the mean is calculated apparently.

I am using root v5 on linux 2.4.21-32.0.1.EL. I compiled the root source code, rather than taking a precompiled binary.

Thanks,

Mark
test.C (397 Bytes)