File indexing completed on 2025-01-18 09:12:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsFatras/Geant4/PDGtoG4Converter.hpp"
0010
0011 #include <cstdlib>
0012 #include <utility>
0013
0014 #include "G4ParticleDefinition.hh"
0015 #include "G4ParticleTypes.hh"
0016
0017 ActsFatras::PDGtoG4Converter::PDGtoG4Converter() : m_pdgG4ParticleMap() {
0018
0019 fillPredefinedParticles();
0020 }
0021
0022 G4ParticleDefinition* ActsFatras::PDGtoG4Converter::getParticleDefinition(
0023 Acts::PdgParticle pdgCode) const {
0024 std::unordered_map<Acts::PdgParticle, G4ParticleDefinition*>::const_iterator
0025 it = m_pdgG4ParticleMap.find(pdgCode);
0026
0027
0028 if (it != m_pdgG4ParticleMap.end()) {
0029 return it->second;
0030 } else {
0031
0032
0033 it = m_pdgG4ParticleMap.find(makeAbsolutePdgParticle(pdgCode));
0034 if (it != m_pdgG4ParticleMap.end() &&
0035 std::abs(it->second->GetPDGCharge()) < 0.1) {
0036 return it->second;
0037 }
0038 }
0039
0040 return nullptr;
0041 }
0042
0043 void ActsFatras::PDGtoG4Converter::fillPredefinedParticles() {
0044
0045 addParticle(G4Gamma::GammaDefinition());
0046
0047
0048 addParticle(G4Electron::ElectronDefinition());
0049 addParticle(G4NeutrinoE::NeutrinoEDefinition());
0050 addParticle(G4MuonMinus::MuonMinusDefinition());
0051 addParticle(G4NeutrinoMu::NeutrinoMuDefinition());
0052 addParticle(G4TauMinus::TauMinusDefinition());
0053 addParticle(G4NeutrinoTau::NeutrinoTauDefinition());
0054 addParticle(G4Positron::PositronDefinition());
0055 addParticle(G4AntiNeutrinoE::AntiNeutrinoEDefinition());
0056 addParticle(G4MuonPlus::MuonPlusDefinition());
0057 addParticle(G4AntiNeutrinoMu::AntiNeutrinoMuDefinition());
0058 addParticle(G4TauPlus::TauPlusDefinition());
0059 addParticle(G4AntiNeutrinoTau::AntiNeutrinoTauDefinition());
0060
0061
0062 addParticle(G4PionZero::PionZeroDefinition());
0063 addParticle(G4PionPlus::PionPlusDefinition());
0064 addParticle(G4PionMinus::PionMinusDefinition());
0065
0066
0067 addParticle(G4Eta::EtaDefinition());
0068 addParticle(G4EtaPrime::EtaPrimeDefinition());
0069
0070
0071 addParticle(G4KaonZeroLong::KaonZeroLongDefinition());
0072 addParticle(G4KaonZeroShort::KaonZeroShortDefinition());
0073 addParticle(G4KaonZero::KaonZeroDefinition());
0074 addParticle(G4KaonPlus::KaonPlusDefinition());
0075 addParticle(G4AntiKaonZero::AntiKaonZeroDefinition());
0076 addParticle(G4KaonMinus::KaonMinusDefinition());
0077
0078
0079 addParticle(G4DMesonPlus::DMesonPlusDefinition());
0080 addParticle(G4DMesonZero::DMesonZeroDefinition());
0081 addParticle(G4DsMesonPlus::DsMesonPlusDefinition());
0082 addParticle(G4DMesonMinus::DMesonMinusDefinition());
0083 addParticle(G4AntiDMesonZero::AntiDMesonZeroDefinition());
0084 addParticle(G4DsMesonMinus::DsMesonMinusDefinition());
0085
0086
0087 addParticle(G4BMesonZero::BMesonZeroDefinition());
0088 addParticle(G4BMesonPlus::BMesonPlusDefinition());
0089 addParticle(G4BsMesonZero::BsMesonZeroDefinition());
0090 addParticle(G4AntiBMesonZero::AntiBMesonZeroDefinition());
0091 addParticle(G4BMesonMinus::BMesonMinusDefinition());
0092 addParticle(G4AntiBsMesonZero::AntiBsMesonZeroDefinition());
0093
0094
0095 addParticle(G4JPsi::JPsiDefinition());
0096
0097
0098 addParticle(G4Proton::ProtonDefinition());
0099 addParticle(G4Neutron::NeutronDefinition());
0100 addParticle(G4AntiProton::AntiProtonDefinition());
0101 addParticle(G4AntiNeutron::AntiNeutronDefinition());
0102
0103
0104 addParticle(G4Lambda::LambdaDefinition());
0105 addParticle(G4SigmaPlus::SigmaPlusDefinition());
0106 addParticle(G4SigmaZero::SigmaZeroDefinition());
0107 addParticle(G4SigmaMinus::SigmaMinusDefinition());
0108 addParticle(G4XiZero::XiZeroDefinition());
0109 addParticle(G4XiMinus::XiMinusDefinition());
0110 addParticle(G4OmegaMinus::OmegaMinusDefinition());
0111 addParticle(G4AntiLambda::AntiLambdaDefinition());
0112 addParticle(G4AntiSigmaPlus::AntiSigmaPlusDefinition());
0113 addParticle(G4AntiSigmaZero::AntiSigmaZeroDefinition());
0114 addParticle(G4AntiSigmaMinus::AntiSigmaMinusDefinition());
0115 addParticle(G4AntiXiZero::AntiXiZeroDefinition());
0116 addParticle(G4AntiXiMinus::AntiXiMinusDefinition());
0117 addParticle(G4AntiOmegaMinus::AntiOmegaMinusDefinition());
0118
0119
0120 addParticle(G4LambdacPlus::LambdacPlusDefinition());
0121 addParticle(G4SigmacPlusPlus::SigmacPlusPlusDefinition());
0122 addParticle(G4SigmacPlus::SigmacPlusDefinition());
0123 addParticle(G4SigmacZero::SigmacZeroDefinition());
0124 addParticle(G4XicPlus::XicPlusDefinition());
0125 addParticle(G4XicZero::XicZeroDefinition());
0126 addParticle(G4OmegacZero::OmegacZeroDefinition());
0127 addParticle(G4AntiLambdacPlus::AntiLambdacPlusDefinition());
0128 addParticle(G4AntiSigmacPlusPlus::AntiSigmacPlusPlusDefinition());
0129 addParticle(G4AntiSigmacPlus::AntiSigmacPlusDefinition());
0130 addParticle(G4AntiSigmacZero::AntiSigmacZeroDefinition());
0131 addParticle(G4AntiXicPlus::AntiXicPlusDefinition());
0132 addParticle(G4AntiXicZero::AntiXicZeroDefinition());
0133 addParticle(G4AntiOmegacZero::AntiOmegacZeroDefinition());
0134 }
0135
0136 void ActsFatras::PDGtoG4Converter::addParticle(G4ParticleDefinition* pDef) {
0137 if (pDef == nullptr) {
0138 return;
0139 }
0140
0141 m_pdgG4ParticleMap[static_cast<Acts::PdgParticle>(pDef->GetPDGEncoding())] =
0142 pDef;
0143 }