Geant4  10.02.p02
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 95470 2016-02-12 09:02:26Z 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();
99 
100  public: // With Description
101  G4int GetNumberOfElements() const;
102  // Get number of elements defined in the IonTable
103 
104  // Register Isotope table
106  G4VIsotopeTable* GetIsotopeTable(size_t idx=0) const;
107  // G4IonTable asks properties of isotopes to this G4VIsotopeTable
108  // by using FindIsotope(G4IsotopeProperty* property) method.
109 
110  // ---------------------------
111  // FindIon/GetIon
112  // FindIon methods return pointer of ion if it exists
113  // GetIon methods also return pointer of ion. In GetIon
114  // methods the designated ion will be created if it does not exist.
115  //
116  // !! PDGCharge inG4ParticleDefinition of ions is !!
117  // !! electric charge of nucleus (i.e. fully ionized ions) !!
118  // -----------------------------
119 
120  void CreateAllIon();
121  // All ground state ions will be created
122  // stabele ground states are defined in G4NuclearProperty
123 
124  void CreateAllIsomer();
125  // All excited ions with long life time (>1.0*ns) will be created
126  // isomers are defined in G4VIsotopeTable
127 
128  void PrepareNuclideTable();
129  void PreloadNuclide();
130  // All nuclide with a life time longer than certain value will be created
131  // prior to the event loop.
132 
133  // Find/Get "ground state" and "excited state"
138  G4double E, G4int J=0);
139  // Z: Atomic Number
140  // A: Atomic Mass (nn + np +nlambda)
141  // L: Number of Lmabda
142  // E: Excitaion energy
143  // lvl: Isomer Level 0: ground state)
144  // J: Total Angular momentum (in unit of 1/2) : not used
145 
147  // The ion can be get by using PDG encoding
148  // !! Only ground state can be obtained .i.e. Isomer = 0
149 
150  // Find/Get "excited state"
155  G4double E, G4int J=0);
156  // Z: Atomic Number
157  // A: Atomic Mass (nn + np +nlambda)
158  // L: Number of Lmabda
159  // E: Excitaion energy
160  // lvl: Isomer Level 0: ground state)
161  // J: Total Angular momentum (in unit of 1/2) : not used
162 
163  static G4bool IsIon(const G4ParticleDefinition*);
164  // return true if the particle is ion
165 
166  static G4bool IsAntiIon(const G4ParticleDefinition*);
167  // return true if the particle is anti_ion
168 
169 
170  const G4String& GetIonName(G4int Z, G4int A, G4int lvl=0) const;
171  const G4String& GetIonName(G4int Z, G4int A, G4double E) const;
172  const G4String& GetIonName(G4int Z, G4int A, G4int L, G4double E) const;
173  const G4String& GetIonName(G4int Z, G4int A, G4int L, G4int lvl) const;
174  // get ion name
175 
176  static G4int GetNucleusEncoding(G4int Z, G4int A,
177  G4double E=0.0, G4int lvl=0);
178  // get PDG code for Ions
179  // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI.
180  //For a nucleus consisting of np protons and nn neutrons
181  // A = np + nn and Z = np.
182  // I gives the isomer level, with I = 0 corresponding
183  // to the ground state and I >0 to excitations
184 
186  G4double E=0.0, G4int lvl=0);
187  // get PDG code for Hyper-Nucleus Ions
188  // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI.
189  //For a nucleus consisting of np protons and nn neutrons
190  // A = np + nn +nlambda and Z = np.
191  // L = nlambda
192  // I gives the isomer level, with I = 0 corresponding
193  // to the ground state and I >0 to excitations
194 
196  G4int &Z, G4int &A,
197  G4double &E, G4int &lvl);
199  G4int &Z, G4int &A, G4int &L,
200  G4double &E, G4int &lvl);
201  // Energy will not be given even for excited state!!
202 
203  G4double GetIonMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
204  G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
205  G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const;
206  // These methods returns Nucleus (i.e. full ionized atom) mass
207  // ,where Z is Atomic Number (number of protons) and
208  // A is Atomic Number (number of nucleons and hyperons)
209  // L is number of lambda (A= nn + np + nlambda)
210  // lvl is isomer level
211 
213  G4double GetLifeTime(G4int Z, G4int A, G4double E) const;
214  // Returns a life time of an ion. -1 for stable ion, and -1001 for ion
215  // that is not listed in G4NuclideTable.
216 
217  G4int Entries() const;
218  // Return number of ions in the table
219 
220  G4ParticleDefinition* GetParticle(G4int index) const;
221  // Return the pointer of index-th ion in the table
222 
223  G4bool Contains(const G4ParticleDefinition *particle) const;
224  // Return 'true' if the ion exists
225 
226  void Insert(const G4ParticleDefinition* particle);
227  void Remove(const G4ParticleDefinition* particle);
228  // Insert/Remove an ion in the table
229 
230  void clear();
231  // erase all contents in the list (not delete just remove)
232 
233  G4int size() const;
234  // Return number of ions in the table
235 
236  void DumpTable(const G4String &particle_name = "ALL") const;
237  // dump information of particles specified by name
238 
239 
240  protected:
245  G4double E, G4int J=0);
246 
251 
252  void InsertWorker(const G4ParticleDefinition* particle);
253 
254  // Obsolete
255  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4double E);
256  // All threads share the particle table and particles including ions. This method
257  // is invoked by any work thread for ions that have been created by other threads
258  // to achieve the partial effect when ions are created by other threads.
259  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4int L, G4double E);
260  // All threads share the particle table and particles including ions. This method
261  // is invoked by any work thread for ions that have been created by other threads
262  // to achieve the partial effect when ions are created by other threads.
263 
264  // Create Ion
265 
267  G4IsotopeProperty* FindIsotope(G4int Z, G4int A, G4int lvl) const;
268  // Ask properties of isotopes to this G4VIsotopeTable
269 
272 
273  G4bool IsLightIon(const G4ParticleDefinition*) const;
275  // return true if the particle is pre-defined ion
276 
278  // Add process manager to ions with name of 'ionName'
279 
280  G4int GetVerboseLevel() const;
281  // get Verbose Level defined in G4ParticleTable
282 
283  private:
286  // Isomer table and flag of creation
287 
288  public:
289  static G4ThreadLocal G4IonList* fIonList;
290  static G4ThreadLocal std::vector<G4VIsotopeTable*> *fIsotopeTableList;
291  static G4IonList* fIonListShadow;
292  static std::vector<G4VIsotopeTable*> *fIsotopeTableListShadow;
293  // It is very important for multithreaded Geant4 to keep only one copy of the
294  // particle table pointer and the ion table pointer. However, we try to let
295  // each worker thread hold its own copy of the particle dictionary and the
296  // ion list. This implementation is equivalent to make the ion table thread
297  // private. The two shadow ponters are used by each worker thread to copy the
298  // content from the master thread.
299 
300  enum { numberOfElements = 118};
302 
303  //needed for MT
304  void InitializeLightIons();
305 
306  private:
308 
309 #ifdef G4MULTITHREADED
310  public:
311  static G4Mutex ionTableMutex;
312 #endif
313 };
314 
316 {
317  return numberOfElements;
318 }
319 
320 #endif
void InitializeLightIons()
Definition: G4IonTable.cc:178
void RegisterIsotopeTable(G4VIsotopeTable *table)
Definition: G4IonTable.cc:1487
void WorkerG4IonTable()
Definition: G4IonTable.cc:152
static std::vector< G4VIsotopeTable * > * fIsotopeTableListShadow
Definition: G4IonTable.hh:292
G4int size() const
Definition: G4IonTable.cc:1638
G4int Entries() const
Definition: G4IonTable.cc:1632
void PrepareNuclideTable()
Definition: G4IonTable.cc:1561
void DumpTable(const G4String &particle_name="ALL") const
Definition: G4IonTable.cc:1410
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:491
void Remove(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1348
G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1273
static G4bool IsIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1091
G4bool IsLightAntiIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1151
G4VIsotopeTable * GetIsotopeTable(size_t idx=0) const
Definition: G4IonTable.cc:1501
void InsertWorker(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1322
static G4bool IsAntiIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1116
static G4int GetNucleusEncoding(G4int Z, G4int A, G4double E=0.0, G4int lvl=0)
Definition: G4IonTable.cc:898
G4int GetVerboseLevel() const
Definition: G4IonTable.cc:1442
static G4ThreadLocal std::vector< G4VIsotopeTable * > * fIsotopeTableList
Definition: G4IonTable.hh:290
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4IsotopeProperty * FindIsotope(G4int Z, G4int A, G4double E) const
Definition: G4IonTable.cc:1512
static const double L
Definition: G4SIunits.hh:123
static G4bool GetNucleusByEncoding(G4int encoding, G4int &Z, G4int &A, G4double &E, G4int &lvl)
Definition: G4IonTable.cc:939
const G4String & GetIonName(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1038
void Insert(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1307
void SlaveG4IonTable()
Definition: G4IonTable.cc:147
G4IonTable & operator=(const G4IonTable &)
Definition: G4IonTable.hh:93
static G4IonList * fIonListShadow
Definition: G4IonTable.hh:291
G4bool isIsomerCreated
Definition: G4IonTable.hh:285
void CreateAllIsomer()
Definition: G4IonTable.cc:1555
G4ParticleDefinition * CreateIon(G4int Z, G4int A, G4double E)
Definition: G4IonTable.cc:243
G4IonTable * GetIonTable() const
double A(double temperature)
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:1279
#define encoding
Definition: xmlparse.cc:605
void AddProcessManager(G4ParticleDefinition *)
Definition: G4IonTable.cc:1448
static G4IonTable * GetIonTable()
Definition: G4IonTable.hh:78
G4bool Contains(const G4ParticleDefinition *particle) const
Definition: G4IonTable.cc:1610
G4ParticleDefinition * FindIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:798
G4int G4Mutex
Definition: G4Threading.hh:173
G4int GetNumberOfElements() const
Definition: G4IonTable.hh:315
G4NuclideTable * pNuclideTable
Definition: G4IonTable.hh:284
static G4ParticleTable * GetParticleTable()
void PreloadNuclide()
Definition: G4IonTable.cc:1567
G4int n_error
Definition: G4IonTable.hh:307
void CreateAllIon()
Definition: G4IonTable.cc:1549
void clear()
Definition: G4IonTable.cc:1289
void DestroyWorkerG4IonTable()
Definition: G4IonTable.cc:213
static G4ThreadLocal G4IonList * fIonList
Definition: G4IonTable.hh:289
G4double GetLifeTime(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1768
G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const
Definition: G4IonTable.cc:1214
G4ParticleDefinition * GetLightAntiIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1186
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * GetLightIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1161
G4ParticleDefinition * FindIonInMaster(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:1708
G4bool IsLightIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1142
std::multimap< G4int, const G4ParticleDefinition * >::iterator G4IonListIterator
Definition: G4IonTable.hh:75
static const G4String elementName[numberOfElements]
Definition: G4IonTable.hh:301
virtual ~G4IonTable()
Definition: G4IonTable.cc:186
G4ParticleDefinition * GetParticle(G4int index) const
Definition: G4IonTable.cc:1586