Ameen
February 2, 2018, 5:07am
1
Dear experts,
I have created a leaf in a root file to store some normalization weight using a simple python script:
chain = TChain("Delphes")
tree = chain.CloneTree(0)
wght = np.zeros(1, dtype=float)
tree.Branch('wght', wght, 'wght/D')
for ...
...
tree.Fill()
Now I am trying to access this leaf using a C++ macro by typing
Double_t branchWeight = chain.GetLeaf("wght")->GetValue(0);
All I am getting is zeros. How can one access a leaf in this situation?
Thank you,
Amin
sbinet
February 2, 2018, 12:23pm
2
apart from this line:
wght = np.zeros(1, dtype=float)
that I’d write more explicitly as:
wght = np.zeros(1, dtype=np.float64)
this looks legit.
(NB: CloneTree(0)
only copies active branches, though…)
so, probably the issue is in how you fill that wght
variable…
hth,
-s
Ameen
February 2, 2018, 2:50pm
3
Thank you Sebastian. This is how I fill wght:
for i in xrange(nEntries):
chain.GetEntry(i)
wght[0] = ....some value ....
tree.Fill()
When I open the root file and click on the leaf I can see the stored values but I cannot extract them using GetLeaf.
Best,
Amin
sbinet
February 2, 2018, 7:48pm
4
ok then, I think we’d need a little (as minimal as possible) script that reproduces your issue.
Ameen
February 2, 2018, 9:20pm
5
I was using this wrapper code ExRootTreeReader and it seems that it doesn’t work when trying to read objects that are not of array type. I fixed this now and it is working.
Thank you very much.
Best,
Amin
system
Closed
February 16, 2018, 9:20pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.