Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // Author: Mathieu Karamitros (kara (AT) cenbg 27 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 28 // 28 // 29 // History: 29 // History: 30 // ----------- 30 // ----------- 31 // 10 Oct 2011 M.Karamitros created 31 // 10 Oct 2011 M.Karamitros created 32 // 32 // 33 // ------------------------------------------- 33 // ------------------------------------------------------------------- 34 34 35 #include "G4ITStepProcessor.hh" 35 #include "G4ITStepProcessor.hh" 36 #include "G4LossTableManager.hh" 36 #include "G4LossTableManager.hh" 37 #include "G4EnergyLossTables.hh" 37 #include "G4EnergyLossTables.hh" 38 #include "G4ProductionCuts.hh" 38 #include "G4ProductionCuts.hh" 39 #include "G4ProductionCutsTable.hh" 39 #include "G4ProductionCutsTable.hh" 40 #include "G4VITProcess.hh" 40 #include "G4VITProcess.hh" 41 #include "G4TrackingInformation.hh" 41 #include "G4TrackingInformation.hh" 42 #include "G4IT.hh" << 43 #include "G4ITTrackingManager.hh" << 44 #include "G4ITTransportation.hh" << 45 42 46 #include "G4ITNavigator.hh" // Inc << 47 << 48 #include "G4ITSteppingVerbose.hh" << 49 #include "G4VITSteppingVerbose.hh" << 50 << 51 #include "G4ITTrackHolder.hh" << 52 #include "G4ITReaction.hh" << 53 << 54 << 55 //#define DEBUG_MEM 1 << 56 << 57 #ifdef DEBUG_MEM << 58 #include "G4MemStat.hh" << 59 using namespace G4MemStat; << 60 using G4MemStat::MemStat; << 61 #endif << 62 43 63 void G4ITStepProcessor::DealWithSecondaries(G4 44 void G4ITStepProcessor::DealWithSecondaries(G4int& counter) 64 { 45 { 65 // Now Store the secondaries from ParticleCh << 46 // Now Store the secondaries from ParticleChange to SecondaryList 66 G4Track* tempSecondaryTrack; << 47 G4Track* tempSecondaryTrack; 67 << 68 for(G4int DSecLoop = 0; DSecLoop < fpParticl << 69 DSecLoop++) << 70 { << 71 tempSecondaryTrack = fpParticleChange->Get << 72 << 73 if(tempSecondaryTrack->GetDefinition()->Ge << 74 { << 75 ApplyProductionCut(tempSecondaryTrack); << 76 } << 77 << 78 // Set parentID << 79 tempSecondaryTrack->SetParentID(fpTrack->G << 80 << 81 // Set the process pointer which created t << 82 tempSecondaryTrack->SetCreatorProcess(fpCu << 83 48 84 // If this 2ndry particle has 'zero' kinet << 49 for(G4int DSecLoop=0 ; 85 // it invokes a rest process at the beginn << 50 DSecLoop<fpParticleChange->GetNumberOfSecondaries() ; 86 if(tempSecondaryTrack->GetKineticEnergy() << 51 DSecLoop++) 87 { 52 { 88 G4ProcessManager* pm = tempSecondaryTrac << 53 tempSecondaryTrack = fpParticleChange->GetSecondary(DSecLoop); 89 if (pm->GetAtRestProcessVector()->entrie << 90 { << 91 tempSecondaryTrack->SetTrackStatus( fS << 92 fpSecondary->push_back( tempSecondaryT << 93 fN2ndariesAtRestDoIt++; << 94 } << 95 else << 96 { << 97 delete tempSecondaryTrack; << 98 } << 99 } << 100 else << 101 { << 102 fpSecondary->push_back( tempSecondaryTra << 103 counter++; << 104 } << 105 } //end of loop on secondary << 106 } << 107 54 108 //____________________________________________ << 55 if(tempSecondaryTrack->GetDefinition()->GetApplyCutsFlag()) >> 56 { >> 57 ApplyProductionCut(tempSecondaryTrack); >> 58 } 109 59 110 void G4ITStepProcessor::DoIt(double timeStep) << 60 // Set parentID >> 61 tempSecondaryTrack->SetParentID( fpTrack->GetTrackID() ); 111 62 112 // Call the process having the min step length << 63 // Set the process pointer which created this track >> 64 tempSecondaryTrack->SetCreatorProcess( fpCurrentProcess ); 113 65 114 // If the track is "leading the step" (ie one << 66 // If this 2ndry particle has 'zero' kinetic energy, make sure 115 // as the one having the minimum time step ove << 67 // it invokes a rest process at the beginning of the tracking 116 // it will undergo its selected processes. Oth << 68 if(tempSecondaryTrack->GetKineticEnergy() <= DBL_MIN) 117 // on the given time step. << 69 { >> 70 G4ProcessManager* pm = tempSecondaryTrack->GetDefinition()->GetProcessManager(); >> 71 if (pm->GetAtRestProcessVector()->entries()>0){ >> 72 tempSecondaryTrack->SetTrackStatus( fStopButAlive ); >> 73 fpSecondary->push_back( tempSecondaryTrack ); >> 74 fN2ndariesAtRestDoIt++; >> 75 } else { >> 76 delete tempSecondaryTrack; >> 77 } >> 78 } >> 79 else >> 80 { >> 81 fpSecondary->push_back( tempSecondaryTrack ); >> 82 counter++; >> 83 } >> 84 } //end of loop on secondary >> 85 } 118 86 >> 87 ////////////////////////////////////////////////////// >> 88 void G4ITStepProcessor::InvokeAtRestDoItProcs() >> 89 ////////////////////////////////////////////////////// 119 { 90 { 120 if(fpVerbose != nullptr) fpVerbose->DoItStar << 91 fpStep->SetStepLength( 0. ); //the particle has stopped 121 << 92 fpTrack->SetStepLength( 0. ); 122 G4TrackManyList* mainList = fpTrackContainer << 123 G4TrackManyList::iterator it = mainList->end << 124 it--; << 125 std::size_t initialSize = mainList->size(); << 126 << 127 // G4cout << "initialSize = " << initialSiz << 128 << 129 for(std::size_t i = 0 ; i < initialSize ; ++ << 130 { << 131 << 132 // G4cout << "i = " << i << G4endl; << 133 << 134 G4Track* track = *it; << 135 if (track == nullptr) << 136 { << 137 G4ExceptionDescription exceptionDescript << 138 exceptionDescription << "No track was po << 139 G4Exception("G4ITStepProcessor::DoIt", " << 140 FatalException, exceptionDes << 141 } << 142 // G4TrackManyList::iterator next_it (it); << 143 // next_it--; << 144 // it = next_it; << 145 << 146 it--; << 147 // Must be called before EndTracking(track << 148 // Otherwise the iterator will point to th << 149 93 150 if(track->GetTrackStatus() == fStopAndKill << 94 // invoke selected process >> 95 for(size_t np=0; np < MAXofAtRestLoops; np++) 151 { 96 { 152 fpTrackingManager->EndTracking(track); << 97 // 153 // G4cout << GetIT(track)->GetName() << G << 98 // Note: DoItVector has inverse order against GetPhysIntVector 154 // G4cout << " ************************ C << 99 // and SelectedAtRestDoItVector. 155 continue; << 100 // 156 } << 101 if( (*fpSelectedAtRestDoItVector)[MAXofAtRestLoops-np-1] != InActivated) 157 << 158 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_ << 159 MemStat mem_first, mem_second, mem_diff; << 160 mem_first = MemoryUsage(); << 161 #endif << 162 << 163 Stepping(track, timeStep); << 164 << 165 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_ << 166 MemStat mem_intermediaire = MemoryUsage(); << 167 mem_diff = mem_intermediaire-mem_first; << 168 G4cout << "\t\t >> || MEM || In DoIT with << 169 << track->GetTrackID() << ", diff is : << 170 #endif << 171 << 172 ExtractDoItData(); << 173 << 174 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_ << 175 mem_second = MemoryUsage(); << 176 mem_diff = mem_second-mem_first; << 177 G4cout << "\t >> || MEM || In DoIT with tr << 178 << track->GetTrackID() << 179 << ", diff is : " << mem_diff << G4end << 180 #endif << 181 } << 182 << 183 << 184 fpTrackContainer->MergeSecondariesWithMainLi << 185 fpTrackContainer->KillTracks(); // (18-06-15 << 186 fLeadingTracks.Reset(); << 187 } << 188 << 189 //____________________________________________ << 190 << 191 void G4ITStepProcessor::ExtractDoItData() << 192 { << 193 if (fpTrack == nullptr) << 194 { << 195 CleanProcessor(); << 196 return; << 197 } << 198 << 199 G4TrackStatus status = fpTrack->GetTrackStat << 200 << 201 switch (status) << 202 { << 203 case fAlive: << 204 case fStopButAlive: << 205 case fSuspend: << 206 case fPostponeToNextEvent: << 207 default: << 208 PushSecondaries(); << 209 break; << 210 << 211 case fStopAndKill: << 212 G4ITReactionSet::Instance()->RemoveReact << 213 PushSecondaries(); << 214 // G4TrackList::Pop(fpTrack); << 215 fpTrackingManager->EndTracking(fpTrack); << 216 // fTrackContainer->PushToKill(fpTrack); << 217 break; << 218 << 219 case fKillTrackAndSecondaries: << 220 G4ITReactionSet::Instance()->RemoveReact << 221 if (fpSecondary != nullptr) << 222 { << 223 for (auto & i : *fpSecondary) << 224 { 102 { 225 delete i; << 103 fpCurrentProcess = (G4VITProcess*) (*fpAtRestDoItVector)[np]; 226 } << 227 fpSecondary->clear(); << 228 } << 229 // G4TrackList::Pop(fpTrack); << 230 fpTrackingManager->EndTracking(fpTrack); << 231 // fTrackContainer->PushToKill(fpTrack); << 232 break; << 233 } << 234 104 235 CleanProcessor(); << 105 fpCurrentProcess->SetProcessState( 236 } << 106 fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID())); >> 107 fpParticleChange >> 108 = fpCurrentProcess->AtRestDoIt( *fpTrack, *fpStep); >> 109 fpCurrentProcess->SetProcessState(0); 237 110 238 //____________________________________________ << 111 // Set the current process as a process which defined this Step length >> 112 fpStep->GetPostStepPoint() >> 113 ->SetProcessDefinedStep(fpCurrentProcess); 239 114 240 void G4ITStepProcessor::PushSecondaries() << 115 // Update Step 241 { << 116 fpParticleChange->UpdateStepForAtRest(fpStep); 242 if ((fpSecondary == nullptr) || fpSecondary- << 243 { << 244 // DEBUG << 245 // G4cout << "NO SECONDARIES !!! " << << 246 return; << 247 } << 248 << 249 // DEBUG << 250 // G4cout << "There are secondaries : "<< << 251 << 252 auto secondaries_i = fpSecondary->begin(); << 253 << 254 for (; secondaries_i != fpSecondary->end(); << 255 { << 256 G4Track* secondary = *secondaries_i; << 257 fpTrackContainer->_PushTrack(secondary); << 258 } << 259 } << 260 117 261 //____________________________________________ << 118 // Now Store the secondaries from ParticleChange to SecondaryList >> 119 DealWithSecondaries(fN2ndariesAtRestDoIt) ; 262 120 263 void G4ITStepProcessor::Stepping(G4Track* trac << 121 // clear ParticleChange 264 { << 122 fpParticleChange->Clear(); 265 123 266 #ifdef DEBUG_MEM << 124 } //if(fSelectedAtRestDoItVector[np] != InActivated){ 267 MemStat mem_first, mem_second, mem_diff; << 125 } //for(size_t np=0; np < MAXofAtRestLoops; np++){ 268 #endif << 126 fpStep->UpdateTrack(); 269 << 127 270 #ifdef DEBUG_MEM << 128 fpTrack->SetTrackStatus( fStopAndKill ); 271 mem_first = MemoryUsage(); << 272 #endif << 273 << 274 CleanProcessor(); << 275 << 276 #ifdef DEBUG_MEM << 277 MemStat mem_intermediaire = MemoryUsage(); << 278 mem_diff = mem_intermediaire-mem_first; << 279 G4cout << "\t\t\t >> || MEM || After CleanPr << 280 #endif << 281 << 282 if(track == nullptr) return; // maybe put an << 283 fTimeStep = timeStep; << 284 SetTrack(track); << 285 DoStepping(); << 286 } 129 } 287 //____________________________________________ 130 //______________________________________________________________________________ 288 131 289 // ******************************************* << 132 void G4ITStepProcessor::InvokeAlongStepDoItProcs() 290 // Stepping << 291 // ******************************************* << 292 void G4ITStepProcessor::DoStepping() << 293 { 133 { 294 SetupMembers(); << 295 << 296 #ifdef DEBUG_MEM << 297 MemStat mem_first, mem_second, mem_diff; << 298 #endif << 299 << 300 #ifdef DEBUG_MEM << 301 mem_first = MemoryUsage(); << 302 #endif << 303 << 304 #ifdef G4VERBOSE << 305 if(fpVerbose != nullptr) fpVerbose->PreSte << 306 #endif << 307 << 308 if(fpProcessInfo == nullptr) << 309 { << 310 G4ExceptionDescription exceptionDescriptio << 311 exceptionDescription << "No process info f << 312 << fpTrack->GetDefini << 313 G4Exception("G4ITStepProcessor::DoStepping << 314 "ITStepProcessor0012", << 315 FatalErrorInArgument, << 316 exceptionDescription); << 317 return; << 318 } << 319 // else if(fpTrack->GetTrackStatus() == fStop << 320 // { << 321 // fpState->fStepStatus = fUndefined; << 322 // return; << 323 // } << 324 << 325 if(fpProcessInfo->MAXofPostStepLoops == 0 && << 326 fpProcessInfo->MAXofAlongStepLoops == 0 << 327 && fpProcessInfo->MAXofAtRestLoops == 0) << 328 {/* << 329 G4ExceptionDescription exceptionDescriptio << 330 exceptionDescription << "No process was fo << 331 << fpTrack->GetDefini << 332 G4Exception("G4ITStepProcessor::DoStepping << 333 "ITStepProcessorNoProcess", << 334 JustWarning, << 335 exceptionDescription); << 336 << 337 fpTrack->SetTrackStatus(fStopAndKill); << 338 fpState->fStepStatus = fUndefined;*/ << 339 return; << 340 } << 341 << 342 //-------- << 343 // Prelude << 344 //-------- << 345 #ifdef G4VERBOSE << 346 // !!!!! Verbose << 347 if(fpVerbose != nullptr) fpVerbose->NewStep( << 348 #endif << 349 << 350 //--------------------------------- << 351 // AtRestStep, AlongStep and PostStep Proces << 352 //--------------------------------- << 353 << 354 fpNavigator->SetNavigatorState(fpITrack->Get << 355 // fpNavigator->ResetHierarchyAndLocate << 356 // << 357 // << 358 // fpNavigator->SetNavigatorState(fpITr << 359 // We reset the navigator state before check << 360 // in case a AtRest processe would use a nav << 361 << 362 #ifdef DEBUG_MEM << 363 MemStat mem_intermediaire = MemoryUsage(); << 364 mem_diff = mem_intermediaire-mem_first; << 365 G4cout << "\t\t\t >> || MEM || G4ITStepProce << 366 #endif << 367 << 368 if(fpTrack->GetTrackStatus() == fStopButAliv << 369 { << 370 if(fpProcessInfo->MAXofAtRestLoops > 0 && << 371 != nullptr) // second condition to mak << 372 { << 373 //----------------- << 374 // AtRestStepDoIt << 375 //----------------- << 376 InvokeAtRestDoItProcs(); << 377 fpState->fStepStatus = fAtRestDoItProc; << 378 fpStep->GetPostStepPoint()->SetStepStatu << 379 << 380 #ifdef G4VERBOSE << 381 // !!!!! Verbose << 382 if(fpVerbose != nullptr) fpVerbose->AtRe << 383 #endif << 384 134 385 } << 135 // If the current Step is defined by a 'ExclusivelyForced' 386 // Make sure the track is killed << 136 // PostStepDoIt, then don't invoke any AlongStepDoIt 387 // fpTrack->SetTrackStatus(fStopAndKill); << 137 if(*fpStepStatus == fExclusivelyForcedProc) 388 } << 389 else // if(fTimeStep > 0.) // Bye, because P << 390 { << 391 if(fpITrack == nullptr) << 392 { 138 { 393 G4ExceptionDescription exceptionDescript << 139 return; // Take note 'return' at here !!! 394 exceptionDescription << " !!! TrackID : << 395 << G4endl<< " !!! T << 396 << " !!! Particle Name : "<< fpTrack -> << 397 << "No G4ITStepProcessor::fpITrack found << 398 << 399 G4Exception("G4ITStepProcessor::DoSteppi << 400 "ITStepProcessor0013", << 401 FatalErrorInArgument, << 402 exceptionDescription); << 403 return; // to make coverity happy << 404 } 140 } 405 141 406 if(!fpITrack->GetTrackingInfo()->IsLeading << 142 // Invoke the all active continuous processes >> 143 for( size_t ci=0 ; ci<MAXofAlongStepLoops ; ci++ ) 407 { 144 { 408 // In case the track has NOT the minimum << 145 fpCurrentProcess = (G4VITProcess*) (*fpAlongStepDoItVector)[ci]; 409 // Given the final step time, the transp << 146 if (fpCurrentProcess== 0) continue; 410 // will compute the final position of th << 147 // NULL means the process is inactivated by a user on fly. 411 fpState->fStepStatus = fPostStepDoItProc << 412 fpStep->GetPostStepPoint()->SetProcessDe << 413 FindTransportationStep(); << 414 } << 415 << 416 #ifdef DEBUG_MEM << 417 mem_intermediaire = MemoryUsage(); << 418 mem_diff = mem_intermediaire-mem_first; << 419 G4cout << "\t\t\t >> || MEM || G4ITStepPro << 420 #endif << 421 << 422 // Store the Step length (geometrical leng << 423 fpTrack->SetStepLength(fpState->fPhysicalS << 424 fpStep->SetStepLength(fpState->fPhysicalSt << 425 << 426 G4double GeomStepLength = fpState->fPhysic << 427 << 428 // Store StepStatus to PostStepPoint << 429 fpStep->GetPostStepPoint()->SetStepStatus( << 430 << 431 // Invoke AlongStepDoIt << 432 InvokeAlongStepDoItProcs(); << 433 148 434 #ifdef DEBUG_MEM << 149 fpCurrentProcess->SetProcessState(fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID())); 435 mem_intermediaire = MemoryUsage(); << 150 fpParticleChange 436 mem_diff = mem_intermediaire-mem_first; << 151 = fpCurrentProcess->AlongStepDoIt( *fpTrack, *fpStep ); 437 G4cout << "\t\t\t >> || MEM || G4ITStepPro << 152 fpCurrentProcess->SetProcessState(0); 438 #endif << 153 // Update the PostStepPoint of Step according to ParticleChange >> 154 fpParticleChange->UpdateStepForAlongStep(fpStep); 439 155 440 #ifdef G4VERBOSE << 156 // Now Store the secondaries from ParticleChange to SecondaryList 441 // !!!!! Verbose << 157 DealWithSecondaries(fN2ndariesAlongStepDoIt) ; 442 if(fpVerbose != nullptr) fpVerbose->AlongS << 443 #endif << 444 158 445 // Update track by taking into account all << 159 // Set the track status according to what the process defined 446 // fpStep->UpdateTrack(); // done in Invok << 160 // if kinetic energy >0, otherwise set fStopButAlive >> 161 fpTrack->SetTrackStatus( fpParticleChange->GetTrackStatus() ); 447 162 448 // Update safety after invocation of all A << 163 // clear ParticleChange 449 fpState->fEndpointSafOrigin = fpPostStepPo << 164 fpParticleChange->Clear(); 450 << 451 fpState->fEndpointSafety = << 452 std::max(fpState->fProposedSafety - Ge << 453 << 454 fpStep->GetPostStepPoint()->SetSafety(fpSt << 455 << 456 if(GetIT(fpTrack)->GetTrackingInfo()->IsLe << 457 { << 458 // Invoke PostStepDoIt including G4ITTra << 459 InvokePostStepDoItProcs(); << 460 << 461 #ifdef DEBUG_MEM << 462 mem_intermediaire = MemoryUsage(); << 463 mem_diff = mem_intermediaire-mem_first; << 464 G4cout << "\t\t\t >> || MEM || G4ITStepP << 465 #endif << 466 #ifdef G4VERBOSE << 467 // !!!!! Verbose << 468 if(fpVerbose != nullptr) fpVerbose->StepIn << 469 #endif << 470 } << 471 else << 472 { << 473 // Only invoke transportation and all ot << 474 InvokeTransportationProc(); << 475 fpStep->GetPostStepPoint()->SetProcessDe << 476 << 477 #ifdef DEBUG_MEM << 478 mem_intermediaire = MemoryUsage(); << 479 mem_diff = mem_intermediaire-mem_first; << 480 G4cout << "\t\t\t >> || MEM || G4ITStepP << 481 #endif << 482 } 165 } 483 166 484 #ifdef G4VERBOSE << 167 fpStep->UpdateTrack(); 485 // !!!!! Verbose << 168 G4TrackStatus fNewStatus = fpTrack->GetTrackStatus(); 486 if(fpVerbose != nullptr) fpVerbose->PostSt << 487 #endif << 488 } << 489 << 490 fpNavigator->ResetNavigatorState(); << 491 << 492 #ifdef DEBUG_MEM << 493 mem_intermediaire = MemoryUsage(); << 494 mem_diff = mem_intermediaire-mem_first; << 495 G4cout << "\t\t\t >> || MEM || G4ITStepProce << 496 #endif << 497 << 498 //------- << 499 // Finale << 500 //------- << 501 << 502 // Update 'TrackLength' and remeber the Step << 503 fpTrack->AddTrackLength(fpStep->GetStepLengt << 504 fpTrack->IncrementCurrentStepNumber(); << 505 << 506 //#ifdef G4VERBOSE << 507 // // !!!!! Verbose << 508 // if(fpVerbose) fpVerbose->StepInfo(); << 509 //#endif << 510 << 511 #ifdef G4VERBOSE << 512 if(fpVerbose != nullptr) fpVerbose->PostSt << 513 #endif << 514 << 515 // G4cout << " G4ITStepProcessor::DoSteppin << 516 << 517 // Send G4Step information to Hit/Dig if the << 518 /*** << 519 fpCurrentVolume = fpStep->GetPreStepPoint() << 520 StepControlFlag = fpStep->GetControlFlag() << 521 << 522 if( fpCurrentVolume != 0 && StepControlFlag << 523 { << 524 fpSensitive = fpStep->GetPreStepPoint()-> << 525 GetSensitiveDetector(); << 526 if( fpSensitive != 0 ) << 527 { << 528 fpSensitive->Hit(fpStep); << 529 } << 530 } << 531 << 532 User intervention process. << 533 if( fpUserSteppingAction != 0 ) << 534 { << 535 fpUserSteppingAction->UserSteppingAction(fp << 536 } << 537 G4UserSteppingAction* regionalAction << 538 = fpStep->GetPreStepPoint()->GetPhysicalVol << 539 ->GetRegionalSteppingAction(); << 540 if( regionalAction ) regionalAction->UserSt << 541 ***/ << 542 fpTrackingManager->AppendStep(fpTrack, fpSte << 543 // Stepping process finish. Return the value << 544 << 545 #ifdef DEBUG_MEM << 546 MemStat mem_intermediaire = MemoryUsage(); << 547 mem_diff = mem_intermediaire-mem_first; << 548 G4cout << "\t\t\t >> || MEM || End of DoStep << 549 #endif << 550 169 551 // return fpState->fStepStatus; << 170 if ( fNewStatus == fAlive && fpTrack->GetKineticEnergy() <= DBL_MIN ) 552 } << 553 << 554 //____________________________________________ << 555 << 556 // ******************************************* << 557 // AtRestDoIt << 558 // ******************************************* << 559 << 560 void G4ITStepProcessor::InvokeAtRestDoItProcs( << 561 { << 562 fpStep->SetStepLength(0.); //the particle h << 563 fpTrack->SetStepLength(0.); << 564 << 565 G4SelectedAtRestDoItVector& selectedAtRestDo << 566 fpState->fSelectedAtRestDoItVector; << 567 << 568 // invoke selected process << 569 for(std::size_t np = 0; np < fpProcessInfo-> << 570 { << 571 // << 572 // Note: DoItVector has inverse order agai << 573 // and SelectedAtRestDoItVector. << 574 // << 575 if(selectedAtRestDoItVector[fpProcessInfo- << 576 { 171 { 577 fpCurrentProcess = << 172 G4cout << "G4ITStepProcessor::InvokeAlongStepDoItProcs : Track will be killed" << G4endl; 578 (G4VITProcess*) (*fpProcessInfo->fpA << 173 if(MAXofAtRestLoops>0) fNewStatus = fStopButAlive; 579 << 174 else fNewStatus = fStopAndKill; 580 // G4cout << " Invoke : " << 175 fpTrack->SetTrackStatus( fNewStatus ); 581 // << fpCurrentProcess->GetProcess << 176 } 582 // << G4endl; << 583 << 584 // if(fpVerbose) << 585 // { << 586 // fpVerbose->AtRestDoItOneByOne(); << 587 // } << 588 << 589 fpCurrentProcess->SetProcessState(fpTrac << 590 ->GetProcessID())); << 591 fpParticleChange = fpCurrentProcess->AtR << 592 fpCurrentProcess->ResetProcessState(); << 593 << 594 // Set the current process as a process << 595 fpStep->GetPostStepPoint()->SetProcessDe << 596 << 597 // Update Step << 598 fpParticleChange->UpdateStepForAtRest(fp << 599 << 600 // Now Store the secondaries from Partic << 601 DealWithSecondaries(fN2ndariesAtRestDoIt << 602 << 603 // Set the track status according to wha << 604 // if kinetic energy >0, otherwise set << 605 fpTrack->SetTrackStatus(fpParticleChange << 606 << 607 // clear ParticleChange << 608 fpParticleChange->Clear(); << 609 << 610 } //if(fSelectedAtRestDoItVector[np] != In << 611 } //for(std::size_t np=0; np < MAXofAtRestLo << 612 fpStep->UpdateTrack(); << 613 << 614 // Modification par rapport au transport sta << 615 // fStopAndKill doit etre propose par le mod << 616 // sinon d autres processus AtRest seront ap << 617 // au pas suivant << 618 // fpTrack->SetTrackStatus(fStopAndKill); << 619 } << 620 << 621 //____________________________________________ << 622 << 623 // ******************************************* << 624 // AlongStepDoIt << 625 // ******************************************* << 626 << 627 void G4ITStepProcessor::InvokeAlongStepDoItPro << 628 { << 629 << 630 #ifdef DEBUG_MEM << 631 MemStat mem_first, mem_second, mem_diff; << 632 #endif << 633 << 634 #ifdef DEBUG_MEM << 635 mem_first = MemoryUsage(); << 636 #endif << 637 << 638 // If the current Step is defined by a 'Excl << 639 // PostStepDoIt, then don't invoke any Along << 640 if(fpState->fStepStatus == fExclusivelyForce << 641 { << 642 return; // Take note 'return << 643 } << 644 << 645 // Invoke the all active continuous processe << 646 for(std::size_t ci = 0; ci < fpProcessInfo-> << 647 { << 648 fpCurrentProcess = << 649 (G4VITProcess*) (*fpProcessInfo->fpAlo << 650 if(fpCurrentProcess == nullptr) continue; << 651 // NULL means the process is inactivated b << 652 << 653 fpCurrentProcess->SetProcessState(fpTracki << 654 ->GetProcessID())); << 655 fpParticleChange = fpCurrentProcess->Along << 656 << 657 #ifdef DEBUG_MEM << 658 MemStat mem_intermediaire = MemoryUsage(); << 659 mem_diff = mem_intermediaire-mem_first; << 660 G4cout << "\t\t\t >> || MEM || After calli << 661 #endif << 662 << 663 // fpCurrentProcess->SetProcessState(0) << 664 fpCurrentProcess->ResetProcessState(); << 665 // Update the PostStepPoint of Step accord << 666 << 667 fpParticleChange->UpdateStepForAlongStep(f << 668 << 669 #ifdef G4VERBOSE << 670 // !!!!! Verbose << 671 if(fpVerbose != nullptr) fpVerbose->AlongS << 672 #endif << 673 << 674 // Now Store the secondaries from Particle << 675 DealWithSecondaries(fN2ndariesAlongStepDoI << 676 << 677 // Set the track status according to what << 678 // if kinetic energy >0, otherwise set fS << 679 fpTrack->SetTrackStatus(fpParticleChange-> << 680 << 681 // clear ParticleChange << 682 fpParticleChange->Clear(); << 683 } << 684 << 685 #ifdef DEBUG_MEM << 686 MemStat mem_intermediaire = MemoryUsage(); << 687 mem_diff = mem_intermediaire-mem_first; << 688 G4cout << "\t\t\t >> || MEM || After looping << 689 #endif << 690 << 691 fpStep->UpdateTrack(); << 692 << 693 G4TrackStatus fNewStatus = fpTrack->GetTrack << 694 << 695 if(fNewStatus == fAlive && fpTrack->GetKinet << 696 { << 697 // G4cout << "G4ITStepProcessor::In << 698 if(fpProcessInfo->MAXofAtRestLoops>0) fNew << 699 else fNewStatus = fStopAndKill; << 700 fpTrack->SetTrackStatus( fNewStatus ); << 701 } << 702 177 703 } 178 } 704 179 705 //____________________________________________ << 180 //////////////////////////////////////////////////////// 706 << 707 // ******************************************* << 708 // PostStepDoIt << 709 // ******************************************* << 710 << 711 void G4ITStepProcessor::InvokePostStepDoItProc 181 void G4ITStepProcessor::InvokePostStepDoItProcs() >> 182 //////////////////////////////////////////////////////// 712 { 183 { 713 std::size_t _MAXofPostStepLoops = fpProcessI << 184 714 G4SelectedPostStepDoItVector& selectedPostSt << 185 // Invoke the specified discrete processes 715 ->fSelectedPostStepDoItVector; << 186 for(size_t np=0; np < MAXofPostStepLoops; np++) 716 G4StepStatus& stepStatus = fpState->fStepSta << 717 << 718 // Invoke the specified discrete processes << 719 for(std::size_t np = 0; np < _MAXofPostStepL << 720 { << 721 // << 722 // Note: DoItVector has inverse order agai << 723 // and SelectedPostStepDoItVector. << 724 // << 725 G4int Cond = selectedPostStepDoItVector[_M << 726 - << 727 if(Cond != InActivated) << 728 { << 729 if(((Cond == NotForced) && (stepStatus = << 730 ((Cond == Forced) && (stepStatus != << 731 || << 732 // ((Cond == Conditionally) && (stepS << 733 ((Cond == ExclusivelyForced) && (step << 734 || ((Cond == StronglyForced))) << 735 { << 736 << 737 InvokePSDIP(np); << 738 } << 739 } //if(*fSelectedPostStepDoItVector(np)... << 740 << 741 // Exit from PostStepLoop if the track has << 742 // but extra treatment for processes with << 743 if(fpTrack->GetTrackStatus() == fStopAndKi << 744 { 187 { 745 for(std::size_t np1 = np + 1; np1 < _MAX << 188 // 746 { << 189 // Note: DoItVector has inverse order against GetPhysIntVector 747 G4int Cond2 = selectedPostStepDoItVect << 190 // and SelectedPostStepDoItVector. 748 << 191 // 749 if(Cond2 == StronglyForced) << 192 G4int Cond = (*fpSelectedPostStepDoItVector)[MAXofPostStepLoops-np-1]; >> 193 if(Cond != InActivated) >> 194 { >> 195 if( ((Cond == NotForced) && (*fpStepStatus == fPostStepDoItProc)) || >> 196 ((Cond == Forced) && (*fpStepStatus != fExclusivelyForcedProc)) || >> 197 ((Cond == Conditionally) && (*fpStepStatus == fAlongStepDoItProc)) || >> 198 ((Cond == ExclusivelyForced) && (*fpStepStatus == fExclusivelyForcedProc)) || >> 199 ((Cond == StronglyForced) ) >> 200 ) >> 201 { >> 202 >> 203 InvokePSDIP(np); >> 204 } >> 205 } //if(*fSelectedPostStepDoItVector(np)........ >> 206 >> 207 // Exit from PostStepLoop if the track has been killed, >> 208 // but extra treatment for processes with Strongly Forced flag >> 209 if(fpTrack->GetTrackStatus() == fStopAndKill) 750 { 210 { 751 InvokePSDIP(np1); << 211 for(size_t np1=np+1; np1 < MAXofPostStepLoops; np1++) >> 212 { >> 213 G4int Cond2 = (*fpSelectedPostStepDoItVector)[MAXofPostStepLoops-np1-1]; >> 214 if (Cond2 == StronglyForced) >> 215 { >> 216 InvokePSDIP(np1); >> 217 } >> 218 } >> 219 break; 752 } 220 } 753 } << 221 } //for(size_t np=0; np < MAXofPostStepLoops; np++){ 754 break; << 755 } << 756 } //for(std::size_t np=0; np < MAXofPostStep << 757 } 222 } 758 223 759 //____________________________________________ << 224 //////////////////////////////////////////////////////// 760 << 225 void G4ITStepProcessor::InvokePSDIP(size_t np) 761 void G4ITStepProcessor::InvokePSDIP(std::size_ << 226 //////////////////////////////////////////////////////// 762 { 227 { 763 fpCurrentProcess = (G4VITProcess*) (*fpProce << 228 fpCurrentProcess = (G4VITProcess*) (*fpPostStepDoItVector)[np]; 764 << 765 fpCurrentProcess->SetProcessState(fpTracking << 766 ->GetProcessID())); << 767 fpParticleChange = fpCurrentProcess->PostSte << 768 // fpCurrentProcess->SetProcessState(0); << 769 fpCurrentProcess->ResetProcessState(); << 770 << 771 // Update PostStepPoint of Step according to << 772 fpParticleChange->UpdateStepForPostStep(fpSt << 773 << 774 #ifdef G4VERBOSE << 775 // !!!!! Verbose << 776 if(fpVerbose != nullptr) fpVerbose->PostStep << 777 #endif << 778 229 779 // Update G4Track according to ParticleChang << 230 fpCurrentProcess->SetProcessState(fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID())); 780 fpStep->UpdateTrack(); << 231 fpParticleChange >> 232 = fpCurrentProcess->PostStepDoIt( *fpTrack, *fpStep); >> 233 fpCurrentProcess->SetProcessState(0); 781 234 782 // Update safety after each invocation of Po << 235 // Update PostStepPoint of Step according to ParticleChange 783 fpStep->GetPostStepPoint()->SetSafety(Calcul << 236 fpParticleChange->UpdateStepForPostStep(fpStep); 784 237 785 // Now Store the secondaries from ParticleCh << 238 // Update G4Track according to ParticleChange after each PostStepDoIt 786 DealWithSecondaries(fN2ndariesPostStepDoIt); << 239 fpStep->UpdateTrack(); 787 240 788 // Set the track status according to what th << 241 // Update safety after each invocation of PostStepDoIts 789 fpTrack->SetTrackStatus(fpParticleChange->Ge << 242 fpStep->GetPostStepPoint()->SetSafety( CalculateSafety() ); 790 << 791 // clear ParticleChange << 792 fpParticleChange->Clear(); << 793 } << 794 << 795 //____________________________________________ << 796 << 797 // ******************************************* << 798 // Transport on a given time << 799 // ******************************************* << 800 << 801 void G4ITStepProcessor::FindTransportationStep << 802 { << 803 double physicalStep(0.); << 804 243 805 fpTransportation = fpProcessInfo->fpTranspor << 244 // Now Store the secondaries from ParticleChange to SecondaryList 806 // dynamic_cast<G4ITTransportation*>((fpProc << 245 DealWithSecondaries(fN2ndariesPostStepDoIt) ; 807 246 808 if(fpTrack == nullptr) << 247 // Set the track status according to what the process defined 809 { << 248 fpTrack->SetTrackStatus( fpParticleChange->GetTrackStatus() ); 810 G4ExceptionDescription exceptionDescriptio << 811 exceptionDescription << "No G4ITStepProces << 812 G4Exception("G4ITStepProcessor::FindTransp << 813 "ITStepProcessor0013", << 814 FatalErrorInArgument, << 815 exceptionDescription); << 816 return; << 817 << 818 } << 819 if(fpITrack == nullptr) << 820 { << 821 G4ExceptionDescription exceptionDescriptio << 822 exceptionDescription << "No G4ITStepProces << 823 G4Exception("G4ITStepProcessor::FindTransp << 824 "ITStepProcessor0014", << 825 FatalErrorInArgument, << 826 exceptionDescription); << 827 return; << 828 } << 829 if((fpITrack->GetTrack()) == nullptr) << 830 { << 831 G4ExceptionDescription exceptionDescriptio << 832 exceptionDescription << "No G4ITStepProces << 833 G4Exception("G4ITStepProcessor::FindTransp << 834 "ITStepProcessor0015", << 835 FatalErrorInArgument, << 836 exceptionDescription); << 837 return; << 838 } << 839 << 840 if(fpTransportation != nullptr) << 841 { << 842 fpTransportation->SetProcessState(fpTracki << 843 ->GetProcessID())); << 844 fpTransportation->ComputeStep(*fpTrack, *f << 845 << 846 // fpTransportation->SetProcessState(0) << 847 fpTransportation->ResetProcessState(); << 848 } << 849 << 850 if(physicalStep >= DBL_MAX) << 851 { << 852 // G4cout << "---- 2) Setting stop and kill << 853 fpTrack -> SetTrackStatus(fStopAndKill); << 854 return; << 855 } << 856 249 857 fpState->fPhysicalStep = physicalStep; << 250 // clear ParticleChange >> 251 fpParticleChange->Clear(); 858 } 252 } 859 253 860 //____________________________________________ << 254 //////////////////////////////////////////////////////// 861 << 862 void G4ITStepProcessor::InvokeTransportationPr 255 void G4ITStepProcessor::InvokeTransportationProc() >> 256 //////////////////////////////////////////////////////// 863 { 257 { 864 std::size_t _MAXofPostStepLoops = fpProcessI << 258 // Invoke the specified discrete processes 865 G4SelectedPostStepDoItVector& selectedPostSt << 259 for(size_t np=0; np < MAXofPostStepLoops; np++) 866 ->fSelectedPostStepDoItVector; << 867 G4StepStatus& stepStatus = fpState->fStepSta << 868 << 869 // Invoke the specified discrete processes << 870 for(std::size_t np = 0; np < _MAXofPostStepL << 871 { << 872 // << 873 // Note: DoItVector has inverse order agai << 874 // and SelectedPostStepDoItVector. << 875 // << 876 G4int Cond = selectedPostStepDoItVector[_M << 877 if(Cond != InActivated) << 878 { 260 { 879 if(((Cond == Forced) && (stepStatus != f << 261 // 880 // ((Cond == Conditionally) && (stepStat << 262 // Note: DoItVector has inverse order against GetPhysIntVector 881 ((Cond == ExclusivelyForced) && (stepSta << 263 // and SelectedPostStepDoItVector. 882 || ((Cond == StronglyForced))) << 264 // 883 { << 265 G4int Cond = (*fpSelectedPostStepDoItVector)[MAXofPostStepLoops-np-1]; 884 << 266 if(Cond != InActivated) 885 InvokePSDIP(np); << 267 { 886 } << 268 if( 887 } //if(Cond != InActivated) << 269 ((Cond == Forced) && (*fpStepStatus != fExclusivelyForcedProc)) || 888 << 270 ((Cond == Conditionally) && (*fpStepStatus == fAlongStepDoItProc)) || 889 // Exit from PostStepLoop if the track has << 271 ((Cond == ExclusivelyForced) && (*fpStepStatus == fExclusivelyForcedProc)) || 890 // but extra treatment for processes with << 272 ((Cond == StronglyForced) ) 891 if(fpTrack->GetTrackStatus() == fStopAndKi << 273 ) 892 { << 274 { 893 for(std::size_t np1 = np + 1; np1 < _MAX << 275 894 { << 276 InvokePSDIP(np); 895 G4int Cond2 = selectedPostStepDoItVect << 277 } 896 if(Cond2 == StronglyForced) << 278 } //if(*fSelectedPostStepDoItVector(np)........ >> 279 >> 280 // Exit from PostStepLoop if the track has been killed, >> 281 // but extra treatment for processes with Strongly Forced flag >> 282 if(fpTrack->GetTrackStatus() == fStopAndKill) 897 { 283 { 898 InvokePSDIP(np1); << 284 for(size_t np1=np+1; np1 < MAXofPostStepLoops; np1++) >> 285 { >> 286 G4int Cond2 = (*fpSelectedPostStepDoItVector)[MAXofPostStepLoops-np1-1]; >> 287 if (Cond2 == StronglyForced) >> 288 { >> 289 InvokePSDIP(np1); >> 290 } >> 291 } >> 292 break; 899 } 293 } 900 } << 901 break; << 902 } 294 } 903 } << 904 } 295 } 905 296 906 //____________________________________________ << 297 /////////////////////////////////////////////////////////////// 907 << 908 // ******************************************* << 909 // Apply cuts << 910 // ******************************************* << 911 << 912 void G4ITStepProcessor::ApplyProductionCut(G4T 298 void G4ITStepProcessor::ApplyProductionCut(G4Track* aSecondary) >> 299 /////////////////////////////////////////////////////////////// 913 { 300 { 914 G4bool tBelowCutEnergyAndSafety = false; << 301 G4bool tBelowCutEnergyAndSafety = false; 915 G4int tPtclIdx = G4ProductionCuts::GetIndex( << 302 G4int tPtclIdx 916 if(tPtclIdx < 0) << 303 = G4ProductionCuts::GetIndex(aSecondary->GetDefinition()); 917 { << 304 if (tPtclIdx<0) 918 return; << 305 { 919 } << 306 return; 920 G4ProductionCutsTable* tCutsTbl = << 307 } 921 G4ProductionCutsTable::GetProductionCuts << 308 G4ProductionCutsTable* tCutsTbl 922 G4int tCoupleIdx = tCutsTbl->GetCoupleIndex( << 309 = G4ProductionCutsTable::GetProductionCutsTable(); 923 ->GetMaterialCutsCouple()); << 310 G4int tCoupleIdx 924 G4double tProdThreshold = << 311 = tCutsTbl->GetCoupleIndex(fpPreStepPoint->GetMaterialCutsCouple()); 925 (*(tCutsTbl->GetEnergyCutsVector(tPtclId << 312 G4double tProdThreshold 926 if(aSecondary->GetKineticEnergy() < tProdThr << 313 = (*(tCutsTbl->GetEnergyCutsVector(tPtclIdx)))[tCoupleIdx]; 927 { << 314 if( aSecondary->GetKineticEnergy()<tProdThreshold ) 928 tBelowCutEnergyAndSafety = true; << 929 if(std::abs(aSecondary->GetDynamicParticle << 930 { 315 { 931 G4double currentRange << 316 tBelowCutEnergyAndSafety = true; 932 = G4LossTableManager::Instance()->GetRan << 317 if(std::abs(aSecondary->GetDynamicParticle()->GetCharge()) > DBL_MIN) 933 aSecondary->GetKineticEnergy(), << 318 { 934 fpPreStepPoint->GetMaterialCutsCoupl << 319 G4double currentRange 935 tBelowCutEnergyAndSafety = (currentRange << 320 = G4LossTableManager::Instance()->GetRange(aSecondary->GetDefinition(), >> 321 aSecondary->GetKineticEnergy(), >> 322 fpPreStepPoint->GetMaterialCutsCouple()); >> 323 tBelowCutEnergyAndSafety = (currentRange < CalculateSafety() ); >> 324 } 936 } 325 } 937 } << 938 326 939 if(tBelowCutEnergyAndSafety) << 327 if( tBelowCutEnergyAndSafety ) 940 { << 941 if(!(aSecondary->IsGoodForTracking())) << 942 { 328 { 943 // Add kinetic energy to the total energ << 329 if( !(aSecondary->IsGoodForTracking()) ) 944 fpStep->AddTotalEnergyDeposit(aSecondary << 330 { 945 aSecondary->SetKineticEnergy(0.0); << 331 // Add kinetic energy to the total energy deposit >> 332 fpStep->AddTotalEnergyDeposit( >> 333 aSecondary->GetKineticEnergy() ); >> 334 aSecondary->SetKineticEnergy(0.0); >> 335 } 946 } 336 } 947 } << 948 } 337 } 949 338