But, I am getting following error:
[color=#FF0000]
Traceback (most recent call last):
File “TwoDplots_Wjets.py”, line 81, in
hnew.Add(h1);
AttributeError: ‘PyROOT_NoneType’ object has no attribute ‘Add’[/color]
Yes, this also worked for me. Now, I checked and got that I made an if condition which is causing the problem. If I remove the if condition then it worked. If you have idea how I can use “Add” in the if condition then please let me know.
for files in RootFiles:
filename=re.sub('.root','',RootFiles[countf])
filename=re.sub('WWTree_','',filename)
filename=filename.strip()
h1.SetTitle(filename)
f1=ROOT.TFile(path+files,"READ")
T=f1.Get("otree")
print "Total Entries = ",T.GetEntries()
T.Draw(columns[0]+">>h1",cut,"colz")
h1.Scale(factor[countf])
if countf==0:
hnew = h1.Clone("hnew");
print "made new histo......."
else:
print "Adding new histo......."
hnew.Add(h1);
countf=countf+1
c.Print("plots/"+filename+"/Scatter_"+filename+"_"+titles[0]+"_vs_"+titles[1]+".png")
c.Print("plots/"+filename+"/Scatter_"+filename+"_"+titles[0]+"_vs_"+titles[1]+".pdf")
countv=countv+1