Skip to content

Commit

Permalink
Also check Link collections
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Sep 10, 2024
1 parent 2e26229 commit 07230d3
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion test/backwards_compat/test_EDM4hepFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,33 @@ def test_GeneratorPdfInfoCollection(event):
assert gpi.getScale() == next(counter)


# TODO: LINKS
def check_LinkCollection(event, coll_type, from_el, to_el):
"""Check a single link collection of a given type"""
counter = count()
coll_name = f"{coll_type}Collection"
link_coll = event.get(coll_name)
assert len(link_coll) == 1
link = link_coll[0]
assert link.getWeight() == next(counter)
assert link.getFrom() == from_el
assert link.getTo() == to_el


def test_LinkCollections(event, particle, reco_particle, track):
"""Check all the link collections"""
calo_hit = event.get("CalorimeterHitCollection")[0]
simcalo_hit = event.get("SimCalorimeterHitCollection")[0]
cluster = event.get("ClusterCollection")[0]
tracker_hit = event.get("TrackerHit3DCollection")[0]
simtracker_hit = event.get("SimTrackerHitCollection")[0]
vertex = event.get("VertexCollection")[0]

check_LinkCollection(event, "CaloHitSimCaloHitLink", calo_hit, simcalo_hit)
check_LinkCollection(
event, "TrackerHitSimTrackerHitLink", tracker_hit, simtracker_hit
)
check_LinkCollection(event, "CaloHitMCParticleLink", calo_hit, particle)
check_LinkCollection(event, "ClusterMCParticleLink", cluster, particle)
check_LinkCollection(event, "TrackMCParticleLink", track, particle)
check_LinkCollection(event, "RecoMCParticleLink", reco_particle, particle)
check_LinkCollection(event, "VertexRecoParticleLink", vertex, reco_particle)

0 comments on commit 07230d3

Please sign in to comment.