Geant4  10.01.p03
G4IonTable.hh
Go to the documentation of this file.
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: G4IonTable.hh 83920 2014-09-23 09:00:36Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // History: first implementation,
34 // based on object model of June 27, 98 H.Kurashige
35 // ------------------------------------------------------------
36 // added clear() 20 Mar., 08 H.Kurashige
37 // modified GetIon 02 Aug., 98 H.Kurashige
38 // added Remove() 06 Nov.,98 H.Kurashige
39 // add GetNucleusMass 15 Mar. 99 H.Kurashige
40 // -----
41 // Modified GetIon methods 17 Aug. 99 H.Kurashige
42 // New design using G4VIsotopeTable 5 Oct. 99 H.Kurashige
43 // Add GetNucleusEncoding according PDG 2006 9 Oct. 2006 H.Kurashige
44 // Use STL map 30 Jul. 2009 H.Kurashige
45 // Add GetIsomerMass 25 July 2013 H.Kurashige
46 //
47 #ifndef G4IonTable_h
48 #define G4IonTable_h 1
49 
50 #include "G4ios.hh"
51 #include "globals.hh"
52 #include "G4ParticleDefinition.hh"
53 #include "G4ParticleTable.hh"
54 #include "G4Ions.hh"
55 
56 #include <cmath>
57 #include <vector>
58 #include <map>
59 
60 class G4ParticleTable;
61 class G4VIsotopeTable;
62 class G4IsotopeProperty;
63 class G4NuclideTable;
64 
66 {
67  // Class Description
68  // G4IonTable is the table of pointer to G4ParticleDefinition
69  // In G4IonTable, each G4ParticleDefinition pointer is stored
70  //
71 
72  public:
73  // Use STL map as list of ions
74  typedef std::multimap<G4int, const G4ParticleDefinition*> G4IonList;
75  typedef std::multimap<G4int, const G4ParticleDefinition*>::iterator G4IonListIterator;
76 
77  public:
80 
81  public:
82  // constructor
83  G4IonTable();
84 
85  void SlaveG4IonTable();
86  void WorkerG4IonTable();
87  // Method is used by each worker thread to copy the content from the master
88  // thread.
89 
90  protected:
91  // hide copy construictor as protected
92  G4IonTable(const G4IonTable &right);
93  G4IonTable & operator = (const G4IonTable &) {return *this;}
94 
95  public:
96  // destructor
97  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"
137  G4double E, G4int J=0);
138  // Z: Atomic Number
139  // A: Atomic Mass (nn + np +nlambda)
140  // L: Number of Lmabda
141  // E: Excitaion energy
142  // lvl: Isomer Level 0: ground state)
143  // J: Total Angular momentum (in unit of 1/2) : not used
144 
146  // The ion can be get by using PDG encoding
147  // !! Only ground state can be obtained .i.e. Isomer = 0
148 
149  // Find/Get "excited state"
154  G4double E, G4int J=0);
155  // Z: Atomic Number
156  // A: Atomic Mass (nn + np +nlambda)
157  // L: Number of Lmabda
158  // E: Excitaion energy
159  // lvl: Isomer Level 0: ground state)
160  // J: Total Angular momentum (in unit of 1/2) : not used
161 
162  static G4bool IsIon(const G4ParticleDefinition*);
163  // return true if the particle is ion
164 
165  static G4bool IsAntiIon(const G4ParticleDefinition*);
166  // return true if the particle is anti_ion
167 
168 
169  const G4String& GetIonName(G4int Z, G4int A, G4int lvl=0) const;
170  const G4String& GetIonName(G4int Z, G4int A, G4double E) const;
171  const G4String& GetIonName(G4int Z, G4int A, G4int L, G4double E) const;
172  const G4String& GetIonName(G4int Z, G4int A, G4int L, G4int lvl) const;
173  // get ion name
174 
175  static G4int GetNucleusEncoding(G4int Z, G4int A,
176  G4double E=0.0, G4int lvl=0);
177  // get PDG code for Ions
178  // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI.
179  //For a nucleus consisting of np protons and nn neutrons
180  // A = np + nn and Z = np.
181  // I gives the isomer level, with I = 0 corresponding
182  // to the ground state and I >0 to excitations
183 
185  G4double E=0.0, G4int lvl=0);
186  // get PDG code for Hyper-Nucleus Ions
187  // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI.
188  //For a nucleus consisting of np protons and nn neutrons
189  // A = np + nn +nlambda and Z = np.
190  // L = nlambda
191  // I gives the isomer level, with I = 0 corresponding
192  // to the ground state and I >0 to excitations
193 
195  G4int &Z, G4int &A,
196  G4double &E, G4int &lvl);
198  G4int &Z, G4int &A, G4int &L,
199  G4double &E, G4int &lvl);
200  // Energy will not be given even for excited state!!
201 
202  G4double GetIonMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
203  G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
204  G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const;
205  // These methods returns Nucleus (i.e. full ionized atom) mass
206  // ,where Z is Atomic Number (number of protons) and
207  // A is Atomic Number (number of nucleons and hyperons)
208  // L is number of lambda (A= nn + np + nlambda)
209  // lvl is isomer level
210 
212  // Returns a life time of an ion. -1 for stable ion, and -1001 for ion
213  // that is not listed in G4NuclideTable.
214 
215  G4int Entries() const;
216  // Return number of ions in the table
217 
218  G4ParticleDefinition* GetParticle(G4int index) const;
219  // Return the pointer of index-th ion in the table
220 
221  G4bool Contains(const G4ParticleDefinition *particle) const;
222  // Return 'true' if the ion exists
223 
224  void Insert(const G4ParticleDefinition* particle);
225  void Remove(const G4ParticleDefinition* particle);
226  // Insert/Remove an ion in the table
227 
228  void clear();
229  // erase all contents in the list (not delete just remove)
230 
231  G4int size() const;
232  // Return number of ions in the table
233 
234  void DumpTable(const G4String &particle_name = "ALL") const;
235  // dump information of particles specified by name
236 
237 
238  protected:
243  G4double E, G4int J=0);
244 
249 
250  void InsertWorker(const G4ParticleDefinition* particle);
251 
252  // Obsolete
253  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4double E);
254  // All threads share the particle table and particles including ions. This method
255  // is invoked by any work thread for ions that have been created by other threads
256  // to achieve the partial effect when ions are created by other threads.
257  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4int L, G4double E);
258  // All threads share the particle table and particles including ions. This method
259  // is invoked by any work thread for ions that have been created by other threads
260  // to achieve the partial effect when ions are created by other threads.
261 
262  // Create Ion
263 
265  G4IsotopeProperty* FindIsotope(G4int Z, G4int A, G4int lvl) const;
266  // Ask properties of isotopes to this G4VIsotopeTable
267 
270 
271  G4bool IsLightIon(const G4ParticleDefinition*) const;
273  // return true if the particle is pre-defined ion
274 
276  // Add process manager to ions with name of 'ionName'
277 
278  G4int GetVerboseLevel() const;
279  // get Verbose Level defined in G4ParticleTable
280 
281  private:
284  // Isomer table and flag of creation
285 
286  public:
287  static G4ThreadLocal G4IonList* fIonList;
288  static G4ThreadLocal std::vector<G4VIsotopeTable*> *fIsotopeTableList;
289  static G4IonList* fIonListShadow;
290  static std::vector<G4VIsotopeTable*> *fIsotopeTableListShadow;
291  // It is very important for multithreaded Geant4 to keep only one copy of the
292  // particle table pointer and the ion table pointer. However, we try to let
293  // each worker thread hold its own copy of the particle dictionary and the
294  // ion list. This implementation is equivalent to make the ion table thread
295  // private. The two shadow ponters are used by each worker thread to copy the
296  // content from the master thread.
297  static const G4double tolerance;
298 
299  enum { numberOfElements = 118};
301 
302  //needed for MT
303  void InitializeLightIons();
304 
305  private:
307 
308 #ifdef G4MULTITHREADED
309  public:
310  static G4Mutex ionTableMutex;
311 #endif
312 };
313 
315 {
316  return numberOfElements;
317 }
318 
319 #endif
void InitializeLightIons()
Definition: G4IonTable.cc:178
void RegisterIsotopeTable(G4VIsotopeTable *table)
Definition: G4IonTable.cc:1457
void WorkerG4IonTable()
Definition: G4IonTable.cc:153
static std::vector< G4VIsotopeTable * > * fIsotopeTableListShadow
Definition: G4IonTable.hh:290
G4int size() const
Definition: G4IonTable.cc:1608
G4int Entries() const
Definition: G4IonTable.cc:1602
void PrepareNuclideTable()
Definition: G4IonTable.cc:1531
void DumpTable(const G4String &particle_name="ALL") const
Definition: G4IonTable.cc:1380
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:463
void Remove(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1318
G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1243
static G4bool IsIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1061
G4bool IsLightAntiIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1121
G4VIsotopeTable * GetIsotopeTable(size_t idx=0) const
Definition: G4IonTable.cc:1471
void InsertWorker(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1292
static G4bool IsAntiIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1086
static G4int GetNucleusEncoding(G4int Z, G4int A, G4double E=0.0, G4int lvl=0)
Definition: G4IonTable.cc:868
G4int GetVerboseLevel() const
Definition: G4IonTable.cc:1412
static G4ThreadLocal std::vector< G4VIsotopeTable * > * fIsotopeTableList
Definition: G4IonTable.hh:288
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4IsotopeProperty * FindIsotope(G4int Z, G4int A, G4double E) const
Definition: G4IonTable.cc:1482
static G4bool GetNucleusByEncoding(G4int encoding, G4int &Z, G4int &A, G4double &E, G4int &lvl)
Definition: G4IonTable.cc:909
const G4String & GetIonName(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1008
void Insert(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1277
void SlaveG4IonTable()
Definition: G4IonTable.cc:148
G4IonTable & operator=(const G4IonTable &)
Definition: G4IonTable.hh:93
static G4IonList * fIonListShadow
Definition: G4IonTable.hh:289
static const G4int L[nN]
G4bool isIsomerCreated
Definition: G4IonTable.hh:283
void CreateAllIsomer()
Definition: G4IonTable.cc:1525
G4ParticleDefinition * CreateIon(G4int Z, G4int A, G4double E)
Definition: G4IonTable.cc:216
G4IonTable * GetIonTable() const
std::multimap< G4int, const G4ParticleDefinition * > G4IonList
Definition: G4IonTable.hh:74
bool G4bool
Definition: G4Types.hh:79
G4double GetIonMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const
Definition: G4IonTable.cc:1249
#define encoding
Definition: xmlparse.cc:588
static const G4double A[nN]
void AddProcessManager(G4ParticleDefinition *)
Definition: G4IonTable.cc:1418
static G4IonTable * GetIonTable()
Definition: G4IonTable.hh:78
G4bool Contains(const G4ParticleDefinition *particle) const
Definition: G4IonTable.cc:1580
G4ParticleDefinition * FindIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:768
G4int G4Mutex
Definition: G4Threading.hh:173
G4int GetNumberOfElements() const
Definition: G4IonTable.hh:314
G4NuclideTable * pNuclideTable
Definition: G4IonTable.hh:282
static G4ParticleTable * GetParticleTable()
void PreloadNuclide()
Definition: G4IonTable.cc:1537
G4int n_error
Definition: G4IonTable.hh:306
void CreateAllIon()
Definition: G4IonTable.cc:1519
void clear()
Definition: G4IonTable.cc:1259
static const G4double tolerance
Definition: G4IonTable.hh:297
static G4ThreadLocal G4IonList * fIonList
Definition: G4IonTable.hh:287
G4double GetLifeTime(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1738
G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const
Definition: G4IonTable.cc:1184
G4ParticleDefinition * GetLightAntiIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1156
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * GetLightIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1131
G4ParticleDefinition * FindIonInMaster(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:1678
G4bool IsLightIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1112
std::multimap< G4int, const G4ParticleDefinition * >::iterator G4IonListIterator
Definition: G4IonTable.hh:75
static const G4String elementName[numberOfElements]
Definition: G4IonTable.hh:300
virtual ~G4IonTable()
Definition: G4IonTable.cc:186
G4ParticleDefinition * GetParticle(G4int index) const
Definition: G4IonTable.cc:1556