# Error getting mean and standard deviation

**URL:** <https://root-forum.cern.ch/t/error-getting-mean-and-standard-deviation/45906>\
**Category:** Newbie\
**Tags:** root\
**Created:** [July 19, 2021, 2:29pm UTC](https://root-forum.cern.ch/t/error-getting-mean-and-standard-deviation/45906 "2021-07-19T14:29:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oskiiiii](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oskiiiii](https://root-forum.cern.ch/u/oskiiiii)\
**Post date:** [July 19, 2021, 2:29pm UTC](https://root-forum.cern.ch/t/error-getting-mean-and-standard-deviation/45906/1 "2021-07-19T14:29:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [July 19, 2021, 2:34pm UTC](https://root-forum.cern.ch/t/error-getting-mean-and-standard-deviation/45906/2 "2021-07-19T14:34:11Z")

</div>

Hi Oscar,

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

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

```

instead of

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

```

?

---

<div class="post-metadata">

**Author:** ![oskiiiii](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@oskiiiii](https://root-forum.cern.ch/u/oskiiiii)\
**Post date:** [July 19, 2021, 2:40pm UTC](https://root-forum.cern.ch/t/error-getting-mean-and-standard-deviation/45906/3 "2021-07-19T14:40:30Z")

</div>

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