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