Skip to content

Commit

Permalink
Simplify python util unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Nov 13, 2023
1 parent a36ee9a commit 2100076
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions test/utils/test_kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,18 @@ class TestKinematics(unittest.TestCase):

def test_p4(self):
"""Test the p4 functionality since that has shown to trip-up cppyy"""
# podio doesn't expose the Mutable constructors so we have to use the full
# glory of the immutable types here
p = edm4hep.MCParticle(11, # PDG
-1, # generatorStatus
-1, # simulatorStatus
1.0, # charge
0.0, # time
125.0, # charge
edm4hep.Vector3d(0, 0, 0), # vertex
edm4hep.Vector3d(0, 0, 0), # endpoint
edm4hep.Vector3f(1.0, 2.0, 3.0), # momentum
edm4hep.Vector3f(0, 0, 0), # momentumAtEndpoint
edm4hep.Vector3f(0, 0, 0), # spin
edm4hep.Vector2i(0, 0) # colorFlow
)
p = edm4hep.MutableMCParticle()
p.setMomentum(edm4hep.Vector3f(1.0, 2.0, 3.0))
p.setMass(125.0)

self.assertEqual(p4(p), LVM(1.0, 2.0, 3.0, 125.0))
self.assertEqual(p4(p, SetEnergy(42.0)), LVE(1.0, 2.0, 3.0, 42.0))
self.assertEqual(p4(p, SetMass(250.0)), LVM(1.0, 2.0, 3.0, 250.0))

p = edm4hep.ReconstructedParticle(11, # type
250.0, # energy
edm4hep.Vector3f(1.0, 2.0, 3.0), # momentum
edm4hep.Vector3f(0, 0, 0), # referencePoint
1.0, # charge
125.0, # mass
0.0, # goodnessOfPID
cppyy.gbl.std.array('float', 10)() # covMatrix
)
p = edm4hep.MutableReconstructedParticle()
p.setMomentum(edm4hep.Vector3f(1.0, 2.0, 3.0))
p.setMass(125.0)
p.setEnergy(250.0)

self.assertEqual(p4(p), LVM(1.0, 2.0, 3.0, 125.0))
self.assertEqual(p4(p, UseEnergy), LVE(1.0, 2.0, 3.0, 250.0))
Expand Down

0 comments on commit 2100076

Please sign in to comment.