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