ATLAS Offline Software
Loading...
Searching...
No Matches
iFatras::PDGToG4Particle Class Reference

AlgTool to convert a pdgCode into a particle definition used by the G4 decayer. More...

#include <PDGToG4Particle.h>

Inheritance diagram for iFatras::PDGToG4Particle:
Collaboration diagram for iFatras::PDGToG4Particle:

Public Types

typedef std::map< int, G4ParticleDefinition * > PDGG4ParticleMap

Public Member Functions

virtual StatusCode initialize () override
 AlgTool initailize method.
G4ParticleDefinition * getParticleDefinition (int pdgCode) const
 Returns the G4ParticleDefinition of particle with PDG ID pdgCode, 0 otherwise.
std::vector< std::pair< int, std::string > > listOfParticles () const
 returns a vector of pdgid / particlename pairs containing all particles
void printListOfParticles (bool withDecayTableOnly=false) const
 prints list of particles to stdout
 AthAlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor from base class.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::map< int, G4ParticleDefinition * > predefinedParticles ()
 fills default particles in map
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

PDGG4ParticleMap m_pdgG4ParticleMap
 map from pdg codes to defined Geant4 particles
Gaudi::Property< std::vector< int > > m_useParticles
Gaudi::Property< bool > m_printList
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

AlgTool to convert a pdgCode into a particle definition used by the G4 decayer.

Author
Joerg.Mechnich -at- cern.ch, Andreas.Salzburger -at- cern.ch

Definition at line 29 of file PDGToG4Particle.h.

Member Typedef Documentation

◆ PDGG4ParticleMap

typedef std::map<int,G4ParticleDefinition*> iFatras::PDGToG4Particle::PDGG4ParticleMap

Definition at line 52 of file PDGToG4Particle.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Function Documentation

◆ AthAlgTool()

AthAlgTool::AthAlgTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructor from base class.

Definition at line 31 of file AthAlgTool.cxx.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getParticleDefinition()

G4ParticleDefinition * iFatras::PDGToG4Particle::getParticleDefinition ( int pdgCode) const

Returns the G4ParticleDefinition of particle with PDG ID pdgCode, 0 otherwise.

Definition at line 92 of file PDGToG4Particle.cxx.

93{
94 G4ParticleDefinition* ret = 0;
95
96 PDGG4ParticleMap::const_iterator it =
97 m_pdgG4ParticleMap.find( pdgCode);
98
99 if( it != m_pdgG4ParticleMap.end()) ret = it->second;
100 else
101 {
102 it = m_pdgG4ParticleMap.find( std::abs( pdgCode));
103 if( it != m_pdgG4ParticleMap.end())
104 {
105 if( std::abs( it->second->GetPDGCharge()) < 0.1)
106 ret = it->second;
107 else
108 {
109 ATH_MSG_WARNING( "PDG Code " << pdgCode << " not found,"
110 << " " << -pdgCode << " exists but is charged!" );
111 }
112 }
113 }
114
115 return ret;
116}
#define ATH_MSG_WARNING(x)
PDGG4ParticleMap m_pdgG4ParticleMap
map from pdg codes to defined Geant4 particles

◆ initialize()

StatusCode iFatras::PDGToG4Particle::initialize ( )
overridevirtual

AlgTool initailize method.

Definition at line 35 of file PDGToG4Particle.cxx.

