Getting the mean value of the y-axis

Hello,

I am trying to get the mean value for my y-axis. I tried the method GetMean(2) but I only get zeros.
Basically what I am trying to do: I want to get the mean value for an efficiency in a range from 3-10 GeV in the x-axis, that’s why I used the setrange option.
TH1D* effprojectionmb[nbins];
TH1D* effprojectiontrdmb[nbins];
TH1D* efficrun;
efficrun = new TH1D(“efficrun”,“Eff vs Run”,nbins,271000, 295000);
TH1D* meanefficiency[nbins];

Double_t meaneff[nbins];

for (Int_t i = 1; i <= nbins; i++) {
Int_t e1 = i;
Int_t e2 = i;
cout << e1 << " " << e1 << endl;
effprojectionmb[i+1] = (TH1D*) effsamples[0]->ProjectionY(Form("projectionmb ef%i ",i+1 ),e1,e2);
effprojectiontrdmb[i+1] = (TH1D*) effsamples[2]->ProjectionY(Form("projectiontrdmb ef%i ",i+1 ),e1,e2);
effprojectionmb[i+1]->Sumw2();
effprojectiontrdmb[i+1]->Sumw2();
DrawPrettyHist1(effprojectionmb[i+1], “Projection of RunNo on p_{T}”, “p_{T} [GeV/c]”, “Entries”);

// calculate efficiency per run
meanefficiency[i+1] = (TH1D*)effprojectionmb[i+1]->Clone(Form("eff for run %i", i+1));
meanefficiency[i+1]->Divide(effprojectiontrdmb[i+1], effprojectionmb[i+1]);

// get mean value
meanefficiency[i+1]->GetXaxis()->SetRange(meanefficiency[i+1]->FindBin(3),meanefficiency[i+1]->FindBin(10));
meaneff[i+1] = meanefficiency[i+1]->GetMean(2);
cout << meaneff[i+1] << endl;
// fill histogram
efficrun->SetBinContent(i, meaneff[i+1]);
efficrun->SetBinError(i, 0.001);
}

Does anyone have a tip on how I can do this?

Thank you,
Felix

The y axis of a 1D histogram is not binned, so you cannot use GetMean(2) on it; you would need a TH2D for that. I suppose effsamples[i] are TH2D? maybe what you want is to use GetMean on them?