2D histogram addition

Dear Root members,
Hi !
I am facing problem in adding two 2D histogram. In the script (chams.C) attached with this mail, I want to add histograms “h2” & “h3” and want to generate their resultant histogram “h_new”. Through this script, I am able to generate all the histograms, the generated “h_new” histogram doesn’t show any data. The script does not give any error on running, and therefore I am unable to find the error myself.
So if possible , please look into the attched script and suggest me the solution of this problem. The data file (‘chams.root’ is huge in size (~ 50 MB), so unable to attach with the mail.
Thanks & regards,
cylab123
chams.C (3.32 KB)

your script requires data files. Please indicate where to pick them?

Rene

Dear Rene,
Hi !
Thanks for the reply. I have defined the data histograms & now I am adding them with the following script -
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// Addition
MyC1->cd(4);
//
TFile *fA = new TFile(“mat_G13_56CoFe0808_IMPAC_up_L.root”, “read”);
TH2F nh1 = (TH2F)fA->Get(“2hG13_up_L”);
//
TFile *fB = new TFile(“mat_G13_56CoFe0808_IMPAC_up_R.root”, “read”);
TH2F nh2 = (TH2F)fB->Get(“2hG13_up_R”);
//
TAxis *ax1 = nh1->GetXaxis();
TAxis *ay1 = nh1->GetYaxis();
TAxis *ax2 = nh2->GetXaxis();
TAxis *ay2 = nh2->GetYaxis();
//
TH2F *sum = new TH2F(“sum”,“nh1+nh2”,4000,0,4000,4000,0,4000);
//
Int_t i,j;
Float_t x,y;
for (i=1;i<=4000;i++) {
x = ax1->GetBinCenter(i);
for (j=1;j<=4000;j++) {
y = ay1->GetBinCenter(j);
sum->Fill(x,y,nh1->GetCellContent(i,j));
}
}
for (i=1;i<=4000;i++) {
x = ax2->GetBinCenter(i);
for (j=1;j<=4000;j++) {
y = ay2->GetBinCenter(j);
sum->Fill(x,y,nh2->GetCellContent(i,j));
}
}

sum->Draw();
//
}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

With this script, I am able to generate the sum of the two histograms.
But the number of entries in this sum histogram - “nh1+nh2” (3.20*10^7) is not equal to the sum of sum of entries in histograms - “2hG13_up_L” (173055) & “2hG13_up_R” (603312),
as it should have been (please see the attached picture).
Please suggest if I have done something wrong in the script.
Thanks & regards
cylab123