19 std::shared_ptr<HepMC3::GenEvent> event,
const double momentumUnit) {
21 HepMC3::Units::MomentumUnit
mom;
23 mom = HepMC3::Units::MomentumUnit::MEV;
25 mom = HepMC3::Units::MomentumUnit::GEV;
28 std::cout <<
"Invalid unit of momentum: " << momentumUnit << std::endl;
29 std::cout <<
"Momentum unit [GeV] will be used instead" << std::endl;
30 mom = HepMC3::Units::MomentumUnit::GEV;
33 event->set_units(mom, event->length_unit());
37 std::shared_ptr<HepMC3::GenEvent> event,
const double lengthUnit) {
39 HepMC3::Units::LengthUnit len;
41 len = HepMC3::Units::LengthUnit::MM;
43 len = HepMC3::Units::LengthUnit::CM;
46 std::cout <<
"Invalid unit of length: " << lengthUnit << std::endl;
47 std::cout <<
"Length unit [mm] will be used instead" << std::endl;
48 len = HepMC3::Units::LengthUnit::MM;
52 event->set_units(event->momentum_unit(), len);
56 std::shared_ptr<HepMC3::GenEvent> event,
const Acts::Vector3D& deltaPos,
57 const double deltaTime) {
59 const HepMC3::FourVector vec(deltaPos(0), deltaPos(1), deltaPos(2),
61 event->shift_position_by(vec);
68 const HepMC3::FourVector vec(
pos(0),
pos(1),
pos(2), time);
69 event->shift_position_to(vec);
75 const HepMC3::FourVector vec(
pos(0),
pos(1),
pos(2), event->event_pos().t());
76 event->shift_position_to(vec);
80 std::shared_ptr<HepMC3::GenEvent> event,
const double time) {
82 const HepMC3::FourVector vec(event->event_pos().x(),
event->event_pos().y(),
83 event->event_pos().z(),
time);
84 event->shift_position_to(vec);
92 std::shared_ptr<SimParticle> actsParticle) {
94 const auto mom4 = actsParticle->momentum4();
95 const HepMC3::FourVector vec(mom4[0], mom4[1], mom4[2], mom4[3]);
97 HepMC3::GenParticle genParticle(vec, actsParticle->pdg());
98 genParticle.set_generated_mass(actsParticle->mass());
100 return std::shared_ptr<HepMC3::GenParticle>(&genParticle);
104 std::shared_ptr<HepMC3::GenEvent> event,
105 std::shared_ptr<SimParticle>
particle) {
107 event->add_particle(actsParticleToGen(particle));
111 const std::shared_ptr<SimVertex>& actsVertex) {
112 const HepMC3::FourVector vec(
113 actsVertex->position4[0], actsVertex->position4[1],
114 actsVertex->position4[2], actsVertex->position4[3]);
117 HepMC3::GenVertex genVertex(vec);
120 for (
auto&
particle : actsVertex->incoming) {
121 HepMC3::GenParticlePtr genParticle =
122 actsParticleToGen(std::make_shared<SimParticle>(
particle));
123 genVertex.add_particle_in(genParticle);
126 for (
auto&
particle : actsVertex->outgoing) {
127 HepMC3::GenParticlePtr genParticle =
128 actsParticleToGen(std::make_shared<SimParticle>(
particle));
129 genVertex.add_particle_out(genParticle);
131 return std::shared_ptr<HepMC3::GenVertex>(&genVertex);
135 std::shared_ptr<HepMC3::GenEvent> event,
136 const std::shared_ptr<SimVertex> vertex) {
138 event->add_vertex(createGenVertex(vertex));
146 std::shared_ptr<HepMC3::GenEvent> event,
147 const std::shared_ptr<SimParticle>&
particle) {
148 const std::vector<HepMC3::GenParticlePtr> genParticles =
event->particles();
149 const auto id = particle->particleId();
151 for (
auto& genParticle : genParticles) {
152 if (genParticle->id() == id) {
154 event->remove_particle(genParticle);
161 const std::shared_ptr<SimVertex>& actsVertex,
162 const HepMC3::GenVertexPtr& genVertex) {
165 HepMC3::FourVector genVec = genVertex->position();
166 if (actsVertex->position4[0] != genVec.x())
168 if (actsVertex->position4[1] != genVec.y())
170 if (actsVertex->position4[2] != genVec.z())
172 if (actsVertex->position4[3] != genVec.t())
174 if (actsVertex->incoming.size() != genVertex->particles_in().size())
176 if (actsVertex->outgoing.size() != genVertex->particles_out().size())
182 std::shared_ptr<HepMC3::GenEvent> event,
183 const std::shared_ptr<SimVertex>& vertex) {
184 const std::vector<HepMC3::GenVertexPtr> genVertices =
event->vertices();
186 for (
auto& genVertex : genVertices)
187 if (compareVertices(vertex, genVertex)) {
189 event->remove_vertex(genVertex);
199 const std::shared_ptr<HepMC3::GenEvent> event) {
201 return (event->momentum_unit() == HepMC3::Units::MomentumUnit::MEV
207 const std::shared_ptr<HepMC3::GenEvent> event) {
209 return (event->length_unit() == HepMC3::Units::LengthUnit::MM
215 const std::shared_ptr<HepMC3::GenEvent> event) {
218 vec(0) =
event->event_pos().x();
219 vec(1) =
event->event_pos().y();
220 vec(2) =
event->event_pos().z();
225 const std::shared_ptr<HepMC3::GenEvent> event) {
227 return event->event_pos().t();
230 std::vector<std::unique_ptr<ActsExamples::SimParticle>>
232 const std::shared_ptr<HepMC3::GenEvent> event) {
233 std::vector<std::unique_ptr<SimParticle>> actsParticles;
234 const std::vector<HepMC3::GenParticlePtr> genParticles =
event->particles();
239 for (
auto& genParticle : genParticles)
240 actsParticles.push_back(
241 simPart.
particle(std::make_shared<HepMC3::GenParticle>(*genParticle)));
243 return actsParticles;
246 std::vector<std::unique_ptr<ActsExamples::SimVertex>>
248 const std::shared_ptr<HepMC3::GenEvent> event) {
249 std::vector<std::unique_ptr<SimVertex>> actsVertices;
250 const std::vector<HepMC3::GenVertexPtr> genVertices =
event->vertices();
255 for (
auto& genVertex : genVertices) {
256 actsVertices.push_back(
257 simVert.
processVertex(std::make_shared<HepMC3::GenVertex>(*genVertex)));
262 std::vector<std::unique_ptr<ActsExamples::SimParticle>>
264 const std::shared_ptr<HepMC3::GenEvent> event) {
265 std::vector<std::unique_ptr<SimParticle>> actsBeams;
266 const std::vector<HepMC3::GenParticlePtr> genBeams =
event->beams();
271 for (
auto& genBeam : genBeams)
273 simPart.
particle(std::make_shared<HepMC3::GenParticle>(*genBeam)));
277 std::vector<std::unique_ptr<ActsExamples::SimParticle>>
279 const std::shared_ptr<HepMC3::GenEvent> event) {
280 std::vector<HepMC3::GenParticlePtr> particles =
event->particles();
281 std::vector<std::unique_ptr<SimParticle>> fState;