Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 99621 2016-09-29 10:14:44Z 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"
140  char flbChar, G4int J=0);
142  G4int J=0);
146  char flbChar, G4int J=0);
147  // Z: Atomic Number
148  // A: Atomic Mass (nn + np +nlambda)
149  // L: Number of Lmabda
150  // E: Excitaion energy
151  // lvl: Isomer Level 0: ground state)
152  // flb: Floating level base (enum defined in G4Ions.hh)
153  // flbChar: Floating level base denoted by a character
154  // (<null>,X,Y,Z,U,V,W,R,S,T,A,B,C,D,E)
155  // J: Total Angular momentum (in unit of 1/2) : not used
156 
158  // The ion can be get by using PDG encoding
159  // !! Only ground state can be obtained .i.e. Isomer = 0
160 
161  // Find/Get "excited state"
168  char flbChar, G4int J=0);
170  G4int J=0);
174  char flbChar, G4int J=0);
175  // Z: Atomic Number
176  // A: Atomic Mass (nn + np +nlambda)
177  // L: Number of Lmabda
178  // E: Excitaion energy
179  // lvl: Isomer Level 0: ground state)
180  // flb: Floating level base (enum defined in G4Ions.hh)
181  // flbChar: Floating level base denoted by a character
182  // (<null>,X,Y,Z,U,V,W,R,S,T,A,B,C,D,E)
183  // J: Total Angular momentum (in unit of 1/2) : not used
184 
185  static G4bool IsIon(const G4ParticleDefinition*);
186  // return true if the particle is ion
187 
188  static G4bool IsAntiIon(const G4ParticleDefinition*);
189  // return true if the particle is anti_ion
190 
191 
192  const G4String& GetIonName(G4int Z, G4int A, G4int lvl=0) const;
197  const G4String& GetIonName(G4int Z, G4int A, G4int L, G4int lvl) const;
198  // get ion name
199 
201  G4double E=0.0, G4int lvl=0);
202  // get PDG code for Ions
203  // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI.
204  //For a nucleus consisting of np protons and nn neutrons
205  // A = np + nn and Z = np.
206  // I gives the isomer level, with I = 0 corresponding
207  // to the ground state and I >0 to excitations
208 
210  G4double E=0.0, G4int lvl=0);
211  // get PDG code for Hyper-Nucleus Ions
212  // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI.
213  //For a nucleus consisting of np protons and nn neutrons
214  // A = np + nn +nlambda and Z = np.
215  // L = nlambda
216  // I gives the isomer level, with I = 0 corresponding
217  // to the ground state and I >0 to excitations
218 
220  G4int &Z, G4int &A,
221  G4double &E, G4int &lvl);
223  G4int &Z, G4int &A, G4int &L,
224  G4double &E, G4int &lvl);
225  // Energy will not be given even for excited state!!
226 
227  G4double GetIonMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
228  G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const;
229  G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const;
230  // These methods returns Nucleus (i.e. full ionized atom) mass
231  // ,where Z is Atomic Number (number of protons) and
232  // A is Atomic Number (number of nucleons and hyperons)
233  // L is number of lambda (A= nn + np + nlambda)
234  // lvl is isomer level
235 
239  G4double GetLifeTime(G4int Z, G4int A, G4double E, char flbChar) const;
240  // Returns a life time of an ion. -1 for stable ion, and -1001 for ion
241  // that is not listed in G4NuclideTable.
242 
243  G4int Entries() const;
244  // Return number of ions in the table
245 
246  G4ParticleDefinition* GetParticle(G4int index) const;
247  // Return the pointer of index-th ion in the table
248 
249  G4bool Contains(const G4ParticleDefinition *particle) const;
250  // Return 'true' if the ion exists
251 
252  void Insert(const G4ParticleDefinition* particle);
253  void Remove(const G4ParticleDefinition* particle);
254  // Insert/Remove an ion in the table
255 
256  void clear();
257  // erase all contents in the list (not delete just remove)
258 
259  G4int size() const;
260  // Return number of ions in the table
261 
262  void DumpTable(const G4String &particle_name = "ALL") const;
263  // dump information of particles specified by name
264 
265 
266  protected:
273 
278 
279  void InsertWorker(const G4ParticleDefinition* particle);
280 
281  // Obsolete
282  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4double E);
283  // All threads share the particle table and particles including ions. This method
284  // is invoked by any work thread for ions that have been created by other threads
285  // to achieve the partial effect when ions are created by other threads.
286  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4int L, G4double E);
287  // All threads share the particle table and particles including ions. This method
288  // is invoked by any work thread for ions that have been created by other threads
289  // to achieve the partial effect when ions are created by other threads.
290 
291  // Create Ion
292 
295  // Ask properties of isotopes to this G4VIsotopeTable
296 
299 
300  G4bool IsLightIon(const G4ParticleDefinition*) const;
302  // return true if the particle is pre-defined ion
303 
305  // Add process manager to ions with name of 'ionName'
306 
307  G4int GetVerboseLevel() const;
308  // get Verbose Level defined in G4ParticleTable
309 
310  private:
311  G4NuclideTable* pNuclideTable;
312  G4bool isIsomerCreated;
313  // Isomer table and flag of creation
314 
315  public:
317  static G4ThreadLocal std::vector<G4VIsotopeTable*> *fIsotopeTableList;
319  static std::vector<G4VIsotopeTable*> *fIsotopeTableListShadow;
320  // It is very important for multithreaded Geant4 to keep only one copy of the
321  // particle table pointer and the ion table pointer. However, we try to let
322  // each worker thread hold its own copy of the particle dictionary and the
323  // ion list. This implementation is equivalent to make the ion table thread
324  // private. The two shadow ponters are used by each worker thread to copy the
325  // content from the master thread.
326 
327  enum { numberOfElements = 118};
329 
330  //needed for MT
331  void InitializeLightIons();
332 
333  private:
334  G4int n_error;
335 
336  public:
339 
340 #ifdef G4MULTITHREADED
341  public:
342  static G4Mutex ionTableMutex;
343 #endif
344 };
345 
347 {
348  return numberOfElements;
349 }
350 
351 #endif
void InitializeLightIons()
Definition: G4IonTable.cc:182
void RegisterIsotopeTable(G4VIsotopeTable *table)
Definition: G4IonTable.cc:1543
void WorkerG4IonTable()
Definition: G4IonTable.cc:156
static std::vector< G4VIsotopeTable * > * fIsotopeTableListShadow
Definition: G4IonTable.hh:319
G4int size() const
Definition: G4IonTable.cc:1695
G4int Entries() const
Definition: G4IonTable.cc:1689
void PrepareNuclideTable()
Definition: G4IonTable.cc:1618
void DumpTable(const G4String &particle_name="ALL") const
Definition: G4IonTable.cc:1466
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:503
void Remove(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1404
G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1329
static G4bool IsIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1147
G4bool IsLightAntiIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1207
G4VIsotopeTable * GetIsotopeTable(size_t idx=0) const
Definition: G4IonTable.cc:1557
void InsertWorker(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1378
static G4bool IsAntiIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1172
static G4int GetNucleusEncoding(G4int Z, G4int A, G4double E=0.0, G4int lvl=0)
Definition: G4IonTable.cc:949
G4int GetVerboseLevel() const
Definition: G4IonTable.cc:1498
static G4ThreadLocal std::vector< G4VIsotopeTable * > * fIsotopeTableList
Definition: G4IonTable.hh:317
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
static G4bool GetNucleusByEncoding(G4int encoding, G4int &Z, G4int &A, G4double &E, G4int &lvl)
Definition: G4IonTable.cc:990
const G4String & GetIonName(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1094
G4IsotopeProperty * FindIsotope(G4int Z, G4int A, G4double E, G4Ions::G4FloatLevelBase flb) const
Definition: G4IonTable.cc:1568
void Insert(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1363
void SlaveG4IonTable()
Definition: G4IonTable.cc:151
G4ParticleDefinition * CreateIon(G4int Z, G4int A, G4double E, G4Ions::G4FloatLevelBase flb)
Definition: G4IonTable.cc:247
G4IonTable & operator=(const G4IonTable &)
Definition: G4IonTable.hh:93
static G4IonList * fIonListShadow
Definition: G4IonTable.hh:318
void CreateAllIsomer()
Definition: G4IonTable.cc:1612
G4IonTable * GetIonTable() const
double A(double temperature)
Definition: G4Ions.hh:51
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:1335
void AddProcessManager(G4ParticleDefinition *)
Definition: G4IonTable.cc:1504
static G4IonTable * GetIonTable()
Definition: G4IonTable.hh:78
G4bool Contains(const G4ParticleDefinition *particle) const
Definition: G4IonTable.cc:1667
G4ParticleDefinition * FindIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:849
G4int G4Mutex
Definition: G4Threading.hh:173
G4int GetNumberOfElements() const
Definition: G4IonTable.hh:346
static G4ParticleTable * GetParticleTable()
void PreloadNuclide()
Definition: G4IonTable.cc:1624
void CreateAllIon()
Definition: G4IonTable.cc:1606
void clear()
Definition: G4IonTable.cc:1345
G4ParticleDefinition * GetMuonicAtom(G4Ions const *)
Definition: G4IonTable.cc:1871
void DestroyWorkerG4IonTable()
Definition: G4IonTable.cc:217
static G4ThreadLocal G4IonList * fIonList
Definition: G4IonTable.hh:316
G4double GetLifeTime(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1833
G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const
Definition: G4IonTable.cc:1270
G4ParticleDefinition * GetLightAntiIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1242
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * GetLightIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1217
static constexpr double L
Definition: G4SIunits.hh:124
G4ParticleDefinition * FindIonInMaster(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:1773
G4bool IsLightIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1198
std::multimap< G4int, const G4ParticleDefinition * >::iterator G4IonListIterator
Definition: G4IonTable.hh:75
G4FloatLevelBase
Definition: G4Ions.hh:95
static const G4String elementName[numberOfElements]
Definition: G4IonTable.hh:328
virtual ~G4IonTable()
Definition: G4IonTable.cc:190
G4ParticleDefinition * GetParticle(G4int index) const
Definition: G4IonTable.cc:1643