ProjectionY problem


I attached a small piece of code and also a TH2F. The histogram has 3 bins in the X axis and the only the second is not empty. However when you run the code it tells you that the first bin has the same content as the second bin.

I am not really sure why this is happening, could you please take a look?

test.cxx (468 Bytes)
test.root (4.51 KB)

The TH2::ProjectionY method description explicitly says that the projection is made from the channels along the X axis ranging from firstxbin to lastxbin INCLUDED. { TFile f("test.root","read"); TH2F *h2d; f.GetObject("engmss2d", h2d); if (h2d) { cout<<"UNDERFLOW "<<h2d->ProjectionY(" ",0,0)->Integral()<<endl; cout<<"INTEGRAL OF 1ST BIN "<<h2d->ProjectionY(" ",1,1)->Integral()<<endl; cout<<"INTEGRAL OF 2ND BIN "<<h2d->ProjectionY(" ",2,2)->Integral()<<endl; cout<<"INTEGRAL OF 3RD BIN "<<h2d->ProjectionY(" ",3,3)->Integral()<<endl; cout<<"INTEGRAL OF 4TH BIN "<<h2d->ProjectionY(" ",4,4)->Integral()<<endl; cout<<"OVERFLOW "<<h2d->ProjectionY(" ",5,5)->Integral()<<endl; } }


Sorry, you are right, I was doing binx to binx+1 instead of binx to binx to get the bin binx, my mistake. :blush: