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 // G4ParticleTable << 27 // 26 // 28 // Class description: << 27 // $Id: G4ParticleTable.hh,v 1.18 2006/06/29 19:24:32 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-02 $ 29 // 29 // 30 // G4ParticleTable is the table of pointers to << 30 // 31 // It is a "singleton" (only one static object << 31 // ------------------------------------------------------------ 32 // Each G4ParticleDefinition pointer is stored << 32 // GEANT 4 class header file 33 // to itself. So, each G4ParticleDefinition ob << 33 // 34 // name. << 34 // History: first implementation, based on object model of 35 << 35 // 27 June 1996, H.Kurashige 36 // Authors: G.Cosmo, 2 December 1995 - Design, << 36 // ------------------------------------------------------------ 37 // H.Kurashige, 27 June 1996 - First << 37 // added fParticleMessenger 14 Nov., 97 H.Kurashige 38 // History: << 38 // added Create/DeleteMessenger 06 Jul., 98 H.Kurashige 39 // - 14 Nov 1997, H.Kurashige - Added messenge << 39 // modified FindIon 02 Aug., 98 H.Kurashige 40 // - 24 Sep 1998, H.Kurashige - Added dictiona << 40 // added dictionary for encoding 24 Sep., 98 H.Kurashige 41 // - 28 Oct 1999, H.Kurashige - Migration to S << 41 // added RemoveAllParticles() 8 Nov., 98 H.Kurashige 42 // - 15 Sep 2017, K.L.Genser - Added support f << 42 // -------------------------------- 43 // ------------------------------------------- << 43 // fixed some improper codings 08 Apr., 99 H.Kurashige 44 #ifndef G4ParticleTable_hh << 44 // modified FindIon/GetIon methods 17 AUg., 99 H.Kurashige 45 #define G4ParticleTable_hh 1 << 45 // implement new version for using STL map instaed of RW PtrHashedDictionary >> 46 // 28 ct., 99 H.Kurashige >> 47 >> 48 #ifndef G4ParticleTable_h >> 49 #define G4ParticleTable_h 1 46 50 47 #include "G4ParticleDefinition.hh" << 48 #include "G4ParticleTableIterator.hh" << 49 #include "G4Threading.hh" << 50 #include "G4ios.hh" 51 #include "G4ios.hh" 51 #include "globals.hh" 52 #include "globals.hh" >> 53 #include "G4ParticleDefinition.hh" >> 54 52 55 53 #include <map> 56 #include <map> >> 57 #include "G4ParticleTableIterator.hh" 54 58 55 class G4UImessenger; 59 class G4UImessenger; 56 class G4ParticleMessenger; 60 class G4ParticleMessenger; 57 class G4IonTable; 61 class G4IonTable; >> 62 class G4ShortLivedTable; 58 63 59 class G4ParticleTable 64 class G4ParticleTable 60 { 65 { 61 public: << 66 // Class Description 62 using G4PTblDictionary = G4ParticleTableIt << 67 // G4ParticleTable is the table of pointer to G4ParticleDefinition 63 using G4PTblDicIterator = G4ParticleTableI << 68 // G4ParticleTable is a "singleton" (only one and staic object) 64 using G4PTblEncodingDictionary = G4Particl << 69 // In G4ParticleTable, each G4ParticleDefinition pointer is stored 65 using G4PTblEncodingDicIterator = G4Partic << 70 // with its name as a key to itself. So, each G4ParticleDefinition 66 << 71 // object must have unique name for itself. 67 virtual ~G4ParticleTable(); << 72 // 68 << 73 69 // Copy constructor and assignment operato << 74 public: 70 G4ParticleTable(const G4ParticleTable&) = << 75 71 G4ParticleTable& operator=(const G4Particl << 76 typedef G4ParticleTableIterator<G4String, G4ParticleDefinition*>::Map G4PTblDictionary; 72 << 77 typedef G4ParticleTableIterator<G4String, G4ParticleDefinition*> G4PTblDicIterator; 73 // This method is similar to the construct << 78 typedef G4ParticleTableIterator<G4int, G4ParticleDefinition*>::Map G4PTblEncodingDictionary; 74 // thread to achieve the partial effect as << 79 typedef G4ParticleTableIterator<G4int, G4ParticleDefinition*> G4PTblEncodingDicIterator; 75 void WorkerG4ParticleTable(); << 80 76 << 81 protected: 77 // This method is similar to the destructo << 82 G4ParticleTable(); 78 // thread to achieve the partial effect as << 83 G4ParticleTable(const G4ParticleTable &right); 79 void DestroyWorkerG4ParticleTable(); << 84 80 << 85 public: 81 // Return the pointer to the G4ParticleTab << 86 virtual ~G4ParticleTable(); 82 // G4ParticleTable is a "singleton" and ca << 87 83 // function. At the first time of calling << 88 public: // With Description 84 // G4ParticleTable object is instantiated << 89 static G4ParticleTable* GetParticleTable(); 85 static G4ParticleTable* GetParticleTable() << 90 // return the pointer to G4ParticleTable object 86 << 91 // G4ParticleTable is a "singleton" and can get its pointer by this function 87 // Returns TRUE if the ParticleTable conta << 92 // At the first time of calling this function, the G4ParticleTable object 88 inline G4bool contains(const G4ParticleDef << 93 // is instantiated 89 G4bool contains(const G4String& particle_n << 94 90 << 95 G4bool contains(const G4ParticleDefinition *particle); 91 // Returns the number of particles in the << 96 G4bool contains(const G4String &particle_name); 92 G4int entries() const; << 97 // returns TRUE if the ParticleTable contains 93 G4int size() const; << 98 94 << 99 G4int entries() const; 95 // Returns a pointer to the i-th particle << 100 G4int size() const; 96 // 0 <= index < entries() << 101 // returns the number of Particles in the ParticleTable 97 G4ParticleDefinition* GetParticle(G4int in << 102 98 << 103 G4ParticleDefinition* GetParticle(G4int index); 99 // Returns the name of i-th particle in th << 104 // returns a pointer to i-th particles in the ParticleTable 100 const G4String& GetParticleName(G4int inde << 105 // 0<= index < entries() 101 << 106 102 // Returns a pointer to the particle (0 if << 107 const G4String& GetParticleName(G4int index); 103 G4ParticleDefinition* FindParticle(G4int P << 108 // returns name of i-th particles in the ParticleTable 104 G4ParticleDefinition* FindParticle(const G << 109 105 G4ParticleDefinition* FindParticle(const G << 110 G4ParticleDefinition* FindParticle(G4int PDGEncoding ); 106 << 111 G4ParticleDefinition* FindParticle(const G4String &particle_name); 107 // Returns a pointer to its anti-particle << 112 G4ParticleDefinition* FindParticle(const G4ParticleDefinition *particle); 108 inline G4ParticleDefinition* FindAntiParti << 113 // returns a pointer to the particle (0 if not contained) 109 inline G4ParticleDefinition* FindAntiParti << 114 110 inline G4ParticleDefinition* FindAntiParti << 115 G4ParticleDefinition* FindAntiParticle(G4int PDGEncoding ); 111 << 116 G4ParticleDefinition* FindAntiParticle(const G4String &particle_name); 112 // Returns the pointer to the Iterator << 117 G4ParticleDefinition* FindAntiParticle(const G4ParticleDefinition *particle); 113 G4PTblDicIterator* GetIterator() const; << 118 // returns a pointer to its anti-particle (0 if not contained) 114 << 119 115 // Dumps information of particles specifie << 120 G4ParticleDefinition* FindIon( G4int atomicNumber, 116 void DumpTable(const G4String& particle_na << 121 G4int atomicMass, 117 << 122 G4double excitationEnergy ); 118 // Returns the pointer to the G4IonTable o << 123 // return the pointer to an ion (returns 0 if the ion does not exist) 119 G4IonTable* GetIonTable() const; << 124 // the ion has excitation energy nearest to given excitationEnergy (0: ground state) 120 << 125 121 // Inserts the particle into ParticleTable << 126 G4ParticleDefinition* GetIon( G4int atomicNumber, 122 // Returned value is the same as particle << 127 G4int atomicMass, 123 // or the pointer to another G4ParticleD << 128 G4double excitationEnergy); 124 // which has same particle name << 129 // return the pointer to an ion ( create ion if the ion does not exist) 125 // or nullptr if failing to insert by ot << 130 // It has excitation energy nearest to given excitationEnergy (0: ground state) 126 G4ParticleDefinition* Insert(G4ParticleDef << 131 127 << 132 G4ParticleDefinition* FindIon( G4int atomicNumber, 128 // Removes the particle from the table (no << 133 G4int atomicMass, 129 G4ParticleDefinition* Remove(G4ParticleDef << 134 G4int dummy1, 130 << 135 G4int dummy2 ); 131 // Removes all particles from G4ParticleTa << 136 // return the pointer to an ion 132 void RemoveAllParticles(); << 137 // !! This routine behaves same as GetIon( atomicNumber, atomicMass, 0) 133 << 138 // !! The third and fourth arguments are meaningless 134 // Removes and deletes all particles from << 139 // !! This routine is provided for compatibility to old version 135 void DeleteAllParticles(); << 140 136 << 141 G4PTblDicIterator* GetIterator(); 137 // Creates messenger << 142 // return the pointer of Iterator (RW compatible) 138 G4UImessenger* CreateMessenger(); << 143 139 << 144 void DumpTable(const G4String &particle_name = "ALL"); 140 void SelectParticle(const G4String& name); << 145 // dump information of particles specified by name 141 << 146 142 inline const G4ParticleDefinition* GetSele << 147 public: 143 << 148 G4ParticleDefinition* Insert(G4ParticleDefinition *particle); 144 inline void SetVerboseLevel(G4int value); << 149 // insert the particle into ParticleTable 145 inline G4int GetVerboseLevel() const; << 150 // return value is same as particle if successfully inserted 146 << 151 // or pointer to another G4ParticleDefinition object 147 inline void SetReadiness(G4bool val = true << 152 // which has same name of particle 148 inline G4bool GetReadiness() const; << 153 // or 0 if fail to insert by another reason 149 << 154 150 inline G4ParticleDefinition* GetGenericIon << 155 protected: 151 inline void SetGenericIon(G4ParticleDefini << 156 G4ParticleDefinition* Remove(G4ParticleDefinition *particle); 152 << 157 // Remove Particle 153 inline G4ParticleDefinition* GetGenericMuo << 158 154 inline void SetGenericMuonicAtom(G4Particl << 159 G4PTblDictionary* GetDictionary(); 155 << 160 156 // Public data --------------------------- << 161 const G4String& GetKey(const G4ParticleDefinition *particle) const; 157 << 162 // return key value of the particle (i.e. particle name) 158 // These fields should be thread local or << 163 159 // class, we can change any member field a << 164 const G4PTblEncodingDictionary* GetEncodingDictionary(); 160 // because there is only one instance. The << 165 // return the pointer to EncodingDictionary 161 // "G4ThreadLocal" << 166 162 G4ParticleMessenger* fParticleMessenger = << 167 public: //With Description 163 static G4ThreadLocal G4PTblDictionary* fDi << 168 164 static G4ThreadLocal G4PTblDicIterator* fI << 169 const G4IonTable* GetIonTable(); 165 static G4ThreadLocal G4PTblEncodingDiction << 170 // return the pointer to G4IonTable object 166 << 171 167 // Particle table is being shared << 172 const G4ShortLivedTable* GetShortLivedTable(); 168 static G4ParticleTable* fgParticleTable; << 173 // return the pointer to G4ShortLivedTable object 169 << 174 170 // This field should be thread private. Ho << 175 public: 171 // of the ion table pointer. So we change << 176 G4UImessenger* CreateMessenger(); 172 // G4IonTable to be thread local << 177 void DeleteMessenger(); 173 G4IonTable* fIonTable = nullptr; << 178 // create/delete messenger for the particle table 174 << 179 175 // These shadow pointers are used by each << 180 protected: 176 // from the master thread << 181 void RemoveAllParticles(); 177 // << 182 // remove all particles from G4ParticleTable and 178 static G4PTblDictionary* fDictionaryShadow << 183 // delete them if they were created dynamically (i.e. not static objects) 179 static G4PTblDicIterator* fIteratorShadow; << 184 180 static G4PTblEncodingDictionary* fEncoding << 185 private: 181 << 186 G4int verboseLevel; 182 #ifdef G4MULTITHREADED << 187 // controle flag for output message 183 // Shared instance of a mutex << 188 // 0: Silent 184 static G4GLOB_DLL G4Mutex& particleTableMu << 189 // 1: Warning message 185 static G4GLOB_DLL G4int& lockCount(); << 190 // 2: More 186 #endif << 191 187 << 192 public: 188 protected: << 193 void SetVerboseLevel(G4int value); 189 const G4PTblDictionary* GetDictionary() co << 194 G4int GetVerboseLevel() const; 190 << 195 191 // Returns key value of the particle (i.e. << 196 private: 192 inline const G4String& GetKey(const G4Part << 197 G4ParticleMessenger* fParticleMessenger; 193 << 198 G4PTblDictionary* fDictionary; 194 // Returns the pointer to EncodingDictiona << 199 G4PTblDicIterator* fIterator; 195 const G4PTblEncodingDictionary* GetEncodin << 200 G4PTblEncodingDictionary* fEncodingDictionary; 196 << 201 G4int DictionaryBucketSize; 197 private: << 202 198 // Provate default constructor << 203 static G4ParticleTable* fgParticleTable; 199 G4ParticleTable(); << 204 200 << 205 G4IonTable* fIonTable; 201 void CheckReadiness() const; << 206 G4ShortLivedTable* fShortLivedTable; >> 207 >> 208 G4String noName; >> 209 >> 210 G4bool readyToUse; >> 211 >> 212 public: >> 213 void SetReadiness(); >> 214 G4bool GetReadiness() const; >> 215 private: >> 216 void CheckReadiness(); >> 217 }; >> 218 #include "G4ParticleTable.icc" 202 219 203 // Private data -------------------------- << 220 #endif 204 221 205 G4ParticleDefinition* genericIon = nullptr << 206 G4ParticleDefinition* genericMuonicAtom = << 207 const G4ParticleDefinition* selectedPartic << 208 222 209 const G4String noName = " "; << 210 G4String selectedName = "undefined"; << 211 223 212 // Control flag for output message << 213 // 0: Silent << 214 // 1: Warning message << 215 // 2: More << 216 G4int verboseLevel = 1; << 217 224 218 G4bool readyToUse = false; << 219 }; << 220 225 221 #include "G4ParticleTable.icc" << 222 226 223 #endif << 224 227