74G4Mutex& G4ParticleTable::particleTableMutex()
79G4int& G4ParticleTable::lockCount()
81 static G4int _instance = 0;
103G4ParticleTable::G4ParticleTable()
146#ifdef G4MULTITHREADED
147 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
148 G4ParticleTable::lockCount()++;
183#ifdef G4MULTITHREADED
273 G4cout <<
"G4ParticleTable::DeleteAllParticles() " <<
G4endl;
289 delete (piter->
value());
299 G4Exception(
"G4ParticleTable::RemoveAllParticle()",
301 "No effects because readyToUse is true.");
308 G4cout <<
"G4ParticleTable::RemoveAllParticles() " <<
G4endl;
329 if ((particle ==
nullptr) || (
GetKey(particle).isNull()))
333 "Particle witnout name can not be registered.");
337 G4cout <<
"The particle[Addr:" << particle <<
"] has no name "<<
G4endl;
354 msg +=
" has already been registered in the Particle Table ";
366#ifdef G4MULTITHREADED
380 pedic->insert( std::pair<
G4int,
382#ifdef G4MULTITHREADED
404 <<
" is inserted in the ParticleTable " <<
G4endl;
415 if( particle ==
nullptr)
return nullptr;
416#ifdef G4MULTITHREADED
421 <<
" is ignored as it is invoked from a worker thread.";
432 G4String msg =
"Request of removing ";
434 msg +=
" has No effects other than Pre_Init";
444 <<
" will be removed from the ParticleTable " <<
G4endl;
476 <<
" is removed from the ParticleTable " <<
G4endl;
487 if ( (index >=0) && (index <
entries()) )
490 piter -> reset(
false);
494 if ( counter == index )
return piter->
value();
501 G4cout <<
" G4ParticleTable::GetParticle"
502 <<
" invalid index (=" << index <<
")" <<
G4endl;
512 if (aParticle !=
nullptr)
526 G4PTblDictionary::iterator it =
fDictionary->find(particle_name);
533#ifdef G4MULTITHREADED
537 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
542 ptcl = (*its).second;
559 if(name != selectedName)
564#ifdef G4MULTITHREADED
565 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
567 selectedParticle = part;
569#ifdef G4MULTITHREADED
590 if (aPDGEncoding == 0)
595 G4cout <<
"PDGEncoding [" << aPDGEncoding <<
"] is not valid "
605 G4PTblEncodingDictionary::iterator it = pedic->find(aPDGEncoding );
606 if (it != pedic->end())
608 particle = (*it).second;
611#ifdef G4MULTITHREADED
614 G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
615 G4PTblEncodingDictionary::iterator its
619 particle = (*its).second;
630 if ((particle ==
nullptr) && (verboseLevel>1) )
632 G4cout <<
"CODE:" << aPDGEncoding <<
" does not exist in ParticleTable "
643 if (( particle_name ==
"ALL" ) || (particle_name ==
"all"))
666 G4cout <<
" G4ParticleTable::DumpTable : "
667 << particle_name <<
" does not exist in ParticleTable "
676void G4ParticleTable::CheckReadiness()
const
681 msg =
"Illegal use of G4ParticleTable :\n";
682 msg +=
"Access to G4ParticleTable for finding a particle or equivalent\n";
683 msg +=
"operation occurs before G4VUserPhysicsList is instantiated and\n";
684 msg +=
"assigned to G4RunManager. Such an access is prohibited since\n";
685 msg +=
"Geant4 version 8.0. To fix this problem, please make sure that\n";
686 msg +=
"your main() instantiates G4VUserPhysicsList and set it to\n";
687 msg +=
"G4RunManager before instantiating other user classes such as\n";
688 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()