Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDGtoG4Converter.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PDGtoG4Converter.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 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 
11 #include <cstdlib>
12 #include <utility>
13 
14 #include "G4ParticleDefinition.hh"
15 #include "G4ParticleTypes.hh"
16 
20 }
21 
23  Acts::PdgParticle pdgCode) const {
24  std::unordered_map<Acts::PdgParticle, G4ParticleDefinition*>::const_iterator
25  it = m_pdgG4ParticleMap.find(pdgCode);
26 
27  // Find the corresponding particle and return it
28  if (it != m_pdgG4ParticleMap.end()) {
29  return it->second;
30  } else {
31  // Rescue mechanism: If the particle is neutral and its anti-particle is
32  // stored then return that one instead
33  it = m_pdgG4ParticleMap.find(makeAbsolutePdgParticle(pdgCode));
34  if (it != m_pdgG4ParticleMap.end() &&
35  std::abs(it->second->GetPDGCharge()) < 0.1) {
36  return it->second;
37  }
38  }
39  // No particle found
40  return nullptr;
41 }
42 
44  // Gauge and Higgs Bosons
45  addParticle(G4Gamma::GammaDefinition());
46 
47  // Leptons
48  addParticle(G4Electron::ElectronDefinition());
49  addParticle(G4NeutrinoE::NeutrinoEDefinition());
50  addParticle(G4MuonMinus::MuonMinusDefinition());
51  addParticle(G4NeutrinoMu::NeutrinoMuDefinition());
52  addParticle(G4TauMinus::TauMinusDefinition());
53  addParticle(G4NeutrinoTau::NeutrinoTauDefinition());
54  addParticle(G4Positron::PositronDefinition());
55  addParticle(G4AntiNeutrinoE::AntiNeutrinoEDefinition());
56  addParticle(G4MuonPlus::MuonPlusDefinition());
57  addParticle(G4AntiNeutrinoMu::AntiNeutrinoMuDefinition());
58  addParticle(G4TauPlus::TauPlusDefinition());
59  addParticle(G4AntiNeutrinoTau::AntiNeutrinoTauDefinition());
60 
61  // Light I=1 Mesons
62  addParticle(G4PionZero::PionZeroDefinition());
63  addParticle(G4PionPlus::PionPlusDefinition());
64  addParticle(G4PionMinus::PionMinusDefinition());
65 
66  // Light I=0 Mesons
67  addParticle(G4Eta::EtaDefinition());
68  addParticle(G4EtaPrime::EtaPrimeDefinition());
69 
70  // Strange Mesons
71  addParticle(G4KaonZeroLong::KaonZeroLongDefinition());
72  addParticle(G4KaonZeroShort::KaonZeroShortDefinition());
73  addParticle(G4KaonZero::KaonZeroDefinition());
74  addParticle(G4KaonPlus::KaonPlusDefinition());
75  addParticle(G4AntiKaonZero::AntiKaonZeroDefinition());
76  addParticle(G4KaonMinus::KaonMinusDefinition());
77 
78  // Charmed Mesons
79  addParticle(G4DMesonPlus::DMesonPlusDefinition());
80  addParticle(G4DMesonZero::DMesonZeroDefinition());
81  addParticle(G4DsMesonPlus::DsMesonPlusDefinition());
82  addParticle(G4DMesonMinus::DMesonMinusDefinition());
83  addParticle(G4AntiDMesonZero::AntiDMesonZeroDefinition());
84  addParticle(G4DsMesonMinus::DsMesonMinusDefinition());
85 
86  // Bottom Mesons
87  addParticle(G4BMesonZero::BMesonZeroDefinition());
88  addParticle(G4BMesonPlus::BMesonPlusDefinition());
89  addParticle(G4BsMesonZero::BsMesonZeroDefinition());
90  addParticle(G4AntiBMesonZero::AntiBMesonZeroDefinition());
91  addParticle(G4BMesonMinus::BMesonMinusDefinition());
92  addParticle(G4AntiBsMesonZero::AntiBsMesonZeroDefinition());
93 
94  // ccbar Mesons
95  addParticle(G4JPsi::JPsiDefinition());
96 
97  // Light Baryons
98  addParticle(G4Proton::ProtonDefinition());
99  addParticle(G4Neutron::NeutronDefinition());
100  addParticle(G4AntiProton::AntiProtonDefinition());
101  addParticle(G4AntiNeutron::AntiNeutronDefinition());
102 
103  // Strange Baryons
104  addParticle(G4Lambda::LambdaDefinition());
105  addParticle(G4SigmaPlus::SigmaPlusDefinition());
106  addParticle(G4SigmaZero::SigmaZeroDefinition());
107  addParticle(G4SigmaMinus::SigmaMinusDefinition());
108  addParticle(G4XiZero::XiZeroDefinition());
109  addParticle(G4XiMinus::XiMinusDefinition());
110  addParticle(G4OmegaMinus::OmegaMinusDefinition());
111  addParticle(G4AntiLambda::AntiLambdaDefinition());
112  addParticle(G4AntiSigmaPlus::AntiSigmaPlusDefinition());
113  addParticle(G4AntiSigmaZero::AntiSigmaZeroDefinition());
114  addParticle(G4AntiSigmaMinus::AntiSigmaMinusDefinition());
115  addParticle(G4AntiXiZero::AntiXiZeroDefinition());
116  addParticle(G4AntiXiMinus::AntiXiMinusDefinition());
117  addParticle(G4AntiOmegaMinus::AntiOmegaMinusDefinition());
118 
119  // Charmed Baryons
120  addParticle(G4LambdacPlus::LambdacPlusDefinition());
121  addParticle(G4SigmacPlusPlus::SigmacPlusPlusDefinition());
122  addParticle(G4SigmacPlus::SigmacPlusDefinition());
123  addParticle(G4SigmacZero::SigmacZeroDefinition());
124  addParticle(G4XicPlus::XicPlusDefinition());
125  addParticle(G4XicZero::XicZeroDefinition());
126  addParticle(G4OmegacZero::OmegacZeroDefinition());
127  addParticle(G4AntiLambdacPlus::AntiLambdacPlusDefinition());
128  addParticle(G4AntiSigmacPlusPlus::AntiSigmacPlusPlusDefinition());
129  addParticle(G4AntiSigmacPlus::AntiSigmacPlusDefinition());
130  addParticle(G4AntiSigmacZero::AntiSigmacZeroDefinition());
131  addParticle(G4AntiXicPlus::AntiXicPlusDefinition());
132  addParticle(G4AntiXicZero::AntiXicZeroDefinition());
133  addParticle(G4AntiOmegacZero::AntiOmegacZeroDefinition());
134 }
135 
136 void ActsFatras::PDGtoG4Converter::addParticle(G4ParticleDefinition* pDef) {
137  if (pDef == nullptr) {
138  return;
139  }
140 
141  m_pdgG4ParticleMap[static_cast<Acts::PdgParticle>(pDef->GetPDGEncoding())] =
142  pDef;
143 }