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