# Get mean in lego plot

Hello rooters

How do I get the mean values in x- and y-direction in a lego plot?

using:

``````  TH2F *plot = new TH2F("plot","Plot der Matrix",dimx,0,dimx,dimy,0,dimy);
for(Int_t i=0;i<dimy;i++){
for(Int_t j=0;j<dimx;j++){
plot->Fill(j,i,matrix[i][j]);
}
}
double mean_x=plot->GetMean();``````

I get the mean in x-direction which agrees with the value displayed in the statistics box. But how can I get the one in y-direction?

Cheers

Christian

see documentation of TH1::GetMean at root.cern.ch/root/html/TH1.html#TH1:GetMean

``````Double_t GetMean(Int_t axis = 1) const

For axis = 1,2 or 3 returns the mean value of the histogram along
X,Y or Z axis.
For axis = 11, 12, 13 returns the standard error of the mean value
of the histogram along X, Y or Z axis

Note that the mean value/RMS is computed using the bins in the currently
defined range (see TAxis::SetRange). By default the range includes
all bins from 1 to nbins included, excluding underflows and overflows.
To force the underflows and overflows in the computation, one must
call the static function TH1::StatOverflows(kTRUE) before filling
the histogram.
``````

Rene

``````  Double_t mean_x=plot2->GetMean(1);