Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Boosting by sum #85

Closed
beojan opened this issue Feb 26, 2019 · 3 comments
Closed

Boosting by sum #85

beojan opened this issue Feb 26, 2019 · 3 comments

Comments

@beojan
Copy link

beojan commented Feb 26, 2019

EDIT: For anyone trying to do this themselves, a boost to the rest frame should actually be p4.boost(-p4.sum().boostp3).

I have a JaggedArray of TLorentzVectors. I want to boost the vectors in each row to the rest frame of that row.

I'm using p4 = p4.boost(p4.sum().boostp3) (well the equivalent, since hh = p4.sum()), but I get the error:

Traceback (most recent call last):
  File "./train.py", line 44, in <module>
    p4 = p4.boost(hh.boostp3)
  File "/usr/lib/python3.7/site-packages/uproot_methods/classes/TLorentzVector.py", line 236, in boost
    v = self.p3 + gamma2*bp*p3 + gamma*p3*self.t
  File "/usr/lib/python3.7/site-packages/numpy/lib/mixins.py", line 25, in func
    return ufunc(self, other)
  File "/usr/lib/python3.7/site-packages/awkward/array/jagged.py", line 924, in __array_ufunc__
    result = getattr(ufunc, method)(*inputs, **kwargs)
  File "/usr/lib/python3.7/site-packages/uproot_methods/classes/TLorentzVector.py", line 301, in __array_ufunc__
    raise TypeError("(arrays of) TLorentzVector can only be added to/subtracted from other (arrays of) TLorentzVector")
TypeError: (arrays of) TLorentzVector can only be added to/subtracted from other (arrays of) TLorentzVector
jpivarski added a commit to scikit-hep/uproot3-methods that referenced this issue Feb 26, 2019
@jpivarski
Copy link
Member

jpivarski commented Feb 26, 2019

This is actually an issue in uproot-methods, since it deals with physics calculations. I've opened a PR on that repo: scikit-hep/uproot3-methods#43, but I'm not entirely sure if this fixes the problem because I don't have good test cases. (When I make up values of 4-vectors, I get NaN because they weren't realistic 4-vectors that are within light cones.)

Could you give that a test? Thanks!

@beojan
Copy link
Author

beojan commented Feb 26, 2019

You could use setptetaphim to generate four vectors

@jpivarski
Copy link
Member

I used TLorentzVectorArray.from_ptetaphim, but I didn't think too hard about the numbers I put in it.

If I don't hear from you today about the correctness of the calculation, I'll take that pull request and leave everything else the same.

(The pull request itself fixes an issue unrelated to the calculation of boost: it's that TLorentzVectors, projected to TVector3s, incorrectly kept their identities as TLorentzVectors and then there was an attempt to add some TVector3s and some supposed TLorentzVectors, which would be wrong if that's what they actually were.)

jpivarski added a commit to scikit-hep/uproot3-methods that referenced this issue Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants