The question is very stupid but I am not able to set the contents for my desired bin
TH1F* meanSteps(TH2F* h2, int ch_mi, int ch_ma,int step_mi, int step_ma, int step) {
int nch = ch_ma-ch_mi;
float nsteps = (step_ma-step_mi)/step;
TH1F* h1=new TH1F("h1","Mean Counts at Threshold", nch, ch_mi-0.5, ch_ma+0.5);
for(int ichan=ch_mi; ichan<ch_ma+1; ichan++) {
int sumCount=0;
float meanCount=0;
for(int istep=step_mi; istep<step_ma; istep= istep+step) {
sumCount=h2->GetBinContent(ichan, istep);
meanCount = (float) sumCount/nsteps;
}
h1->SetBinContent(ichan,meanCount); // this part fails.
}
h1->Draw();
return h1;
}
Can anyone tell me why SetBinContent(…) fails? My histogram has zero entries
Many thanks in advance
Frances