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 // G4VUserPhysicsList << 8 // $Id: G4VUserPhysicsList.hh,v 1.8 2000/11/14 23:53:13 kurasige Exp $ >> 9 // GEANT4 tag $Name: geant4-03-00 $ 27 // 10 // 28 // Class description: << 11 // >> 12 // ------------------------------------------------------------ >> 13 // GEANT 4 class header file >> 14 // Class Description: >> 15 // This class is an abstruct class for >> 16 // constructing particles and processes. >> 17 // User must implement following four virtual methods >> 18 // in his own concrete class derived from this class. >> 19 // G4VUserPhysicsList::ConstructParticle() >> 20 // Construct particles >> 21 // G4VUserPhysicsList::constructPhysics() >> 22 // Construct procesess and register them to particles >> 23 // G4VUserPhysicsList::SetCuts() >> 24 // set cut values in range to all particles >> 25 // (and rebuilding physics table will be invoked ) 29 // 26 // 30 // This class is an abstract class for constru << 27 // ------------------------------------------- 31 // User must implement the following two pure << 28 // History 32 // class derived from this class: << 29 // first version 09 Jan. 1998 by H.Kurashige 33 // - G4VUserPhysicsList::ConstructParticle() << 30 // modified 24 Jan. 1998 by H.Kurashige 34 // Construct particles << 31 // rename DumpCutValues/DumpCutValuesTable 35 // - G4VUserPhysicsList::ConstructProcess() << 32 // change SetCuts method 36 // Construct procesess and register them t << 33 // add SetCutsWithDefault method 37 << 34 // modified 06 June 1998 by H.Kurashige 38 // Original author: H.Kurashige (Kobe Universi << 35 // add AddProcessManager 39 // ------------------------------------------- << 36 // add BuildPhysicsTable 40 #ifndef G4VUserPhysicsList_hh << 37 // modified 29 June 1998 by H.Kurashige 41 #define G4VUserPhysicsList_hh 1 << 38 // add AddProcessManager 42 << 39 // modified 05 Dec. 1998 by H.Kurashige 43 #include "G4ParticleDefinition.hh" << 40 // add ConstructAllParticles() 44 #include "G4ParticleTable.hh" << 41 // modified 14, Apr 1999 by H.Kurashige 45 #include "G4PhysicsModelCatalog.hh" << 42 // change BuildPhysicsTable as public 46 #include "G4ProductionCutsTable.hh" << 43 // removed ConstructAllParticles() and related methods 47 #include "G4Threading.hh" << 44 // changed SetCuts method argument 48 #include "G4VUPLSplitter.hh" << 45 // modified 08, Nov 2000 by H.Kurashige 49 #include "G4ios.hh" << 46 // added Retrieve/StorePhysicsTable and related methods >> 47 // ------------------------------------------------------------ >> 48 #ifndef G4VUserPhysicsList_h >> 49 #define G4VUserPhysicsList_h 1 50 #include "globals.hh" 50 #include "globals.hh" >> 51 #include "G4ios.hh" 51 52 52 #include "rundefs.hh" << 53 #include "G4ParticleTable.hh" 53 #include "tls.hh" << 54 #include "G4ParticleDefinition.hh" 54 55 55 class G4UserPhysicsListMessenger; 56 class G4UserPhysicsListMessenger; 56 class G4PhysicsListHelper; << 57 class G4VProcess; 57 class G4VProcess; 58 58 59 // Encapsulate the fields of class G4VUserPhys << 60 class G4VUPLData << 61 { << 62 public: << 63 void initialize(); << 64 << 65 G4ParticleTable::G4PTblDicIterator* _thePa << 66 G4UserPhysicsListMessenger* _theMessenger << 67 G4PhysicsListHelper* _thePLHelper = nullpt << 68 G4bool _fIsPhysicsTableBuilt = false; << 69 G4int _fDisplayThreshold = 0; << 70 }; << 71 << 72 // The type G4VUPLManager is introduced to enc << 73 // both the master thread and worker threads t << 74 // the fields encapsulated by the class G4VUPL << 75 // changes the value for these fields, it refe << 76 // definition defined below. For every G4VUser << 77 // there is a corresponding G4VUPLData instanc << 78 // are organized by the class G4VUPLManager as << 79 // The field "int g4vuplInstanceID" is added t << 80 // The value of this field in each G4VUserPhys << 81 // subscript of the corresponding G44VUPLData << 82 // In order to use the class G44VUPLManager, w << 83 // G4VUserPhysicsList as follows: "static G4VU << 84 // Both the master thread and worker threads c << 85 // for G44VUPLData instances mutually along wi << 86 // instances are created. For each worker thre << 87 // Consider any thread A, if there is any othe << 88 // This ion is shared by the thread A. So the << 89 // in the array of G4PDefData instances for th << 90 // << 91 // Important Note: you may wonder why we are i << 92 // since there is only one PL << 93 // This is true, in the sense << 94 // to be associated to a G4Run << 95 // instantiate as many PLs are << 96 // of the PLs to be used we th << 97 // guarantee that the system w << 98 // this (unusual) case. This m << 99 // << 100 using G4VUPLManager = G4VUPLSplitter<G4VUPLDat << 101 using G4VUserPhysicsListSubInstanceManager = G << 102 << 103 class G4VUserPhysicsList 59 class G4VUserPhysicsList 104 { 60 { 105 public: << 61 public: 106 G4VUserPhysicsList(); 62 G4VUserPhysicsList(); 107 virtual ~G4VUserPhysicsList(); 63 virtual ~G4VUserPhysicsList(); 108 G4VUserPhysicsList(const G4VUserPhysicsLis << 109 G4VUserPhysicsList& operator=(const G4VUse << 110 << 111 // Each particle type will be instantiated << 112 // This method is invoked by the RunManger << 113 virtual void ConstructParticle() = 0; << 114 64 115 // By calling the "Construct" method, << 65 public: // with description 116 // process manager and processes are creat << 66 // By calling the "Construct" method, >> 67 // particles and processes are created 117 void Construct(); 68 void Construct(); >> 69 >> 70 >> 71 protected: // with description >> 72 // These two methods of ConstructParticle() and ConstructProcess() >> 73 // will be invoked in the Construct() method. 118 74 119 // Each physics process will be instantiat << 75 // each particle type will be instantiated 120 // registered to the process manager of ea << 76 virtual void ConstructParticle() = 0; 121 // Invoked in the Construct() method. << 77 >> 78 // each physics process will be instantiated and >> 79 // registered to the process manager of each particle type 122 virtual void ConstructProcess() = 0; 80 virtual void ConstructProcess() = 0; 123 81 124 // Sets a cut value for all particle types << 82 protected: // with description 125 virtual void SetCuts(); << 83 // User must invoke this method in his ConstructProcess() >> 84 // implementation in order to insures particle transportation. >> 85 // !! Caution: this class must not be overriden !! >> 86 void AddTransportation(); 126 87 127 // Set/get the default cut value. Calling << 88 ///////////////////////////////////// 128 // re-calcuration of cut values and physic << 89 public: // with description 129 // next event loop. << 90 // "SetCuts" method sets a cut value for all particle types 130 void SetDefaultCutValue(G4double newCutVal << 91 // in the particle table 131 G4double GetDefaultCutValue() const; << 92 virtual void SetCuts() = 0; >> 93 >> 94 protected: // with description >> 95 // "SetCutsWithDefault" method sets a cut value with the default >> 96 // cut values for all particle types in the particle table >> 97 void SetCutsWithDefault(); 132 98 133 // Invoke BuildPhysicsTable for all proces << 99 public: // with description >> 100 // Invoke BuildPhysicsTable for all processes for each particle 134 // In case of "Retrieve" flag is ON, Physi 101 // In case of "Retrieve" flag is ON, PhysicsTable will be 135 // retrieved from files. << 102 // retrieved from files 136 void BuildPhysicsTable(); << 103 void BuildPhysicsTable(G4ParticleDefinition* ); 137 << 104 138 // Prepare the PhysicsTable for specified << 105 // Store PhysicsTable together with both material and cut value 139 void PreparePhysicsTable(G4ParticleDefinit << 140 << 141 // Build the PhysicsTable for specified pa << 142 void BuildPhysicsTable(G4ParticleDefinitio << 143 << 144 // Store PhysicsTable together with both m << 145 // information in files under the specifie 106 // information in files under the specified directory. 146 // Returns "true" if files are successfull << 107 // (return true if files are sucessfully created) 147 G4bool StorePhysicsTable(const G4String& d << 108 G4bool StorePhysicsTable(const G4String& directory = "."); 148 << 149 // Return true if "Retrieve" flag is ON. << 150 // (i.e. PhysicsTable will be retrieved fr << 151 G4bool IsPhysicsTableRetrieved() const; << 152 G4bool IsStoredInAscii() const; << 153 109 >> 110 // Return true if "Retrieve" flag is ON. >> 111 // (i.e. PhysicsTable will be retrieved from files) >> 112 G4bool IsPhysicsTableRetrieved() const; 154 // Get directory path for physics table fi 113 // Get directory path for physics table files. 155 const G4String& GetPhysicsTableDirectory() 114 const G4String& GetPhysicsTableDirectory() const; 156 115 157 // Set "Retrieve" flag. Directory path can << 116 // Set "Retrieve" flag 158 // Null string (default) means directory i << 117 // Directory path can be set together. 159 // from the current value. << 118 // Null string (default) means directory is not changed 160 void SetPhysicsTableRetrieved(const G4Stri << 119 // from the current value 161 void SetStoredInAscii(); << 120 void SetPhysicsTableRetrieved(const G4String& directory = ""); 162 << 121 163 // Reset "Retrieve" flag. << 122 // Reset "Retrieve" flag 164 void ResetPhysicsTableRetrieved(); << 123 void ResetPhysicsTableRetrieved(); 165 void ResetStoredInAscii(); << 124 166 << 125 protected: // with description 167 // Print out the List of registered partic << 126 // do BuildPhysicsTable for make the integral schema 168 void DumpList() const; << 127 void BuildIntegralPhysicsTable(G4VProcess* ,G4ParticleDefinition* ); 169 << 128 170 // Request to print out information of cut << 129 protected: // with description 171 // Printing will be performed when all tab << 130 // Retrieve PhysicsTable from files for proccess belongng the particle. 172 void DumpCutValuesTable(G4int flag = 1); << 131 // Normal BuildPhysics procedure of processes will be invoked, 173 << 132 // if it fails (in case of Process's RetrievePhysicsTable returns false) 174 // Triggers the print-out requested by the << 133 virtual void RetrievePhysicsTable(G4ParticleDefinition* ); 175 // This method must be invoked by RunManag << 134 176 void DumpCutValuesTableIfRequested(); << 135 // Store material information in files under the specified directory. 177 << 136 virtual G4bool StoreMaterialInfo(const G4String& directory); 178 // Set/get control flag for output message << 137 // Store cut values information in files under the specified directory. 179 // 0: Silent << 138 virtual G4bool StoreCutValues(const G4String& directory); 180 // 1: Warning message << 139 181 // 2: More << 140 // check stored material and cut values 182 void SetVerboseLevel(G4int value); << 141 virtual G4bool CheckForRetrievePhysicsTable(const G4String& directory); 183 G4int GetVerboseLevel() const; << 142 // check stored material is consistent with the current detector setup. 184 << 143 virtual G4bool CheckMaterialInfo(const G4String& directory); 185 void UseCoupledTransportation(G4bool vl = << 144 // check stored cuvalue is consistent with the current detector setup. 186 << 145 virtual G4bool CheckCutValues(const G4String& directory); 187 // Invokes default SetCuts() method. << 146 188 // Note: cut values will not be overwritte << 147 protected: // with description 189 // Use of default SetCuts() method is reco << 148 // Following are utility methods for SetCuts/reCalcCuts 190 void SetCutsWithDefault(); << 149 191 << 150 // Reset cut values in energy for all particle types 192 // Sets a cut value for a particle type fo << 151 // By calling this methods, the run manager will invoke 193 void SetCutValue(G4double aCut, const G4St << 152 // SetCuts() just before event loop 194 << 153 void ResetCuts(); 195 // Gets a cut value for a particle type fo << 154 196 G4double GetCutValue(const G4String& pname << 155 // SetCutValue sets a cut value for a particle type 197 << 156 void SetCutValue(G4double aCut, const G4String& name); 198 // Sets a cut value for a particle type fo << 157 void ReCalcCutValue(const G4String& name); 199 void SetCutValue(G4double aCut, const G4St << 158 200 << 159 // "setCutsForOthers" method sets a cut value to all particle types 201 // Invoke SetCuts for specified particle f << 160 // which have not be called SetCuts() methods yet. 202 // If the pointer to the region is NULL, t << 161 // (i.e. particles which have no definit cut values) 203 // In case of "Retrieve" flag is ON, cut v << 162 void SetCutValueForOthers(G4double cutValue); 204 // from files. << 163 205 void SetParticleCuts(G4double cut, G4Parti << 164 // "setCutsForOtherThan" sets a cut value to all particle types 206 void SetParticleCuts(G4double cut, const G << 165 // other than particle types specified in arguments 207 << 166 void SetCutValueForOtherThan(G4double cutValue, 208 // Invoke SetCuts() for all particles in a << 167 G4ParticleDefinition* first, 209 void SetCutsForRegion(G4double aCut, const << 168 G4ParticleDefinition* second = NULL, 210 << 169 G4ParticleDefinition* third = NULL, 211 // Gets/sets the flag for ApplyCuts(). << 170 G4ParticleDefinition* fourth = NULL, 212 void SetApplyCuts(G4bool value, const G4St << 171 G4ParticleDefinition* fifth = NULL, 213 G4bool GetApplyCuts(const G4String& name) << 172 G4ParticleDefinition* sixth = NULL, 214 << 173 G4ParticleDefinition* seventh = NULL, 215 // Remove and delete ProcessManagers for a << 174 G4ParticleDefinition* eighth = NULL, 216 // Particle Table. << 175 G4ParticleDefinition* nineth = NULL, 217 void RemoveProcessManager(); << 176 G4ParticleDefinition* tenth = NULL ); 218 << 177 219 // Remove and delete TrackingManagers for << 178 // "reCalcCutsForOthers" method re-calculates a cut value 220 // Particle Table. << 179 // to all particle types which have not be called SetCuts() methods yet. 221 void RemoveTrackingManager(); << 180 void ReCalcCutValueForOthers(); 222 << 181 223 // Add process manager for particles creat << 182 public: // with description 224 void AddProcessManager(G4ParticleDefinitio << 183 // set/get the default cut value 225 G4ProcessManager* n << 184 // Calling SetDefaultCutValue causes re-calcuration of cut values 226 << 185 // and physics tables just before the next event loop 227 // Check consistencies of list of particle << 186 void SetDefaultCutValue(G4double newCutValue); 228 void CheckParticleList(); << 187 G4double GetDefaultCutValue() const; 229 << 230 void DisableCheckParticleList(); << 231 << 232 inline G4int GetInstanceID() const; << 233 static const G4VUPLManager& GetSubInstance << 234 << 235 // Used by Worker threads on the shared in << 236 // to initialise workers. Derived class re << 237 // must also call this base class method. << 238 virtual void InitializeWorker(); << 239 << 240 // Destroy thread-local data. Note that de << 241 // implementing this method should still c << 242 virtual void TerminateWorker(); << 243 188 244 protected: 189 protected: 245 // User must invoke this method in his Con << 190 // this is the default cut value for all particles 246 // implementation in order to enable parti << 191 G4double defaultCutValue; 247 void AddTransportation(); << 248 192 249 // Register a process to the particle type << 193 ///////////////////////////////////// 250 // according to the ordering parameter tab << 194 public: // with description 251 // 'true' is returned if the process is re << 195 // Print out the List of registered particles types 252 G4bool RegisterProcess(G4VProcess* process << 196 void DumpList() const; 253 << 254 // Build PhysicsTable for making the integ << 255 void BuildIntegralPhysicsTable(G4VProcess* << 256 << 257 // Retrieve PhysicsTable from files for pr << 258 // Normal BuildPhysics procedure of proces << 259 // fails (in case of process's RetrievePhy << 260 virtual void RetrievePhysicsTable(G4Partic << 261 G4bool a << 262 197 263 // Adds new ProcessManager to all particle << 198 public: // with description 264 // This function is used in Construct(). << 199 // Print out information of cut values >> 200 void DumpCutValuesTable() const; >> 201 void DumpCutValues(const G4String &particle_name = "ALL") const; >> 202 void DumpCutValues(G4ParticleDefinition* ) const; >> 203 >> 204 protected: // with description >> 205 // adds new ProcessManager to all particles in the Particle Table >> 206 // this routine is used in Construct() 265 void InitializeProcessManager(); 207 void InitializeProcessManager(); 266 208 267 G4ParticleTable::G4PTblDicIterator* GetPar << 209 public: // with description >> 210 // remove and delete ProcessManagers for all particles in tha Particle Table >> 211 // this routine is invoked from RunManager >> 212 void RemoveProcessManager(); 268 213 >> 214 public: // with description >> 215 // add process manager for particles created on-the-fly >> 216 void AddProcessManager(G4ParticleDefinition* newParticle, >> 217 G4ProcessManager* newManager = NULL ); >> 218 269 protected: 219 protected: 270 // The particle table has the complete Lis << 220 // the particle table has the complete List of existing particle types 271 G4ParticleTable* theParticleTable = nullpt << 221 G4ParticleTable* theParticleTable; 272 << 222 G4ParticleTable::G4PTblDicIterator* theParticleIterator; 273 G4int verboseLevel = 1; << 223 274 << 224 protected: 275 // Default cut value for all particles << 225 // pointer to G4UserPhysicsListMessenger 276 G4double defaultCutValue = 1.0; << 226 G4UserPhysicsListMessenger* theMessenger; 277 G4bool isSetDefaultCutValue = false; << 227 278 << 228 public: // with description 279 // Pointer to ProductionCutsTable. << 229 void SetVerboseLevel(G4int value); 280 G4ProductionCutsTable* fCutsTable = nullpt << 230 G4int GetVerboseLevel() const; 281 << 231 // set/get controle flag for output message 282 // Flag to determine if physics table will << 232 // 0: Silent 283 G4bool fRetrievePhysicsTable = false; << 233 // 1: Warning message 284 G4bool fStoredInAscii = true; << 234 // 2: More 285 << 235 286 G4bool fIsCheckedForRetrievePhysicsTable = << 236 protected: 287 G4bool fIsRestoredCutValues = false; << 237 G4int verboseLevel; 288 << 238 289 // Directory name for physics table files. << 239 protected: 290 G4String directoryPhysicsTable = "."; << 240 // flag to determine physics table will be build from file or not 291 << 241 G4bool fRetrievePhysicsTable; 292 // Flag for CheckParticleList(). << 242 293 G4bool fDisableCheckParticleList = false; << 243 G4bool fIsCheckedForRetrievePhysicsTable; 294 << 244 295 // MT data << 245 // directory name for physics table files 296 G4int g4vuplInstanceID = 0; << 246 G4String directoryPhysicsTable; 297 G4RUN_DLL static G4VUPLManager subInstance << 247 >> 248 // number of materials in G4MaterialTable >> 249 // (this member is used by store/restore physics table) >> 250 G4int numberOfMaterial; 298 }; 251 }; 299 252 300 // Inline methods implementations << 301 253 302 inline void G4VUserPhysicsList::Construct() 254 inline void G4VUserPhysicsList::Construct() 303 { 255 { 304 #ifdef G4VERBOSE << 256 #ifdef G4VERBOSE 305 if (verboseLevel > 1) G4cout << "G4VUserPhys << 257 if (verboseLevel >1) G4cout << "G4VUserPhysicsList::Construct()" << G4endl; 306 #endif << 307 258 308 if (G4Threading::IsMasterThread()) G4Physics << 259 if (verboseLevel >1) G4cout << "Construct particles " << G4endl; >> 260 #endif >> 261 ConstructParticle(); 309 262 310 InitializeProcessManager(); 263 InitializeProcessManager(); 311 264 312 #ifdef G4VERBOSE << 265 #ifdef G4VERBOSE 313 if (verboseLevel > 1) G4cout << "Construct p << 266 if (verboseLevel >1) G4cout << "Construct processes " << G4endl; 314 #endif 267 #endif 315 ConstructProcess(); 268 ConstructProcess(); 316 } 269 } 317 270 318 inline G4double G4VUserPhysicsList::GetDefault 271 inline G4double G4VUserPhysicsList::GetDefaultCutValue() const 319 { 272 { 320 return defaultCutValue; 273 return defaultCutValue; 321 } 274 } 322 275 323 inline G4int G4VUserPhysicsList::GetVerboseLev << 276 inline void G4VUserPhysicsList::SetVerboseLevel(G4int value) 324 { 277 { 325 return verboseLevel; << 278 verboseLevel = value; >> 279 #ifdef G4VERBOSE >> 280 if (verboseLevel >1){ >> 281 G4cout << "G4VUserPhysicsList::SetVerboseLevel :"; >> 282 G4cout << " Verbose level is set to " << verboseLevel << G4endl; >> 283 } >> 284 #endif 326 } 285 } 327 286 328 inline G4bool G4VUserPhysicsList::IsPhysicsTab << 287 inline G4int G4VUserPhysicsList::GetVerboseLevel() const 329 { 288 { 330 return fRetrievePhysicsTable; << 289 return verboseLevel; 331 } 290 } 332 291 333 inline G4bool G4VUserPhysicsList::IsStoredInAs << 292 inline >> 293 G4bool G4VUserPhysicsList::IsPhysicsTableRetrieved() const 334 { 294 { 335 return fStoredInAscii; << 295 return fRetrievePhysicsTable; 336 } 296 } 337 297 338 inline const G4String& G4VUserPhysicsList::Get << 298 inline >> 299 const G4String& G4VUserPhysicsList::GetPhysicsTableDirectory() const 339 { 300 { 340 return directoryPhysicsTable; << 301 return directoryPhysicsTable; 341 } 302 } 342 303 343 inline void G4VUserPhysicsList::SetStoredInAsc << 304 inline >> 305 void G4VUserPhysicsList::SetPhysicsTableRetrieved(const G4String& directory) 344 { 306 { 345 fStoredInAscii = true; << 307 fRetrievePhysicsTable = true; >> 308 if(!directory.isNull()) { >> 309 directoryPhysicsTable = directory; >> 310 } >> 311 fIsCheckedForRetrievePhysicsTable=false; 346 } 312 } 347 << 313 348 inline void G4VUserPhysicsList::ResetPhysicsTa << 314 inline >> 315 void G4VUserPhysicsList::ResetPhysicsTableRetrieved() 349 { 316 { 350 fRetrievePhysicsTable = false; 317 fRetrievePhysicsTable = false; 351 fIsRestoredCutValues = false; << 318 fIsCheckedForRetrievePhysicsTable=false; 352 fIsCheckedForRetrievePhysicsTable = false; << 353 } 319 } >> 320 #endif >> 321 >> 322 354 323 355 inline void G4VUserPhysicsList::ResetStoredInA << 356 { << 357 fStoredInAscii = false; << 358 } << 359 324 360 inline void G4VUserPhysicsList::DisableCheckPa << 361 { << 362 fDisableCheckParticleList = true; << 363 } << 364 325 365 inline G4int G4VUserPhysicsList::GetInstanceID << 366 { << 367 return g4vuplInstanceID; << 368 } << 369 326 370 inline const G4VUPLManager& G4VUserPhysicsList << 371 { << 372 return subInstanceManager; << 373 } << 374 327 375 #endif << 376 328