Unable to access an otherwise available field of TLorentzVector in expressions
#959
-
Dear I'm trying to read a import uproot
f = uproot.open('file:tree:)
p = f.arrays(["truth_p4"])
print(p.truth_p4[0])
After I've requested this branch, I have access to any of its fields, e.g. this p.truth_p4.fE yields
I've seen in discussions here that there's possibility to access the fields directly in the But if I try to run f.arrays(["truth_p4.fE"]) I get the following errors
I've got it with Is there a way to access the fields of the Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I've got another question about the import uproot
import awkward as ak
f = uproot.open(file_path)
a = f.arrays(["InDetTrackParticles_hit_gasType"])
ak.sum(a['InDetTrackParticles_hit_gasType'], axis=1) but if I try to run it as f.arrays(['sum(InDetTrackParticles_hit_gasType, axis=1)']) I get the error
Shouldn't the |
Beta Was this translation helpful? Give feedback.
-
In the case of #131, the things with names like Outside of the The set of functions available in the uproot5/src/uproot/language/python.py Lines 258 to 319 in ac23179 We could add It's also possible to use more functions than the default set without changing Uproot. Functions like uproot.TTree.arrays have a PythonLanguage(PythonLanguage.default_functions | {"sum": np.sum}) (Note: It's interesting that you bring this up now because @aryan26roy is currently working on a second uproot.language.python.PythonLanguage with the traditional Footnotes
|
Beta Was this translation helpful? Give feedback.
In the case of #131, the things with names like
"Tracks.fCoordinates.fX"
are TBranches. Using a dotted name inexpressions
makes it look for a TBranch with that name. A TLorentzVector is a single TBranch; the structure is inside of it—there is no TBranch in your file named"truth_p4.fE"
.1Outside of the
expressions
, if you have an Awkward Array namedtruth_p4
, then asking for.fE
extracts a field from it as a projection. That's something where a different library (Awkward vs Uproot) uses the same syntax for a different purpose.The set of functions available in the
expressions
argument of uproot.TTree.arrays and similar is a closed-off set, like NumExpr. Here's the default set:uproot5…