[828] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4VUserPhysicsList.hh,v 1.35 2007/05/30 10:16:27 ahoward Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | // ------------------------------------------------------------ |
---|
| 32 | // GEANT 4 class header file |
---|
| 33 | // Class Description: |
---|
| 34 | // This class is an abstruct class for |
---|
| 35 | // constructing particles and processes. |
---|
| 36 | // User must implement following four virtual methods |
---|
| 37 | // in his own concrete class derived from this class. |
---|
| 38 | // G4VUserPhysicsList::ConstructParticle() |
---|
| 39 | // Construct particles |
---|
| 40 | // G4VUserPhysicsList::constructPhysics() |
---|
| 41 | // Construct procesess and register them to particles |
---|
| 42 | // G4VUserPhysicsList::SetCuts() |
---|
| 43 | // set cut values in range to all particles |
---|
| 44 | // (and rebuilding physics table will be invoked ) |
---|
| 45 | // |
---|
| 46 | // ------------------------------------------- |
---|
| 47 | // History |
---|
| 48 | // first version 09 Jan. 1998 by H.Kurashige |
---|
| 49 | // modified 24 Jan. 1998 by H.Kurashige |
---|
| 50 | // rename DumpCutValues/DumpCutValuesTable |
---|
| 51 | // change SetCuts method |
---|
| 52 | // add SetCutsWithDefault method |
---|
| 53 | // modified 06 June 1998 by H.Kurashige |
---|
| 54 | // add AddProcessManager |
---|
| 55 | // add BuildPhysicsTable |
---|
| 56 | // modified 29 June 1998 by H.Kurashige |
---|
| 57 | // add AddProcessManager |
---|
| 58 | // modified 05 Dec. 1998 by H.Kurashige |
---|
| 59 | // add ConstructAllParticles() |
---|
| 60 | // modified 14, Apr 1999 by H.Kurashige |
---|
| 61 | // change BuildPhysicsTable as public |
---|
| 62 | // removed ConstructAllParticles() and related methods |
---|
| 63 | // changed SetCuts method argument |
---|
| 64 | // modified 08, Nov 2000 by H.Kurashige |
---|
| 65 | // added Retrieve/StorePhysicsTable and related methods |
---|
| 66 | // modified 08, Mar 2001 by H.Kurashige |
---|
| 67 | // added binary mode for Retrieve/StorePhysicsTable |
---|
| 68 | // added RetrieveCutValues and related |
---|
| 69 | // added Set/ResetStoredInAscii() to switch on ascii mode |
---|
| 70 | // for Retrieve/StorePhysicsTable |
---|
| 71 | // modified for CUTS per REGION 10, Oct 2002 by H.Kurashige |
---|
| 72 | // removed following methods |
---|
| 73 | // void ReCalcCutValue() |
---|
| 74 | // void SetCutValueForOthers() |
---|
| 75 | // void SetCutValueForOtherThan() |
---|
| 76 | // void ReCalcCutValueForOthers() |
---|
| 77 | // virtual G4bool StoreMaterialInfo() |
---|
| 78 | // virtual G4bool StoreCutValues() |
---|
| 79 | // virtual G4bool RetrieveCutValues() |
---|
| 80 | // virtual G4bool CheckForRetrievePhysicsTable() |
---|
| 81 | // virtual G4bool CheckMaterialInfo() |
---|
| 82 | // added void BuildPhysicsTable() |
---|
| 83 | // ------------------------------------------------------------ |
---|
| 84 | #ifndef G4VUserPhysicsList_h |
---|
| 85 | #define G4VUserPhysicsList_h 1 |
---|
| 86 | #include "globals.hh" |
---|
| 87 | #include "G4ios.hh" |
---|
| 88 | |
---|
| 89 | #include "G4ParticleTable.hh" |
---|
| 90 | #include "G4ParticleDefinition.hh" |
---|
| 91 | #include "G4ProductionCutsTable.hh" |
---|
| 92 | |
---|
| 93 | class G4UserPhysicsListMessenger; |
---|
| 94 | class G4VProcess; |
---|
| 95 | |
---|
| 96 | class G4VUserPhysicsList |
---|
| 97 | { |
---|
| 98 | public: |
---|
| 99 | G4VUserPhysicsList(); |
---|
| 100 | virtual ~G4VUserPhysicsList(); |
---|
| 101 | |
---|
| 102 | public: // with description |
---|
| 103 | // Each particle type will be instantiated |
---|
| 104 | // This method is invoked by the RunManger |
---|
| 105 | virtual void ConstructParticle() = 0; |
---|
| 106 | |
---|
| 107 | // By calling the "Construct" method, |
---|
| 108 | // process manager and processes are created. |
---|
| 109 | void Construct(); |
---|
| 110 | |
---|
| 111 | // Each physics process will be instantiated and |
---|
| 112 | // registered to the process manager of each particle type |
---|
| 113 | // This method is invoked in Construct" method |
---|
| 114 | virtual void ConstructProcess() = 0; |
---|
| 115 | |
---|
| 116 | protected: // with description |
---|
| 117 | // User must invoke this method in his ConstructProcess() |
---|
| 118 | // implementation in order to insures particle transportation. |
---|
| 119 | // !! Caution: this class must not be overriden !! |
---|
| 120 | void AddTransportation(); |
---|
| 121 | |
---|
| 122 | ///////////////////////////////////////////////////////////////// |
---|
| 123 | public: // with description |
---|
| 124 | // "SetCuts" method sets a cut value for all particle types |
---|
| 125 | // in the particle table |
---|
| 126 | virtual void SetCuts() = 0; |
---|
| 127 | |
---|
| 128 | public: // with description |
---|
| 129 | // set/get the default cut value |
---|
| 130 | // Calling SetDefaultCutValue causes re-calcuration of cut values |
---|
| 131 | // and physics tables just before the next event loop |
---|
| 132 | void SetDefaultCutValue(G4double newCutValue); |
---|
| 133 | G4double GetDefaultCutValue() const; |
---|
| 134 | |
---|
| 135 | ///////////////////////////////////////////////////////////////////// |
---|
| 136 | public: // with description |
---|
| 137 | // Invoke BuildPhysicsTable for all processes for all particles |
---|
| 138 | // In case of "Retrieve" flag is ON, PhysicsTable will be |
---|
| 139 | // retrieved from files |
---|
| 140 | void BuildPhysicsTable(); |
---|
| 141 | |
---|
| 142 | // do PreparePhysicsTable for specified particle type |
---|
| 143 | void PreparePhysicsTable(G4ParticleDefinition* ); |
---|
| 144 | |
---|
| 145 | // do BuildPhysicsTable for specified particle type |
---|
| 146 | void BuildPhysicsTable(G4ParticleDefinition* ); |
---|
| 147 | |
---|
| 148 | // Store PhysicsTable together with both material and cut value |
---|
| 149 | // information in files under the specified directory. |
---|
| 150 | // (return true if files are sucessfully created) |
---|
| 151 | G4bool StorePhysicsTable(const G4String& directory = "."); |
---|
| 152 | |
---|
| 153 | // Return true if "Retrieve" flag is ON. |
---|
| 154 | // (i.e. PhysicsTable will be retrieved from files) |
---|
| 155 | G4bool IsPhysicsTableRetrieved() const; |
---|
| 156 | G4bool IsStoredInAscii() const; |
---|
| 157 | |
---|
| 158 | // Get directory path for physics table files. |
---|
| 159 | const G4String& GetPhysicsTableDirectory() const; |
---|
| 160 | |
---|
| 161 | // Set "Retrieve" flag |
---|
| 162 | // Directory path can be set together. |
---|
| 163 | // Null string (default) means directory is not changed |
---|
| 164 | // from the current value |
---|
| 165 | void SetPhysicsTableRetrieved(const G4String& directory = ""); |
---|
| 166 | void SetStoredInAscii(); |
---|
| 167 | |
---|
| 168 | // Reset "Retrieve" flag |
---|
| 169 | void ResetPhysicsTableRetrieved(); |
---|
| 170 | void ResetStoredInAscii(); |
---|
| 171 | |
---|
| 172 | /////////////////////////////////////////////////////////////////////// |
---|
| 173 | public: // with description |
---|
| 174 | // Print out the List of registered particles types |
---|
| 175 | void DumpList() const; |
---|
| 176 | |
---|
| 177 | public: // with description |
---|
| 178 | // Request to print out information of cut values |
---|
| 179 | // Printing will be performed when all tables are made |
---|
| 180 | void DumpCutValuesTable(G4int nParticles=3); |
---|
| 181 | |
---|
| 182 | // The following method actually trigger the print-out requested |
---|
| 183 | // by the above method. This method must be invoked by RunManager |
---|
| 184 | // at the proper moment. |
---|
| 185 | void DumpCutValuesTableIfRequested(); |
---|
| 186 | |
---|
| 187 | void DumpCutValues(const G4String &particle_name = "ALL"); |
---|
| 188 | void DumpCutValues(G4ParticleDefinition* ); |
---|
| 189 | |
---|
| 190 | public: // with description |
---|
| 191 | void SetVerboseLevel(G4int value); |
---|
| 192 | G4int GetVerboseLevel() const; |
---|
| 193 | // set/get controle flag for output message |
---|
| 194 | // 0: Silent |
---|
| 195 | // 1: Warning message |
---|
| 196 | // 2: More |
---|
| 197 | |
---|
| 198 | /////////////////////////////////////////////////////////////////////////// |
---|
| 199 | public: // with description |
---|
| 200 | // "SetCutsWithDefault" method sets the default cut value |
---|
| 201 | // for all particles for the default region. |
---|
| 202 | void SetCutsWithDefault(); |
---|
| 203 | |
---|
| 204 | // Following are utility methods for SetCuts |
---|
| 205 | |
---|
| 206 | // SetCutValue sets a cut value for a particle type for the default region |
---|
| 207 | void SetCutValue(G4double aCut, const G4String& pname); |
---|
| 208 | |
---|
| 209 | // SetCutValue sets a cut value for a particle type for a region |
---|
| 210 | void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname); |
---|
| 211 | |
---|
| 212 | // Invoke SetCuts for specified particle for a region |
---|
| 213 | // If the pointer to the region is NULL, the default region is used |
---|
| 214 | // In case of "Retrieve" flag is ON, |
---|
| 215 | // Cut values will be retrieved from files |
---|
| 216 | void SetParticleCuts(G4double cut,G4ParticleDefinition* particle,G4Region* region=0); |
---|
| 217 | |
---|
| 218 | // Invoke SetCuts for all particles in a region |
---|
| 219 | void SetCutsForRegion(G4double aCut, const G4String& rname); |
---|
| 220 | |
---|
| 221 | // Following are utility methods are obsolete |
---|
| 222 | void ResetCuts(); |
---|
| 223 | |
---|
| 224 | /////////////////////////////////////////////////////////////////// |
---|
| 225 | public: |
---|
| 226 | // Get/SetApplyCuts gets/sets the flag for ApplyCuts |
---|
| 227 | void SetApplyCuts(G4bool value, const G4String& name); |
---|
| 228 | G4bool GetApplyCuts(const G4String& name) const; |
---|
| 229 | |
---|
| 230 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 231 | protected: |
---|
| 232 | // do BuildPhysicsTable for make the integral schema |
---|
| 233 | void BuildIntegralPhysicsTable(G4VProcess* ,G4ParticleDefinition* ); |
---|
| 234 | |
---|
| 235 | |
---|
| 236 | protected: |
---|
| 237 | // Retrieve PhysicsTable from files for proccess belongng the particle. |
---|
| 238 | // Normal BuildPhysics procedure of processes will be invoked, |
---|
| 239 | // if it fails (in case of Process's RetrievePhysicsTable returns false) |
---|
| 240 | virtual void RetrievePhysicsTable(G4ParticleDefinition* , |
---|
| 241 | const G4String& directory, |
---|
| 242 | G4bool ascii = false); |
---|
| 243 | |
---|
| 244 | ///////////////////////////////////////////////////////////////// |
---|
| 245 | protected: |
---|
| 246 | // adds new ProcessManager to all particles in the Particle Table |
---|
| 247 | // this routine is used in Construct() |
---|
| 248 | void InitializeProcessManager(); |
---|
| 249 | |
---|
| 250 | public: // with description |
---|
| 251 | // remove and delete ProcessManagers for all particles in tha Particle Table |
---|
| 252 | // this routine is invoked from RunManager |
---|
| 253 | void RemoveProcessManager(); |
---|
| 254 | |
---|
| 255 | public: // with description |
---|
| 256 | // add process manager for particles created on-the-fly |
---|
| 257 | void AddProcessManager(G4ParticleDefinition* newParticle, |
---|
| 258 | G4ProcessManager* newManager = 0 ); |
---|
| 259 | |
---|
| 260 | |
---|
| 261 | //////////////////////////////////////////////////////////////////////// |
---|
| 262 | protected: |
---|
| 263 | // the particle table has the complete List of existing particle types |
---|
| 264 | G4ParticleTable* theParticleTable; |
---|
| 265 | G4ParticleTable::G4PTblDicIterator* theParticleIterator; |
---|
| 266 | |
---|
| 267 | protected: |
---|
| 268 | // pointer to G4UserPhysicsListMessenger |
---|
| 269 | G4UserPhysicsListMessenger* theMessenger; |
---|
| 270 | |
---|
| 271 | protected: |
---|
| 272 | G4int verboseLevel; |
---|
| 273 | |
---|
| 274 | protected: |
---|
| 275 | // this is the default cut value for all particles |
---|
| 276 | G4double defaultCutValue; |
---|
| 277 | |
---|
| 278 | protected: |
---|
| 279 | // pointer to ProductionCutsTable |
---|
| 280 | G4ProductionCutsTable* fCutsTable; |
---|
| 281 | |
---|
| 282 | // flag to determine physics table will be build from file or not |
---|
| 283 | G4bool fRetrievePhysicsTable; |
---|
| 284 | G4bool fStoredInAscii; |
---|
| 285 | |
---|
| 286 | G4bool fIsCheckedForRetrievePhysicsTable; |
---|
| 287 | G4bool fIsRestoredCutValues; |
---|
| 288 | |
---|
| 289 | // directory name for physics table files |
---|
| 290 | G4String directoryPhysicsTable; |
---|
| 291 | |
---|
| 292 | // flag for displaying the range cuts & energy thresholds |
---|
| 293 | G4int fDisplayThreshold; |
---|
| 294 | |
---|
| 295 | private: |
---|
| 296 | enum { FixedStringLengthForStore = 32 }; |
---|
| 297 | |
---|
| 298 | |
---|
| 299 | private: |
---|
| 300 | G4bool useCoupledTransportation; |
---|
| 301 | |
---|
| 302 | public: |
---|
| 303 | inline void UseCoupledTransportation(G4bool vl=true) |
---|
| 304 | { useCoupledTransportation = vl; } |
---|
| 305 | |
---|
| 306 | //////////////////////////////////////////////////////////////////////////// |
---|
| 307 | // Following method is for backward compatibility and removed soon |
---|
| 308 | //////////////////////////////////////////////////////////////////////////// |
---|
| 309 | protected: |
---|
| 310 | void SetCutValueForOthers(G4double) const; |
---|
| 311 | |
---|
| 312 | }; |
---|
| 313 | |
---|
| 314 | inline |
---|
| 315 | void G4VUserPhysicsList::SetCutValueForOthers(G4double) const |
---|
| 316 | { |
---|
| 317 | G4cerr << "WARNING !" << G4endl; |
---|
| 318 | G4cerr << " SetCutValueForOthers became obsolete." << G4endl; |
---|
| 319 | G4cerr << " It is harmless to remove this invokation without any side effects." << G4endl; |
---|
| 320 | G4cerr << " This dummy method implementation will be removed soon." << G4endl; |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | inline void G4VUserPhysicsList::Construct() |
---|
| 324 | { |
---|
| 325 | #ifdef G4VERBOSE |
---|
| 326 | if (verboseLevel >1) G4cout << "G4VUserPhysicsList::Construct()" << G4endl; |
---|
| 327 | #endif |
---|
| 328 | |
---|
| 329 | InitializeProcessManager(); |
---|
| 330 | |
---|
| 331 | #ifdef G4VERBOSE |
---|
| 332 | if (verboseLevel >1) G4cout << "Construct processes " << G4endl; |
---|
| 333 | #endif |
---|
| 334 | ConstructProcess(); |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | inline G4double G4VUserPhysicsList::GetDefaultCutValue() const |
---|
| 338 | { |
---|
| 339 | return defaultCutValue; |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | |
---|
| 343 | inline G4int G4VUserPhysicsList::GetVerboseLevel() const |
---|
| 344 | { |
---|
| 345 | return verboseLevel; |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | inline |
---|
| 349 | G4bool G4VUserPhysicsList::IsPhysicsTableRetrieved() const |
---|
| 350 | { |
---|
| 351 | return fRetrievePhysicsTable; |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | inline |
---|
| 355 | G4bool G4VUserPhysicsList::IsStoredInAscii() const |
---|
| 356 | { |
---|
| 357 | return fStoredInAscii; |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | inline |
---|
| 361 | const G4String& G4VUserPhysicsList::GetPhysicsTableDirectory() const |
---|
| 362 | { |
---|
| 363 | return directoryPhysicsTable; |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | inline |
---|
| 367 | void G4VUserPhysicsList::SetStoredInAscii() |
---|
| 368 | { |
---|
| 369 | fStoredInAscii = true; |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | |
---|
| 373 | inline |
---|
| 374 | void G4VUserPhysicsList::ResetPhysicsTableRetrieved() |
---|
| 375 | { |
---|
| 376 | fRetrievePhysicsTable = false; |
---|
| 377 | fIsRestoredCutValues = false; |
---|
| 378 | fIsCheckedForRetrievePhysicsTable=false; |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | |
---|
| 382 | inline |
---|
| 383 | void G4VUserPhysicsList::ResetStoredInAscii() |
---|
| 384 | { |
---|
| 385 | fStoredInAscii = false; |
---|
| 386 | } |
---|
| 387 | #endif |
---|
| 388 | |
---|