70G4Mutex& G4ParticleTable::particleTableMutex()
75G4int& G4ParticleTable::lockCount()
77 static G4int _instance = 0;
96G4ParticleTable::G4ParticleTable()
134#ifdef G4MULTITHREADED
135 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
136 G4ParticleTable::lockCount()++;
156 fDictionary->insert(std::pair<G4String, G4ParticleDefinition*>(
GetKey(particle), particle));
164#ifdef G4MULTITHREADED
243 if (verboseLevel > 1) {
244 G4cout <<
"G4ParticleTable::DeleteAllParticles() " <<
G4endl;
254 if (verboseLevel > 2) {
255 G4cout <<
"Delete " << (piter->
value())->GetParticleName() <<
" " << (piter->
value())
259 delete (piter->
value());
268 "No effects because readyToUse is true.");
273 if (verboseLevel > 1) {
274 G4cout <<
"G4ParticleTable::RemoveAllParticles() " <<
G4endl;
292 if ((particle ==
nullptr) || (
GetKey(particle).empty())) {
294 "Particle witnout name can not be registered.");
296 if (verboseLevel > 1) {
297 G4cout <<
"The particle[Addr:" << particle <<
"] has no name " <<
G4endl;
305 if (verboseLevel > 2) {
311 msg +=
" has already been registered in the Particle Table ";
320 pdic->insert(std::pair<G4String, G4ParticleDefinition*>(
GetKey(particle), particle));
321#ifdef G4MULTITHREADED
323 fDictionary->insert(std::pair<G4String, G4ParticleDefinition*>(
GetKey(particle), particle));
332 pedic->insert(std::pair<G4int, G4ParticleDefinition*>(
code, particle));
333#ifdef G4MULTITHREADED
349 if (verboseLevel > 3) {
359 if (particle ==
nullptr)
return nullptr;
360#ifdef G4MULTITHREADED
364 <<
" is ignored as it is invoked from a worker thread.";
373 G4String msg =
"Request of removing ";
375 msg +=
" has No effects other than Pre_Init";
381 if (verboseLevel > 0) {
406 if (verboseLevel > 3) {
408 <<
" is removed from the ParticleTable " <<
G4endl;
418 if ((index >= 0) && (index <
entries())) {
424 if (counter == index)
return piter->
value();
429 if (verboseLevel > 1) {
430 G4cout <<
" G4ParticleTable::GetParticle"
431 <<
" invalid index (=" << index <<
")" <<
G4endl;
440 if (aParticle !=
nullptr) {
454#ifdef G4MULTITHREADED
457 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
461 ptcl = (*its).second;
476 if (name != selectedName) {
478 if (part !=
nullptr) {
479#ifdef G4MULTITHREADED
480 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
482 selectedParticle = part;
484#ifdef G4MULTITHREADED
502 if (aPDGEncoding == 0) {
504 if (verboseLevel > 1) {
505 G4cout <<
"PDGEncoding [" << aPDGEncoding <<
"] is not valid " <<
G4endl;
514 if (pedic !=
nullptr) {
515 auto it = pedic->find(aPDGEncoding);
516 if (it != pedic->end()) {
517 particle = (*it).second;
521#ifdef G4MULTITHREADED
523 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
526 particle = (*its).second;
529 fDictionary->insert(std::pair<G4String, G4ParticleDefinition*>(key, particle));
536 if ((particle ==
nullptr) && (verboseLevel > 1)) {
537 G4cout <<
"CODE:" << aPDGEncoding <<
" does not exist in ParticleTable " <<
G4endl;
546 if ((particle_name ==
"ALL") || (particle_name ==
"all")) {
552 (piter->
value())->DumpTable();
558 if (ptr !=
nullptr) {
563 if (verboseLevel > 1) {
564 G4cout <<
" G4ParticleTable::DumpTable : " << particle_name
565 <<
" does not exist in ParticleTable " <<
G4endl;
572void G4ParticleTable::CheckReadiness()
const
576 msg =
"Illegal use of G4ParticleTable :\n";
577 msg +=
"Access to G4ParticleTable for finding a particle or equivalent\n";
578 msg +=
"operation occurs before G4VUserPhysicsList is instantiated and\n";
579 msg +=
"assigned to G4RunManager. Such an access is prohibited since\n";
580 msg +=
"Geant4 version 8.0. To fix this problem, please make sure that\n";
581 msg +=
"your main() instantiates G4VUserPhysicsList and set it to\n";
582 msg +=
"G4RunManager before instantiating other user classes such as\n";
583 msg +=
"G4VUserPrimaryParticleGeneratorAction.";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
#define G4MUTEXLOCK(mutex)
#define G4MUTEXUNLOCK(mutex)
G4GLOB_DLL std::ostream G4cout
void Remove(const G4ParticleDefinition *particle)
void DestroyWorkerG4IonTable()
static G4bool IsIon(const G4ParticleDefinition *)
void Insert(const G4ParticleDefinition *particle)
G4int GetPDGEncoding() const
void SetVerboseLevel(G4int value)
const G4String & GetParticleName() const
void reset(G4bool ifSkipIon=true)
G4IonTable * GetIonTable() const
static G4ThreadLocal G4PTblEncodingDictionary * fEncodingDictionary
G4ParticleDefinition * GetParticle(G4int index) const
static G4PTblEncodingDictionary * fEncodingDictionaryShadow
void DestroyWorkerG4ParticleTable()
G4bool contains(const G4ParticleDefinition *particle) const
static G4ParticleTable * fgParticleTable
G4PTblDicIterator * GetIterator() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
G4ParticleDefinition * Insert(G4ParticleDefinition *particle)
void SelectParticle(const G4String &name)
G4ParticleTableIterator< G4int, G4ParticleDefinition * >::Map G4PTblEncodingDictionary
G4ParticleDefinition * Remove(G4ParticleDefinition *particle)
static G4PTblDictionary * fDictionaryShadow
static G4PTblDicIterator * fIteratorShadow
void RemoveAllParticles()
void DeleteAllParticles()
G4ParticleTableIterator< G4String, G4ParticleDefinition * > G4PTblDicIterator
void WorkerG4ParticleTable()
G4UImessenger * CreateMessenger()
virtual ~G4ParticleTable()
G4ParticleMessenger * fParticleMessenger
const G4String & GetKey(const G4ParticleDefinition *particle) const
static G4ThreadLocal G4PTblDicIterator * fIterator
const G4PTblDictionary * GetDictionary() const
const G4PTblEncodingDictionary * GetEncodingDictionary() const
const G4String & GetParticleName(G4int index) const
G4ParticleTableIterator< G4String, G4ParticleDefinition * >::Map G4PTblDictionary
static G4ThreadLocal G4PTblDictionary * fDictionary
void DumpTable(const G4String &particle_name="ALL")
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()