GetRMS on TH1D class

Hi,

I have data for the analysis and I need to present the fluctuation in the information. I’m using a histo with TH1D class and I’d like to show the RMS value for the data, not the Std Dev. The data haven’t a gaussian distribution, so the average isn’t zero. But If I choose GetRMS or GetStdDev I have the same value. When I looked at the TH1.h (line 316) documentation to read about the GetRMS method I see that the RMS call StdDev values.

I have many histo to generate. Is it possible to edit the class to implement this method?

Att.
msandesd.

Hello,

You can create a subclass of TH1D and override GetRMS if you so wish.

Also citing @moneta to comment on the equivalence of StdDev and RMS.

I might be wrong but I think that “historical” … It use to be RMS (from CERNLIB/PAW) but that “RMS” was indeed the SdtDev. So we created the StdDev methods to be more precise and keep the “RMS” ones for backward compatibility. That’s what I have in mind. But @moneta can will give a better picture I am sure.

Hi,

If you just want the root mean square, you could implement just as a free function, something like this (for a 1-dimensiona histogram)

double GetRootMeanSquare( const TH1 & h1) { 
   double stats[TH1::kNstat]; 
   h1.GetStats(stats); 
   return (stats[0] > 0) ? std::sqrt(stats[3]/stats[0]) : 0;
}

Best regards

Lorenzo

Thanks @moneta for the solution. I was looking for something like this to simplify the method to calculate the RMS value.

Hi @etejedor,
I was thinking to create a subclass or something like that. But I don’t know yet how to make a subclass on ROOT.

Thanks for your help.