19 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 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);
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);
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<SimParticle>
particle) {
106 event->add_particle(actsParticleToGen(particle));
110 const std::shared_ptr<SimVertex>& actsVertex) {
111 const HepMC3::FourVector vec(
112 actsVertex->position4[0], actsVertex->position4[1],
113 actsVertex->position4[2], actsVertex->position4[3]);
116 HepMC3::GenVertex genVertex(vec);
119 for (
auto&
particle : actsVertex->incoming) {
120 HepMC3::GenParticlePtr genParticle =
121 actsParticleToGen(std::make_shared<SimParticle>(
particle));
122 genVertex.add_particle_in(genParticle);
125 for (
auto&
particle : actsVertex->outgoing) {
126 HepMC3::GenParticlePtr genParticle =
127 actsParticleToGen(std::make_shared<SimParticle>(
particle));
128 genVertex.add_particle_out(genParticle);
130 return std::shared_ptr<HepMC3::GenVertex>(&genVertex);
134 const std::shared_ptr<SimVertex> vertex) {
136 event->add_vertex(createGenVertex(vertex));
144 std::shared_ptr<HepMC3::GenEvent> event,
145 const std::shared_ptr<SimParticle>&
particle) {
146 const std::vector<HepMC3::GenParticlePtr> genParticles =
event->particles();
147 const auto id = particle->particleId();
149 for (
auto& genParticle : genParticles) {
150 if (genParticle->id() == id) {
152 event->remove_particle(genParticle);
159 const std::shared_ptr<SimVertex>& actsVertex,
160 const HepMC3::GenVertexPtr& genVertex) {
163 HepMC3::FourVector genVec = genVertex->position();
164 if (actsVertex->position4[0] != genVec.x())
166 if (actsVertex->position4[1] != genVec.y())
168 if (actsVertex->position4[2] != genVec.z())
170 if (actsVertex->position4[3] != genVec.t())
172 if (actsVertex->incoming.size() != genVertex->particles_in().size())
174 if (actsVertex->outgoing.size() != genVertex->particles_out().size())
180 const std::shared_ptr<SimVertex>& vertex) {
181 const std::vector<HepMC3::GenVertexPtr> genVertices =
event->vertices();
183 for (
auto& genVertex : genVertices)
184 if (compareVertices(vertex, genVertex)) {
186 event->remove_vertex(genVertex);
196 const std::shared_ptr<HepMC3::GenEvent> event) {
198 return (event->momentum_unit() == HepMC3::Units::MomentumUnit::MEV
204 const std::shared_ptr<HepMC3::GenEvent> event) {
206 return (event->length_unit() == HepMC3::Units::LengthUnit::MM
212 const std::shared_ptr<HepMC3::GenEvent> event) {
215 vec(0) =
event->event_pos().x();
216 vec(1) =
event->event_pos().y();
217 vec(2) =
event->event_pos().z();
222 const std::shared_ptr<HepMC3::GenEvent> event) {
224 return event->event_pos().t();
228 const std::shared_ptr<HepMC3::GenEvent> event) {
229 std::vector<std::unique_ptr<SimParticle>> actsParticles;
230 const std::vector<HepMC3::GenParticlePtr> genParticles =
event->particles();
235 for (
auto& genParticle : genParticles)
236 actsParticles.push_back(std::move(
237 simPart.
particle(std::make_shared<HepMC3::GenParticle>(*genParticle))));
239 return std::move(actsParticles);
243 const std::shared_ptr<HepMC3::GenEvent> event) {
244 std::vector<std::unique_ptr<SimVertex>> actsVertices;
245 const std::vector<HepMC3::GenVertexPtr> genVertices =
event->vertices();
250 for (
auto& genVertex : genVertices) {
252 std::make_shared<HepMC3::GenVertex>(*genVertex))));
254 return std::move(actsVertices);
258 const std::shared_ptr<HepMC3::GenEvent> event) {
259 std::vector<std::unique_ptr<SimParticle>> actsBeams;
260 const std::vector<HepMC3::GenParticlePtr> genBeams =
event->beams();
265 for (
auto& genBeam : genBeams)
266 actsBeams.push_back(std::move(
267 simPart.
particle(std::make_shared<HepMC3::GenParticle>(*genBeam))));
268 return std::move(actsBeams);
272 const std::shared_ptr<HepMC3::GenEvent> event) {
273 std::vector<HepMC3::GenParticlePtr> particles =
event->particles();
274 std::vector<std::unique_ptr<SimParticle>> fState;