Open lukasheinrich opened 5 years ago
I see what's going on here: it's a casualty of scope creep. Originally, these functions were written for Numpy arrays—the idea being that you could have flat arrays of Lorentz vectors—but in most cases, they "just worked" for awkward arrays (because they share Numpy idioms) and this fact is clearly useful. However, awkward arrays don't support masked-assignment (I'm hoping to make this possible in awkward 1.0). In most of these functions, I removed masked-assignment and in-place assignment, but I must have missed this one.
The masked-assignment is intended to protect against division by zero—specifically, zero over zero (corresponding to boosting by exactly zero). To do this truly vectorially, we should let the division by zero happen and clean up afterward. Since these are zero over zero cases, the result we want to clean up is NaN. If the array is Numpy, we can mask-assign these cases; otherwise, we can use awkward's fillna
method (name borrowed from Pandas).
I believe that the correct limit for this case is gamma2
→ 0.5. Since you're closer to the physics of this problem, hopefully you can verify this. In fact, I don't know if we've had a customer for boosted 4-vectors yet, so checking the math would be prudent for your goals and very much appreciated for mine.
The fix is in PR #63.
I just noticed that I have an open PR (#63) that should fix this, and it's pretty stale. Did this fix your problem/is it no longer relevant/etc.?
For me this problem is still relevant. I get a
TypeError: (arrays of) TVector3 can only be added to/subtracted from other (arrays of) TVector3
after applying the patch. It seems that this is unrelated as it arises from a few lines further down.
Hi,
I am stumbling over a problem w/ 4-vectors in uproot_methods:
Consider the problem of having events with lorentz vectors and wanting to boost all of them into their rest frame. The operation works per-event, but not o the full full (batched) set of events
I'm looking into what the issue could be but perhaps someone is faster
the first
print
works as expected, the seconds does not and fails with