ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4IonTable.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4IonTable.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,
33 // based on object model of June 27, 98 H.Kurashige
34 // ------------------------------------------------------------
35 // added clear() 20 Mar., 08 H.Kurashige
36 // modified GetIon 02 Aug., 98 H.Kurashige
37 // added Remove() 06 Nov.,98 H.Kurashige
38 // add GetNucleusMass 15 Mar. 99 H.Kurashige
39 // -----
40 // Modified GetIon methods 17 Aug. 99 H.Kurashige
41 // New design using G4VIsotopeTable 5 Oct. 99 H.Kurashige
42 // Add GetNucleusEncoding according PDG 2006 9 Oct. 2006 H.Kurashige
43 // Use STL map 30 Jul. 2009 H.Kurashige
44 // Add GetIsomerMass 25 July 2013 H.Kurashige
45 //
46 #ifndef G4IonTable_h
47 #define G4IonTable_h 1
48 
49 #include "G4ios.hh"
50 #include "globals.hh"
51 #include "G4ParticleDefinition.hh"
52 #include "G4ParticleTable.hh"
53 #include "G4Ions.hh"
54 
55 #include <cmath>
56 #include <vector>
57 #include <map>
58 
59 class G4ParticleTable;
60 class G4VIsotopeTable;
61 class G4IsotopeProperty;
62 class G4NuclideTable;
63 
65 {
66  // Class Description
67  // G4IonTable is the table of pointer to G4ParticleDefinition
68  // In G4IonTable, each G4ParticleDefinition pointer is stored
69  //
70 
71  public:
72  // Use STL map as list of ions
73  typedef std::multimap<G4int, const G4ParticleDefinition*> G4IonList;
74  typedef std::multimap<G4int, const G4ParticleDefinition*>::iterator G4IonListIterator;
75 
76  public:
79 
80  public:
81  // constructor
82  G4IonTable();
83 
84  void SlaveG4IonTable();
85  void WorkerG4IonTable();
86  // Method is used by each worker thread to copy the content from the master
87  // thread.
88 
89  protected:
90  // hide copy construictor as protected
91  G4IonTable(const G4IonTable &right);
92  G4IonTable & operator = (const G4IonTable &) {return *this;}
93 
94  public:
95  // destructor
96  virtual ~G4IonTable();
98 
99  public: // With Description
100  G4int GetNumberOfElements() const;
101  // Get number of elements defined in the IonTable
102 
103  // Register Isotope table
105  G4VIsotopeTable* GetIsotopeTable(size_t idx=0) const;
106  // G4IonTable asks properties of isotopes to this G4VIsotopeTable
107  // by using FindIsotope(G4IsotopeProperty* property) method.
108 
109  // ---------------------------
110  // FindIon/GetIon
111  // FindIon methods return pointer of ion if it exists
112  // GetIon methods also return pointer of ion. In GetIon
113  // methods the designated ion will be created if it does not exist.
114  //
115  // !! PDGCharge inG4ParticleDefinition of ions is !!
116  // !! electric charge of nucleus (i.e. fully ionized ions) !!
117  // -----------------------------
118 
119  void CreateAllIon();
120  // All ground state ions will be created
121  // stabele ground states are defined in G4NuclearProperty
122 
123  void CreateAllIsomer();
124  // All excited ions with long life time (>1.0*ns) will be created
125  // isomers are defined in G4VIsotopeTable
126 
127  void PrepareNuclideTable();
128  void PreloadNuclide();
129  // All nuclide with a life time longer than certain value will be created
130  // prior to the event loop.
131 
132  // Find/Get "ground state" and "excited state"
139  char flbChar, G4int J=0);
141  G4int J=0);
145  char flbChar, G4int J=0);
146  // Z: Atomic Number
147  // A: Atomic Mass (nn + np +nlambda)
148  // L: Number of Lmabda
149  // E: Excitaion energy
150  // lvl: Isomer Level 0: ground state)
151  // flb: Floating level base (enum defined in G4Ions.hh)
152  // flbChar: Floating level base denoted by a character
153  // (<null>,X,Y,Z,U,V,W,R,S,T,A,B,C,D,E)
154  // J: Total Angular momentum (in unit of 1/2) : not used
155 
157  // The ion can be get by using PDG encoding
158  // !! Only ground state can be obtained .i.e. Isomer = 0
159 
160  // Find/Get "excited state"
167  char flbChar, G4int J=0);
169  G4int J=0);
173  char flbChar, G4int J=0);
174  // Z: Atomic Number
175  // A: Atomic Mass (nn + np +nlambda)
176  // L: Number of Lmabda
177  // E: Excitaion energy
178  // lvl: Isomer Level 0: ground state)
179  // flb: Floating level base (enum defined in G4Ions.hh)
180  // flbChar: Floating level base denoted by a character
181  // (<null>,X,Y,Z,U,V,W,R,S,T,A,B,C,D,E)
182  // J: Total Angular momentum (in unit of 1/2) : not used
183 
184  static G4bool IsIon(const G4ParticleDefinition*);
185  // return true if the particle is ion
186 
187  static G4bool IsAntiIon(const G4ParticleDefinition*);
188  // return true if the particle is anti_ion
189 
190 
191  const G4String& GetIonName(G4int Z, G4int A, G4int lvl=0) const;
193  G4Ions::G4FloatLevelBase flb=G4Ions::G4FloatLevelBase::no_Float) const;
195  G4Ions::G4FloatLevelBase flb=G4Ions::G4FloatLevelBase::no_Float) const;
196  const G4String& GetIonName(G4int Z, G4int A, G4int L, G4int lvl) const;
197  // get ion name
198 
200  G4double E=0.0, G4int lvl=0);
201  // get PDG code for Ions
202  // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI.
203  //For a nucleus consisting of np protons and nn neutrons
204  // A = np + nn and Z = np.
205  // I gives the isomer level, with I = 0 corresponding
206  // to the ground state and I >0 to excitations
207 
209  G4double E=0.0, G4int lvl=0);
210  // get PDG code for Hyper-Nucleus Ions
211  // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI.
212  //For a nucleus consisting of np protons and nn neutrons
213  // A = np + nn +nlambda and Z = np.
214  // L = nlambda
215  // I gives the isomer level, with I = 0 corresponding
216  // to the ground state and I >0 to excitations
217 
219  G4int &Z, G4int &A,
220  G4double &E, G4int &lvl);
222  G4int &Z, G4int &A, G4int &L,
223  G4double &E, G4int &lvl);
224  // Energy will not be given even for excited state!!
225 
226  G4double GetIonMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
227  G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
228  G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const;
229  // These methods returns Nucleus (i.e. full ionized atom) mass
230  // ,where Z is Atomic Number (number of protons) and
231  // A is Atomic Number (number of nucleons and hyperons)
232  // L is number of lambda (A= nn + np + nlambda)
233  // lvl is isomer level
234 
237  G4Ions::G4FloatLevelBase flb=G4Ions::G4FloatLevelBase::no_Float) const;
238  G4double GetLifeTime(G4int Z, G4int A, G4double E, char flbChar) const;
239  // Returns a life time of an ion. -1 for stable ion, and -1001 for ion
240  // that is not listed in G4NuclideTable.
241 
242  G4int Entries() const;
243  // Return number of ions in the table
244 
245  G4ParticleDefinition* GetParticle(G4int index) const;
246  // Return the pointer of index-th ion in the table
247 
249  // Return 'true' if the ion exists
250 
251  void Insert(const G4ParticleDefinition* particle);
252  void Remove(const G4ParticleDefinition* particle);
253  // Insert/Remove an ion in the table
254 
255  void clear();
256  // erase all contents in the list (not delete just remove)
257 
258  G4int size() const;
259  // Return number of ions in the table
260 
261  void DumpTable(const G4String &particle_name = "ALL") const;
262  // dump information of particles specified by name
263 
264 
265  protected:
272 
277 
279 
280  // Obsolete
281  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4double E);
282  // All threads share the particle table and particles including ions. This method
283  // is invoked by any work thread for ions that have been created by other threads
284  // to achieve the partial effect when ions are created by other threads.
285  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4int L, G4double E);
286  // All threads share the particle table and particles including ions. This method
287  // is invoked by any work thread for ions that have been created by other threads
288  // to achieve the partial effect when ions are created by other threads.
289 
290  // Create Ion
291 
294  // Ask properties of isotopes to this G4VIsotopeTable
295 
298 
299  G4bool IsLightIon(const G4ParticleDefinition*) const;
301  // return true if the particle is pre-defined ion
302 
304  // Add process manager to ions with name of 'ionName'
305 
306  G4int GetVerboseLevel() const;
307  // get Verbose Level defined in G4ParticleTable
308 
309  private:
312  // Isomer table and flag of creation
313 
314  public:
316  static G4ThreadLocal std::vector<G4VIsotopeTable*> *fIsotopeTableList;
318  static std::vector<G4VIsotopeTable*> *fIsotopeTableListShadow;
319  // It is very important for multithreaded Geant4 to keep only one copy of the
320  // particle table pointer and the ion table pointer. However, we try to let
321  // each worker thread hold its own copy of the particle dictionary and the
322  // ion list. This implementation is equivalent to make the ion table thread
323  // private. The two shadow ponters are used by each worker thread to copy the
324  // content from the master thread.
325 
326  enum { numberOfElements = 118};
328 
329  //needed for MT
330  void InitializeLightIons();
331 
332  private:
334 
335  public:
338 
339 #ifdef G4MULTITHREADED
340  public:
341  static G4Mutex ionTableMutex;
342 #endif
343 };
344 
346 {
347  return numberOfElements;
348 }
349 
350 #endif