Setbincontent along one axis in 2D histogram

Dear Expert

I have a 2d histogram . I want to set bincontent along one axis in 2D histogram and i will continue work with this modified 2D histogram.

Lets consider i have have a 2D histogram in Delta-eta(x axis) and Delta-phi(yaxis) space. Now i take projection along y axis and scale it with the width binwidth of x axis. Now bincontent of projected histogram at 0 is 24.0126( i have attached root file with this threads). I want to set every bin with this value 24.0126 such that i get flat distribution. I did it . After this modification , i can not get modfied 2D histogram. I want 2D plot after modification along y axis bincontent. Could you please give any comment or suggestion

regardsfRootFileMix.root (58.2 KB)
ReBinContent.C (1.4 KB)


You modify the “histProjectionYClone” only (i.e. you do not modify the “hist2D”).

I modify histProjectionYClone after taking projection along Y axis from hist2D. Now I want to set this modified histProjection in 2D such that if i take projection from this 2D histo along y axis , i get flat distribution.

I solved the problem. It is very simple to do it. Fix one bin along x axis, take bincontent along y axis at phi =0 or Pi and do this operation.

for(Int_t binx =1;binx < iBinX+1 ; binx++){
for(Int_t biny =1;biny < iBinY+1 ; biny++){
contentY = hist->GetBinContent(binx,hist->GetYaxis()->FindBin(0.0-0.0001));
//contentError = hist->GetBinError(binx,hist->GetYaxis()->FindBin(0.0-0.0001));
contentError = hist->GetBinError(binx,biny);


contentY = 0.0;


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.