ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticleTable.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
28 //
29 // ------------------------------------------------------------
30 // GEANT 4 class header file
31 //
32 // History: first implementation, based on object model of
33 // 27 June 1996, H.Kurashige
34 // ------------------------------------------------------------
35 // added fParticleMessenger 14 Nov., 97 H.Kurashige
36 // added Create/DeleteMessenger 06 Jul., 98 H.Kurashige
37 // modified FindIon 02 Aug., 98 H.Kurashige
38 // added dictionary for encoding 24 Sep., 98 H.Kurashige
39 // added RemoveAllParticles() 8 Nov., 98 H.Kurashige
40 // --------------------------------
41 // fixed some improper codings 08 Apr., 99 H.Kurashige
42 // modified FindIon/GetIon methods 17 AUg., 99 H.Kurashige
43 // implement new version for using STL map instaed of RW PtrHashedDictionary
44 // 28 ct., 99 H.Kurashige
45 // modified implementation of Remove 21 Mar.,08 H.Kurashige
46 // remove G4ShortLivedTable 25 July, 13 H.Kurashige
47 // added support for MuonicAtom September, 17 K.L.Genser
48 //
49 
50 #ifndef G4ParticleTable_h
51 #define G4ParticleTable_h 1
52 
53 #include <map>
54 
55 #include "G4ios.hh"
56 #include "globals.hh"
57 #include "G4Threading.hh"
58 #include "G4ParticleDefinition.hh"
60 
61 class G4UImessenger;
63 class G4IonTable;
64 
66 {
67  // Class Description
68  // G4ParticleTable is the table of pointer to G4ParticleDefinition
69  // G4ParticleTable is a "singleton" (only one and staic object)
70  // In G4ParticleTable, each G4ParticleDefinition pointer is stored
71  // with its name as a key to itself. So, each G4ParticleDefinition
72  // object must have unique name for itself.
73  //
74 
75  public:
76 
81 
82  protected:
83  // default constructor
85  // Copy constructor and assignment operator
88 
89  public:
90 
91  void SlaveG4ParticleTable();
92  void WorkerG4ParticleTable();
93  // This method is similar to the constructor. It is used by each worker
94  // thread to achieve the partial effect as that of the master thread.
95 
96  virtual ~G4ParticleTable();
98  // This method is similar to the destructor. It is used by each worker
99  // thread to achieve the partial effect as that of the master thread.
100 
101  public: // With Description
103  // return the pointer to G4ParticleTable object
104  // G4ParticleTable is a "singleton" and can get its pointer by this function
105  // At the first time of calling this function, the G4ParticleTable object
106  // is instantiated
107 
109  G4bool contains(const G4String &particle_name) const;
110  // returns TRUE if the ParticleTable contains
111 
112  G4int entries() const;
113  G4int size() const;
114  // returns the number of Particles in the ParticleTable
115 
116  G4ParticleDefinition* GetParticle(G4int index) const;
117  // returns a pointer to i-th particles in the ParticleTable
118  // 0<= index < entries()
119 
120  const G4String& GetParticleName(G4int index) const;
121  // returns name of i-th particles in the ParticleTable
122 
123  G4ParticleDefinition* FindParticle(G4int PDGEncoding );
124  G4ParticleDefinition* FindParticle(const G4String &particle_name);
126  // returns a pointer to the particle (0 if not contained)
127 
129  G4ParticleDefinition* FindAntiParticle(const G4String &particle_name);
131  // returns a pointer to its anti-particle (0 if not contained)
132 
134  // return the pointer of Iterator (RW compatible)
135 
136  void DumpTable(const G4String &particle_name = "ALL");
137  // dump information of particles specified by name
138 
139  public: //With Description
140 
141  G4IonTable* GetIonTable() const;
142  // return the pointer to G4IonTable object
143 
144 
145  public: // With Description
147  // insert the particle into ParticleTable
148  // return value is same as particle if successfully inserted
149  // or pointer to another G4ParticleDefinition object
150  // which has same name of particle
151  // or 0 if fail to insert by another reason
152 
154  // Remove the particle from the table (not delete)
155 
156  void RemoveAllParticles();
157  // remove all particles from G4ParticleTable
158 
159  void DeleteAllParticles();
160  // remove and delete all particles from G4ParticleTable
161 
162  public:
164  void DeleteMessenger();
165  // create/delete messenger for the particle table
166  // these methods are supposed to be invoked by G4RunManager only
167 
168  protected:
169 
170  const G4PTblDictionary* GetDictionary() const;
171 
172  const G4String& GetKey(const G4ParticleDefinition *particle) const;
173  // return key value of the particle (i.e. particle name)
174 
176  // return the pointer to EncodingDictionary
177 
178  private:
180  // controle flag for output message
181  // 0: Silent
182  // 1: Warning message
183  // 2: More
184 
185  public:
187  G4int GetVerboseLevel() const;
188 
193  // These fields should be thread local or thread private. For a singleton
194  // class, we can change any member field as static without any problem
195  // because there is only one instance. Then we are allowed to add
196  // "G4ThreadLocal".
197 
198  //01.25.2009 Xin Dong: Phase II change for Geant4 multi-threading.
199  //Phase I changes this member to be thread local
200  //,while each thread holds its own copy of particles.
201  //Phase II changes this member back in order to share particles.
203 
205  // This field should be thread private. However, we have to keep one copy
206  // of the ion table pointer. So we change all important fields of G4IonTable
207  // to the thread local variable.
208 
209  // These shadow pointers are used by each worker thread to copy the content
210  // from the master thread.
211 
216 
217  private:
219 
223 
224  public:
225  void SetReadiness(G4bool val=true);
226  G4bool GetReadiness() const;
231  private:
232  void CheckReadiness() const;
233 
234 
235 #ifdef G4MULTITHREADED
236 public:
237  //Andrea Dotti January 16. Shared instance of a mutex
238  static G4GLOB_DLL G4Mutex& particleTableMutex();
239  static G4GLOB_DLL G4int& lockCount();
240 #endif
241 };
242 #include "G4ParticleTable.icc"
243 
244 #endif