Specify the binning of an histogram

Dear all,

I have an a-priori very simple thing to do on a 2D histogram:

I want to define a special binning, and thus define the histogram using

    
    Float_t binsX[35]  = { 20, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2700, 2900, 3100, 3300, 3500, 3700, 3900, 4100 };
    Float_t binsY[23]  = {  100, 150,  200,  225,  250, 275, 300, 325, 350, 375, 400, 450, 500, 550, 600, 650, 700, 750, 800, 900, 1000, 1100, 1200 };
  
  TH2F *h = new TH2F( "h", "", 34, binsX, 22, binsMY );

It works fine, but the values I gave in the table ( 20, 50, …) have been taken as the edge of the bin,
h->GetBinCenter(1)
35
while I want them to lie in the center of the bin. I have tried simply shifting the bins by one half of the bin width, but it did not help. Do you know a trick to specify the bin center in the definition of an histo ?

Thanks in advance,

cheers,
Xavier

Yes, that’s how it works. See help.

How have you done that ? if you create the proper BinsX and BinsY array it should work as you wish .