Warning, file /acts/Examples/Io/HepMC3/src/HepMC3Particle.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Io/HepMC3/HepMC3Particle.hpp"
0010
0011 #include "Acts/Definitions/ParticleData.hpp"
0012 #include "ActsExamples/EventData/SimParticle.hpp"
0013 #include "ActsExamples/Io/HepMC3/HepMC3Vertex.hpp"
0014
0015 namespace ActsExamples {
0016
0017 SimBarcode HepMC3Particle::barcode(
0018 const HepMC3::ConstGenParticlePtr& particle) {
0019
0020 return particle->id();
0021 }
0022
0023 SimParticle HepMC3Particle::particle(
0024 const HepMC3::ConstGenParticlePtr& particle) {
0025 SimBarcode particleId = barcode(particle);
0026 Acts::PdgParticle pdg = static_cast<Acts::PdgParticle>(particle->pid());
0027 SimParticleState fw(particleId, pdg, Acts::findCharge(pdg).value_or(0),
0028 particle->generated_mass());
0029 fw.setDirection(particle->momentum().x(), particle->momentum().y(),
0030 particle->momentum().z());
0031 fw.setAbsoluteMomentum(particle->momentum().p3mod());
0032 return SimParticle(fw, fw);
0033 }
0034
0035 int HepMC3Particle::id(const std::shared_ptr<HepMC3::GenParticle>& particle) {
0036 return particle->id();
0037 }
0038
0039 std::unique_ptr<SimVertex> HepMC3Particle::productionVertex(
0040 const std::shared_ptr<HepMC3::GenParticle>& particle) {
0041
0042 if (particle->production_vertex()) {
0043 return HepMC3Vertex::processVertex(
0044 std::make_shared<HepMC3::GenVertex>(*particle->production_vertex()));
0045 } else {
0046 return nullptr;
0047 }
0048 }
0049
0050 std::unique_ptr<SimVertex> HepMC3Particle::endVertex(
0051 const std::shared_ptr<HepMC3::GenParticle>& particle) {
0052
0053 if (particle->end_vertex()) {
0054 return HepMC3Vertex::processVertex(
0055 std::make_shared<HepMC3::GenVertex>(*(particle->end_vertex())));
0056 } else {
0057 return nullptr;
0058 }
0059 }
0060
0061 int HepMC3Particle::pdgID(
0062 const std::shared_ptr<HepMC3::GenParticle>& particle) {
0063 return particle->pid();
0064 }
0065
0066 Acts::Vector3 HepMC3Particle::momentum(
0067 const std::shared_ptr<HepMC3::GenParticle>& particle) {
0068 Acts::Vector3 mom;
0069 mom(0) = particle->momentum().x();
0070 mom(1) = particle->momentum().y();
0071 mom(2) = particle->momentum().z();
0072 return mom;
0073 }
0074
0075 double HepMC3Particle::energy(
0076 const std::shared_ptr<HepMC3::GenParticle>& particle) {
0077 return particle->momentum().e();
0078 }
0079
0080 double HepMC3Particle::mass(
0081 const std::shared_ptr<HepMC3::GenParticle>& particle) {
0082 return particle->generated_mass();
0083 }
0084
0085 double HepMC3Particle::charge(
0086 const std::shared_ptr<HepMC3::GenParticle>& particle) {
0087 return Acts::findCharge(static_cast<Acts::PdgParticle>(particle->pid()))
0088 .value_or(0);
0089 }
0090
0091 void HepMC3Particle::pdgID(const std::shared_ptr<HepMC3::GenParticle>& particle,
0092 const int pid) {
0093 particle->set_pid(pid);
0094 }
0095
0096 void HepMC3Particle::momentum(
0097 const std::shared_ptr<HepMC3::GenParticle>& particle,
0098 const Acts::Vector3& mom) {
0099 HepMC3::FourVector fVec(mom(0), mom(1), mom(2), particle->momentum().e());
0100 particle->set_momentum(fVec);
0101 }
0102
0103 void HepMC3Particle::energy(
0104 const std::shared_ptr<HepMC3::GenParticle>& particle, const double energy) {
0105 HepMC3::FourVector fVec(particle->momentum().x(), particle->momentum().y(),
0106 particle->momentum().z(), energy);
0107 particle->set_momentum(fVec);
0108 }
0109
0110 void HepMC3Particle::mass(const std::shared_ptr<HepMC3::GenParticle>& particle,
0111 const double mass) {
0112 particle->set_generated_mass(mass);
0113 }
0114
0115 }