Error getting mean and standard deviation

Dear all,
I’m quite new to root but so far I have been able to learn on my own. I’m getting a strange error and I would appreciate it if someone could help me. I have a long code, but I will summarize the important parts.
I have a histogram, hMult[nCent], defined as a new TH1D, and I want to get its mean and standard deviation. I do it using the lines:

    Double_t means[nCent];
    Double_t stds[nCent];
    for (Int_t i_c=0;i_c<nCent;i_c++){
            means[i_c]=hMult->GetMean();
            stds[i_c]=hMult->GetStdDev();
    }

The error I’m getting is
error: request for member ‘GetMean’ in ‘(TH1D**)(& hMult)’, which is of non-class type ‘TH1D
And the same for the standard deviation.
Could someone please point what could be wrong?
Thank you,
Òscar

Hi Oscar,

if hMult[nCent] is an array, then shouldn’t you do

            means[i_c]=hMult[i_c]->GetMean();
            stds[i_c]=hMult[i_c]->GetStdDev();

instead of

            means[i_c]=hMult->GetMean();
            stds[i_c]=hMult->GetStdDev();

?

1 Like

Dear Yus,
You are absolutely right, now it’s working! Thanks for your comment.
Best,
Òscar