Skip to content

Commit

Permalink
Merge pull request #1165 from CoffeaTeam/fix-cyl-vectors
Browse files Browse the repository at this point in the history
fix: remove bad accessors for cylindrical pt/eta/phi vectors
  • Loading branch information
lgray authored Aug 19, 2024
2 parents 4cc6b25 + 00c43b3 commit 246f134
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 162 deletions.
4 changes: 2 additions & 2 deletions binder/applying_corrections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,11 @@
"jets['pt_raw'] = (1 - jets['rawFactor']) * jets['pt']\n",
"jets['mass_raw'] = (1 - jets['rawFactor']) * jets['mass']\n",
"jets['pt_gen'] = ak.values_astype(ak.fill_none(jets.matched_gen.pt, 0), np.float32)\n",
"jets['rho'] = ak.broadcast_arrays(events.fixedGridRhoFastjetAll, jets.pt)[0]\n",
"jets['PU_rho'] = ak.broadcast_arrays(events.fixedGridRhoFastjetAll, jets.pt)[0]\n",
"name_map['ptGenJet'] = 'pt_gen'\n",
"name_map['ptRaw'] = 'pt_raw'\n",
"name_map['massRaw'] = 'mass_raw'\n",
"name_map['Rho'] = 'rho'\n",
"name_map['Rho'] = 'PU_rho'\n",
" \n",
"corrector = FactorizedJetCorrector(\n",
" Fall17_17Nov2017_V32_MC_L2Relative_AK4PFPuppi=evaluator['Fall17_17Nov2017_V32_MC_L2Relative_AK4PFPuppi'],\n",
Expand Down
160 changes: 0 additions & 160 deletions src/coffea/nanoevents/methods/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,90 +513,6 @@ class PtEtaPhiMLorentzVector(LorentzVector):
Some additional properties are overridden for performance
"""

@property
def E(self):
"""Alias for `t`"""
return self.t

@property
def pt(self):
"""Alias for `r`"""
return self["pt"]

@property
def eta(self):
r"""Pseudorapidity
:math:`-\ln\tan(\theta/2) = \text{arcsinh}(z/r)`
"""
return self["eta"]

@property
def phi(self):
r"""Azimuthal angle relative to X axis in XY plane
:math:`\text{arctan2}(y, x)`
"""
return self["phi"]

@property
def mass(self):
r"""Invariant mass (+, -, -, -)
:math:`\sqrt{t^2-x^2-y^2-z^2}`
"""
return self["mass"]

@property
def rho(self):
r"""Distance from origin in 3D
:math:`\sqrt{x^2+y^2+z^2} = \sqrt{r^2+z^2}`
"""
return self.pt * numpy.cosh(self.eta)

@property
def theta(self):
r"""Inclination angle from XY plane
:math:`\text{arctan2}(r, z) = 2\text{arctan}(e^{-\eta})`
"""
return 2 * numpy.arctan(numpy.exp(-self.eta))

@property
def r(self):
r"""Distance from origin in XY plane
:math:`\sqrt{x^2+y^2} = \rho \sin(\theta)`
"""
return self.pt

@property
def z(self):
r"""Cartesian z value
:math:`\rho \cos(\theta) = r \sinh(\eta)`
"""
return self.pt * numpy.sinh(self.eta)

@property
def t(self):
r"""Cartesian time component
:math:`\sqrt{\rho^2+m^2}`
"""
return numpy.hypot(self.rho, self.mass)

@property
def rho2(self):
"""Squared `rho`"""
return self.rho * self.rho

@property
def mass2(self):
"""Squared `mass`"""
return self.mass * self.mass

@awkward.mixin_class_method(numpy.multiply, {numbers.Number})
def multiply(self, other):
"""Multiply this vector by a scalar elementwise using `x`, `y`, `z`, and `t` components
Expand Down Expand Up @@ -644,82 +560,6 @@ class PtEtaPhiELorentzVector(LorentzVector):
Some additional properties are overridden for performance
"""

@property
def E(self):
"""Alias for `t`"""
return self.t

@property
def pt(self):
"""Alias for `r`"""
return self["pt"]

@property
def eta(self):
r"""Pseudorapidity
:math:`-\ln\tan(\theta/2) = \text{arcsinh}(z/r)`
"""
return self["eta"]

@property
def phi(self):
r"""Azimuthal angle relative to X axis in XY plane
:math:`\text{arctan2}(y, x)`
"""
return self["phi"]

@property
def energy(self):
"""Alias for `t`"""
return self["energy"]

@property
def t(self):
r"""Cartesian time component
:math:`\sqrt{\rho^2+m^2}`
"""
return self["energy"]

@property
def rho(self):
r"""Distance from origin in 3D
:math:`\sqrt{x^2+y^2+z^2} = \sqrt{r^2+z^2}`
"""
return self.pt * numpy.cosh(self.eta)

@property
def theta(self):
r"""Inclination angle from XY plane
:math:`\text{arctan2}(r, z) = 2\text{arctan}(e^{-\eta})`
"""
return 2 * numpy.arctan(numpy.exp(-self.eta))

@property
def r(self):
r"""Distance from origin in XY plane
:math:`\sqrt{x^2+y^2} = \rho \sin(\theta)`
"""
return self.pt

@property
def z(self):
r"""Cartesian z value
:math:`r \sinh(\eta)`
"""
return self.pt * numpy.sinh(self.eta)

@property
def rho2(self):
"""Squared `rho`"""
return self.rho * self.rho

@awkward.mixin_class_method(numpy.multiply, {numbers.Number})
def multiply(self, other):
"""Multiply this vector by a scalar elementwise using `x`, `y`, `z`, and `t` components
Expand Down

0 comments on commit 246f134

Please sign in to comment.