Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:12

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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   /// Fill the storage
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   // Find the corresponding particle and return it
0028   if (it != m_pdgG4ParticleMap.end()) {
0029     return it->second;
0030   } else {
0031     // Rescue mechanism: If the particle is neutral and its anti-particle is
0032     // stored then return that one instead
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   // No particle found
0040   return nullptr;
0041 }
0042 
0043 void ActsFatras::PDGtoG4Converter::fillPredefinedParticles() {
0044   // Gauge and Higgs Bosons
0045   addParticle(G4Gamma::GammaDefinition());
0046 
0047   // Leptons
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   // Light I=1 Mesons
0062   addParticle(G4PionZero::PionZeroDefinition());
0063   addParticle(G4PionPlus::PionPlusDefinition());
0064   addParticle(G4PionMinus::PionMinusDefinition());
0065 
0066   // Light I=0 Mesons
0067   addParticle(G4Eta::EtaDefinition());
0068   addParticle(G4EtaPrime::EtaPrimeDefinition());
0069 
0070   // Strange Mesons
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   // Charmed Mesons
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   // Bottom Mesons
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   // ccbar Mesons
0095   addParticle(G4JPsi::JPsiDefinition());
0096 
0097   // Light Baryons
0098   addParticle(G4Proton::ProtonDefinition());
0099   addParticle(G4Neutron::NeutronDefinition());
0100   addParticle(G4AntiProton::AntiProtonDefinition());
0101   addParticle(G4AntiNeutron::AntiNeutronDefinition());
0102 
0103   // Strange Baryons
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   // Charmed Baryons
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 }