Skip to content

Commit

Permalink
Workaround pythonizations changing mutability of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Sep 10, 2024
1 parent 07230d3 commit bec3a96
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/createEDM4hepFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def create_MCParticleCollection():
"""Create an MCParticleCollection"""
counter = count()
particles = edm4hep.MCParticleCollection()
p_list = []
for i in range(3):
particle = particles.create()
p_list.append(particle)
particle.setPDG(next(counter))
particle.setGeneratorStatus(next(counter))
particle.setSimulatorStatus(next(counter))
Expand All @@ -52,8 +54,8 @@ def create_MCParticleCollection():
particle.setSpin(edm4hep.Vector3f(next(counter), next(counter), next(counter)))
particle.setColorFlow(edm4hep.Vector2i(next(counter), next(counter)))

particles[0].addToDaughters(particles[1])
particles[0].addToParents(particles[2])
p_list[0].addToDaughters(p_list[1])
p_list[0].addToParents(p_list[2])
return particles


Expand Down Expand Up @@ -151,7 +153,7 @@ def create_ParticleIDCollection(vectorsize):
for j in range(vectorsize):
pid.addToParameters(next(counter))

return pids
return pids, pid


def create_ClusterCollection(vectorsize, calo_hit):
Expand Down Expand Up @@ -273,7 +275,7 @@ def create_VertexCollection(vectorsize):
v.setAlgorithmType(next(counter))
for j in range(vectorsize):
v.addToParameters(next(counter))
return vertex
return vertex, v


def create_ReconstructedParticleCollection(vertex, cluster, track):
Expand Down Expand Up @@ -430,11 +432,9 @@ def create_frame():
)
track = tracks[0]

pids = create_ParticleIDCollection(VECTORSIZE)
pid = pids[0]
pids, pid = create_ParticleIDCollection(VECTORSIZE)

vertices = create_VertexCollection(VECTORSIZE)
vertex = vertices[0]
vertices, vertex = create_VertexCollection(VECTORSIZE)

reco_particles = frame.put(
create_ReconstructedParticleCollection(vertex, cluster, track),
Expand Down

0 comments on commit bec3a96

Please sign in to comment.