GetMean and GetRMS with a TH1D array

Hi everybody,

I need to get the mean and RMS values from a X and Y projection. To illustrate my problem I attached a reduced version of my code generating random data instead my real data.

I have an array [11][3] of TH2F (11 detectors ans 3 particles). I do a loop over detectors and project data in a [3] dimension TH1D array.
For the first projection the GetMean and GetRMS are good. But for the second detector, as TH1D is reset and filled again with the projected contents of the TH2D, the Mean and RMS seem to be wrong.

To run the code I use v5.22
root[] .L histo_tmp.C
root[] histo_tmp()

Any idea ?


histo_tmp.C (6.53 KB)

Ok, I found the problem my self.
When I generated the projections with the method:
TH1D * ProjectionX(const char* name = “_px”, Int_t firstybin = 0, Int_t lastybin = -1, Option_t* option = “”) const
The name was always the same. If I generate it with a different name for each projection, the Mean and RMS values are correct.
I attach the correct macro to this message.

histo_tmp.C (6.64 KB)