36{
37 // Update output level
38 ATH_MSG_VERBOSE( "initialize()" );
39
40 /*-----------------------------------------------------------------------
41 * Fill map of particles
42 *-----------------------------------------------------------------------*/
43 static const auto s_predefinedParticles = predefinedParticles();
44
45 if( m_useParticles.size() == 0)
46 {
47 ATH_MSG_INFO( "using all predefined particles" );
48 m_pdgG4ParticleMap.insert( s_predefinedParticles.begin(),
49 s_predefinedParticles.end());
50 ATH_MSG_INFO( "loaded " << m_pdgG4ParticleMap.size() << " particles" );
51 }
52 else
53 {
54 std::vector<int>::const_iterator pdgIt = m_useParticles.begin();
55 for( ; pdgIt != m_useParticles.end(); ++pdgIt)
56 {
57 PDGG4ParticleMap::const_iterator mapIt =
58 s_predefinedParticles.find( *pdgIt);
59 if( mapIt == s_predefinedParticles.end())
60 {
61 ATH_MSG_WARNING( "particle with pdg code " << *pdgIt
62 << " not found in list of predefined particles, ignoring" );
63 continue;
64 }
65
66 if( m_pdgG4ParticleMap.find( *pdgIt) != m_pdgG4ParticleMap.end())
67 {
68 ATH_MSG_WARNING( "particle with pdg code " << *pdgIt
69 << " already loaded, ignoring" );
70 continue;
71 }
72
73 m_pdgG4ParticleMap[*pdgIt] = mapIt->second;
74 }
75 }
76
77 if( m_printList)
78 {
79 ATH_MSG_INFO( "List of loaded particles:" );
81 }
82
83 return StatusCode::SUCCESS;
84}
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< std::vector< int > > m_useParticles
void printListOfParticles(bool withDecayTableOnly=false) const
prints list of particles to stdout
std::map< int, G4ParticleDefinition * > predefinedParticles()
fills default particles in map
Gaudi::Property< bool > m_printList

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ listOfParticles()

std::vector< std::pair< int, std::string > > iFatras::PDGToG4Particle::listOfParticles ( ) const

returns a vector of pdgid / particlename pairs containing all particles

Definition at line 123 of file PDGToG4Particle.cxx.

124{
125 std::vector<std::pair<int,std::string> > ret;
126
127 for( PDGG4ParticleMap::const_iterator it = m_pdgG4ParticleMap.begin();
128 it != m_pdgG4ParticleMap.end(); ++it)
129 {
130 // Only return matter particles (for consistency with HepPDT)
131 if( it->first > 0)
132 {
133 ret.push_back( std::make_pair( it->first, it->second->GetParticleName()));
134 }
135 }
136
137 return ret;
138}

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ predefinedParticles()

std::map< int, G4ParticleDefinition * > iFatras::PDGToG4Particle::predefinedParticles ( )
private

fills default particles in map

map of predefined particles

Helper to fill map

Definition at line 194 of file PDGToG4Particle.cxx.

