- #1
ChrisVer
Gold Member
- 3,378
- 464
I am trying to make a part of my following code to work but so far I haven't been successful...
I have 1 tree file with several branches but the two I care about are named Trigger and Variable. I have calculated in two histograms h(Variable) the weights I want to obtain.
My function that I am trying to run is supposed to return me the weight of the given Variable value and Trigger (takes values 1 or 2).
The printing output is telling me that the Variable_val is obtained correctly from the tree, but the Trigger_pass is not (it somehow always returns 0). Any help?
I have 1 tree file with several branches but the two I care about are named Trigger and Variable. I have calculated in two histograms h(Variable) the weights I want to obtain.
My function that I am trying to run is supposed to return me the weight of the given Variable value and Trigger (takes values 1 or 2).
Python:
def return_weight(tree, histo_list, branches_list):
#tree containing the variables in branches
#histo_list = [histo_triggerPass(Variable), histo_triggerFail(Variable) ]
#branches_list = [Variable, Trigger]
Variable_val = getattr( tree , branches_list[0])
Trigger_pass= getattr( tree, branches_list[1])
#Problem is supposed to be HERE ^
print Variable_val, " \t ", Trigger_pass
if Trigger_pass==1: ...
else: ...
The printing output is telling me that the Variable_val is obtained correctly from the tree, but the Trigger_pass is not (it somehow always returns 0). Any help?