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