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