42 def fillEvent(self, evt):
44 Sample a list of particle properties, which are then used to create a new GenEvent in StoreGate.
47 offset = self.randomSeed
if self.randomSeed
is not None else 0
48 seed = ROOT.ATHRNG.calculateSeedsPython(self.randomStream, self._ctx.eventID().event_number(), self._ctx.eventID().
run_number(), offset)
51 self.msg.warning(
"Failed to find a seed for the random stream named '%s'.", self.randomStream)
52 seed = self.randomSeed
54 self.msg.
debug(
"Set random seed to %s.",
str(seed))
57 self.msg.
error(
"Failed to set random seed.")
58 return StatusCode.Failure
61 evt.weights().push_back(1.0)
63 for s
in self.samplers:
67 pos = HepMC.FourVector(p.pos.X(), p.pos.Y(), p.pos.Z(), p.pos.T())
68 gv = HepMC.GenVertex(pos)
69 ROOT.SetOwnership(gv,
False)
73 mom = HepMC.FourVector(p.mom.Px(), p.mom.Py(), p.mom.Pz(), p.mom.E())
74 gp = HepMC.GenParticle()
78 if p.mass
is not None:
79 gp.set_generated_mass(p.mass)
80 ROOT.SetOwnership(gp,
False)
81 gv.add_particle_out(gp)
84 evt.set_units(HepMC.Units.MEV, HepMC.Units.MM)
85 evt.weights().push_back(1.0)
86 beamparticle1 = std.shared_ptr[
'HepMC3::GenParticle'](HepMC.GenParticle(HepMC.FourVector(0,0,-7000,7000),2212,4))
87 ROOT.SetOwnership(beamparticle1,
False)
88 beamparticle2 = std.shared_ptr[
'HepMC3::GenParticle'](HepMC.GenParticle(HepMC.FourVector(0,0,7000,7000),2212,4))
89 ROOT.SetOwnership(beamparticle2,
False)
90 primary = std.shared_ptr[
'HepMC3::GenVertex'](HepMC.GenVertex())
91 ROOT.SetOwnership(primary,
False)
92 primary.add_particle_in(beamparticle1)
93 primary.add_particle_in(beamparticle2)
94 evt.add_vertex(primary)
95 evt.add_beam_particle(beamparticle1)
96 evt.add_beam_particle(beamparticle2)
98 for s
in self.samplers:
102 gv = std.shared_ptr[
'HepMC3::GenVertex'](HepMC.GenVertex(HepMC.FourVector(p.pos.X(), p.pos.Y(), p.pos.Z(), p.pos.T())))
103 ROOT.SetOwnership(gv,
False)
106 fakeparticle = std.shared_ptr[
'HepMC3::GenParticle'](HepMC.GenParticle(HepMC.FourVector(p.mom.Px(), p.mom.Py(), p.mom.Pz(), p.mom.E()),p.pid,11))
107 ROOT.SetOwnership(fakeparticle,
False)
108 gv.add_particle_in(fakeparticle)
109 primary.add_particle_out(fakeparticle)
111 gp = std.shared_ptr[
'HepMC3::GenParticle'](HepMC.GenParticle(HepMC.FourVector(p.mom.Px(), p.mom.Py(), p.mom.Pz(), p.mom.E()),p.pid,1))
112 ROOT.SetOwnership(gp,
False)
113 if p.mass
is not None:
114 gp.set_generated_mass(p.mass)
115 gv.add_particle_out(gp)
116 for p
in evt.particles():
117 att = std.shared_ptr[
'HepMC3::IntAttribute'](HepMC.IntAttribute(p.id()))
118 p.add_attribute(
"barcode",att)
119 for v
in evt.vertices():
120 att = std.shared_ptr[
'HepMC3::IntAttribute'](HepMC.IntAttribute(v.id()))
121 v.add_attribute(
"barcode",att)
122 return StatusCode.Success