EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HepMC3Particle.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HepMC3Particle.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 
13 std::unique_ptr<ActsExamples::SimParticle>
15  const std::shared_ptr<HepMC3::GenParticle> particle) {
16  // TODO this is probably not quite right
17  ActsFatras::Barcode particleId;
18  particleId.setParticle(particle->id());
19  SimParticle fw(particleId, static_cast<Acts::PdgParticle>(particle->pid()),
20  HepPID::charge(particle->pid()), particle->generated_mass());
21  fw.setDirection(particle->momentum().x(), particle->momentum().y(),
22  particle->momentum().z());
23  fw.setAbsMomentum(particle->momentum().p3mod());
24  return std::make_unique<SimParticle>(std::move(fw));
25 }
26 
28  const std::shared_ptr<HepMC3::GenParticle> particle) {
29  return particle->id();
30 }
31 
32 std::unique_ptr<ActsExamples::SimVertex>
34  const std::shared_ptr<HepMC3::GenParticle> particle) {
35  HepMC3Vertex simVert;
36 
37  // Return the vertex if it exists
38  if (particle->production_vertex())
39  return simVert.processVertex(
40  std::make_shared<HepMC3::GenVertex>(*particle->production_vertex()));
41  else
42  return nullptr;
43 }
44 
45 std::unique_ptr<ActsExamples::SimVertex>
47  const std::shared_ptr<HepMC3::GenParticle> particle) {
48  HepMC3Vertex simVert;
49 
50  // Return the vertex if it exists
51  if (particle->end_vertex())
52  return simVert.processVertex(
53  std::make_shared<HepMC3::GenVertex>(*(particle->end_vertex())));
54  else
55  return nullptr;
56 }
57 
59  const std::shared_ptr<HepMC3::GenParticle> particle) {
60  return particle->pid();
61 }
62 
64  const std::shared_ptr<HepMC3::GenParticle> particle) {
66  mom(0) = particle->momentum().x();
67  mom(1) = particle->momentum().y();
68  mom(2) = particle->momentum().z();
69  return mom;
70 }
71 
73  const std::shared_ptr<HepMC3::GenParticle> particle) {
74  return particle->momentum().e();
75 }
76 
78  const std::shared_ptr<HepMC3::GenParticle> particle) {
79  return particle->generated_mass();
80 }
81 
83  const std::shared_ptr<HepMC3::GenParticle> particle) {
84  return HepPID::charge(particle->pid());
85 }
86 
88  std::shared_ptr<HepMC3::GenParticle> particle, const int pid) {
89  particle->set_pid(pid);
90 }
91 
93  std::shared_ptr<HepMC3::GenParticle> particle, const Acts::Vector3D& mom) {
94  HepMC3::FourVector fVec(mom(0), mom(1), mom(2), particle->momentum().e());
95  particle->set_momentum(fVec);
96 }
97 
99  std::shared_ptr<HepMC3::GenParticle> particle, const double energy) {
100  HepMC3::FourVector fVec(particle->momentum().x(), particle->momentum().y(),
101  particle->momentum().z(), energy);
102  particle->set_momentum(fVec);
103 }
104 
106  std::shared_ptr<HepMC3::GenParticle> particle, const double mass) {
107  particle->set_generated_mass(mass);
108 }