195{
197 std::map<int,G4ParticleDefinition*> predefinedParticles;
198
200 auto addParticle = [&](G4ParticleDefinition* pDef) {
201 if (pDef) predefinedParticles[pDef->GetPDGEncoding()] = pDef;
202 };
203
204 // Gauge and Higgs Bosons
205 addParticle( G4Gamma::GammaDefinition());
206
207 // Leptons
208 addParticle( G4Electron::ElectronDefinition());
209 addParticle( G4NeutrinoE::NeutrinoEDefinition());
210 addParticle( G4MuonMinus::MuonMinusDefinition());
211 addParticle( G4NeutrinoMu::NeutrinoMuDefinition());
212 addParticle( G4TauMinus::TauMinusDefinition());
213 addParticle( G4NeutrinoTau::NeutrinoTauDefinition());
214 addParticle( G4Positron::PositronDefinition());
215 addParticle( G4AntiNeutrinoE::AntiNeutrinoEDefinition());
216 addParticle( G4MuonPlus::MuonPlusDefinition());
217 addParticle( G4AntiNeutrinoMu::AntiNeutrinoMuDefinition());
218 addParticle( G4TauPlus::TauPlusDefinition());
219 addParticle( G4AntiNeutrinoTau::AntiNeutrinoTauDefinition());
220
221 // Light I=1 Mesons
222 addParticle( G4PionZero::PionZeroDefinition());
223 addParticle( G4PionPlus::PionPlusDefinition());
224 addParticle( G4PionMinus::PionMinusDefinition());
225
226 // Light I=0 Mesons
227 addParticle( G4Eta::EtaDefinition());
228 addParticle( G4EtaPrime::EtaPrimeDefinition());
229
230 // Strange Mesons
231 addParticle( G4KaonZeroLong::KaonZeroLongDefinition());
232 addParticle( G4KaonZeroShort::KaonZeroShortDefinition());
233 addParticle( G4KaonZero::KaonZeroDefinition());
234 addParticle( G4KaonPlus::KaonPlusDefinition());
235 addParticle( G4AntiKaonZero::AntiKaonZeroDefinition());
236 addParticle( G4KaonMinus::KaonMinusDefinition());
237
238 // Charmed Mesons
239 addParticle( G4DMesonPlus::DMesonPlusDefinition());
240 addParticle( G4DMesonZero::DMesonZeroDefinition());
241 addParticle( G4DsMesonPlus::DsMesonPlusDefinition());
242 addParticle( G4DMesonMinus::DMesonMinusDefinition());
243 addParticle( G4AntiDMesonZero::AntiDMesonZeroDefinition());
244 addParticle( G4DsMesonMinus::DsMesonMinusDefinition());
245
246 // Bottom Mesons
247 addParticle( G4BMesonZero::BMesonZeroDefinition());
248 addParticle( G4BMesonPlus::BMesonPlusDefinition());
249 addParticle( G4BsMesonZero::BsMesonZeroDefinition());
250 addParticle( G4AntiBMesonZero::AntiBMesonZeroDefinition());
251 addParticle( G4BMesonMinus::BMesonMinusDefinition());
252 addParticle( G4AntiBsMesonZero::AntiBsMesonZeroDefinition());
253
254 // ccbar Mesons
255 addParticle( G4JPsi::JPsiDefinition());
256
257 // Light Baryons
258 addParticle( G4Proton::ProtonDefinition());
259 addParticle( G4Neutron::NeutronDefinition());
260 addParticle( G4AntiProton::AntiProtonDefinition());
261 addParticle( G4AntiNeutron::AntiNeutronDefinition());
262
263 // Strange Baryons
264 addParticle( G4Lambda::LambdaDefinition());
265 addParticle( G4SigmaPlus::SigmaPlusDefinition());
266 addParticle( G4SigmaZero::SigmaZeroDefinition());
267 addParticle( G4SigmaMinus::SigmaMinusDefinition());
268 addParticle( G4XiZero::XiZeroDefinition());
269 addParticle( G4XiMinus::XiMinusDefinition());
270 addParticle( G4OmegaMinus::OmegaMinusDefinition());
271 addParticle( G4AntiLambda::AntiLambdaDefinition());
272 addParticle( G4AntiSigmaPlus::AntiSigmaPlusDefinition());
273 addParticle( G4AntiSigmaZero::AntiSigmaZeroDefinition());
274 addParticle( G4AntiSigmaMinus::AntiSigmaMinusDefinition());
275 addParticle( G4AntiXiZero::AntiXiZeroDefinition());
276 addParticle( G4AntiXiMinus::AntiXiMinusDefinition());
277 addParticle( G4AntiOmegaMinus::AntiOmegaMinusDefinition());
278
279 // Charmed Baryons
280 addParticle( G4LambdacPlus::LambdacPlusDefinition());
281 addParticle( G4SigmacPlusPlus::SigmacPlusPlusDefinition());
282 addParticle( G4SigmacPlus::SigmacPlusDefinition());
283 addParticle( G4SigmacZero::SigmacZeroDefinition());
284 addParticle( G4XicPlus::XicPlusDefinition());
285 addParticle( G4XicZero::XicZeroDefinition());
286 addParticle( G4OmegacZero::OmegacZeroDefinition());
287 addParticle( G4AntiLambdacPlus::AntiLambdacPlusDefinition());
288 addParticle( G4AntiSigmacPlusPlus::AntiSigmacPlusPlusDefinition());
289 addParticle( G4AntiSigmacPlus::AntiSigmacPlusDefinition());
290 addParticle( G4AntiSigmacZero::AntiSigmacZeroDefinition());
291 addParticle( G4AntiXicPlus::AntiXicPlusDefinition());
292 addParticle( G4AntiXicZero::AntiXicZeroDefinition());
293 addParticle( G4AntiOmegacZero::AntiOmegacZeroDefinition());
294
295#ifdef PDGTOG4PARTICLE_USE_SUSY
296 // SUSY particles from G4Extensions in ATHENA (incomplete)
297 addParticle( G4SElectronMinus::SElectronMinusDefinition());
298 addParticle( G4SElectronPlus::SElectronPlusDefinition());
299 addParticle( G4SMuonMinus::SMuonMinusDefinition());
300 addParticle( G4SMuonPlus::SMuonPlusDefinition());
301 addParticle( G4STauMinus::STauMinusDefinition());
302 addParticle( G4STauPlus::STauPlusDefinition());
303#endif
304
305 return predefinedParticles;
306}

