How to get mean into a variable in a histogram

I am aware that GetMean and GetRMS would print out those information. I guess I wonder how would I go about filling those information into a variable though?
I amsorry if this is a stupid questions. I just can’t find it anywhere online.


TH1F * h = new TH1F("hh", "hh", 10, 0,10); h->Fill(5.); Double_t mm = h->GetMean(); Double_t rms= h->GetRMS();


Hey. Thanks for replying. I have tried exactly that. But when I print out the mean and RMS variable I defined it is empty. Do you know why it would be the case?

What do you mean by empty == 0??
Here is what I get (root 6.02.00, but that is the same for any version)

root [0] TH1F * h = new TH1F("hh", "hh", 10, 0,10);
root [1] h->Fill(5.);
root [2] h->Fill(6.);
root [3] Double_t mm = h->GetMean();
root [4] Double_t rms= h->GetRMS();
root [5] cout <<"Mean: " << mm << " RMS " << rms << endl;
Mean: 5.5 RMS 0.5
root [6] 

If you use a standalone program you might need to look at this:


yeah… i think the problem is that i defined my variable as a float. Thanks a bunch!