Skip to content

Commit d38971c

Browse files
Add tests for LVB accessors
1 parent b25e3f2 commit d38971c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/PseudoJet.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,4 @@ Return the scalar transverse momentum (pt) of a PseudoJet. This accessor uses
211211
the precalculated value that the struct has.
212212
"""
213213
pt(p::PseudoJet) = sqrt(p._pt2)
214-
LorentzVectorBase.pt(p::PseudoJet) = p._pt
214+
LorentzVectorBase.pt(p::PseudoJet) = sqrt(p._pt2)

test/test-jet-types.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ pj_beam = PseudoJet(0.0, 0.0, 5.0, 5.0)
2626
@test LorentzVectorBase.spatial_magnitude2(pj) JetReconstruction.p2(pj)
2727
@test LorentzVectorBase.cos_theta(pj) JetReconstruction.CosTheta(pj)
2828

29+
# These accessors should compare exactly as they use cached values
30+
@test LorentzVectorBase.rapidity(pj) == JetReconstruction.rapidity(pj)
31+
@test LorentzVectorBase.pt2(pj) == JetReconstruction.pt2(pj)
32+
@test LorentzVectorBase.pt(pj) == JetReconstruction.pt(pj)
33+
2934
# This isn't really a test of the output, but rather that the object
3035
# can be printed without error
3136
@test string(pj) == "PseudoJet(px: 1.0 py: 2.0 pz: 3.0 E: 10.0 cluster_hist_index: 7)"

0 commit comments

Comments
 (0)