I made a function to read a branch from tree. It is working when I call branch like:
or
but as soon as I put () for some arithmetics like:
it is giving me following error:
Traceback (most recent call last):
File “main.py”, line 32, in
readTree.treeDraw(branch=[“Lep0_pt*(Lep1_pt)” ])
File “/home/ramkrishna/AdvancedPlotting/readTree.py”, line 168, in treeDraw
yMax = make_histo(z,y,x,cut_t,yMax) # returned yMax so that its value will be reset again and agin in loop
File “/home/ramkrishna/AdvancedPlotting/readTree.py”, line 112, in make_histo
h[x].Scale(1./h[x].Integral())
ZeroDivisionError: float division by zero
Actually I am trying to make a general tree reader in which I just need to give name of branch and it will save histogram corresponding to each variable.
but you don’t only use ‘branch’ for drawing. You also use it as title (fine, I’m sure) and histo id (likely not), so the filling in Draw() fails, the histogram is empty, and it’s Integral() result zero.
Try using histo id’s that do not contain special characters such as ‘*’, ‘(’, ‘)’, etc.
since you also use ‘branch’ as the file name, make sure that all characters used in the name are understood by the OS. Further, you don’t have a Open() call in the code you showed, so not sure what where that message is coming from. Anyway, just make sure that the file names match.