Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -23,32 +23,26 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleTable
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// History: first implementation, based on object model of
|
||||
// 27 June 1996, H.Kurashige
|
||||
// ------------------------------------------------------------
|
||||
// added fParticleMessenger 14 Nov., 97 H.Kurashige
|
||||
// added Create/DeleteMessenger 06 Jul., 98 H.Kurashige
|
||||
// modified FindIon 02 Aug., 98 H.Kurashige
|
||||
// added dictionary for encoding 24 Sep., 98 H.Kurashige
|
||||
// added RemoveAllParticles() 8 Nov., 98 H.Kurashige
|
||||
// --------------------------------
|
||||
// fixed some improper codings 08 Apr., 99 H.Kurashige
|
||||
// modified FindIon/GetIon methods 17 AUg., 99 H.Kurashige
|
||||
// implement new version for using STL map instaed of RW PtrHashedDictionary
|
||||
// 28 ct., 99 H.Kurashige
|
||||
// modified implementation of Remove 21 Mar.,08 H.Kurashige
|
||||
// remove G4ShortLivedTable 25 July, 13 H.Kurashige
|
||||
// added support for MuonicAtom September, 17 K.L.Genser
|
||||
//
|
||||
// G4ParticleTable is the table of pointers to G4ParticleDefinition.
|
||||
// It is a "singleton" (only one static object).
|
||||
// Each G4ParticleDefinition pointer is stored with its name as a key
|
||||
// to itself. So, each G4ParticleDefinition object must have unique
|
||||
// name.
|
||||
|
||||
#ifndef G4ParticleTable_h
|
||||
#define G4ParticleTable_h 1
|
||||
// Authors: G.Cosmo, 2 December 1995 - Design, based on object model
|
||||
// H.Kurashige, 27 June 1996 - First implementation
|
||||
// History:
|
||||
// - 14 Nov 1997, H.Kurashige - Added messenger
|
||||
// - 24 Sep 1998, H.Kurashige - Added dictionary for encoding
|
||||
// - 28 Oct 1999, H.Kurashige - Migration to STL maps
|
||||
// - 15 Sep 2017, K.L.Genser - Added support for MuonicAtom
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4ParticleTable_hh
|
||||
#define G4ParticleTable_hh 1
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -64,181 +58,172 @@ class G4IonTable;
|
||||
|
||||
class G4ParticleTable
|
||||
{
|
||||
// Class Description
|
||||
// G4ParticleTable is the table of pointer to G4ParticleDefinition
|
||||
// G4ParticleTable is a "singleton" (only one and staic object)
|
||||
// In G4ParticleTable, each G4ParticleDefinition pointer is stored
|
||||
// with its name as a key to itself. So, each G4ParticleDefinition
|
||||
// object must have unique name for itself.
|
||||
//
|
||||
public:
|
||||
|
||||
public:
|
||||
using G4PTblDictionary =
|
||||
G4ParticleTableIterator<G4String, G4ParticleDefinition*>::Map;
|
||||
using G4PTblDicIterator =
|
||||
G4ParticleTableIterator<G4String, G4ParticleDefinition*>;
|
||||
using G4PTblEncodingDictionary =
|
||||
G4ParticleTableIterator<G4int, G4ParticleDefinition*>::Map;
|
||||
using G4PTblEncodingDicIterator =
|
||||
G4ParticleTableIterator<G4int, G4ParticleDefinition*>;
|
||||
|
||||
typedef G4ParticleTableIterator<G4String, G4ParticleDefinition*>::Map G4PTblDictionary;
|
||||
typedef G4ParticleTableIterator<G4String, G4ParticleDefinition*> G4PTblDicIterator;
|
||||
typedef G4ParticleTableIterator<G4int, G4ParticleDefinition*>::Map G4PTblEncodingDictionary;
|
||||
typedef G4ParticleTableIterator<G4int, G4ParticleDefinition*> G4PTblEncodingDicIterator;
|
||||
G4ParticleTable(const G4ParticleTable&) = delete;
|
||||
G4ParticleTable& operator=(const G4ParticleTable&) = delete;
|
||||
// Copy constructor and assignment operator not allowed
|
||||
|
||||
protected:
|
||||
// default constructor
|
||||
G4ParticleTable();
|
||||
// Copy constructor and assignment operator
|
||||
G4ParticleTable(const G4ParticleTable &right);
|
||||
G4ParticleTable & operator=(const G4ParticleTable &);
|
||||
void WorkerG4ParticleTable();
|
||||
// This method is similar to the constructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread
|
||||
|
||||
public:
|
||||
|
||||
void SlaveG4ParticleTable();
|
||||
void WorkerG4ParticleTable();
|
||||
// This method is similar to the constructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread.
|
||||
|
||||
virtual ~G4ParticleTable();
|
||||
void DestroyWorkerG4ParticleTable();
|
||||
// This method is similar to the destructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread.
|
||||
virtual ~G4ParticleTable();
|
||||
void DestroyWorkerG4ParticleTable();
|
||||
// This method is similar to the destructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread
|
||||
|
||||
public: // With Description
|
||||
static G4ParticleTable* GetParticleTable();
|
||||
// return the pointer to G4ParticleTable object
|
||||
// G4ParticleTable is a "singleton" and can get its pointer by this function
|
||||
// At the first time of calling this function, the G4ParticleTable object
|
||||
// is instantiated
|
||||
static G4ParticleTable* GetParticleTable();
|
||||
// Return the pointer to the G4ParticleTable object
|
||||
// G4ParticleTable is a "singleton" and can get its pointer by this
|
||||
// function. At the first time of calling this function, the
|
||||
// G4ParticleTable object is instantiated
|
||||
|
||||
G4bool contains(const G4ParticleDefinition *particle) const;
|
||||
G4bool contains(const G4String &particle_name) const;
|
||||
// returns TRUE if the ParticleTable contains
|
||||
inline G4bool contains(const G4ParticleDefinition* particle) const;
|
||||
G4bool contains(const G4String& particle_name) const;
|
||||
// Returns TRUE if the ParticleTable contains the particle's pointer
|
||||
|
||||
G4int entries() const;
|
||||
G4int size() const;
|
||||
// returns the number of Particles in the ParticleTable
|
||||
G4int entries() const;
|
||||
G4int size() const;
|
||||
// Returns the number of particles in the ParticleTable
|
||||
|
||||
G4ParticleDefinition* GetParticle(G4int index) const;
|
||||
// returns a pointer to i-th particles in the ParticleTable
|
||||
// 0<= index < entries()
|
||||
G4ParticleDefinition* GetParticle(G4int index) const;
|
||||
// Returns a pointer to the i-th particle in the ParticleTable
|
||||
// 0 <= index < entries()
|
||||
|
||||
const G4String& GetParticleName(G4int index) const;
|
||||
// returns name of i-th particles in the ParticleTable
|
||||
const G4String& GetParticleName(G4int index) const;
|
||||
// Returns the name of i-th particle in the ParticleTable
|
||||
|
||||
G4ParticleDefinition* FindParticle(G4int PDGEncoding );
|
||||
G4ParticleDefinition* FindParticle(const G4String &particle_name);
|
||||
G4ParticleDefinition* FindParticle(const G4ParticleDefinition *particle);
|
||||
// returns a pointer to the particle (0 if not contained)
|
||||
G4ParticleDefinition* FindParticle(G4int PDGEncoding );
|
||||
G4ParticleDefinition* FindParticle(const G4String& particle_name);
|
||||
G4ParticleDefinition* FindParticle(const G4ParticleDefinition* particle);
|
||||
// Returns a pointer to the particle (0 if not contained)
|
||||
|
||||
G4ParticleDefinition* FindAntiParticle(G4int PDGEncoding );
|
||||
G4ParticleDefinition* FindAntiParticle(const G4String &particle_name);
|
||||
G4ParticleDefinition* FindAntiParticle(const G4ParticleDefinition *particle);
|
||||
// returns a pointer to its anti-particle (0 if not contained)
|
||||
inline G4ParticleDefinition* FindAntiParticle(G4int PDGEncoding );
|
||||
inline G4ParticleDefinition* FindAntiParticle(const G4String& p_name);
|
||||
inline G4ParticleDefinition* FindAntiParticle(const G4ParticleDefinition* p);
|
||||
// Returns a pointer to its anti-particle (0 if not contained)
|
||||
|
||||
G4PTblDicIterator* GetIterator() const;
|
||||
// return the pointer of Iterator (RW compatible)
|
||||
G4PTblDicIterator* GetIterator() const;
|
||||
// Returns the pointer to the Iterator
|
||||
|
||||
void DumpTable(const G4String &particle_name = "ALL");
|
||||
// dump information of particles specified by name
|
||||
void DumpTable(const G4String& particle_name = "ALL");
|
||||
// Dumps information of particles specified by name
|
||||
|
||||
public: //With Description
|
||||
G4IonTable* GetIonTable() const;
|
||||
// Returns the pointer to the G4IonTable object
|
||||
|
||||
G4IonTable* GetIonTable() const;
|
||||
// return the pointer to G4IonTable object
|
||||
G4ParticleDefinition* Insert(G4ParticleDefinition* particle);
|
||||
// Inserts the particle into ParticleTable.
|
||||
// Returned value is the same as particle if successfully inserted
|
||||
// or the pointer to another G4ParticleDefinition object
|
||||
// which has same particle name
|
||||
// or nullptr if failing to insert by other reason
|
||||
|
||||
G4ParticleDefinition* Remove(G4ParticleDefinition* particle);
|
||||
// Removes the particle from the table (not delete)
|
||||
|
||||
public: // With Description
|
||||
G4ParticleDefinition* Insert(G4ParticleDefinition *particle);
|
||||
// insert the particle into ParticleTable
|
||||
// return value is same as particle if successfully inserted
|
||||
// or pointer to another G4ParticleDefinition object
|
||||
// which has same name of particle
|
||||
// or 0 if fail to insert by another reason
|
||||
void RemoveAllParticles();
|
||||
// Removes all particles from G4ParticleTable
|
||||
|
||||
G4ParticleDefinition* Remove(G4ParticleDefinition *particle);
|
||||
// Remove the particle from the table (not delete)
|
||||
void DeleteAllParticles();
|
||||
// Removes and deletes all particles from G4ParticleTable
|
||||
|
||||
void RemoveAllParticles();
|
||||
// remove all particles from G4ParticleTable
|
||||
G4UImessenger* CreateMessenger();
|
||||
// Creates messenger
|
||||
|
||||
void DeleteAllParticles();
|
||||
// remove and delete all particles from G4ParticleTable
|
||||
void SelectParticle(const G4String& name);
|
||||
|
||||
public:
|
||||
G4UImessenger* CreateMessenger();
|
||||
void DeleteMessenger();
|
||||
// create/delete messenger for the particle table
|
||||
// these methods are supposed to be invoked by G4RunManager only
|
||||
inline const G4ParticleDefinition* GetSelectedParticle() const;
|
||||
|
||||
inline void SetVerboseLevel(G4int value);
|
||||
inline G4int GetVerboseLevel() const;
|
||||
|
||||
inline void SetReadiness(G4bool val = true);
|
||||
inline G4bool GetReadiness() const;
|
||||
|
||||
inline G4ParticleDefinition* GetGenericIon() const;
|
||||
inline void SetGenericIon(G4ParticleDefinition*);
|
||||
|
||||
inline G4ParticleDefinition* GetGenericMuonicAtom() const;
|
||||
inline void SetGenericMuonicAtom(G4ParticleDefinition*);
|
||||
|
||||
// Public data ----------------------------------------------------
|
||||
|
||||
G4ParticleMessenger* fParticleMessenger = nullptr;
|
||||
static G4ThreadLocal G4PTblDictionary* fDictionary;
|
||||
static G4ThreadLocal G4PTblDicIterator* fIterator;
|
||||
static G4ThreadLocal G4PTblEncodingDictionary* fEncodingDictionary;
|
||||
// These fields should be thread local or thread private. For a singleton
|
||||
// class, we can change any member field as static without any problem
|
||||
// because there is only one instance. Then we are allowed to add
|
||||
// "G4ThreadLocal"
|
||||
|
||||
protected:
|
||||
static G4ParticleTable* fgParticleTable;
|
||||
// Particle table is being shared
|
||||
|
||||
const G4PTblDictionary* GetDictionary() const;
|
||||
|
||||
const G4String& GetKey(const G4ParticleDefinition *particle) const;
|
||||
// return key value of the particle (i.e. particle name)
|
||||
|
||||
const G4PTblEncodingDictionary* GetEncodingDictionary() const;
|
||||
// return the pointer to EncodingDictionary
|
||||
|
||||
private:
|
||||
G4int verboseLevel;
|
||||
// controle flag for output message
|
||||
// 0: Silent
|
||||
// 1: Warning message
|
||||
// 2: More
|
||||
|
||||
public:
|
||||
void SetVerboseLevel(G4int value);
|
||||
G4int GetVerboseLevel() const;
|
||||
|
||||
static G4ThreadLocal G4ParticleMessenger* fParticleMessenger;
|
||||
static G4ThreadLocal G4PTblDictionary* fDictionary;
|
||||
static G4ThreadLocal G4PTblDicIterator* fIterator;
|
||||
static G4ThreadLocal G4PTblEncodingDictionary* fEncodingDictionary;
|
||||
// These fields should be thread local or thread private. For a singleton
|
||||
// class, we can change any member field as static without any problem
|
||||
// because there is only one instance. Then we are allowed to add
|
||||
// "G4ThreadLocal".
|
||||
|
||||
//01.25.2009 Xin Dong: Phase II change for Geant4 multi-threading.
|
||||
//Phase I changes this member to be thread local
|
||||
//,while each thread holds its own copy of particles.
|
||||
//Phase II changes this member back in order to share particles.
|
||||
static G4ParticleTable* fgParticleTable;
|
||||
|
||||
static G4IonTable* fIonTable;
|
||||
// This field should be thread private. However, we have to keep one copy
|
||||
// of the ion table pointer. So we change all important fields of G4IonTable
|
||||
// to the thread local variable.
|
||||
|
||||
// These shadow pointers are used by each worker thread to copy the content
|
||||
// from the master thread.
|
||||
|
||||
static G4ParticleMessenger* fParticleMessengerShadow;
|
||||
static G4PTblDictionary* fDictionaryShadow;
|
||||
static G4PTblDicIterator* fIteratorShadow;
|
||||
static G4PTblEncodingDictionary* fEncodingDictionaryShadow;
|
||||
|
||||
private:
|
||||
const G4String noName;
|
||||
|
||||
G4bool readyToUse;
|
||||
G4ParticleDefinition* genericIon;
|
||||
G4ParticleDefinition* genericMuonicAtom;
|
||||
|
||||
public:
|
||||
void SetReadiness(G4bool val=true);
|
||||
G4bool GetReadiness() const;
|
||||
G4ParticleDefinition* GetGenericIon() const;
|
||||
void SetGenericIon(G4ParticleDefinition*);
|
||||
G4ParticleDefinition* GetGenericMuonicAtom() const;
|
||||
void SetGenericMuonicAtom(G4ParticleDefinition*);
|
||||
private:
|
||||
void CheckReadiness() const;
|
||||
G4IonTable* fIonTable = nullptr;
|
||||
// This field should be thread private. However, we have to keep one copy
|
||||
// of the ion table pointer. So we change all important fields of
|
||||
// G4IonTable to be thread local
|
||||
|
||||
// These shadow pointers are used by each worker thread to copy the content
|
||||
// from the master thread
|
||||
//
|
||||
static G4PTblDictionary* fDictionaryShadow;
|
||||
static G4PTblDicIterator* fIteratorShadow;
|
||||
static G4PTblEncodingDictionary* fEncodingDictionaryShadow;
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
public:
|
||||
//Andrea Dotti January 16. Shared instance of a mutex
|
||||
static G4GLOB_DLL G4Mutex& particleTableMutex();
|
||||
static G4GLOB_DLL G4int& lockCount();
|
||||
// Shared instance of a mutex
|
||||
static G4GLOB_DLL G4Mutex& particleTableMutex();
|
||||
static G4GLOB_DLL G4int& lockCount();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
const G4PTblDictionary* GetDictionary() const;
|
||||
|
||||
inline const G4String& GetKey(const G4ParticleDefinition* particle) const;
|
||||
// Returns key value of the particle (i.e. particle name)
|
||||
|
||||
const G4PTblEncodingDictionary* GetEncodingDictionary() const;
|
||||
// Returns the pointer to EncodingDictionary
|
||||
|
||||
private:
|
||||
|
||||
G4ParticleTable();
|
||||
// Provate default constructor
|
||||
|
||||
void CheckReadiness() const;
|
||||
|
||||
// Private data ---------------------------------------------------
|
||||
|
||||
G4ParticleDefinition* genericIon = nullptr;
|
||||
G4ParticleDefinition* genericMuonicAtom = nullptr;
|
||||
const G4ParticleDefinition* selectedParticle = nullptr;
|
||||
|
||||
const G4String noName = " ";
|
||||
G4String selectedName = "undefined";
|
||||
|
||||
G4int verboseLevel = 1;
|
||||
// Control flag for output message
|
||||
// 0: Silent
|
||||
// 1: Warning message
|
||||
// 2: More
|
||||
|
||||
G4bool readyToUse = false;
|
||||
};
|
||||
|
||||
#include "G4ParticleTable.icc"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user