18 std::vector<ActsExamples::SimParticle> genParticlesToActs(
19 const std::vector<HepMC3::GenParticlePtr>& genParticles) {
20 std::vector<ActsExamples::SimParticle> actsParticles;
22 for (
auto& genParticle : genParticles) {
24 std::make_shared<HepMC3::GenParticle>(*genParticle)));
33 HepMC3::GenParticlePtr actsParticleToGen(
34 const std::shared_ptr<ActsExamples::SimParticle>& actsParticle) {
36 const auto mom = actsParticle->fourMomentum();
37 const HepMC3::FourVector
vec(mom[0], mom[1], mom[2], mom[3]);
40 std::make_shared<HepMC3::GenParticle>(
vec, actsParticle->pdg());
41 genParticle->set_generated_mass(actsParticle->mass());
52 HepMC3::GenParticlePtr matchParticles(
53 const std::vector<HepMC3::GenParticlePtr>& genParticles,
54 const std::shared_ptr<ActsExamples::SimParticle>& actsParticle) {
55 const auto id = actsParticle->particleId();
57 for (
auto& genParticle : genParticles) {
58 if (genParticle->id() ==
id) {
68 std::unique_ptr<ActsExamples::SimVertex>
70 const std::shared_ptr<HepMC3::GenVertex>&
vertex) {
71 SimVertex vtx({vertex->position().x(), vertex->position().y(),
72 vertex->position().z(), vertex->position().t()});
73 vtx.
incoming = genParticlesToActs(vertex->particles_in());
74 vtx.outgoing = genParticlesToActs(vertex->particles_out());
76 return std::make_unique<SimVertex>(
std::move(vtx));
80 const std::shared_ptr<HepMC3::GenVertex>&
vertex) {
81 return vertex->in_event();
85 const std::shared_ptr<HepMC3::GenVertex>&
vertex) {
90 const std::shared_ptr<HepMC3::GenVertex>&
vertex) {
91 return genParticlesToActs(vertex->particles_in());
95 const std::shared_ptr<HepMC3::GenVertex>&
vertex) {
96 return genParticlesToActs(vertex->particles_out());
100 const std::shared_ptr<HepMC3::GenVertex>&
vertex) {
102 vec(0) = vertex->position().x();
103 vec(1) = vertex->position().y();
104 vec(2) = vertex->position().z();
109 const std::shared_ptr<HepMC3::GenVertex>&
vertex) {
110 return vertex->position().t();
114 const std::shared_ptr<HepMC3::GenVertex>&
vertex,
115 const std::shared_ptr<SimParticle>&
particle) {
116 vertex->add_particle_in(actsParticleToGen(particle));
120 const std::shared_ptr<HepMC3::GenVertex>&
vertex,
121 const std::shared_ptr<SimParticle>&
particle) {
122 vertex->add_particle_out(actsParticleToGen(particle));
126 const std::shared_ptr<HepMC3::GenVertex>&
vertex,
127 const std::shared_ptr<SimParticle>&
particle) {
129 if (HepMC3::GenParticlePtr genParticle =
130 matchParticles(vertex->particles_in(),
particle)) {
131 vertex->remove_particle_in(genParticle);
136 const std::shared_ptr<HepMC3::GenVertex>&
vertex,
137 const std::shared_ptr<SimParticle>&
particle) {
139 if (HepMC3::GenParticlePtr genParticle =
140 matchParticles(vertex->particles_out(),
particle)) {
141 vertex->remove_particle_out(genParticle);
146 const std::shared_ptr<HepMC3::GenVertex>&
vertex,
148 HepMC3::FourVector fVec(
pos(0),
pos(1),
pos(2), vertex->position().t());
149 vertex->set_position(fVec);
153 const std::shared_ptr<HepMC3::GenVertex>&
vertex,
double time) {
154 HepMC3::FourVector fVec(vertex->position().x(), vertex->position().y(),
155 vertex->position().z(),
time);
156 vertex->set_position(fVec);