Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4IonTable << 27 // 26 // 28 // Class description: << 27 // $Id: G4IonTable.hh,v 1.25 2007/09/14 07:04:09 kurasige Exp $ >> 28 // GEANT4 tag $Name: geant4-09-01 $ 29 // 29 // 30 // G4IonTable stores all pointers to G4Particl << 30 // >> 31 // ------------------------------------------------------------ >> 32 // GEANT 4 class header file >> 33 // >> 34 // History: first implementation, >> 35 // based on object model of June 27, 98 H.Kurashige >> 36 // ------------------------------------------------------------ >> 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 31 44 32 // Author: H.Kurashige, 27 June 1998 << 45 #ifndef G4IonTable_h 33 // ------------------------------------------- << 46 #define G4IonTable_h 1 34 #ifndef G4IonTable_hh << 35 #define G4IonTable_hh 1 << 36 47 37 #include "G4Ions.hh" << 38 #include "G4ParticleDefinition.hh" << 39 #include "G4ParticleTable.hh" << 40 #include "G4ios.hh" 48 #include "G4ios.hh" 41 #include "globals.hh" 49 #include "globals.hh" >> 50 #include "G4ParticleDefinition.hh" 42 51 43 #include <cmath> 52 #include <cmath> 44 #include <map> << 45 #include <vector> 53 #include <vector> 46 54 47 class G4ParticleTable; 55 class G4ParticleTable; 48 class G4VIsotopeTable; << 56 class G4VIsotopeTable; 49 class G4IsotopeProperty; 57 class G4IsotopeProperty; 50 class G4NuclideTable; << 51 58 52 class G4IonTable 59 class G4IonTable 53 { 60 { 54 public: << 61 // Class Description 55 using G4IonList = std::multimap<G4int, con << 62 // G4IonTable is the table of pointer to G4ParticleDefinition 56 using G4IonListIterator = std::multimap<G4 << 63 // In G4IonTable, each G4ParticleDefinition pointer is stored 57 << 64 // 58 // Constructor, destructor << 65 59 G4IonTable(); << 66 public: 60 ~G4IonTable(); << 67 // Use STL Vector as list of ions 61 << 68 typedef std::vector<G4ParticleDefinition*> G4IonList; 62 // Forbidden copy constructor and assignme << 69 63 G4IonTable(const G4IonTable&) = delete; << 70 public: 64 G4IonTable& operator=(const G4IonTable&) = << 71 // constructor 65 << 72 G4IonTable(); 66 static G4IonTable* GetIonTable(); << 73 67 << 74 protected: 68 // Method is used by each worker thread to << 75 // hide copy construictor as protected 69 // from the master thread. << 76 G4IonTable(const G4IonTable &right); 70 void WorkerG4IonTable(); << 77 G4IonTable & operator = (const G4IonTable &) {return *this;} 71 << 78 72 // Destructor for worker << 79 public: 73 void DestroyWorkerG4IonTable(); << 80 // destructor 74 << 81 virtual ~G4IonTable(); 75 // Get number of elements defined in the I << 82 76 G4int GetNumberOfElements() const; << 83 public: // With Description 77 << 84 G4int GetNumberOfElements() const; 78 // Register Isotope table << 85 // Get number of elements defined in the IonTable 79 void RegisterIsotopeTable(G4VIsotopeTable* << 86 80 << 87 // Register Isotope table 81 // G4IonTable asks properties of isotopes << 88 void RegisterIsotopeTable(G4VIsotopeTable* table); 82 // by using FindIsotope(G4IsotopeProperty* << 89 G4VIsotopeTable* GetIsotopeTable(size_t idx=0) const; 83 G4VIsotopeTable* GetIsotopeTable(std::size << 90 // G4IonTable asks properties of isotopes to this G4VIsotopeTable 84 << 91 // by using FindIsotope(G4IsotopeProperty* property) method. 85 // All ground state ions are created. << 92 86 // Stable ground states are defined in G4N << 93 // --------------------------- 87 void CreateAllIon(); << 94 // FindIon/GetIon 88 << 95 // FindIon methods return pointer of ion if it exists 89 // All excited ions with long life time (> << 96 // GetIon methods also return pointer of ion. In GetIon 90 // Isomers are defined in G4VIsotopeTable << 97 // methods the designated ion will be created if it does not exist. 91 void CreateAllIsomer(); << 98 // 92 << 99 // !! PDGCharge inG4ParticleDefinition of ions is !! 93 // All nuclide with a life time longer tha << 100 // !! electric charge of nucleus (i.e. fully ionized ions) !! 94 // prior to the event loop << 101 // ----------------------------- 95 void PrepareNuclideTable(); << 102 96 void PreloadNuclide(); << 103 // Find/Get "ground state" 97 << 104 G4ParticleDefinition* GetIon(G4int Z, G4int A, G4int J=0); 98 // --------------------------------------- << 105 // The ion is assumed to be ground state (i.e Excited energy = 0) 99 // FindIon/GetIon << 106 // Z: Atomic Number 100 // FindIon() methods return pointer of i << 107 // A: Atomic Mass 101 // GetIon() methods also return pointer << 108 // J: Total Angular momentum (in unit of 1/2) 102 // ion is created if it does not exist. << 109 G4ParticleDefinition* GetIon(G4int encoding); 103 // << 110 // The ion can be get by using PDG encoding 104 // !! PDGCharge in G4ParticleDefinition of << 111 // !! Only ground state can be obtained .i.e. Isomer = 0 105 // !! electric charge of nucleus (i.e. ful << 112 106 // --------------------------------------- << 113 107 << 114 // Find/Get "excited state" 108 // Find/Get "ground state" and "excited st << 115 G4ParticleDefinition* FindIon(G4int Z, G4int A, G4double E, G4int J=0); 109 // << 116 G4ParticleDefinition* GetIon(G4int Z, G4int A, G4double E, G4int J=0); 110 G4ParticleDefinition* GetIon(G4int Z, G4in << 117 G4ParticleDefinition* FindIon(G4int Z, G4int A, G4int L, 111 G4ParticleDefinition* GetIon(G4int Z, G4in << 118 G4double E, G4int J=0); 112 G4ParticleDefinition* GetIon(G4int Z, G4in << 119 G4ParticleDefinition* GetIon(G4int Z, G4int A, G4int L, 113 G4ParticleDefinition* GetIon(G4int Z, G4in << 120 G4double E, G4int J=0); 114 G4int J = 0); << 121 // Z: Atomic Number 115 G4ParticleDefinition* GetIon(G4int Z, G4in << 122 // A: Atomic Mass (nn + np +nlambda) 116 G4ParticleDefinition* GetIon(G4int Z, G4in << 123 // L: Number of Lmabda 117 G4ParticleDefinition* GetIon(G4int Z, G4in << 124 // J: Total Angular momentum (in unit of 1/2) 118 G4Ions::G4Flo << 125 // E: Excitaion energy 119 G4ParticleDefinition* GetIon(G4int Z, G4in << 126 120 // Z: Atomic Number << 127 G4ParticleDefinition* GetIon(G4int Z, G4int A, G4int J, G4int Q); 121 // A: Atomic Mass (nn + np +nlambda) << 128 // This method is provided for compatibilties 122 // nL: Number of Lambda << 129 // The third and last arguments gives no effect 123 // E: Excitation energy << 130 124 // lvl: Isomer Level 0: ground state) << 131 static G4bool IsIon(G4ParticleDefinition*); 125 // flb: Floating level base (enum defined << 132 // return true if the particle is ion 126 // flbChar: Floating level base denoted b << 133 127 // (<null>,X,Y,Z,U,V,W,R,S,T,A,B << 134 const G4String& GetIonName(G4int Z, G4int A, G4double E) const; 128 // J: Total Angular momentum (in unit of 1 << 135 const G4String& GetIonName(G4int Z, G4int A, G4int L, G4double E) const; 129 << 136 // get ion name 130 // The ion can be retrieved by using PDG e << 137 131 // !! Only ground state can be obtained .i << 138 static G4int GetNucleusEncoding(G4int Z, G4int A, 132 G4ParticleDefinition* GetIon(G4int encodin << 139 G4double E=0.0, G4int J=0); 133 << 140 // get PDG code for Ions 134 // Find/Get "excited state" << 141 // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI. 135 // << 142 //For a nucleus consisting of np protons and nn neutrons 136 G4ParticleDefinition* FindIon(G4int Z, G4i << 143 // A = np + nn and Z = np. 137 G4ParticleDefinition* FindIon(G4int Z, G4i << 144 // I gives the isomer level, with I = 0 corresponding 138 G4ParticleDefinition* FindIon(G4int Z, G4i << 145 // to the ground state and I >0 to excitations 139 G4ParticleDefinition* FindIon(G4int Z, G4i << 146 // 140 G4int J = 0) << 147 //!!! I = 1 is assigned fo all excitation states in Geant4 141 G4ParticleDefinition* FindIon(G4int Z, G4i << 148 142 G4ParticleDefinition* FindIon(G4int Z, G4i << 149 static G4int GetNucleusEncoding(G4int Z, G4int A, G4int L, 143 G4ParticleDefinition* FindIon(G4int Z, G4i << 150 G4double E=0.0, G4int J=0); 144 G4Ions::G4Fl << 151 // get PDG code for Hyper-Nucleus Ions 145 G4ParticleDefinition* FindIon(G4int Z, G4i << 152 // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI. 146 G4int J = 0) << 153 //For a nucleus consisting of np protons and nn neutrons 147 // Z: Atomic Number << 154 // A = np + nn +nlambda and Z = np. 148 // A: Atomic Mass (nn + np +nlambda) << 155 // L = nlambda 149 // nL: Number of Lambda << 156 // I gives the isomer level, with I = 0 corresponding 150 // E: Excitaion energy << 157 // to the ground state and I >0 to excitations 151 // lvl: Isomer Level 0: ground state) << 158 // 152 // flb: Floating level base (enum defined << 159 //!!! I = 1 is assigned fo all excitation states in Geant4 153 // flbChar: Floating level base denoted b << 160 154 // (<null>,X,Y,Z,U,V,W,R,S,T,A,B << 161 static G4bool GetNucleusByEncoding(G4int encoding, 155 // J: Total Angular momentum (in unit of 1 << 162 G4int &Z, G4int &A, 156 << 163 G4double &E, G4int &J); 157 // Return true if the particle is ion << 164 static G4bool GetNucleusByEncoding(G4int encoding, 158 static G4bool IsIon(const G4ParticleDefini << 165 G4int &Z, G4int &A, G4int &L, 159 << 166 G4double &E, G4int &J); 160 // Return true if the particle is anti_ion << 167 //!!! Only ground states are supported now 161 static G4bool IsAntiIon(const G4ParticleDe << 168 162 << 169 163 // Get ion name << 170 G4double GetIonMass(G4int Z, G4int A, G4int L=0) const; 164 G4String GetIonName(G4int Z, G4int A, G4in << 171 G4double GetNucleusMass(G4int Z, G4int A, G4int L=0) const; 165 G4String GetIonName(G4int Z, G4int A, G4do << 172 // These two methods returns Nucleus (i.e. full ionized atom) mass 166 G4Ions::G4FloatLevelBa << 173 // ,where Z is Atomic Number (number of protons) and 167 G4String GetIonName(G4int Z, G4int A, G4in << 174 // A is Atomic Number (number of nucleons and hyperons) 168 G4Ions::G4FloatLevelBa << 175 // L is number of lambda (A= nn + np + nlambda) 169 G4String GetIonName(G4int Z, G4int A, G4in << 176 170 << 177 171 // Get PDG code for Ions. << 178 172 // Nuclear codes are given as 10-digit num << 179 G4int Entries() const; 173 // For a nucleus consisting of np protons << 180 // Return number of ions in the table 174 // A = np + nn and Z = np. << 181 175 // I gives the isomer level, with I = 0 co << 182 G4ParticleDefinition* GetParticle(G4int index) const; 176 // to the ground state and I >0 to excitat << 183 // Return the pointer of index-th ion in the table 177 static G4int GetNucleusEncoding(G4int Z, G << 184 178 << 185 G4bool Contains(const G4ParticleDefinition *particle) const; 179 // Get PDG code for Hyper-Nucleus Ions. << 186 // Return 'true' if the ion exists 180 // Nuclear codes are given as 10-digit num << 187 181 // For a nucleus consisting of np protons << 188 void Insert(G4ParticleDefinition* particle); 182 // A = np + nn +nlambda and Z = np. << 189 void Remove(G4ParticleDefinition* particle); 183 // nL = nlambda << 190 // Insert/Remove an ion in the table 184 // I gives the isomer level, with I = 0 co << 191 185 // to the ground state and I >0 to excitat << 192 void DumpTable(const G4String &particle_name = "ALL") const; 186 static G4int GetNucleusEncoding(G4int Z, G << 193 // dump information of particles specified by name 187 << 194 188 static G4bool GetNucleusByEncoding(G4int e << 195 189 static G4bool GetNucleusByEncoding(G4int e << 196 protected: 190 G4int& << 197 G4ParticleDefinition* CreateIon(G4int Z, G4int A, G4double E, G4int J); 191 // Energy will not be given even for excit << 198 G4ParticleDefinition* CreateIon(G4int Z, G4int A, G4int L, 192 << 199 G4double E, G4int J); 193 // These methods returns Nucleus (i.e. ful << 200 // Create Ion 194 // Z is Atomic Number (number of protons) << 201 195 // A is Atomic Number (number of nucleons << 202 G4IsotopeProperty* FindIsotope(G4int Z, G4int A, G4double E, G4int J); 196 // nL is number of lambda (A= nn + np + n << 203 // Ask properties of isotopes to this G4VIsotopeTable 197 // lvl is isomer level << 204 198 G4double GetIonMass(G4int Z, G4int A, G4in << 205 G4ParticleDefinition* GetLightIon(G4int Z, G4int A) const; 199 G4double GetNucleusMass(G4int Z, G4int A, << 206 200 G4double GetIsomerMass(G4int Z, G4int A, G << 207 201 << 208 G4bool IsLightIon(G4ParticleDefinition*) const; 202 // Returns a life time of an ion. -1 for s << 209 // return true if the particle is pre-defined ion 203 // that is not listed in G4NuclideTable << 210 204 G4double GetLifeTime(const G4ParticleDefin << 211 void AddProcessManager(const G4String& ionName); 205 G4double GetLifeTime(G4int Z, G4int A, G4d << 212 // Add process manager to ions with name of 'ionName' 206 G4Ions::G4FloatLevelB << 213 207 G4double GetLifeTime(G4int Z, G4int A, G4d << 214 G4int GetVerboseLevel() const; 208 << 215 // get Verbose Level defined in G4ParticleTable 209 G4ParticleDefinition* GetMuonicAtom(G4Ions << 216 210 G4ParticleDefinition* GetMuonicAtom(G4int << 217 private: 211 << 218 G4IonList* fIonList; 212 // Return number of ions in the table << 219 213 G4int Entries() const; << 220 std::vector<G4VIsotopeTable*> *fIsotopeTableList; 214 << 221 215 // Return the pointer of index-th ion in t << 222 216 G4ParticleDefinition* GetParticle(G4int in << 223 enum { numberOfElements = 118}; 217 << 224 static const G4String elementName[numberOfElements]; 218 // Return 'true' if the ion exists << 225 219 G4bool Contains(const G4ParticleDefinition << 226 }; 220 << 227 221 // Insert/Remove an ion in the table << 228 inline G4int G4IonTable::GetNumberOfElements() const 222 void Insert(const G4ParticleDefinition* pa << 229 { 223 void Remove(const G4ParticleDefinition* pa << 230 return numberOfElements; 224 << 231 } 225 // Erase all contents in the list (not del << 232 inline G4bool G4IonTable::Contains(const G4ParticleDefinition* particle) const 226 void clear(); << 233 { 227 << 234 G4IonList::iterator i; 228 // Return number of ions in the table << 235 for (i = fIonList->begin(); i!= fIonList->end(); ++i) { 229 G4int size() const; << 236 if (**i==*particle) return true; 230 << 237 } 231 // Dump information of particles specified << 238 return false; 232 void DumpTable(const G4String& particle_na << 239 } 233 << 240 234 public: << 241 inline G4int G4IonTable::Entries() const 235 // Needed for MT << 242 { 236 void InitializeLightIons(); << 243 return fIonList->size(); 237 << 244 } 238 // It is very important for multithreaded << 245 239 // the particle table pointer and the ion << 246 inline G4ParticleDefinition* G4IonTable::GetParticle(G4int index) const 240 // to let each worker thread hold its own << 247 { 241 // and the ion list. This implementation i << 248 if ( (index >=0 ) && (index < Entries()) ){ 242 // table thread private. The two shadow po << 249 return (*fIonList)[index]; 243 // thread to copy the content from the mas << 250 } else { 244 static G4ThreadLocal G4IonList* fIonList; << 251 return 0; 245 static G4ThreadLocal std::vector<G4VIsotop << 252 } 246 static G4IonList* fIonListShadow; << 253 } 247 static std::vector<G4VIsotopeTable*>* fIso << 254 248 << 249 enum << 250 { << 251 numberOfElements = 118 << 252 }; << 253 static const G4String elementName[numberOf << 254 255 255 #ifdef G4MULTITHREADED << 256 static G4Mutex ionTableMutex; << 257 #endif 256 #endif 258 257 259 protected: << 260 G4ParticleDefinition* FindIonInMaster(G4in << 261 G4ParticleDefinition* FindIonInMaster(G4in << 262 G4ParticleDefinition* FindIonInMaster(G4in << 263 G4Io << 264 G4ParticleDefinition* FindIonInMaster(G4in << 265 G4Io << 266 << 267 G4ParticleDefinition* CreateIon(G4int Z, G << 268 G4ParticleDefinition* CreateIon(G4int Z, G << 269 G4Ions::G4 << 270 G4ParticleDefinition* CreateIon(G4int Z, G << 271 G4ParticleDefinition* CreateIon(G4int Z, G << 272 << 273 void InsertWorker(const G4ParticleDefiniti << 274 << 275 // Create Ion << 276 << 277 G4IsotopeProperty* FindIsotope(G4int Z, G4 << 278 G4Ions::G4F << 279 G4IsotopeProperty* FindIsotope(G4int Z, G4 << 280 // Ask properties of isotopes << 281 << 282 G4ParticleDefinition* GetLightIon(G4int Z, << 283 G4ParticleDefinition* GetLightAntiIon(G4in << 284 << 285 // Return true if the particle is pre-defi << 286 G4bool IsLightIon(const G4ParticleDefiniti << 287 G4bool IsLightAntiIon(const G4ParticleDefi << 288 << 289 // Add process manager to ions with name o << 290 void AddProcessManager(G4ParticleDefinitio << 291 258 292 // Get Verbose Level defined in G4Particle << 293 G4int GetVerboseLevel() const; << 294 259 295 private: << 296 G4NuclideTable* pNuclideTable = nullptr; << 297 260 298 // Isomer table and flag of creation << 299 G4bool isIsomerCreated = false; << 300 }; << 301 261 302 // ------------------------ << 303 // Inline methods << 304 // ------------------------ << 305 262 306 inline G4int G4IonTable::GetNumberOfElements() << 307 { << 308 return numberOfElements; << 309 } << 310 263 311 #endif << 264 >> 265 >> 266 312 267