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