Geant4_10
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 75166 2013-10-29 09:06:54Z 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 G4IsomerTable 5 May. 2013 H.Kurashige
46 // Add GetIsomerMass 25 July 2013 H.Kurashige
47 //
48 #ifndef G4IonTable_h
49 #define G4IonTable_h 1
50 
51 #include "G4ios.hh"
52 #include "globals.hh"
53 #include "G4ParticleDefinition.hh"
54 #include "G4ParticleTable.hh"
55 #include "G4Ions.hh"
56 
57 #include <cmath>
58 #include <vector>
59 #include <map>
60 
61 class G4ParticleTable;
62 class G4VIsotopeTable;
63 class G4IsotopeProperty;
64 class G4IsomerTable;
65 class G4NuclideTable;
66 
68 {
69  // Class Description
70  // G4IonTable is the table of pointer to G4ParticleDefinition
71  // In G4IonTable, each G4ParticleDefinition pointer is stored
72  //
73 
74  public:
75  // Use STL map as list of ions
76  typedef std::multimap<G4int, const G4ParticleDefinition*> G4IonList;
77  typedef std::multimap<G4int, const G4ParticleDefinition*>::iterator G4IonListIterator;
78 
79  public:
82 
83  public:
84  // constructor
85  G4IonTable();
86 
87  void SlaveG4IonTable();
88  void WorkerG4IonTable();
89  // Method is used by each worker thread to copy the content from the master
90  // thread.
91 
92  protected:
93  // hide copy construictor as protected
94  G4IonTable(const G4IonTable &right);
95  G4IonTable & operator = (const G4IonTable &) {return *this;}
96 
97  public:
98  // destructor
99  virtual ~G4IonTable();
100 
101  public: // With Description
102  G4int GetNumberOfElements() const;
103  // Get number of elements defined in the IonTable
104 
105  // Register Isotope table
107  G4VIsotopeTable* GetIsotopeTable(size_t idx=0) const;
108  // G4IonTable asks properties of isotopes to this G4VIsotopeTable
109  // by using FindIsotope(G4IsotopeProperty* property) method.
110 
111  // ---------------------------
112  // FindIon/GetIon
113  // FindIon methods return pointer of ion if it exists
114  // GetIon methods also return pointer of ion. In GetIon
115  // methods the designated ion will be created if it does not exist.
116  //
117  // !! PDGCharge inG4ParticleDefinition of ions is !!
118  // !! electric charge of nucleus (i.e. fully ionized ions) !!
119  // -----------------------------
120 
121  void CreateAllIon();
122  // All ground state ions will be created
123  // stabele ground states are defined in G4NuclearProperty
124 
125  void CreateAllIsomer();
126  // All excited ions with long life time (>1.0*ns) will be created
127  // isomers are defined in G4VIsotopeTable
128 
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 
185  static G4int GetNucleusEncoding(G4int Z, G4int A, G4int L,
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 
212 
213  G4int Entries() const;
214  // Return number of ions in the table
215 
217  // Return the pointer of index-th ion in the table
218 
219  G4bool Contains(const G4ParticleDefinition *particle) const;
220  // Return 'true' if the ion exists
221 
222  void Insert(const G4ParticleDefinition* particle);
223  void Remove(const G4ParticleDefinition* particle);
224  // Insert/Remove an ion in the table
225 
226  void clear();
227  // erase all contents in the list (not delete just remove)
228 
229  G4int size() const;
230  // Return number of ions in the table
231 
232  void DumpTable(const G4String &particle_name = "ALL") const;
233  // dump information of particles specified by name
234 
235 
236  protected:
241  G4double E, G4int J=0);
242 
247 
248  void InsertWorker(const G4ParticleDefinition* particle);
249 
250  // Obsolete
251  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4double E);
252  // All threads share the particle table and particles including ions. This method
253  // is invoked by any work thread for ions that have been created by other threads
254  // to achieve the partial effect when ions are created by other threads.
255  // G4ParticleDefinition* SlaveCreateIon(G4ParticleDefinition* ion, G4int Z, G4int A, G4int L, 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 
260  // Create Ion
261 
263  G4IsotopeProperty* FindIsotope(G4int Z, G4int A, G4int lvl) const;
264  // Ask properties of isotopes to this G4VIsotopeTable
265 
268 
269  G4bool IsLightIon(const G4ParticleDefinition*) const;
271  // return true if the particle is pre-defined ion
272 
274  // Add process manager to ions with name of 'ionName'
275 
276  G4int GetVerboseLevel() const;
277  // get Verbose Level defined in G4ParticleTable
278 
279  private:
280  G4IsomerTable* pIsomerTable;
281  G4NuclideTable* pNuclideTable;
282  G4bool isIsomerCreated;
283  // Isomer table and flag of creation
284 
285  public:
287  static G4ThreadLocal std::vector<G4VIsotopeTable*> *fIsotopeTableList;
289  static std::vector<G4VIsotopeTable*> *fIsotopeTableListShadow;
290  // It is very important for multithreaded Geant4 to keep only one copy of the
291  // particle table pointer and the ion table pointer. However, we try to let
292  // each worker thread hold its own copy of the particle dictionary and the
293  // ion list. This implementation is equivalent to make the ion table thread
294  // private. The two shadow ponters are used by each worker thread to copy the
295  // content from the master thread.
296  static const G4double tolerance;
297 
298  enum { numberOfElements = 118};
300 
301  //needed for MT
302  void InitializeLightIons();
303 
304  private:
305  G4int n_error;
306 
307 #ifdef G4MULTITHREADED
308  public:
309  static G4Mutex ionTableMutex;
310 #endif
311 };
312 
314 {
315  return numberOfElements;
316 }
317 
318 #endif
void InitializeLightIons()
Definition: G4IonTable.cc:177
void RegisterIsotopeTable(G4VIsotopeTable *table)
Definition: G4IonTable.cc:1440
void WorkerG4IonTable()
Definition: G4IonTable.cc:152
static std::vector< G4VIsotopeTable * > * fIsotopeTableListShadow
Definition: G4IonTable.hh:289
G4int size() const
Definition: G4IonTable.cc:1590
G4int Entries() const
Definition: G4IonTable.cc:1584
Int_t index
Definition: macro.C:9
void DumpTable(const G4String &particle_name="ALL") const
Definition: G4IonTable.cc:1363
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:449
void Remove(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1301
G4double GetIsomerMass(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:1226
static G4bool IsIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1044
G4bool IsLightAntiIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1104
G4VIsotopeTable * GetIsotopeTable(size_t idx=0) const
Definition: G4IonTable.cc:1454
void InsertWorker(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1275
static G4bool IsAntiIon(const G4ParticleDefinition *)
Definition: G4IonTable.cc:1069
static G4int GetNucleusEncoding(G4int Z, G4int A, G4double E=0.0, G4int lvl=0)
Definition: G4IonTable.cc:854
G4int GetVerboseLevel() const
Definition: G4IonTable.cc:1395
static G4ThreadLocal std::vector< G4VIsotopeTable * > * fIsotopeTableList
Definition: G4IonTable.hh:287
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4IsotopeProperty * FindIsotope(G4int Z, G4int A, G4double E) const
Definition: G4IonTable.cc:1465
static G4bool GetNucleusByEncoding(G4int encoding, G4int &Z, G4int &A, G4double &E, G4int &lvl)
Definition: G4IonTable.cc:895
const G4String & GetIonName(G4int Z, G4int A, G4int lvl=0) const
Definition: G4IonTable.cc:992
void Insert(const G4ParticleDefinition *particle)
Definition: G4IonTable.cc:1260
void SlaveG4IonTable()
Definition: G4IonTable.cc:147
G4IonTable & operator=(const G4IonTable &)
Definition: G4IonTable.hh:95
static G4IonList * fIonListShadow
Definition: G4IonTable.hh:288
void CreateAllIsomer()
Definition: G4IonTable.cc:1508
G4ParticleDefinition * CreateIon(G4int Z, G4int A, G4double E)
Definition: G4IonTable.cc:215
G4IonTable * GetIonTable() const
Float_t Z
Definition: plot.C:39
std::multimap< G4int, const G4ParticleDefinition * > G4IonList
Definition: G4IonTable.hh:76
bool G4bool
Definition: G4Types.hh:79
G4double GetIonMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const
Definition: G4IonTable.cc:1232
void AddProcessManager(G4ParticleDefinition *)
Definition: G4IonTable.cc:1401
static G4IonTable * GetIonTable()
Definition: G4IonTable.hh:80
G4bool Contains(const G4ParticleDefinition *particle) const
Definition: G4IonTable.cc:1562
G4ParticleDefinition * FindIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:754
G4int G4Mutex
Definition: G4Threading.hh:156
G4int GetNumberOfElements() const
Definition: G4IonTable.hh:313
static G4ParticleTable * GetParticleTable()
void PreloadNuclide()
Definition: G4IonTable.cc:1515
void CreateAllIon()
Definition: G4IonTable.cc:1502
void clear()
Definition: G4IonTable.cc:1242
static const G4double tolerance
Definition: G4IonTable.hh:296
static G4ThreadLocal G4IonList * fIonList
Definition: G4IonTable.hh:286
G4double GetNucleusMass(G4int Z, G4int A, G4int L=0, G4int lvl=0) const
Definition: G4IonTable.cc:1167
G4ParticleDefinition * GetLightAntiIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1139
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * GetLightIon(G4int Z, G4int A) const
Definition: G4IonTable.cc:1114
G4ParticleDefinition * FindIonInMaster(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:1660
G4bool IsLightIon(const G4ParticleDefinition *) const
Definition: G4IonTable.cc:1095
std::multimap< G4int, const G4ParticleDefinition * >::iterator G4IonListIterator
Definition: G4IonTable.hh:77
static const G4String elementName[numberOfElements]
Definition: G4IonTable.hh:299
virtual ~G4IonTable()
Definition: G4IonTable.cc:185
G4ParticleDefinition * GetParticle(G4int index) const
Definition: G4IonTable.cc:1538