Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ParticleTable.hh
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ParticleTable.hh 110257 2018-05-17 14:20:12Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // History: first implementation, based on object model of
34 // 27 June 1996, H.Kurashige
35 // ------------------------------------------------------------
36 // added fParticleMessenger 14 Nov., 97 H.Kurashige
37 // added Create/DeleteMessenger 06 Jul., 98 H.Kurashige
38 // modified FindIon 02 Aug., 98 H.Kurashige
39 // added dictionary for encoding 24 Sep., 98 H.Kurashige
40 // added RemoveAllParticles() 8 Nov., 98 H.Kurashige
41 // --------------------------------
42 // fixed some improper codings 08 Apr., 99 H.Kurashige
43 // modified FindIon/GetIon methods 17 AUg., 99 H.Kurashige
44 // implement new version for using STL map instaed of RW PtrHashedDictionary
45 // 28 ct., 99 H.Kurashige
46 // modified implementation of Remove 21 Mar.,08 H.Kurashige
47 // remove G4ShortLivedTable 25 July, 13 H.Kurashige
48 // added support for MuonicAtom September, 17 K.L.Genser
49 //
50 
51 #ifndef G4ParticleTable_h
52 #define G4ParticleTable_h 1
53 
54 #include <map>
55 
56 #include "G4ios.hh"
57 #include "globals.hh"
58 #include "G4Threading.hh"
59 #include "G4ParticleDefinition.hh"
61 
62 class G4UImessenger;
64 class G4IonTable;
65 
67 {
68  // Class Description
69  // G4ParticleTable is the table of pointer to G4ParticleDefinition
70  // G4ParticleTable is a "singleton" (only one and staic object)
71  // In G4ParticleTable, each G4ParticleDefinition pointer is stored
72  // with its name as a key to itself. So, each G4ParticleDefinition
73  // object must have unique name for itself.
74  //
75 
76  public:
77 
82 
83  protected:
84  // default constructor
86  // Copy constructor and assignment operator
89 
90  public:
91 
92  void SlaveG4ParticleTable();
93  void WorkerG4ParticleTable();
94  // This method is similar to the constructor. It is used by each worker
95  // thread to achieve the partial effect as that of the master thread.
96 
97  virtual ~G4ParticleTable();
99  // This method is similar to the destructor. It is used by each worker
100  // thread to achieve the partial effect as that of the master thread.
101 
102  public: // With Description
104  // return the pointer to G4ParticleTable object
105  // G4ParticleTable is a "singleton" and can get its pointer by this function
106  // At the first time of calling this function, the G4ParticleTable object
107  // is instantiated
108 
109  G4bool contains(const G4ParticleDefinition *particle) const;
110  G4bool contains(const G4String &particle_name) const;
111  // returns TRUE if the ParticleTable contains
112 
113  G4int entries() const;
114  G4int size() const;
115  // returns the number of Particles in the ParticleTable
116 
117  G4ParticleDefinition* GetParticle(G4int index) const;
118  // returns a pointer to i-th particles in the ParticleTable
119  // 0<= index < entries()
120 
121  const G4String& GetParticleName(G4int index) const;
122  // returns name of i-th particles in the ParticleTable
123 
124  G4ParticleDefinition* FindParticle(G4int PDGEncoding );
125  G4ParticleDefinition* FindParticle(const G4String &particle_name);
127  // returns a pointer to the particle (0 if not contained)
128 
130  G4ParticleDefinition* FindAntiParticle(const G4String &particle_name);
132  // returns a pointer to its anti-particle (0 if not contained)
133 
135  // return the pointer of Iterator (RW compatible)
136 
137  void DumpTable(const G4String &particle_name = "ALL");
138  // dump information of particles specified by name
139 
140  public: //With Description
141 
142  G4IonTable* GetIonTable() const;
143  // return the pointer to G4IonTable object
144 
145 
146  public: // With Description
148  // insert the particle into ParticleTable
149  // return value is same as particle if successfully inserted
150  // or pointer to another G4ParticleDefinition object
151  // which has same name of particle
152  // or 0 if fail to insert by another reason
153 
155  // Remove the particle from the table (not delete)
156 
157  void RemoveAllParticles();
158  // remove all particles from G4ParticleTable
159 
160  void DeleteAllParticles();
161  // remove and delete all particles from G4ParticleTable
162 
163  public:
165  void DeleteMessenger();
166  // create/delete messenger for the particle table
167  // these methods are supposed to be invoked by G4RunManager only
168 
169  protected:
170 
171  const G4PTblDictionary* GetDictionary() const;
172 
173  const G4String& GetKey(const G4ParticleDefinition *particle) const;
174  // return key value of the particle (i.e. particle name)
175 
177  // return the pointer to EncodingDictionary
178 
179  private:
181  // controle flag for output message
182  // 0: Silent
183  // 1: Warning message
184  // 2: More
185 
186  public:
188  G4int GetVerboseLevel() const;
189 
194  // These fields should be thread local or thread private. For a singleton
195  // class, we can change any member field as static without any problem
196  // because there is only one instance. Then we are allowed to add
197  // "G4ThreadLocal".
198 
199  //01.25.2009 Xin Dong: Phase II change for Geant4 multi-threading.
200  //Phase I changes this member to be thread local
201  //,while each thread holds its own copy of particles.
202  //Phase II changes this member back in order to share particles.
204 
206  // This field should be thread private. However, we have to keep one copy
207  // of the ion table pointer. So we change all important fields of G4IonTable
208  // to the thread local variable.
209 
210  // These shadow pointers are used by each worker thread to copy the content
211  // from the master thread.
212 
217 
218  private:
220 
224 
225  public:
226  void SetReadiness(G4bool val=true);
227  G4bool GetReadiness() const;
232  private:
233  void CheckReadiness() const;
234 
235 
236 #ifdef G4MULTITHREADED
237 public:
238  //Andrea Dotti January 16. Shared instance of a mutex
239  static G4GLOB_DLL G4Mutex& particleTableMutex();
240  static G4GLOB_DLL G4int& lockCount();
241 #endif
242 };
243 #include "G4ParticleTable.icc"
244 
245 #endif
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void DumpTable(const G4String &particle_name="ALL")
G4ParticleDefinition * GetGenericMuonicAtom() const
G4ParticleDefinition * genericMuonicAtom
G4int size() const
void DestroyWorkerG4ParticleTable()
static G4ParticleTable * GetParticleTable()
G4bool contains(const G4ParticleDefinition *particle) const
static G4IonTable * fIonTable
static G4ParticleMessenger * fParticleMessengerShadow
G4UImessenger * CreateMessenger()
const G4String & GetKey(const G4ParticleDefinition *particle) const
G4IonTable * GetIonTable() const
const G4String noName
#define G4ThreadLocal
Definition: tls.hh:69
const G4PTblDictionary * GetDictionary() const
G4ParticleTableIterator< G4int, G4ParticleDefinition * >::Map G4PTblEncodingDictionary
G4PTblDicIterator * GetIterator() const
static G4PTblEncodingDictionary * fEncodingDictionaryShadow
static G4ParticleTable * fgParticleTable
G4int entries() const
G4ParticleTableIterator< G4String, G4ParticleDefinition * >::Map G4PTblDictionary
G4ParticleTableIterator< G4String, G4ParticleDefinition * > G4PTblDicIterator
G4ParticleDefinition * GetParticle(G4int index) const
G4ParticleTable & operator=(const G4ParticleTable &)
static G4PTblDictionary * fDictionaryShadow
bool G4bool
Definition: G4Types.hh:79
static G4ThreadLocal G4ParticleMessenger * fParticleMessenger
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4ParticleDefinition * genericIon
#define G4GLOB_DLL
Definition: G4Types.hh:64
G4int GetVerboseLevel() const
G4ParticleDefinition * GetGenericIon() const
void SetGenericIon(G4ParticleDefinition *)
std::map< K, V, std::less< K > > Map
G4ParticleDefinition * Remove(G4ParticleDefinition *particle)
int G4int
Definition: G4Types.hh:78
void CheckReadiness() const
static G4PTblDicIterator * fIteratorShadow
void WorkerG4ParticleTable()
G4ParticleDefinition * Insert(G4ParticleDefinition *particle)
static G4ThreadLocal G4PTblDicIterator * fIterator
void SetReadiness(G4bool val=true)
G4ParticleDefinition * FindAntiParticle(G4int PDGEncoding)
const G4String & GetParticleName(G4int index) const
G4ParticleTableIterator< G4int, G4ParticleDefinition * > G4PTblEncodingDicIterator
G4bool GetReadiness() const
void SetGenericMuonicAtom(G4ParticleDefinition *)
virtual ~G4ParticleTable()
void SetVerboseLevel(G4int value)
static G4ThreadLocal G4PTblEncodingDictionary * fEncodingDictionary
static G4ThreadLocal G4PTblDictionary * fDictionary
const G4PTblEncodingDictionary * GetEncodingDictionary() const
std::mutex G4Mutex
Definition: G4Threading.hh:84