Hi,
I am trying to add two 2D histogram but in the final histogram when I was trying to see the binContent of resultant histogram, it is showing the bincintent of last histogram. Here is the code:
import ROOT as r
file=['zzTo4L_controlPlot.root','TT_controlPlot.root']
var='2D_pt_distribution_of_Leading_#tau_SubLeading_#tau_with_totCharge!=0_in_tau1anti_iso_nofake_weight'
hist1_Mc = r.TH2F('tau1_Mc', '', 50,0,150,50,0,150)
for i in range(2) :
f=r.TFile(file[i])
hist = f.Get(var)
for ibin in range(hist.GetNbinsX()) :
print ibin+1, '\t',hist.ProjectionX().GetBinContent(ibin+1)
hist1_Mc.Add(hist)
for ibin in range(hist1_Mc.GetNbinsX()) :
print ibin+1,'\t',hist1_Mc.ProjectionX().GetBinContent(ibin+1)
I am getting output for 1st 10 bin, something like
1 0.0
2 0.0
3 0.0
4 0.0
5 0.0
6 0.0
7 0.0
8 0.0262326151133
9 0.0672479541972
10 0.0409734905697
1 0.0
2 0.0
3 0.0
4 0.0
5 0.0
6 0.0
7 0.258228719234
8 1.14812922478
9 1.08459419012
10 1.11708201282
1 0.0
2 0.0
3 0.0
4 0.0
5 0.0
6 0.0
7 0.258228719234
8 1.14812919497
9 1.08459419012
10 1.11708201282
For example, at bin #8 I expected the resultant bincontent would be 0.0262326151133+1.14812922478 = 1.17436184, but am getting 1.14812919497. Please point me where I am doing wrong. Thanks in advance
Saswati
1.14812919497