◆ printListOfParticles()

void iFatras::PDGToG4Particle::printListOfParticles ( bool withDecayTableOnly = false) const

prints list of particles to stdout

Definition at line 145 of file PDGToG4Particle.cxx.

146{
147 std::cout << "****************************************"
148 << "****************************************"
149 << std::endl;
150
151 std::cout << "* "
152 << std::setw( 8) << "PDG Code" << " "
153 << std::setw(16) << "Particle Name" << " "
154 << std::setw( 8) << "G4 PDGID" << " "
155 << std::setw( 8) << "Mass" << " "
156 << std::setw(16) << "Width" << " "
157 << std::setw( 6) << "Charge" << " "
158 << std::setw( 7) << "#DecChn" << " "
159 << std::endl;
160
161 std::cout << "****************************************"
162 << "****************************************"
163 << std::endl;
164
165 for( PDGG4ParticleMap::const_iterator it = m_pdgG4ParticleMap.begin();
166 it != m_pdgG4ParticleMap.end(); ++it)
167 {
168 G4DecayTable* dt = it->second->GetDecayTable();
169 int nDecayChannels = 0;
170 if( dt) nDecayChannels = dt->entries();
171 else if( withDecayTableOnly) continue;
172
173 std::cout << "* "
174 << std::setw( 8) << it->first << " "
175 << std::setw(16) << it->second->GetParticleName() << " "
176 << std::setw( 8) << it->second->GetPDGEncoding() << " "
177 << std::setw( 8) << it->second->GetPDGMass() << " "
178 << std::setw(16) << it->second->GetPDGWidth() << " "
179 << std::setw( 6) << it->second->GetPDGCharge() << " "
180 << std::setw( 7) << nDecayChannels << " "
181 << std::endl;
182 }
183
184 std::cout << "****************************************"
185 << "****************************************"
186 << std::endl;
187}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_pdgG4ParticleMap

PDGG4ParticleMap iFatras::PDGToG4Particle::m_pdgG4ParticleMap
private

map from pdg codes to defined Geant4 particles

Definition at line 62 of file PDGToG4Particle.h.

◆ m_printList

Gaudi::Property<bool> iFatras::PDGToG4Particle::m_printList
private
Initial value:
{this, "PrintList", false,
"Print list of loaded particles in initialize()"}

Definition at line 70 of file PDGToG4Particle.h.

70 {this, "PrintList", false,
71 "Print list of loaded particles in initialize()"};

◆ m_useParticles

Gaudi::Property<std::vector<int> > iFatras::PDGToG4Particle::m_useParticles
private
Initial value:
{this, "UseParticles", {},
"List of particles which should be available for conversion"}

Definition at line 67 of file PDGToG4Particle.h.

67 {this, "UseParticles", {},
68 "List of particles which should be available for conversion"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: