TH1: Get Mean of square along a particular axis

I stored variables x and x’ in a TH2D. Is there any built-in function or method to compute mean of square of a particular variable and the mean of x’*x. I am calculating beam emittance.

image


_ROOT Version: 6.24 (PyROOT via conda)
_Platform:Centos7
_Compiler: gcc9


I guess you should first project the TH2D along x and then use the TH1’s appropriate getters. @moneta is that correct?

Hi,
The histogram accumulates during filling and stores these quantities in order to compute mean and std along a particular axis. They can be retrieved calling TH2::GetStats.

What you want is similar to what computed in TH2::GetCovariance, see as example the code here:
https://root.cern.ch/doc/master/TH2_8cxx_source.html#l01115

Lorenzo

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.