Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 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 // 26 // G4VProcess 27 // 28 // Class description: 29 // 30 // This class is the virtual class for physics 31 // It defines public methods which describe th 32 // a physics process. 33 34 // Authors: 35 // - 2 December 1995, G.Cosmo - First implemen 36 // - 18 December 1996, H.Kurashige - New Physi 37 // ------------------------------------------- 38 #ifndef G4VProcess_hh 39 #define G4VProcess_hh 1 40 41 #include <cmath> 42 43 #include "globals.hh" 44 #include "G4ios.hh" 45 #include "Randomize.hh" 46 47 #include "G4PhysicsTable.hh" 48 #include "G4VParticleChange.hh" 49 #include "G4ForceCondition.hh" 50 #include "G4GPILSelection.hh" 51 #include "G4ParticleChange.hh" 52 #include "G4ProcessType.hh" 53 54 class G4ParticleDefinition; 55 class G4DynamicParticle; 56 class G4Track; 57 class G4Step; 58 class G4ProcessTable; 59 60 class G4VProcess 61 { 62 63 public: 64 65 G4VProcess(const G4String& aName = "NoName 66 G4ProcessType aType = fNotDefin 67 // Constructor requires the process name 68 69 G4VProcess(const G4VProcess& right); 70 // Copy constructor copies the name but 71 // physics table (null pointer is assign 72 73 virtual ~G4VProcess(); 74 // Destructor 75 76 G4VProcess& operator=(const G4VProcess&) = 77 78 G4bool operator==(const G4VProcess& right) 79 G4bool operator!=(const G4VProcess& right) 80 // Equality operators 81 82 //////////////////////////// 83 // DoIt ///////////////// 84 //////////////////////////// 85 86 virtual G4VParticleChange* PostStepDoIt( 87 const G4Track& tr 88 const G4Step& ste 89 ) = 0; 90 91 virtual G4VParticleChange* AlongStepDoIt( 92 const G4Track& tr 93 const G4Step& ste 94 ) = 0; 95 virtual G4VParticleChange* AtRestDoIt( 96 const G4Track& tr 97 const G4Step& ste 98 ) = 0; 99 // A virtual base class function that ha 100 // by any subclass. The DoIt() method ac 101 // physics process and determines either 102 // of the production of secondaries etc. 103 // Arguments 104 // const G4Track& track: 105 // reference to the current G4Tra 106 // const G4Step& stepData: 107 // reference to the current G4Ste 108 109 ////////////////////////// 110 // GPIL /////////////// 111 ////////////////////////// 112 113 virtual G4double AlongStepGetPhysicalInter 114 const G4Track& tr 115 G4double previous 116 G4double currentM 117 G4double& propose 118 G4GPILSelection* 119 120 virtual G4double AtRestGetPhysicalInteract 121 const G4Track& tr 122 G4ForceCondition* 123 124 virtual G4double PostStepGetPhysicalIntera 125 const G4Track& tr 126 G4double previous 127 G4ForceCondition* 128 // Returns the Step-size (actual length 129 // by "this" process. (for AtRestGetPhy 130 // return value is Step-time) The Numbe 131 // recalculated by using previousStepSi 132 // calucalted accoding to the resultant 133 // using NumberOfInteractionLengthLeft, 134 // arguments 135 // const G4Track& track: 136 // reference to the current G4Tra 137 // G4double* previousStepS 138 // the Step-size (actual length) 139 // of this track. Negative calue 140 // NumberOfInteractionLengthLeft 141 // the current physical interacti 142 // G4ForceCondition* condition: 143 // the flag indicates DoIt of thi 144 // to be called 145 // Forced: Corresponding DoIt 146 // NotForced: Corresponding DoIt 147 // if the Step size o 148 // by this process 149 // !! AlongStepDoIt is always cal 150 // G4double& currentMinimumStep: 151 // this value is used for transfo 152 // true path length to geometrica 153 154 inline G4double GetCurrentInteractionLengt 155 // Returns currentInteractionLength 156 157 ////////// PIL factor //////// 158 // 159 inline void SetPILfactor(G4double value); 160 inline G4double GetPILfactor() const; 161 // Set/Get factor for PhysicsInteraction 162 // which is passed to G4SteppingManager 163 164 // These three GPIL methods are used by St 165 // They invoke virtual GPIL methods listed 166 // As for AtRest and PostStep the returned 167 // thePILfactor 168 // 169 inline G4double AlongStepGPIL( const G4Tra 170 G4double pr 171 G4double cu 172 G4double& p 173 G4GPILSelec 174 175 inline G4double AtRestGPIL( const G4Track& 176 G4ForceConditi 177 178 inline G4double PostStepGPIL( const G4Trac 179 G4double pre 180 G4ForceCondi 181 182 virtual G4bool IsApplicable(const G4Partic 183 // Returns true if this process object i 184 // the particle type. Process will not b 185 // particle if IsApplicable is false 186 187 virtual void BuildPhysicsTable(const G4Par 188 // Messaged by the Particle definition ( 189 // whenever cross-section tables have to 190 // materials have been defined). 191 // It is overloaded by individual proces 192 // tables 193 194 virtual void PreparePhysicsTable(const G4P 195 // Messaged by the Particle definition ( 196 // whenever cross-section tables have to 197 // (i.e. if new materials have been defi 198 // It is overloaded by individual proces 199 // tables 200 201 // Processes which Build physics tables in 202 // (for example in their constructors) sho 203 // void BuildThePhysicsTable() and void Pr 204 // *Not* another BuildPhysicsTable 205 206 virtual G4bool StorePhysicsTable(const G4P 207 const G4S 208 // Store PhysicsTable in a file. 209 // Return false in case of failure at I/ 210 211 virtual G4bool RetrievePhysicsTable(const 212 const G4 213 // Retrieve Physics from a file. 214 // Return true if the Physics Table can 215 // Return false if the process has no fu 216 // of failure. File name should be defin 217 // file should be placed under the direc 218 219 const G4String& GetPhysicsTableFileName(co 220 co 221 co 222 G4 223 // This method is utility for Store/Retr 224 225 inline const G4String& GetProcessName() co 226 // Returns the name of the process 227 228 inline G4ProcessType GetProcessType() cons 229 // Returns the process type 230 231 inline void SetProcessType(G4ProcessType); 232 // Sets the process type 233 234 inline G4int GetProcessSubType() const; 235 // Returns the process sub type 236 237 inline void SetProcessSubType(G4int); 238 // Sets the process sub type 239 240 static const G4String& GetProcessTypeName( 241 // Returns the process type name 242 243 virtual const G4VProcess* GetCreatorProces 244 // Returns the process to be used as Cre 245 // coming from this process 246 247 virtual void StartTracking(G4Track*); 248 virtual void EndTracking(); 249 // Inform Start/End of tracking for each 250 251 virtual void SetProcessManager(const G4Pro 252 // A process manager sets its own pointe 253 // is registered in the process Manager 254 virtual const G4ProcessManager* GetProcess 255 // Get the process manager which the pro 256 257 virtual void ResetNumberOfInteractionLengt 258 // Reset (determine the value of) Number 259 260 inline G4double GetNumberOfInteractionLeng 261 // Get NumberOfInteractionLengthLeft 262 263 inline G4double GetTotalNumberOfInteractio 264 // Get NumberOfInteractionLength after 265 // ResetNumberOfInteractionLengthLeft() 266 267 inline G4bool isAtRestDoItIsEnabled() cons 268 inline G4bool isAlongStepDoItIsEnabled() c 269 inline G4bool isPostStepDoItIsEnabled() co 270 // These methods indicate which DoIt is 271 // They are used by G4ProcessManager to 272 // that ordering parameters are properly 273 274 virtual void DumpInfo() const; 275 // Dump out process information 276 277 virtual void ProcessDescription(std::ostre 278 // Write out to html file for automatic 279 280 inline void SetVerboseLevel(G4int value); 281 inline G4int GetVerboseLevel() const; 282 // set/get control flag for output messa 283 // 0: Silent 284 // 1: Warning message 285 // 2: More 286 287 virtual void SetMasterProcess(G4VProcess* 288 // Sets the master thread process instan 289 inline const G4VProcess* GetMasterProcess( 290 // Returns the master thread process ins 291 // Can be used to initialise worker type 292 // instances from master one (e.g. to sh 293 // if ( this != GetMasterProcess() ) { / 294 // else { /* master or sequential */ } 295 296 virtual void BuildWorkerPhysicsTable(const 297 // Messaged by the Particle definition ( 298 // in worker threads. See BuildWorkerPhy 299 // Can be used to share among threads ph 300 // Use GetMasterProcess() to get pointer 301 // worker thread. 302 // By default this method makes a forwar 303 304 virtual void PrepareWorkerPhysicsTable(con 305 // Messaged by the Particle definition ( 306 // in worker threads. See Preparephysics 307 // Can be used to share among threads ph 308 // Use GetMasterProcess() to get pointer 309 // worker thread 310 // By default this method makes a forwar 311 312 protected: 313 314 inline void SubtractNumberOfInteractionLen 315 // Subtract NumberOfInteractionLengthLef 316 // to previousStepSize 317 318 inline void ClearNumberOfInteractionLength 319 // This method should be at the end of P 320 321 protected: 322 323 const G4ProcessManager* aProcessManager = 324 325 G4VParticleChange* pParticleChange = nullp 326 // The pointer to G4VParticleChange obje 327 // which is modified and returned by add 328 // This pointer should be set in each ph 329 // after construction of derived class o 330 331 G4ParticleChange aParticleChange; 332 // This object is kept for compatibility 333 // May be removed in future 334 335 G4double theNumberOfInteractionLengthLeft 336 // The flight length left for the curren 337 // in unit of "Interaction length" 338 339 G4double currentInteractionLength = -1.0; 340 // The InteractionLength in the current 341 342 G4double theInitialNumberOfInteractionLeng 343 // The initial value when ResetNumberOfI 344 345 G4String theProcessName; 346 // The name of the process 347 348 G4String thePhysicsTableFileName; 349 350 G4ProcessType theProcessType = fNotDefined 351 // The type of the process 352 353 G4int theProcessSubType = -1; 354 // The sub type of the process 355 356 G4double thePILfactor = 1.0; 357 // Factor for PhysicsInteractionLength 358 // which is passed to G4SteppingManager 359 360 G4int verboseLevel = 0; 361 // Controle flag for output message 362 363 G4bool enableAtRestDoIt = true; 364 G4bool enableAlongStepDoIt = true; 365 G4bool enablePostStepDoIt = true; 366 367 private: 368 369 G4VProcess(); 370 // Hidden default constructor 371 372 private: 373 374 G4VProcess* masterProcessShadow = nullptr; 375 // For multi-threaded: pointer to the in 376 // for the master thread 377 378 G4ProcessTable* fProcessTable = nullptr; 379 }; 380 381 // ----------------------------------------- 382 // inlined function members implementation 383 // ----------------------------------------- 384 385 inline 386 const G4String& G4VProcess::GetProcessName() c 387 { 388 return theProcessName; 389 } 390 391 inline 392 G4ProcessType G4VProcess::GetProcessType() con 393 { 394 return theProcessType; 395 } 396 397 inline 398 void G4VProcess::SetProcessType(G4ProcessType 399 { 400 theProcessType = aType; 401 } 402 403 inline 404 G4int G4VProcess::GetProcessSubType() const 405 { 406 return theProcessSubType; 407 } 408 409 inline 410 void G4VProcess::SetProcessSubType(G4int value 411 { 412 theProcessSubType = value; 413 } 414 415 inline 416 void G4VProcess::SetVerboseLevel(G4int value) 417 { 418 verboseLevel = value; 419 } 420 421 inline 422 G4int G4VProcess::GetVerboseLevel() const 423 { 424 return verboseLevel; 425 } 426 427 inline 428 void G4VProcess::ClearNumberOfInteractionLengt 429 { 430 theInitialNumberOfInteractionLength = -1.0; 431 theNumberOfInteractionLengthLeft = -1.0; 432 } 433 434 inline 435 G4double G4VProcess::GetNumberOfInteractionLen 436 { 437 return theNumberOfInteractionLengthLeft; 438 } 439 440 inline 441 G4double G4VProcess::GetTotalNumberOfInteracti 442 { 443 return theInitialNumberOfInteractionLength - 444 } 445 446 inline 447 G4double G4VProcess::GetCurrentInteractionLeng 448 { 449 return currentInteractionLength; 450 } 451 452 inline 453 void G4VProcess::SetPILfactor(G4double value) 454 { 455 if (value>0.) { thePILfactor = value; } 456 } 457 458 inline 459 G4double G4VProcess::GetPILfactor() const 460 { 461 return thePILfactor; 462 } 463 464 inline 465 G4double G4VProcess::AlongStepGPIL( const G4Tr 466 G4double 467 G4double 468 G4double& 469 G4GPILSele 470 { 471 return AlongStepGetPhysicalInteractionLength 472 currentMinimumSte 473 } 474 475 inline 476 G4double G4VProcess::AtRestGPIL( const G4Track 477 G4ForceCondit 478 { 479 return thePILfactor * AtRestGetPhysicalInter 480 } 481 482 inline 483 G4double G4VProcess::PostStepGPIL( const G4Tra 484 G4double pr 485 G4ForceCond 486 { 487 return thePILfactor * 488 PostStepGetPhysicalInteractionLength(tra 489 } 490 491 inline 492 void G4VProcess::SetProcessManager(const G4Pro 493 { 494 aProcessManager = procMan; 495 } 496 497 inline 498 const G4ProcessManager* G4VProcess::GetProcess 499 { 500 return aProcessManager; 501 } 502 503 inline 504 G4bool G4VProcess::isAtRestDoItIsEnabled() con 505 { 506 return enableAtRestDoIt; 507 } 508 509 inline 510 G4bool G4VProcess::isAlongStepDoItIsEnabled() 511 { 512 return enableAlongStepDoIt; 513 } 514 515 inline 516 G4bool G4VProcess::isPostStepDoItIsEnabled() c 517 { 518 return enablePostStepDoIt; 519 } 520 521 inline 522 const G4VProcess* G4VProcess::GetMasterProcess 523 { 524 return masterProcessShadow; 525 } 526 527 inline 528 void G4VProcess::SubtractNumberOfInteractionLe 529 { 530 if (currentInteractionLength>0.0) 531 { 532 theNumberOfInteractionLengthLeft -= prevSt 533 if(theNumberOfInteractionLengthLeft<0.) 534 { 535 theNumberOfInteractionLengthLeft=CLHEP: 536 } 537 } 538 else 539 { 540 #ifdef G4VERBOSE 541 if (verboseLevel>0) 542 { 543 G4cerr << "G4VProcess::SubtractNumberOfI 544 G4cerr << " [" << theProcessName << "]" 545 G4cerr << " currentInteractionLength = " 546 << currentInteractionLength << " 547 G4cerr << " previousStepSize = " << prev 548 G4cerr << G4endl; 549 } 550 #endif 551 G4String msg = "Negative currentInteractio 552 msg += theProcessName; 553 G4Exception("G4VProcess::SubtractNumberOfI 554 "ProcMan201", EventMustBeAbort 555 } 556 } 557 558 #endif 559