Combinations within an array of p4 vectors #107
Replies: 1 comment 8 replies
-
The default If I'm interpreting the data type correctly, Instead of putting this inside an event loop, collect all your data as lists of vectors in all events (one list per event). Then call Here's an example of doing that without having to create a bunch of Python objects (which use a lot of memory). It uses ak.ArrayBuilder: builder = ak.ArrayBuilder()
for event in events:
sixb_pt = event["sixb_pt"] # however you get these from the events
sixb_eta = event["sixb_eta"]
sixb_phi = event["sixb_phi"]
with builder.list():
for pt, eta, phi in zip(sixb_pt, sixb_eta, sixb_phi):
with builder.record("Momentum4D"): # not MomentumObject4D
builder.field("pt"); builder.real(pt)
builder.field("eta"); builder.real(eta)
builder.field("phi"); builder.real(phi)
signal_p4 = builder.snapshot()
combos = ak.combinations(signal_p4, 2)
lefts, rights = ak.unzip(combos)
deltaRs = lefts.deltaR(rights) (The name of the record type is not "MomentumObject4D" because it is not a Python object.) |
Beta Was this translation helpful? Give feedback.
-
Hi, I have an array of p4 vectors and I am trying to calculate the DeltaR between all vectors in the array. I build the array like this:
for each event in a ROOT file. For now, there are exactly 6 entries in the array but this may vary later. The output is a list of these arrays. Then, I try to find the combinations of pairs but I get an error when running the following code:
combos = ak.combinations(signal_p4s[0], 2) lefts, rights = ak.unzip(combos)
The error is as follows:
Any advice on how to handle this? Thank you!
Beta Was this translation helpful? Give feedback.
All reactions