Hi, I have this piece of code and I fail in the line h2fp->Fill(ch,st,150.);. My problem is it does not take the 3rd argument that assigned for the fill function. It does not complain, it enters the if statement conditional statement, but it fills the histogram with the variable value. What did i miss. Many thanks.
TH2F *foo(int minChan, int maxChan, TH2F *h2, int stepInterval) {
int totalChannels = maxChan-minChan+1;
int totalSteps = h2->GetYaxis()->GetNbins(); printf("totalSteps %d\n",totalSteps );
int step_low = (h2->GetYaxis()->GetXmin()) +1; printf("step_low %d\n", step_low );
int step_high = h2->GetYaxis()->GetXmax(); printf("step_high %d\n", step_high);
Double_t step;
Double_t value;
TH2F *h2fp = new TH2F ("h2fp", "", totalChannels,minChan-0.5, maxChan+0.5, ((step_high-step_low)/stepInterval)+1, step_low-(Double_t)stepInterval/2.,step_high + (Double_t) stepInterval/2.);
h2fp->SetStats(kFALSE);
for (int ch=minChan;ch<maxChan; ch++){
TH1F *h1 = getCh(h2, ch);
TH1F *h1_spectrum = spectrumFromCh(h1);
for (int st =step_low ; st<step_high+1; st=st+stepInterval){
value= h1_spectrum->GetBinContent(st);
if(value>150.) {
h2fp->Fill(ch,st,150.);
}
h2fp->Fill(ch,st,value);
}
delete h1;
delete h1_spectrum;
}
return h2fp;
}