hi. i would like to ask a stupid question.
I have a 2D histogram (TH2F). I would like to extract Count, given i and j. For instance
TH1F *getAve(TH2F *h2, int ch_mi, int ch_ma) {
Int_t i, j;
Double_t Count = 0.;
Double_t sumCount=0.;
Double_t meanCounts;
Double_t mi = h2->GetYaxis()->GetXmin();
Double_t ma = h2->GetYaxis()->GetXmax();
Int_t nsteps = h2->GetYaxis()->GetNbins();
Double_t chan_diff = (Double_t) ch_ma - (Double_t) ch_mi;
TH1F* h1=new TH1F("h1", "Average:Channels",nsteps,mi,ma);
for (j=mi; j<ma; j++) {
sumCount = 0.;
Count = 0.;
meanCounts=0.;
for (i=ch_mi; i<ch_ma+1;i++) {
Count += h2->GetBinContent(i,j);
meanCounts=Count/chan_diff;
}
h1->SetBinContent(j,meanCounts);
}
return h1;
}
GetBinContent(i,j) provides me zeroz while i am expecting non-zero Count values. Am I using the right function the values in the 3rd dimension of my plot?, or am I using the function correctly?
Thanks.
f.