Dear all,
I am currently trying to figure out the best way to use your Tree implementation to map plain ntuples to objects.
For this I am following your event loop example [1].
In my ROOT files I have a tree with the following branches (short list for example purposes):
- Event.Run
- Jets.px, .py, .pz, .energy
The behaviour I want is:
```python
for event in tree:
print(event.Run)
for jet in event.Jets:
print(jet.Pt())
```
The jet class is just an object with a four vector (in this example):
```python
class Jet(object):
def __init__(self, energy, px, py, pz):
self.vector = LorentzVector(energy, px, py, pz)
def Pt():
```
The first one, 'print(event.Run)’, was relatively easy to include [2] although I doubt that this is the best way to do so (maybe better to adapt the ntuple format). The second bit however (jets) is where I struggle.
Using TreeBuffer.define_collection it is easy enough to mix the classes, but I am not sure how to fill the four vector.
Is there a way I can customise the constructor of the mixing classes such that they read attributes from the TreeObject?
Similarly I would like (at a later stage) to map the ‘event’ object in 'for event in tree’ to my own class (to provide more understandable access to selections).
I would appreciate if you have some useful hints in this regard.
Cheers,
Luke
[1]
[2]