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 << 36 #include "G4UImanager.hh" 37 #include "G4ForceCondition.hh" 37 #include "G4ForceCondition.hh" 38 #include "G4GPILSelection.hh" 38 #include "G4GPILSelection.hh" >> 39 #include "G4ITTransportationManager.hh" >> 40 // #include "G4VSensitiveDetector.hh" // Include from 'hits/digi' 39 #include "G4GeometryTolerance.hh" 41 #include "G4GeometryTolerance.hh" >> 42 #include "G4ParticleTable.hh" >> 43 #include "G4ITTrackingManager.hh" >> 44 #include "G4TrackingInformation.hh" 40 #include "G4IT.hh" 45 #include "G4IT.hh" 41 #include "G4ITNavigator.hh" // Inc 46 #include "G4ITNavigator.hh" // Include from 'geometry' 42 #include "G4ITSteppingVerbose.hh" << 47 >> 48 #include "G4VITProcess.hh" >> 49 #include "G4VProcess.hh" >> 50 #include "G4ITTransportation.hh" >> 51 43 #include "G4ITTrackHolder.hh" 52 #include "G4ITTrackHolder.hh" >> 53 >> 54 #include "G4ITSteppingVerbose.hh" >> 55 #include "G4VITSteppingVerbose.hh" 44 #include "G4ITTrackingInteractivity.hh" 56 #include "G4ITTrackingInteractivity.hh" 45 #include "G4ITTrackingManager.hh" << 57 46 #include "G4ITTransportation.hh" << 47 #include "G4ITTransportationManager.hh" << 48 #include "G4ParticleTable.hh" << 49 #include "G4TrackingInformation.hh" 58 #include "G4TrackingInformation.hh" 50 #include "G4UImanager.hh" << 51 #include "G4VITProcess.hh" << 52 #include "G4VITSteppingVerbose.hh" << 53 #include "G4VProcess.hh" << 54 59 55 #include <iomanip> // Include fro 60 #include <iomanip> // Include from 'system' 56 #include <vector> // Include fro 61 #include <vector> // Include from 'system' 57 62 58 using namespace std; 63 using namespace std; 59 64 60 static const std::size_t SizeOfSelectedDoItVec << 65 static const size_t SizeOfSelectedDoItVector = 100; 61 66 62 template<typename T> 67 template<typename T> 63 inline bool IsInf(T value) 68 inline bool IsInf(T value) 64 { 69 { 65 return std::numeric_limits<T>::has_infinit 70 return std::numeric_limits<T>::has_infinity 66 && value == std::numeric_limits<T>::in 71 && value == std::numeric_limits<T>::infinity(); 67 } 72 } 68 73 69 //____________________________________________ 74 //______________________________________________________________________________ 70 75 71 G4ITStepProcessor::G4ITStepProcessor() 76 G4ITStepProcessor::G4ITStepProcessor() 72 { 77 { 73 fpVerbose = nullptr; << 78 fpVerbose = 0; 74 // fpUserSteppingAction = 0 ; 79 // fpUserSteppingAction = 0 ; 75 fStoreTrajectory = 0; 80 fStoreTrajectory = 0; 76 fpTrackingManager = nullptr; << 81 fpTrackingManager = 0; 77 fpNavigator = nullptr; << 82 fpNavigator = 0; 78 kCarTolerance = -1.; 83 kCarTolerance = -1.; 79 fInitialized = false; 84 fInitialized = false; 80 fPreviousTimeStep = DBL_MAX; 85 fPreviousTimeStep = DBL_MAX; 81 fILTimeStep = DBL_MAX; 86 fILTimeStep = DBL_MAX; 82 fpTrackContainer = nullptr; << 87 fpTrackContainer = 0; 83 88 84 CleanProcessor(); 89 CleanProcessor(); 85 ResetSecondaries(); 90 ResetSecondaries(); 86 } 91 } 87 92 88 //____________________________________________ 93 //______________________________________________________________________________ 89 94 90 //G4ITStepProcessor:: 95 //G4ITStepProcessor:: 91 G4ITStepProcessorState::G4ITStepProcessorState 96 G4ITStepProcessorState::G4ITStepProcessorState() : 92 G4ITStepProcessorState_Lock(), 97 G4ITStepProcessorState_Lock(), 93 fSelectedAtRestDoItVector(G4VITProcess::Ge 98 fSelectedAtRestDoItVector(G4VITProcess::GetMaxProcessIndex(), 0), 94 fSelectedPostStepDoItVector(G4VITProcess:: 99 fSelectedPostStepDoItVector(G4VITProcess::GetMaxProcessIndex(), 0) 95 { 100 { 96 fPhysicalStep = -1.; 101 fPhysicalStep = -1.; 97 fPreviousStepSize = -1.; 102 fPreviousStepSize = -1.; 98 103 99 fSafety = -1.; 104 fSafety = -1.; 100 fProposedSafety = -1.; 105 fProposedSafety = -1.; 101 fEndpointSafety = -1; 106 fEndpointSafety = -1; 102 107 103 fStepStatus = fUndefined; 108 fStepStatus = fUndefined; 104 109 105 fTouchableHandle = nullptr; << 110 fTouchableHandle = 0; 106 } 111 } 107 112 108 //____________________________________________ 113 //______________________________________________________________________________ 109 114 110 //G4ITStepProcessor:: 115 //G4ITStepProcessor:: 111 G4ITStepProcessorState::G4ITStepProcessorState 116 G4ITStepProcessorState::G4ITStepProcessorState(const G4ITStepProcessorState& right) : 112 G4ITStepProcessorState_Lock(), 117 G4ITStepProcessorState_Lock(), 113 fSelectedAtRestDoItVector(right.fSelectedA 118 fSelectedAtRestDoItVector(right.fSelectedAtRestDoItVector), 114 fSelectedPostStepDoItVector(right.fSelecte 119 fSelectedPostStepDoItVector(right.fSelectedPostStepDoItVector) 115 { 120 { 116 fPhysicalStep = right.fPhysicalStep; 121 fPhysicalStep = right.fPhysicalStep; 117 fPreviousStepSize = right.fPreviousStepSize; 122 fPreviousStepSize = right.fPreviousStepSize; 118 123 119 fSafety = right.fSafety; 124 fSafety = right.fSafety; 120 fProposedSafety = right.fProposedSafety; 125 fProposedSafety = right.fProposedSafety; 121 fEndpointSafety = right.fEndpointSafety; 126 fEndpointSafety = right.fEndpointSafety; 122 127 123 fStepStatus = right.fStepStatus; 128 fStepStatus = right.fStepStatus; 124 129 125 fTouchableHandle = right.fTouchableHandle; 130 fTouchableHandle = right.fTouchableHandle; 126 } 131 } 127 132 128 //____________________________________________ 133 //______________________________________________________________________________ 129 134 130 //G4ITStepProcessor:: 135 //G4ITStepProcessor:: 131 G4ITStepProcessorState& 136 G4ITStepProcessorState& 132 //G4ITStepProcessor:: 137 //G4ITStepProcessor:: 133 G4ITStepProcessorState::operator=(const G4ITSt 138 G4ITStepProcessorState::operator=(const G4ITStepProcessorState& right) 134 { 139 { 135 if(this == &right) return *this; 140 if(this == &right) return *this; 136 141 137 fSelectedAtRestDoItVector.clear(); 142 fSelectedAtRestDoItVector.clear(); 138 fSelectedAtRestDoItVector = right.fSelectedA 143 fSelectedAtRestDoItVector = right.fSelectedAtRestDoItVector; 139 fSelectedPostStepDoItVector.clear(); 144 fSelectedPostStepDoItVector.clear(); 140 fSelectedPostStepDoItVector = right.fSelecte 145 fSelectedPostStepDoItVector = right.fSelectedPostStepDoItVector; 141 146 142 fPhysicalStep = right.fPhysicalStep; 147 fPhysicalStep = right.fPhysicalStep; 143 fPreviousStepSize = right.fPreviousStepSize; 148 fPreviousStepSize = right.fPreviousStepSize; 144 149 145 fSafety = right.fSafety; 150 fSafety = right.fSafety; 146 fProposedSafety = right.fProposedSafety; 151 fProposedSafety = right.fProposedSafety; 147 fEndpointSafety = right.fEndpointSafety; 152 fEndpointSafety = right.fEndpointSafety; 148 153 149 fStepStatus = right.fStepStatus; 154 fStepStatus = right.fStepStatus; 150 155 151 fTouchableHandle = right.fTouchableHandle; 156 fTouchableHandle = right.fTouchableHandle; 152 return *this; 157 return *this; 153 } 158 } 154 159 155 //____________________________________________ 160 //______________________________________________________________________________ 156 161 157 //G4ITStepProcessor:: 162 //G4ITStepProcessor:: 158 G4ITStepProcessorState::~G4ITStepProcessorStat 163 G4ITStepProcessorState::~G4ITStepProcessorState() 159 { 164 { 160 ; 165 ; 161 } 166 } 162 167 163 //____________________________________________ 168 //______________________________________________________________________________ 164 169 165 void G4ITStepProcessor::ClearProcessInfo() 170 void G4ITStepProcessor::ClearProcessInfo() 166 { 171 { 167 std::map<const G4ParticleDefinition*, Proces 172 std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it; 168 173 169 for(it = fProcessGeneralInfoMap.begin(); it 174 for(it = fProcessGeneralInfoMap.begin(); it != fProcessGeneralInfoMap.end(); 170 it++) 175 it++) 171 { 176 { 172 if(it->second != nullptr) << 177 if(it->second) 173 { 178 { 174 delete it->second; 179 delete it->second; 175 it->second = 0; 180 it->second = 0; 176 } 181 } 177 } 182 } 178 183 179 fProcessGeneralInfoMap.clear(); 184 fProcessGeneralInfoMap.clear(); 180 } 185 } 181 186 182 //____________________________________________ 187 //______________________________________________________________________________ 183 188 184 void G4ITStepProcessor::ForceReInitialization( 189 void G4ITStepProcessor::ForceReInitialization() 185 { 190 { 186 fInitialized = false; 191 fInitialized = false; 187 ClearProcessInfo(); 192 ClearProcessInfo(); 188 Initialize(); 193 Initialize(); 189 } 194 } 190 195 191 //____________________________________________ 196 //______________________________________________________________________________ 192 197 193 void G4ITStepProcessor::Initialize() 198 void G4ITStepProcessor::Initialize() 194 { 199 { 195 CleanProcessor(); 200 CleanProcessor(); 196 if(fInitialized) return; 201 if(fInitialized) return; 197 // ActiveOnlyITProcess(); 202 // ActiveOnlyITProcess(); 198 203 199 SetNavigator(G4ITTransportationManager::GetT 204 SetNavigator(G4ITTransportationManager::GetTransportationManager() 200 ->GetNavigatorForTracking()); 205 ->GetNavigatorForTracking()); 201 206 202 fPhysIntLength = DBL_MAX; 207 fPhysIntLength = DBL_MAX; 203 kCarTolerance = 0.5 208 kCarTolerance = 0.5 204 * G4GeometryTolerance::GetInstance()->Ge 209 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); 205 210 206 if(fpVerbose == nullptr) << 211 if(fpVerbose == 0) 207 { 212 { 208 G4ITTrackingInteractivity* interactivity = 213 G4ITTrackingInteractivity* interactivity = fpTrackingManager->GetInteractivity(); 209 214 210 if(interactivity != nullptr) << 215 if(interactivity) 211 { 216 { 212 fpVerbose = interactivity->GetSteppingVe 217 fpVerbose = interactivity->GetSteppingVerbose(); 213 fpVerbose->SetStepProcessor(this); 218 fpVerbose->SetStepProcessor(this); 214 } 219 } 215 } 220 } 216 221 217 fpTrackContainer = G4ITTrackHolder::Instance 222 fpTrackContainer = G4ITTrackHolder::Instance(); 218 223 219 fInitialized = true; 224 fInitialized = true; 220 } 225 } 221 //____________________________________________ 226 //______________________________________________________________________________ 222 227 223 G4ITStepProcessor::~G4ITStepProcessor() 228 G4ITStepProcessor::~G4ITStepProcessor() 224 { 229 { 225 if(fpStep != nullptr) << 230 if(fpStep) 226 { 231 { 227 fpStep->DeleteSecondaryVector(); 232 fpStep->DeleteSecondaryVector(); 228 delete fpStep; 233 delete fpStep; 229 } 234 } 230 235 231 delete fpSecondary; << 236 if(fpSecondary) delete fpSecondary; 232 ClearProcessInfo(); 237 ClearProcessInfo(); 233 //G4ITTransportationManager::DeleteInstance( 238 //G4ITTransportationManager::DeleteInstance(); 234 239 235 // if(fpUserSteppingAction) d 240 // if(fpUserSteppingAction) delete fpUserSteppingAction; 236 } 241 } 237 //____________________________________________ 242 //______________________________________________________________________________ 238 // should not be used 243 // should not be used 239 G4ITStepProcessor::G4ITStepProcessor(const G4I 244 G4ITStepProcessor::G4ITStepProcessor(const G4ITStepProcessor& rhs) 240 { 245 { 241 fpVerbose = rhs.fpVerbose; 246 fpVerbose = rhs.fpVerbose; 242 fStoreTrajectory = rhs.fStoreTrajectory; 247 fStoreTrajectory = rhs.fStoreTrajectory; 243 248 244 // fpUserSteppingAction = 0 ; 249 // fpUserSteppingAction = 0 ; 245 fpTrackingManager = nullptr; << 250 fpTrackingManager = 0; 246 fpNavigator = nullptr; << 251 fpNavigator = 0; 247 fInitialized = false; 252 fInitialized = false; 248 253 249 kCarTolerance = rhs.kCarTolerance; 254 kCarTolerance = rhs.kCarTolerance; 250 fInitialized = false; 255 fInitialized = false; 251 fPreviousTimeStep = DBL_MAX; 256 fPreviousTimeStep = DBL_MAX; 252 257 253 CleanProcessor(); 258 CleanProcessor(); 254 ResetSecondaries(); 259 ResetSecondaries(); 255 fpTrackContainer = nullptr; << 260 fpTrackContainer = 0; 256 fILTimeStep = DBL_MAX; 261 fILTimeStep = DBL_MAX; 257 } 262 } 258 263 259 //____________________________________________ 264 //______________________________________________________________________________ 260 265 261 void G4ITStepProcessor::ResetLeadingTracks() 266 void G4ITStepProcessor::ResetLeadingTracks() 262 { 267 { 263 fLeadingTracks.Reset(); 268 fLeadingTracks.Reset(); 264 } 269 } 265 270 266 //____________________________________________ 271 //______________________________________________________________________________ 267 272 268 void G4ITStepProcessor::PrepareLeadingTracks() 273 void G4ITStepProcessor::PrepareLeadingTracks() 269 { 274 { 270 fLeadingTracks.PrepareLeadingTracks(); 275 fLeadingTracks.PrepareLeadingTracks(); 271 } 276 } 272 277 273 //____________________________________________ 278 //______________________________________________________________________________ 274 279 275 G4ITStepProcessor& G4ITStepProcessor::operator 280 G4ITStepProcessor& G4ITStepProcessor::operator=(const G4ITStepProcessor& rhs) 276 { 281 { 277 if(this == &rhs) return *this; // handle sel 282 if(this == &rhs) return *this; // handle self assignment 278 //assignment operator 283 //assignment operator 279 return *this; 284 return *this; 280 } 285 } 281 286 282 //____________________________________________ 287 //______________________________________________________________________________ 283 288 284 void G4ITStepProcessor::ActiveOnlyITProcess() 289 void G4ITStepProcessor::ActiveOnlyITProcess() 285 { 290 { 286 // Method not used for the time being 291 // Method not used for the time being 287 #ifdef debug 292 #ifdef debug 288 G4cout<<"G4ITStepProcessor::CloneProcesses: 293 G4cout<<"G4ITStepProcessor::CloneProcesses: is called"<<G4endl; 289 #endif 294 #endif 290 295 291 G4ParticleTable* theParticleTable = G4Partic 296 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable(); 292 G4ParticleTable::G4PTblDicIterator* theParti 297 G4ParticleTable::G4PTblDicIterator* theParticleIterator = theParticleTable 293 ->GetIterator(); 298 ->GetIterator(); 294 299 295 theParticleIterator->reset(); 300 theParticleIterator->reset(); 296 // TODO : Ne faire la boucle que sur les IT 301 // TODO : Ne faire la boucle que sur les IT **** !!! 297 while((*theParticleIterator)()) 302 while((*theParticleIterator)()) 298 { 303 { 299 G4ParticleDefinition* particle = thePartic 304 G4ParticleDefinition* particle = theParticleIterator->value(); 300 G4ProcessManager* pm = particle->GetProces 305 G4ProcessManager* pm = particle->GetProcessManager(); 301 306 302 if(pm == nullptr) << 307 if(!pm) 303 { 308 { 304 G4cerr << "ERROR - G4ITStepProcessor::Ge 309 G4cerr << "ERROR - G4ITStepProcessor::GetProcessNumber()" << G4endl<< " ProcessManager is NULL for particle = " 305 << particle->GetParticleName() << ", PDG 310 << particle->GetParticleName() << ", PDG_code = " 306 << particle->GetPDGEncoding() << G4endl; 311 << particle->GetPDGEncoding() << G4endl; 307 G4Exception("G4ITStepProcessor::GetProce 312 G4Exception("G4ITStepProcessor::GetProcessNumber()", "ITStepProcessor0001", 308 FatalException, "Process Manager is 313 FatalException, "Process Manager is not found."); 309 return; 314 return; 310 } 315 } 311 316 312 ActiveOnlyITProcess(pm); 317 ActiveOnlyITProcess(pm); 313 } 318 } 314 } 319 } 315 320 316 //____________________________________________ 321 //______________________________________________________________________________ 317 322 318 void G4ITStepProcessor::ActiveOnlyITProcess(G4 323 void G4ITStepProcessor::ActiveOnlyITProcess(G4ProcessManager* processManager) 319 { 324 { 320 // Method not used for the time being 325 // Method not used for the time being 321 G4ProcessVector* processVector = processMana 326 G4ProcessVector* processVector = processManager->GetProcessList(); 322 327 323 G4VITProcess* itProcess = nullptr; << 328 G4VITProcess* itProcess = 0; 324 for(G4int i = 0; i < (G4int)processVector->s << 329 for(std::size_t i = 0; i < processVector->size(); ++i) 325 { 330 { 326 G4VProcess* base_process = (*processVector 331 G4VProcess* base_process = (*processVector)[i]; 327 itProcess = dynamic_cast<G4VITProcess*>(ba 332 itProcess = dynamic_cast<G4VITProcess*>(base_process); 328 333 329 if(itProcess == nullptr) << 334 if(!itProcess) 330 { 335 { 331 processManager->SetProcessActivation(bas 336 processManager->SetProcessActivation(base_process, false); 332 } 337 } 333 } 338 } 334 } 339 } 335 340 336 //____________________________________________ 341 //______________________________________________________________________________ 337 342 338 void G4ITStepProcessor::SetupGeneralProcessInf 343 void G4ITStepProcessor::SetupGeneralProcessInfo(G4ParticleDefinition* particle, 339 344 G4ProcessManager* pm) 340 { 345 { 341 346 342 #ifdef debug 347 #ifdef debug 343 G4cout<<"G4ITStepProcessor::GetProcessNumber 348 G4cout<<"G4ITStepProcessor::GetProcessNumber: is called track"<<G4endl; 344 #endif 349 #endif 345 if(pm == nullptr) << 350 if(!pm) 346 { 351 { 347 G4cerr << "ERROR - G4SteppingManager::GetP 352 G4cerr << "ERROR - G4SteppingManager::GetProcessNumber()" << G4endl<< " ProcessManager is NULL for particle = " 348 << particle->GetParticleName() << ", PDG_c 353 << particle->GetParticleName() << ", PDG_code = " 349 << particle->GetPDGEncoding() << G4endl; 354 << particle->GetPDGEncoding() << G4endl; 350 G4Exception("G4SteppingManager::GetProcess 355 G4Exception("G4SteppingManager::GetProcessNumber()", "ITStepProcessor0002", 351 FatalException, "Process Manager is no 356 FatalException, "Process Manager is not found."); 352 return; 357 return; 353 } 358 } 354 359 355 auto it = << 360 std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it = 356 fProcessGeneralInfoMap.find(particle); 361 fProcessGeneralInfoMap.find(particle); 357 if(it != fProcessGeneralInfoMap.end()) 362 if(it != fProcessGeneralInfoMap.end()) 358 { 363 { 359 G4Exception("G4SteppingManager::SetupGener 364 G4Exception("G4SteppingManager::SetupGeneralProcessInfo()", 360 "ITStepProcessor0003", 365 "ITStepProcessor0003", 361 FatalException, "Process info already 366 FatalException, "Process info already registered."); 362 return; 367 return; 363 } 368 } 364 369 365 // here used as temporary 370 // here used as temporary 366 fpProcessInfo = new ProcessGeneralInfo(); 371 fpProcessInfo = new ProcessGeneralInfo(); 367 372 368 // AtRestDoits 373 // AtRestDoits 369 fpProcessInfo->MAXofAtRestLoops = pm->GetAtR 374 fpProcessInfo->MAXofAtRestLoops = pm->GetAtRestProcessVector()->entries(); 370 fpProcessInfo->fpAtRestDoItVector = pm->GetA 375 fpProcessInfo->fpAtRestDoItVector = pm->GetAtRestProcessVector(typeDoIt); 371 fpProcessInfo->fpAtRestGetPhysIntVector = 376 fpProcessInfo->fpAtRestGetPhysIntVector = 372 pm->GetAtRestProcessVector(typeGPIL); 377 pm->GetAtRestProcessVector(typeGPIL); 373 #ifdef debug 378 #ifdef debug 374 G4cout << "G4ITStepProcessor::GetProcessNumb 379 G4cout << "G4ITStepProcessor::GetProcessNumber: #ofAtRest=" 375 << fpProcessInfo->MAXofAtRestLoops << G4endl 380 << fpProcessInfo->MAXofAtRestLoops << G4endl; 376 #endif 381 #endif 377 382 378 // AlongStepDoits 383 // AlongStepDoits 379 fpProcessInfo->MAXofAlongStepLoops = 384 fpProcessInfo->MAXofAlongStepLoops = 380 pm->GetAlongStepProcessVector()->entries(); 385 pm->GetAlongStepProcessVector()->entries(); 381 fpProcessInfo->fpAlongStepDoItVector = 386 fpProcessInfo->fpAlongStepDoItVector = 382 pm->GetAlongStepProcessVector(typeDoIt); 387 pm->GetAlongStepProcessVector(typeDoIt); 383 fpProcessInfo->fpAlongStepGetPhysIntVector = 388 fpProcessInfo->fpAlongStepGetPhysIntVector = 384 pm->GetAlongStepProcessVector(typeGPIL); 389 pm->GetAlongStepProcessVector(typeGPIL); 385 #ifdef debug 390 #ifdef debug 386 G4cout << "G4ITStepProcessor::GetProcessNumb 391 G4cout << "G4ITStepProcessor::GetProcessNumber:#ofAlongStp=" 387 << fpProcessInfo->MAXofAlongStepLoops << G4e 392 << fpProcessInfo->MAXofAlongStepLoops << G4endl; 388 #endif 393 #endif 389 394 390 // PostStepDoits 395 // PostStepDoits 391 fpProcessInfo->MAXofPostStepLoops = 396 fpProcessInfo->MAXofPostStepLoops = 392 pm->GetPostStepProcessVector()->entries(); 397 pm->GetPostStepProcessVector()->entries(); 393 fpProcessInfo->fpPostStepDoItVector = pm->Ge 398 fpProcessInfo->fpPostStepDoItVector = pm->GetPostStepProcessVector(typeDoIt); 394 fpProcessInfo->fpPostStepGetPhysIntVector = 399 fpProcessInfo->fpPostStepGetPhysIntVector = 395 pm->GetPostStepProcessVector(typeGPIL); 400 pm->GetPostStepProcessVector(typeGPIL); 396 #ifdef debug 401 #ifdef debug 397 G4cout << "G4ITStepProcessor::GetProcessNumb 402 G4cout << "G4ITStepProcessor::GetProcessNumber: #ofPostStep=" 398 << fpProcessInfo->MAXofPostStepLoops << G4en 403 << fpProcessInfo->MAXofPostStepLoops << G4endl; 399 #endif 404 #endif 400 405 401 if (SizeOfSelectedDoItVector<fpProcessInfo-> 406 if (SizeOfSelectedDoItVector<fpProcessInfo->MAXofAtRestLoops || 402 SizeOfSelectedDoItVector<fpProcessInfo-> 407 SizeOfSelectedDoItVector<fpProcessInfo->MAXofAlongStepLoops || 403 SizeOfSelectedDoItVector<fpProcessInfo-> 408 SizeOfSelectedDoItVector<fpProcessInfo->MAXofPostStepLoops ) 404 { 409 { 405 G4cerr << "ERROR - G4ITStepProcessor::GetP 410 G4cerr << "ERROR - G4ITStepProcessor::GetProcessNumber()" << G4endl 406 << " SizeOfSelectedDoItVector= " << 411 << " SizeOfSelectedDoItVector= " << SizeOfSelectedDoItVector 407 << " ; is smaller then one of MAXofAtRestL 412 << " ; is smaller then one of MAXofAtRestLoops= " 408 << fpProcessInfo->MAXofAtRestLoops << G4en 413 << fpProcessInfo->MAXofAtRestLoops << G4endl 409 << " or MAXofAlongStepLoops= " << f 414 << " or MAXofAlongStepLoops= " << fpProcessInfo->MAXofAlongStepLoops 410 << " or MAXofPostStepLoops= " << fpProcess 415 << " or MAXofPostStepLoops= " << fpProcessInfo->MAXofPostStepLoops << G4endl; 411 G4Exception("G4ITStepProcessor::GetProcess 416 G4Exception("G4ITStepProcessor::GetProcessNumber()", 412 "ITStepProcessor0004", FatalException, 417 "ITStepProcessor0004", FatalException, 413 "The array size is smaller than the ac 418 "The array size is smaller than the actual No of processes."); 414 } 419 } 415 420 416 if((fpProcessInfo->fpAtRestDoItVector == nul << 421 if(!fpProcessInfo->fpAtRestDoItVector && 417 (fpProcessInfo->fpAlongStepDoItVector == << 422 !fpProcessInfo->fpAlongStepDoItVector && 418 (fpProcessInfo->fpPostStepDoItVector == << 423 !fpProcessInfo->fpPostStepDoItVector) 419 { 424 { 420 G4ExceptionDescription exceptionDescriptio 425 G4ExceptionDescription exceptionDescription; 421 exceptionDescription << "No DoIt process f 426 exceptionDescription << "No DoIt process found "; 422 G4Exception("G4ITStepProcessor::DoStepping 427 G4Exception("G4ITStepProcessor::DoStepping","ITStepProcessor0005", 423 FatalErrorInArgument,exceptionDescript 428 FatalErrorInArgument,exceptionDescription); 424 return; 429 return; 425 } 430 } 426 431 427 if((fpProcessInfo->fpAlongStepGetPhysIntVect << 432 if(fpProcessInfo->fpAlongStepGetPhysIntVector 428 && fpProcessInfo->MAXofAlongStepLoops>0) 433 && fpProcessInfo->MAXofAlongStepLoops>0) 429 { 434 { 430 fpProcessInfo->fpTransportation = dynamic_ 435 fpProcessInfo->fpTransportation = dynamic_cast<G4ITTransportation*> 431 ((*fpProcessInfo->fpAlongStepGetPhysIntVec 436 ((*fpProcessInfo->fpAlongStepGetPhysIntVector) 432 [G4int(fpProcessInfo->MAXofAlongStepLo << 437 [fpProcessInfo->MAXofAlongStepLoops-1]); 433 438 434 if(fpProcessInfo->fpTransportation == null << 439 if(fpProcessInfo->fpTransportation == 0) 435 { 440 { 436 G4ExceptionDescription exceptionDescript 441 G4ExceptionDescription exceptionDescription; 437 exceptionDescription << "No transportati 442 exceptionDescription << "No transportation process found "; 438 G4Exception("G4ITStepProcessor::SetupGen 443 G4Exception("G4ITStepProcessor::SetupGeneralProcessInfo", 439 "ITStepProcessor0006", 444 "ITStepProcessor0006", 440 FatalErrorInArgument,exceptionDescri 445 FatalErrorInArgument,exceptionDescription); 441 } 446 } 442 } 447 } 443 fProcessGeneralInfoMap[particle] = fpProcess 448 fProcessGeneralInfoMap[particle] = fpProcessInfo; 444 // fpProcessInfo = 0; 449 // fpProcessInfo = 0; 445 } 450 } 446 451 447 //____________________________________________ 452 //______________________________________________________________________________ 448 453 449 void G4ITStepProcessor::SetTrack(G4Track* trac 454 void G4ITStepProcessor::SetTrack(G4Track* track) 450 { 455 { 451 fpTrack = track; 456 fpTrack = track; 452 if(fpTrack != nullptr) << 457 if(fpTrack) 453 { 458 { 454 fpITrack = GetIT(fpTrack); 459 fpITrack = GetIT(fpTrack); 455 fpStep = const_cast<G4Step*>(fpTrack->GetS 460 fpStep = const_cast<G4Step*>(fpTrack->GetStep()); 456 461 457 if(fpITrack != nullptr) << 462 if(fpITrack) 458 { 463 { 459 fpTrackingInfo = fpITrack->GetTrackingIn 464 fpTrackingInfo = fpITrack->GetTrackingInfo(); 460 } 465 } 461 else 466 else 462 { 467 { 463 fpTrackingInfo = nullptr; << 468 fpTrackingInfo = 0; 464 G4cerr << "Track ID : " << fpTrack->GetT 469 G4cerr << "Track ID : " << fpTrack->GetTrackID() << G4endl; 465 470 466 G4ExceptionDescription errMsg; 471 G4ExceptionDescription errMsg; 467 errMsg << "No IT pointer was attached to 472 errMsg << "No IT pointer was attached to the track you try to process."; 468 G4Exception("G4ITStepProcessor::SetTrack 473 G4Exception("G4ITStepProcessor::SetTrack", 469 "ITStepProcessor0007", 474 "ITStepProcessor0007", 470 FatalErrorInArgument, 475 FatalErrorInArgument, 471 errMsg); 476 errMsg); 472 } 477 } 473 } 478 } 474 else 479 else 475 { 480 { 476 fpITrack = nullptr; << 481 fpITrack = 0; 477 fpStep = nullptr; << 482 fpStep = 0; 478 } 483 } 479 } 484 } 480 //____________________________________________ 485 //______________________________________________________________________________ 481 486 482 void G4ITStepProcessor::GetProcessInfo() 487 void G4ITStepProcessor::GetProcessInfo() 483 { 488 { 484 G4ParticleDefinition* particle = fpTrack->Ge 489 G4ParticleDefinition* particle = fpTrack->GetDefinition(); 485 auto it = << 490 std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it = 486 fProcessGeneralInfoMap.find(particle); 491 fProcessGeneralInfoMap.find(particle); 487 492 488 if(it == fProcessGeneralInfoMap.end()) 493 if(it == fProcessGeneralInfoMap.end()) 489 { 494 { 490 SetupGeneralProcessInfo(particle, 495 SetupGeneralProcessInfo(particle, 491 fpTrack->GetDefini 496 fpTrack->GetDefinition()->GetProcessManager()); 492 if(fpProcessInfo == nullptr) << 497 if(fpProcessInfo == 0) 493 { 498 { 494 G4ExceptionDescription exceptionDescript 499 G4ExceptionDescription exceptionDescription("..."); 495 G4Exception("G4ITStepProcessor::GetProce 500 G4Exception("G4ITStepProcessor::GetProcessNumber", 496 "ITStepProcessor0008", 501 "ITStepProcessor0008", 497 FatalErrorInArgument, 502 FatalErrorInArgument, 498 exceptionDescription); 503 exceptionDescription); 499 return; 504 return; 500 } 505 } 501 } 506 } 502 else 507 else 503 { 508 { 504 fpProcessInfo = it->second; 509 fpProcessInfo = it->second; 505 } 510 } 506 } 511 } 507 512 508 //____________________________________________ 513 //______________________________________________________________________________ 509 514 510 void G4ITStepProcessor::SetupMembers() 515 void G4ITStepProcessor::SetupMembers() 511 { 516 { 512 fpSecondary = fpStep->GetfSecondary(); 517 fpSecondary = fpStep->GetfSecondary(); 513 fpPreStepPoint = fpStep->GetPreStepPoint(); 518 fpPreStepPoint = fpStep->GetPreStepPoint(); 514 fpPostStepPoint = fpStep->GetPostStepPoint() 519 fpPostStepPoint = fpStep->GetPostStepPoint(); 515 520 516 fpState = (G4ITStepProcessorState*) fpITrack 521 fpState = (G4ITStepProcessorState*) fpITrack->GetTrackingInfo() 517 ->GetStepProcessorState(); 522 ->GetStepProcessorState(); 518 523 519 GetProcessInfo(); 524 GetProcessInfo(); 520 ResetSecondaries(); 525 ResetSecondaries(); 521 } 526 } 522 527 523 //____________________________________________ 528 //______________________________________________________________________________ 524 529 525 void G4ITStepProcessor::ResetSecondaries() 530 void G4ITStepProcessor::ResetSecondaries() 526 { 531 { 527 // Reset the secondary particles 532 // Reset the secondary particles 528 fN2ndariesAtRestDoIt = 0; 533 fN2ndariesAtRestDoIt = 0; 529 fN2ndariesAlongStepDoIt = 0; 534 fN2ndariesAlongStepDoIt = 0; 530 fN2ndariesPostStepDoIt = 0; 535 fN2ndariesPostStepDoIt = 0; 531 } 536 } 532 537 533 //____________________________________________ 538 //______________________________________________________________________________ 534 539 535 void G4ITStepProcessor::GetAtRestIL() 540 void G4ITStepProcessor::GetAtRestIL() 536 { 541 { 537 // Select the rest process which has the sho 542 // Select the rest process which has the shortest time before 538 // it is invoked. In rest processes, GPIL() 543 // it is invoked. In rest processes, GPIL() 539 // returns the time before a process occurs. 544 // returns the time before a process occurs. 540 G4double lifeTime(DBL_MAX), shortestLifeTime 545 G4double lifeTime(DBL_MAX), shortestLifeTime (DBL_MAX); 541 546 542 fAtRestDoItProcTriggered = 0; 547 fAtRestDoItProcTriggered = 0; 543 shortestLifeTime = DBL_MAX; 548 shortestLifeTime = DBL_MAX; 544 549 545 unsigned int NofInactiveProc=0; 550 unsigned int NofInactiveProc=0; 546 551 547 for( G4int ri=0; ri < (G4int)fpProcessInfo-> << 552 for( size_t ri=0; ri < fpProcessInfo->MAXofAtRestLoops; ri++ ) 548 { 553 { 549 fpCurrentProcess = dynamic_cast<G4VITProce 554 fpCurrentProcess = dynamic_cast<G4VITProcess*>((*fpProcessInfo->fpAtRestGetPhysIntVector)[ri]); 550 if (fpCurrentProcess== nullptr) << 555 if (fpCurrentProcess== 0) 551 { 556 { 552 (fpState->fSelectedAtRestDoItVector)[ri] 557 (fpState->fSelectedAtRestDoItVector)[ri] = InActivated; 553 NofInactiveProc++; 558 NofInactiveProc++; 554 continue; 559 continue; 555 } // NULL means the process is inactivated 560 } // NULL means the process is inactivated by a user on fly. 556 561 557 fCondition=NotForced; 562 fCondition=NotForced; 558 fpCurrentProcess->SetProcessState( 563 fpCurrentProcess->SetProcessState( 559 fpTrackingInfo->GetProcessState(fpCurr 564 fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID())); 560 565 561 lifeTime = fpCurrentProcess->AtRestGPIL( * 566 lifeTime = fpCurrentProcess->AtRestGPIL( *fpTrack, &fCondition ); 562 fpCurrentProcess->ResetProcessState(); 567 fpCurrentProcess->ResetProcessState(); 563 568 564 if(fCondition==Forced) 569 if(fCondition==Forced) 565 { 570 { 566 (fpState->fSelectedAtRestDoItVector)[ri] 571 (fpState->fSelectedAtRestDoItVector)[ri] = Forced; 567 } 572 } 568 else 573 else 569 { 574 { 570 (fpState->fSelectedAtRestDoItVector)[ri] 575 (fpState->fSelectedAtRestDoItVector)[ri] = InActivated; 571 if(lifeTime < shortestLifeTime ) 576 if(lifeTime < shortestLifeTime ) 572 { 577 { 573 shortestLifeTime = lifeTime; 578 shortestLifeTime = lifeTime; 574 fAtRestDoItProcTriggered = G4int(ri); 579 fAtRestDoItProcTriggered = G4int(ri); 575 } 580 } 576 } 581 } 577 } 582 } 578 583 579 (fpState->fSelectedAtRestDoItVector)[fAtRest 584 (fpState->fSelectedAtRestDoItVector)[fAtRestDoItProcTriggered] = NotForced; 580 585 581 // G4cout << " --> Selected at rest process : 586 // G4cout << " --> Selected at rest process : " 582 // << (*fpProcessInfo->fpAtRestGetPhys 587 // << (*fpProcessInfo->fpAtRestGetPhysIntVector)[fAtRestDoItProcTriggered] 583 // ->GetProcessName() 588 // ->GetProcessName() 584 // << G4endl; 589 // << G4endl; 585 590 586 fTimeStep = shortestLifeTime; 591 fTimeStep = shortestLifeTime; 587 592 588 // at least one process is necessary to dest 593 // at least one process is necessary to destroy the particle 589 // exit with warning 594 // exit with warning 590 if(NofInactiveProc==fpProcessInfo->MAXofAtRe 595 if(NofInactiveProc==fpProcessInfo->MAXofAtRestLoops) 591 { 596 { 592 G4cerr << "ERROR - G4ITStepProcessor::Invo 597 G4cerr << "ERROR - G4ITStepProcessor::InvokeAtRestDoItProcs()" << G4endl 593 << " No AtRestDoIt process is activ 598 << " No AtRestDoIt process is active!" << G4endl; 594 } 599 } 595 } 600 } 596 601 597 //____________________________________________ 602 //_________________________________________________________________________ 598 G4double G4ITStepProcessor::ComputeInteraction 603 G4double G4ITStepProcessor::ComputeInteractionLength(double previousTimeStep) 599 { 604 { 600 G4TrackManyList* mainList = fpTrackContainer 605 G4TrackManyList* mainList = fpTrackContainer->GetMainList(); 601 G4TrackManyList::iterator it = mainList ->be 606 G4TrackManyList::iterator it = mainList ->begin(); 602 G4TrackManyList::iterator end = mainList ->e 607 G4TrackManyList::iterator end = mainList ->end(); 603 608 604 SetPreviousStepTime(previousTimeStep); 609 SetPreviousStepTime(previousTimeStep); 605 610 606 fILTimeStep = DBL_MAX; 611 fILTimeStep = DBL_MAX; 607 612 608 for (; it != end; ) 613 for (; it != end; ) 609 { 614 { 610 G4Track * track = *it; 615 G4Track * track = *it; 611 616 612 #ifdef DEBUG 617 #ifdef DEBUG 613 G4cout << "*CIL* " << GetIT(track)->GetNam 618 G4cout << "*CIL* " << GetIT(track)->GetName() 614 << " ID: " << track->GetTrackID() 619 << " ID: " << track->GetTrackID() 615 << " at time : " << track->GetGlobalT 620 << " at time : " << track->GetGlobalTime() 616 << G4endl; 621 << G4endl; 617 #endif 622 #endif 618 623 619 ++it; 624 ++it; 620 DefinePhysicalStepLength(track); 625 DefinePhysicalStepLength(track); 621 626 622 ExtractILData(); 627 ExtractILData(); 623 } 628 } 624 629 625 return fILTimeStep; 630 return fILTimeStep; 626 } 631 } 627 632 628 //____________________________________________ 633 //_________________________________________________________________________ 629 634 630 void G4ITStepProcessor::ExtractILData() 635 void G4ITStepProcessor::ExtractILData() 631 { 636 { 632 assert(fpTrack != 0); 637 assert(fpTrack != 0); 633 if (fpTrack == nullptr) << 638 if (fpTrack == 0) 634 { 639 { 635 CleanProcessor(); 640 CleanProcessor(); 636 return; 641 return; 637 } 642 } 638 643 639 // assert(fpTrack->GetTrackStatus() != fStop 644 // assert(fpTrack->GetTrackStatus() != fStopAndKill); 640 645 641 if (fpTrack->GetTrackStatus() == fStopAndKil 646 if (fpTrack->GetTrackStatus() == fStopAndKill) 642 { 647 { 643 // trackContainer->GetMainList()->pop(fpTra 648 // trackContainer->GetMainList()->pop(fpTrack); 644 fpTrackingManager->EndTracking(fpTrack); 649 fpTrackingManager->EndTracking(fpTrack); 645 CleanProcessor(); 650 CleanProcessor(); 646 return; 651 return; 647 } 652 } 648 653 649 if (IsInf(fTimeStep)) 654 if (IsInf(fTimeStep)) 650 { 655 { 651 // G4cout << "!!!!!!!!!!!! IS INF " << tra 656 // G4cout << "!!!!!!!!!!!! IS INF " << track->GetTrackID() << G4endl; 652 CleanProcessor(); 657 CleanProcessor(); 653 return; 658 return; 654 } 659 } 655 if (fTimeStep < fILTimeStep - DBL_EPSILON) << 660 else if (fTimeStep < fILTimeStep - DBL_EPSILON) 656 { 661 { 657 // G4cout << "!!!!!!!!!!!! TEMPS DIFFERENT 662 // G4cout << "!!!!!!!!!!!! TEMPS DIFFERENTS " 658 // << track->GetTrackID() << G4endl; 663 // << track->GetTrackID() << G4endl; 659 664 660 fLeadingTracks.Reset(); 665 fLeadingTracks.Reset(); 661 666 662 fILTimeStep = GetInteractionTime(); 667 fILTimeStep = GetInteractionTime(); 663 668 664 // G4cout << "Will set leading step to true 669 // G4cout << "Will set leading step to true for time :" 665 // << SP -> GetInteractionTime() << 670 // << SP -> GetInteractionTime() << " against fTimeStep : " 666 // << G4BestUnit(fILTimeStep, "Time" 671 // << G4BestUnit(fILTimeStep, "Time") << " the trackID is : " << track->GetTrackID() 667 // << G4endl; 672 // << G4endl; 668 673 669 // GetIT(fpTrack)->GetTrackingInfo()->SetLe 674 // GetIT(fpTrack)->GetTrackingInfo()->SetLeadingStep(true); 670 fLeadingTracks.Push(fpTrack); 675 fLeadingTracks.Push(fpTrack); 671 } 676 } 672 else if(fabs(fILTimeStep - fTimeStep) < DBL_ 677 else if(fabs(fILTimeStep - fTimeStep) < DBL_EPSILON ) 673 { 678 { 674 679 675 // G4cout << "!!!!!!!!!!!! MEME TEMPS " << 680 // G4cout << "!!!!!!!!!!!! MEME TEMPS " << track->GetTrackID() << G4endl; 676 // G4cout << "Will set leading step to tru 681 // G4cout << "Will set leading step to true for time :" 677 // << SP -> GetInteractionTime() << 682 // << SP -> GetInteractionTime() << " against fTimeStep : " 678 // << fTimeStep << " the trackID is 683 // << fTimeStep << " the trackID is : " << track->GetTrackID()<< G4endl; 679 // GetIT(fpTrack)->GetTrackingInfo()->SetLe 684 // GetIT(fpTrack)->GetTrackingInfo()->SetLeadingStep(true); 680 fLeadingTracks.Push(fpTrack); 685 fLeadingTracks.Push(fpTrack); 681 } 686 } 682 // else 687 // else 683 // { 688 // { 684 // G4cout << "!!!! Bigger time : " << "c 689 // G4cout << "!!!! Bigger time : " << "currentTime : "<<fILTimeStep 685 // << " proposedTime : " << SP -> GetIntera 690 // << " proposedTime : " << SP -> GetInteractionTime() << G4endl; 686 // } 691 // } 687 692 688 CleanProcessor(); 693 CleanProcessor(); 689 } 694 } 690 695 691 //____________________________________________ 696 //___________________________________________________________________________ 692 697 693 void G4ITStepProcessor::DefinePhysicalStepLeng 698 void G4ITStepProcessor::DefinePhysicalStepLength(G4Track* track) 694 { 699 { 695 SetTrack(track); 700 SetTrack(track); 696 DoDefinePhysicalStepLength(); 701 DoDefinePhysicalStepLength(); 697 } 702 } 698 703 699 //____________________________________________ 704 //______________________________________________________________________________ 700 705 701 void G4ITStepProcessor::SetInitialStep() 706 void G4ITStepProcessor::SetInitialStep() 702 { 707 { 703 // DEBUG 708 // DEBUG 704 // G4cout << "SetInitialStep for : " << f 709 // G4cout << "SetInitialStep for : " << fpITrack-> GetName() << G4endl; 705 //__________________________________________ 710 //________________________________________________________ 706 // Initialize geometry 711 // Initialize geometry 707 712 708 if(!fpTrack->GetTouchableHandle()) 713 if(!fpTrack->GetTouchableHandle()) 709 { 714 { 710 //======================================== 715 //========================================================================== 711 // Create navigator state and Locate parti 716 // Create navigator state and Locate particle in geometry 712 //======================================== 717 //========================================================================== 713 /* 718 /* 714 fpNavigator->NewNavigatorStateAndLocate(f 719 fpNavigator->NewNavigatorStateAndLocate(fpTrack->GetPosition(), 715 fpTrack->GetMomentumDirection()); 720 fpTrack->GetMomentumDirection()); 716 721 717 fpITrack->GetTrackingInfo()-> 722 fpITrack->GetTrackingInfo()-> 718 SetNavigatorState(fpNavigator->GetNavigat 723 SetNavigatorState(fpNavigator->GetNavigatorState()); 719 */ 724 */ 720 fpNavigator->NewNavigatorState(); 725 fpNavigator->NewNavigatorState(); 721 fpITrack->GetTrackingInfo()->SetNavigatorS 726 fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator 722 ->GetNavigatorState()); 727 ->GetNavigatorState()); 723 728 724 G4ThreeVector direction = fpTrack->GetMome 729 G4ThreeVector direction = fpTrack->GetMomentumDirection(); 725 fpNavigator->LocateGlobalPointAndSetup(fpT 730 fpNavigator->LocateGlobalPointAndSetup(fpTrack->GetPosition(), 726 &di 731 &direction, 727 fal 732 false, 728 fal 733 false); // was false, false 729 734 730 fpState->fTouchableHandle = fpNavigator->C 735 fpState->fTouchableHandle = fpNavigator->CreateTouchableHistory(); 731 736 732 fpTrack->SetTouchableHandle(fpState->fTouc 737 fpTrack->SetTouchableHandle(fpState->fTouchableHandle); 733 fpTrack->SetNextTouchableHandle(fpState->f 738 fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle); 734 } 739 } 735 else 740 else 736 { 741 { 737 fpState->fTouchableHandle = fpTrack->GetTo 742 fpState->fTouchableHandle = fpTrack->GetTouchableHandle(); 738 fpTrack->SetNextTouchableHandle(fpState->f 743 fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle); 739 744 740 //======================================== 745 //========================================================================== 741 // Create OR set navigator state 746 // Create OR set navigator state 742 //======================================== 747 //========================================================================== 743 748 744 if(fpITrack->GetTrackingInfo()->GetNavigat << 749 if(fpITrack->GetTrackingInfo()->GetNavigatorState()) 745 { 750 { 746 fpNavigator->SetNavigatorState(fpITrack- 751 fpNavigator->SetNavigatorState(fpITrack->GetTrackingInfo() 747 ->GetNavigatorState()); 752 ->GetNavigatorState()); 748 fpITrack->GetTrackingInfo()->SetNavigato 753 fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator 749 ->GetNavigatorState()); 754 ->GetNavigatorState()); 750 } 755 } 751 else 756 else 752 { 757 { 753 fpNavigator->NewNavigatorState(*((G4Touc 758 fpNavigator->NewNavigatorState(*((G4TouchableHistory*) fpState 754 ->fTouchableHandle())); 759 ->fTouchableHandle())); 755 fpITrack->GetTrackingInfo()->SetNavigato 760 fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator 756 ->GetNavigatorState()); 761 ->GetNavigatorState()); 757 } 762 } 758 763 759 G4VPhysicalVolume* oldTopVolume = 764 G4VPhysicalVolume* oldTopVolume = 760 fpTrack->GetTouchableHandle()->GetVolu 765 fpTrack->GetTouchableHandle()->GetVolume(); 761 766 762 //======================================== 767 //========================================================================== 763 // Locate particle in geometry 768 // Locate particle in geometry 764 //======================================== 769 //========================================================================== 765 770 766 // G4VPhysicalVolume* newTopVolume = 771 // G4VPhysicalVolume* newTopVolume = 767 // fpNavigator->LocateGlobalPointAndSet 772 // fpNavigator->LocateGlobalPointAndSetup( 768 // fpTrack->GetPosition(), 773 // fpTrack->GetPosition(), 769 // &fpTrack->GetMomentumDirection() 774 // &fpTrack->GetMomentumDirection(), 770 // true, false); 775 // true, false); 771 776 772 G4VPhysicalVolume* newTopVolume = 777 G4VPhysicalVolume* newTopVolume = 773 fpNavigator->ResetHierarchyAndLocate(f 778 fpNavigator->ResetHierarchyAndLocate(fpTrack->GetPosition(), 774 f 779 fpTrack->GetMomentumDirection(), 775 * 780 *((G4TouchableHistory*) fpTrack 776 781 ->GetTouchableHandle()())); 777 782 778 if(newTopVolume != oldTopVolume || oldTopV 783 if(newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId() 779 == 1) 784 == 1) 780 { 785 { 781 fpState->fTouchableHandle = fpNavigator- 786 fpState->fTouchableHandle = fpNavigator->CreateTouchableHistory(); 782 fpTrack->SetTouchableHandle(fpState->fTo 787 fpTrack->SetTouchableHandle(fpState->fTouchableHandle); 783 fpTrack->SetNextTouchableHandle(fpState- 788 fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle); 784 } 789 } 785 } 790 } 786 791 787 fpCurrentVolume = fpState->fTouchableHandle- 792 fpCurrentVolume = fpState->fTouchableHandle->GetVolume(); 788 793 789 //__________________________________________ 794 //________________________________________________________ 790 // If the primary track has 'Suspend' or 'Po 795 // If the primary track has 'Suspend' or 'PostponeToNextEvent' state, 791 // set the track state to 'Alive'. 796 // set the track state to 'Alive'. 792 if((fpTrack->GetTrackStatus() == fSuspend) | 797 if((fpTrack->GetTrackStatus() == fSuspend) || (fpTrack->GetTrackStatus() 793 == fPostponeToNextEvent)) 798 == fPostponeToNextEvent)) 794 { 799 { 795 fpTrack->SetTrackStatus(fAlive); 800 fpTrack->SetTrackStatus(fAlive); 796 } 801 } 797 802 798 //HoangTRAN: it's better to check the status 803 //HoangTRAN: it's better to check the status here 799 if(fpTrack->GetTrackStatus() == fStopAndKill 804 if(fpTrack->GetTrackStatus() == fStopAndKill) return; 800 805 801 // If the primary track has 'zero' kinetic e 806 // If the primary track has 'zero' kinetic energy, set the track 802 // state to 'StopButAlive'. 807 // state to 'StopButAlive'. 803 if(fpTrack->GetKineticEnergy() <= 0.0) 808 if(fpTrack->GetKineticEnergy() <= 0.0) 804 { 809 { 805 fpTrack->SetTrackStatus(fStopButAlive); 810 fpTrack->SetTrackStatus(fStopButAlive); 806 } 811 } 807 //__________________________________________ 812 //________________________________________________________ 808 // Set vertex information of G4Track at here 813 // Set vertex information of G4Track at here 809 if(fpTrack->GetCurrentStepNumber() == 0) 814 if(fpTrack->GetCurrentStepNumber() == 0) 810 { 815 { 811 fpTrack->SetVertexPosition(fpTrack->GetPos 816 fpTrack->SetVertexPosition(fpTrack->GetPosition()); 812 fpTrack->SetVertexMomentumDirection(fpTrac 817 fpTrack->SetVertexMomentumDirection(fpTrack->GetMomentumDirection()); 813 fpTrack->SetVertexKineticEnergy(fpTrack->G 818 fpTrack->SetVertexKineticEnergy(fpTrack->GetKineticEnergy()); 814 fpTrack->SetLogicalVolumeAtVertex(fpTrack- 819 fpTrack->SetLogicalVolumeAtVertex(fpTrack->GetVolume()->GetLogicalVolume()); 815 } 820 } 816 //__________________________________________ 821 //________________________________________________________ 817 // If track is already outside the world bou 822 // If track is already outside the world boundary, kill it 818 if(fpCurrentVolume == nullptr) << 823 if(fpCurrentVolume == 0) 819 { 824 { 820 // If the track is a primary, stop process 825 // If the track is a primary, stop processing 821 if(fpTrack->GetParentID() == 0) 826 if(fpTrack->GetParentID() == 0) 822 { 827 { 823 G4cerr << "ERROR - G4ITStepProcessor::Se 828 G4cerr << "ERROR - G4ITStepProcessor::SetInitialStep()" << G4endl<< " Primary particle starting at - " 824 << fpTrack->GetPosition() 829 << fpTrack->GetPosition() 825 << " - is outside of the world volume." 830 << " - is outside of the world volume." << G4endl; 826 G4Exception("G4ITStepProcessor::SetIniti 831 G4Exception("G4ITStepProcessor::SetInitialStep()", "ITStepProcessor0011", 827 FatalException, "Primary vertex outs 832 FatalException, "Primary vertex outside of the world!"); 828 } 833 } 829 834 830 fpTrack->SetTrackStatus( fStopAndKill ); 835 fpTrack->SetTrackStatus( fStopAndKill ); 831 G4cout << "WARNING - G4ITStepProcessor::Se 836 G4cout << "WARNING - G4ITStepProcessor::SetInitialStep()" << G4endl 832 << " Initial track position is ou 837 << " Initial track position is outside world! - " 833 << fpTrack->GetPosition() << G4endl; 838 << fpTrack->GetPosition() << G4endl; 834 } 839 } 835 else 840 else 836 { 841 { 837 // Initial set up for attribues of 'Step' 842 // Initial set up for attribues of 'Step' 838 fpStep->InitializeStep( fpTrack ); 843 fpStep->InitializeStep( fpTrack ); 839 } 844 } 840 845 841 fpState->fStepStatus = fUndefined; 846 fpState->fStepStatus = fUndefined; 842 } 847 } 843 //____________________________________________ 848 //______________________________________________________________________________ 844 849 845 void G4ITStepProcessor::InitDefineStep() 850 void G4ITStepProcessor::InitDefineStep() 846 { 851 { 847 852 848 if(fpStep == nullptr) << 853 if(!fpStep) 849 { 854 { 850 // Create new Step and give it to the trac 855 // Create new Step and give it to the track 851 fpStep = new G4Step(); 856 fpStep = new G4Step(); 852 fpTrack->SetStep(fpStep); 857 fpTrack->SetStep(fpStep); 853 fpSecondary = fpStep->NewSecondaryVector() 858 fpSecondary = fpStep->NewSecondaryVector(); 854 859 855 // Create new state and set it in the trac 860 // Create new state and set it in the trackingInfo 856 fpState = new G4ITStepProcessorState(); 861 fpState = new G4ITStepProcessorState(); 857 fpITrack->GetTrackingInfo()->SetStepProces 862 fpITrack->GetTrackingInfo()->SetStepProcessorState((G4ITStepProcessorState_Lock*) fpState); 858 863 859 SetupMembers(); 864 SetupMembers(); 860 SetInitialStep(); 865 SetInitialStep(); 861 866 862 fpTrackingManager->StartTracking(fpTrack); 867 fpTrackingManager->StartTracking(fpTrack); 863 } 868 } 864 else 869 else 865 { 870 { 866 SetupMembers(); 871 SetupMembers(); 867 872 868 fpState->fPreviousStepSize = fpTrack->GetS 873 fpState->fPreviousStepSize = fpTrack->GetStepLength(); 869 /*** 874 /*** 870 // Send G4Step information to Hit/Dig if 875 // Send G4Step information to Hit/Dig if the volume is sensitive 871 fpCurrentVolume = fpStep->GetPreStepPoint 876 fpCurrentVolume = fpStep->GetPreStepPoint()->GetPhysicalVolume(); 872 StepControlFlag = fpStep->GetControlFlag 877 StepControlFlag = fpStep->GetControlFlag(); 873 if( fpCurrentVolume != 0 && StepControlFl 878 if( fpCurrentVolume != 0 && StepControlFlag != AvoidHitInvocation) 874 { 879 { 875 fpSensitive = fpStep->GetPreStepPoint()-> 880 fpSensitive = fpStep->GetPreStepPoint()-> 876 GetSensitiveDetector(); 881 GetSensitiveDetector(); 877 882 878 // if( fSensitive != 0 ) { 883 // if( fSensitive != 0 ) { 879 // fSensitive->Hit(fStep); 884 // fSensitive->Hit(fStep); 880 // } 885 // } 881 } 886 } 882 ***/ 887 ***/ 883 // Store last PostStepPoint to PreStepPoin 888 // Store last PostStepPoint to PreStepPoint, and swap current and next 884 // volume information of G4Track. Reset to 889 // volume information of G4Track. Reset total energy deposit in one Step. 885 fpStep->CopyPostToPreStepPoint(); 890 fpStep->CopyPostToPreStepPoint(); 886 fpStep->ResetTotalEnergyDeposit(); 891 fpStep->ResetTotalEnergyDeposit(); 887 892 888 //JA Set the volume before it is used (in 893 //JA Set the volume before it is used (in DefineStepLength() for User Limit) 889 fpCurrentVolume = fpStep->GetPreStepPoint( 894 fpCurrentVolume = fpStep->GetPreStepPoint()->GetPhysicalVolume(); 890 /* 895 /* 891 G4cout << G4endl; 896 G4cout << G4endl; 892 G4cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" < 897 G4cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl; 893 G4cout << "PreStepPoint Volume : " 898 G4cout << "PreStepPoint Volume : " 894 << fpCurrentVolume->GetName() << G4endl; 899 << fpCurrentVolume->GetName() << G4endl; 895 G4cout << "Track Touchable : " 900 G4cout << "Track Touchable : " 896 << fpTrack->GetTouchableHandle()->GetVolu 901 << fpTrack->GetTouchableHandle()->GetVolume()->GetName() << G4endl; 897 G4cout << "Track NextTouchable : " 902 G4cout << "Track NextTouchable : " 898 << fpTrack->GetNextTouchableHandle()->Get 903 << fpTrack->GetNextTouchableHandle()->GetVolume()->GetName() 899 << G4endl; 904 << G4endl; 900 */ 905 */ 901 // Reset the step's auxiliary points vecto 906 // Reset the step's auxiliary points vector pointer 902 fpStep->SetPointerToVectorOfAuxiliaryPoint << 907 fpStep->SetPointerToVectorOfAuxiliaryPoints(0); 903 908 904 // Switch next touchable in track to curre 909 // Switch next touchable in track to current one 905 fpTrack->SetTouchableHandle(fpTrack->GetNe 910 fpTrack->SetTouchableHandle(fpTrack->GetNextTouchableHandle()); 906 fpState->fTouchableHandle = fpTrack->GetTo 911 fpState->fTouchableHandle = fpTrack->GetTouchableHandle(); 907 fpTrack->SetNextTouchableHandle(fpState->f 912 fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle); 908 913 909 //! ADDED BACK 914 //! ADDED BACK 910 /* 915 /* 911 G4VPhysicalVolume* oldTopVolume = 916 G4VPhysicalVolume* oldTopVolume = 912 fpTrack->GetTouchableHandle()->GetVolume( 917 fpTrack->GetTouchableHandle()->GetVolume(); 913 fpNavigator->SetNavigatorState( 918 fpNavigator->SetNavigatorState( 914 fpITrack->GetTrackingInfo()->GetNavigator 919 fpITrack->GetTrackingInfo()->GetNavigatorState()); 915 920 916 G4VPhysicalVolume* newTopVolume = fpNavig 921 G4VPhysicalVolume* newTopVolume = fpNavigator->ResetHierarchyAndLocate( 917 fpTrack->GetPosition(), fpTrack->GetMomen 922 fpTrack->GetPosition(), fpTrack->GetMomentumDirection(), 918 *((G4TouchableHistory*) fpTrack->GetTouch 923 *((G4TouchableHistory*) fpTrack->GetTouchableHandle()())); 919 924 920 // G4VPhysicalVolume* newTopVolume= 925 // G4VPhysicalVolume* newTopVolume= 921 // fpNavigator->LocateGlobalPointAndS 926 // fpNavigator->LocateGlobalPointAndSetup(fpTrack->GetPosition(), 922 // 927 // &fpTrack->GetMomentumDirection(), 923 // 928 // true, false); 924 929 925 // G4cout << "New Top Volume : " < 930 // G4cout << "New Top Volume : " << newTopVolume->GetName() << G4endl; 926 931 927 if (newTopVolume != oldTopVolume || oldTo 932 if (newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId() 928 == 1) 933 == 1) 929 { 934 { 930 fpState->fTouchableHandle = fpNavigator-> 935 fpState->fTouchableHandle = fpNavigator->CreateTouchableHistory(); 931 fpTrack->SetTouchableHandle(fpState->fTou 936 fpTrack->SetTouchableHandle(fpState->fTouchableHandle); 932 fpTrack->SetNextTouchableHandle(fpState-> 937 fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle); 933 } 938 } 934 939 935 */ 940 */ 936 //! ADDED BACK 941 //! ADDED BACK 937 //======================================== 942 //========================================================================== 938 // Only reset navigator state + reset volu 943 // Only reset navigator state + reset volume hierarchy (internal) 939 // No need to relocate 944 // No need to relocate 940 //======================================== 945 //========================================================================== 941 fpNavigator->SetNavigatorState(fpITrack->G 946 fpNavigator->SetNavigatorState(fpITrack->GetTrackingInfo() 942 ->GetNavigatorState()); 947 ->GetNavigatorState()); 943 } 948 } 944 } 949 } 945 950 946 //____________________________________________ 951 //______________________________________________________________________________ 947 952 948 // ------------------------------------------- 953 // ------------------------------------------------------------------------ 949 // Compute Interaction Length 954 // Compute Interaction Length 950 // ------------------------------------------- 955 // ------------------------------------------------------------------------ 951 void G4ITStepProcessor::DoDefinePhysicalStepLe 956 void G4ITStepProcessor::DoDefinePhysicalStepLength() 952 { 957 { 953 958 954 InitDefineStep(); 959 InitDefineStep(); 955 960 956 #ifdef G4VERBOSE 961 #ifdef G4VERBOSE 957 // !!!!! Verbose 962 // !!!!! Verbose 958 if(fpVerbose != nullptr) fpVerbose->DPSLStar << 963 if(fpVerbose) fpVerbose->DPSLStarted(); 959 #endif 964 #endif 960 965 961 G4TrackStatus trackStatus = fpTrack->GetTrac 966 G4TrackStatus trackStatus = fpTrack->GetTrackStatus(); 962 967 963 if(trackStatus == fStopAndKill) 968 if(trackStatus == fStopAndKill) 964 { 969 { 965 return; 970 return; 966 } 971 } 967 972 968 if(trackStatus == fStopButAlive) 973 if(trackStatus == fStopButAlive) 969 { 974 { 970 fpITrack->GetTrackingInfo()->SetNavigatorS 975 fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator 971 ->GetNavigatorState()); 976 ->GetNavigatorState()); 972 fpNavigator->ResetNavigatorState(); 977 fpNavigator->ResetNavigatorState(); 973 return GetAtRestIL(); 978 return GetAtRestIL(); 974 } 979 } 975 980 976 // Find minimum Step length and correspondin 981 // Find minimum Step length and corresponding time 977 // demanded by active disc./cont. processes 982 // demanded by active disc./cont. processes 978 983 979 // ReSet the counter etc. 984 // ReSet the counter etc. 980 fpState->fPhysicalStep = DBL_MAX; // Initial 985 fpState->fPhysicalStep = DBL_MAX; // Initialize by a huge number 981 fPhysIntLength = DBL_MAX; // Initialize by a 986 fPhysIntLength = DBL_MAX; // Initialize by a huge number 982 987 983 G4double proposedTimeStep = DBL_MAX; << 988 double proposedTimeStep = DBL_MAX; 984 G4VProcess* processWithPostStepGivenByTimeSt << 989 G4VProcess* processWithPostStepGivenByTimeStep(0); 985 990 986 // GPIL for PostStep 991 // GPIL for PostStep 987 fPostStepDoItProcTriggered = fpProcessInfo-> 992 fPostStepDoItProcTriggered = fpProcessInfo->MAXofPostStepLoops; 988 fPostStepAtTimeDoItProcTriggered = fpProcess 993 fPostStepAtTimeDoItProcTriggered = fpProcessInfo->MAXofPostStepLoops; 989 994 990 // G4cout << "fpProcessInfo->MAXofPostStepL 995 // G4cout << "fpProcessInfo->MAXofPostStepLoops : " 991 // << fpProcessInfo->MAXofPostStepLo 996 // << fpProcessInfo->MAXofPostStepLoops 992 // << " mol : " << fpITrack -> GetNa 997 // << " mol : " << fpITrack -> GetName() 993 // << " id : " << fpTrack->GetTrackI 998 // << " id : " << fpTrack->GetTrackID() 994 // << G4endl; 999 // << G4endl; 995 1000 996 for(std::size_t np = 0; np < fpProcessInfo-> << 1001 for(size_t np = 0; np < fpProcessInfo->MAXofPostStepLoops; np++) 997 { 1002 { 998 fpCurrentProcess = dynamic_cast<G4VITProce 1003 fpCurrentProcess = dynamic_cast<G4VITProcess*>((*fpProcessInfo 999 ->fpPostStepGetPhysIntVector)[(G4int)n << 1004 ->fpPostStepGetPhysIntVector)[np]); 1000 if(fpCurrentProcess == nullptr) << 1005 if(fpCurrentProcess == 0) 1001 { 1006 { 1002 (fpState->fSelectedPostStepDoItVector)[ 1007 (fpState->fSelectedPostStepDoItVector)[np] = InActivated; 1003 continue; 1008 continue; 1004 } // NULL means the process is inactivate 1009 } // NULL means the process is inactivated by a user on fly. 1005 1010 1006 fCondition = NotForced; 1011 fCondition = NotForced; 1007 fpCurrentProcess->SetProcessState(fpTrack 1012 fpCurrentProcess->SetProcessState(fpTrackingInfo->GetProcessState(fpCurrentProcess 1008 ->GetProcessID())); 1013 ->GetProcessID())); 1009 1014 1010 // G4cout << "Is going to call : " 1015 // G4cout << "Is going to call : " 1011 // << fpCurrentProcess -> GetProce 1016 // << fpCurrentProcess -> GetProcessName() 1012 // << G4endl; 1017 // << G4endl; 1013 fPhysIntLength = fpCurrentProcess->PostSt 1018 fPhysIntLength = fpCurrentProcess->PostStepGPIL(*fpTrack, 1014 1019 fpState->fPreviousStepSize, 1015 1020 &fCondition); 1016 1021 1017 #ifdef G4VERBOSE 1022 #ifdef G4VERBOSE 1018 // !!!!! Verbose 1023 // !!!!! Verbose 1019 if(fpVerbose != nullptr) fpVerbose->DPSLP << 1024 if(fpVerbose) fpVerbose->DPSLPostStep(); 1020 #endif 1025 #endif 1021 1026 1022 fpCurrentProcess->ResetProcessState(); 1027 fpCurrentProcess->ResetProcessState(); 1023 //fpCurrentProcess->SetProcessState(0); 1028 //fpCurrentProcess->SetProcessState(0); 1024 1029 1025 switch(fCondition) 1030 switch(fCondition) 1026 { 1031 { 1027 case ExclusivelyForced: // Will need sp 1032 case ExclusivelyForced: // Will need special treatment 1028 (fpState->fSelectedPostStepDoItVector 1033 (fpState->fSelectedPostStepDoItVector)[np] = ExclusivelyForced; 1029 fpState->fStepStatus = fExclusivelyFo 1034 fpState->fStepStatus = fExclusivelyForcedProc; 1030 fpStep->GetPostStepPoint()->SetProces 1035 fpStep->GetPostStepPoint()->SetProcessDefinedStep(fpCurrentProcess); 1031 break; 1036 break; 1032 1037 1033 case Conditionally: 1038 case Conditionally: 1034 // (fpState->fSelectedPostStepD 1039 // (fpState->fSelectedPostStepDoItVector)[np] = Conditionally; 1035 G4Exception("G4ITStepProcessor::Defin 1040 G4Exception("G4ITStepProcessor::DefinePhysicalStepLength()", 1036 "ITStepProcessor0008", 1041 "ITStepProcessor0008", 1037 FatalException, 1042 FatalException, 1038 "This feature is no more 1043 "This feature is no more supported"); 1039 break; 1044 break; 1040 1045 1041 case Forced: 1046 case Forced: 1042 (fpState->fSelectedPostStepDoItVector 1047 (fpState->fSelectedPostStepDoItVector)[np] = Forced; 1043 break; 1048 break; 1044 1049 1045 case StronglyForced: 1050 case StronglyForced: 1046 (fpState->fSelectedPostStepDoItVector 1051 (fpState->fSelectedPostStepDoItVector)[np] = StronglyForced; 1047 break; 1052 break; 1048 1053 1049 default: 1054 default: 1050 (fpState->fSelectedPostStepDoItVector 1055 (fpState->fSelectedPostStepDoItVector)[np] = InActivated; 1051 break; 1056 break; 1052 } 1057 } 1053 1058 1054 if(fCondition == ExclusivelyForced) 1059 if(fCondition == ExclusivelyForced) 1055 { 1060 { 1056 for(std::size_t nrest = np + 1; nrest < << 1061 for(size_t nrest = np + 1; nrest < fpProcessInfo->MAXofPostStepLoops; 1057 ++nrest) << 1062 nrest++) 1058 { 1063 { 1059 (fpState->fSelectedPostStepDoItVector 1064 (fpState->fSelectedPostStepDoItVector)[nrest] = InActivated; 1060 } 1065 } 1061 return; // Please note the 'return' at 1066 return; // Please note the 'return' at here !!! 1062 } 1067 } 1063 << 1068 else 1064 if(fPhysIntLength < fpState->fPhysicalSte << 1065 { 1069 { 1066 // To avoid checking whether the proces << 1070 if(fPhysIntLength < fpState->fPhysicalStep) 1067 // proposing a time step, the returned << 1068 // negative (just for tagging) << 1069 if(fpCurrentProcess->ProposesTimeStep() << 1070 { 1071 { 1071 fPhysIntLength *= -1; << 1072 // To avoid checking whether the process is actually 1072 if(fPhysIntLength < proposedTimeStep) << 1073 // proposing a time step, the returned time steps are >> 1074 // negative (just for tagging) >> 1075 if(fpCurrentProcess->ProposesTimeStep()) 1073 { 1076 { 1074 proposedTimeStep = fPhysIntLength; << 1077 fPhysIntLength *= -1; 1075 fPostStepAtTimeDoItProcTriggered = << 1078 if(fPhysIntLength < proposedTimeStep) 1076 processWithPostStepGivenByTimeStep << 1079 { >> 1080 proposedTimeStep = fPhysIntLength; >> 1081 fPostStepAtTimeDoItProcTriggered = np; >> 1082 processWithPostStepGivenByTimeStep = fpCurrentProcess; >> 1083 } >> 1084 } >> 1085 else >> 1086 { >> 1087 fpState->fPhysicalStep = fPhysIntLength; >> 1088 fpState->fStepStatus = fPostStepDoItProc; >> 1089 fPostStepDoItProcTriggered = G4int(np); >> 1090 fpStep->GetPostStepPoint()->SetProcessDefinedStep(fpCurrentProcess); 1077 } 1091 } 1078 } << 1079 else << 1080 { << 1081 fpState->fPhysicalStep = fPhysIntLeng << 1082 fpState->fStepStatus = fPostStepDoItP << 1083 fPostStepDoItProcTriggered = G4int(np << 1084 fpStep->GetPostStepPoint()->SetProces << 1085 } 1092 } 1086 } 1093 } 1087 } 1094 } 1088 1095 1089 // GPIL for AlongStep 1096 // GPIL for AlongStep 1090 fpState->fProposedSafety = DBL_MAX; 1097 fpState->fProposedSafety = DBL_MAX; 1091 G4double safetyProposedToAndByProcess = fpS 1098 G4double safetyProposedToAndByProcess = fpState->fProposedSafety; 1092 1099 1093 for(std::size_t kp = 0; kp < fpProcessInfo- << 1100 for(size_t kp = 0; kp < fpProcessInfo->MAXofAlongStepLoops; kp++) 1094 { 1101 { 1095 fpCurrentProcess = dynamic_cast<G4VITProc 1102 fpCurrentProcess = dynamic_cast<G4VITProcess*>((*fpProcessInfo 1096 ->fpAlongStepGetPhysIntVector)[(G4int << 1103 ->fpAlongStepGetPhysIntVector)[kp]); 1097 if(fpCurrentProcess == nullptr) continue; << 1104 if(fpCurrentProcess == 0) continue; 1098 // NULL means the process is inactivated 1105 // NULL means the process is inactivated by a user on fly. 1099 1106 1100 fpCurrentProcess->SetProcessState( 1107 fpCurrentProcess->SetProcessState( 1101 fpTrackingInfo->GetProcessState(fpCur 1108 fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID())); 1102 fPhysIntLength = 1109 fPhysIntLength = 1103 fpCurrentProcess->AlongStepGPIL(*fpTr 1110 fpCurrentProcess->AlongStepGPIL(*fpTrack, 1104 fpSta 1111 fpState->fPreviousStepSize, 1105 fpSta 1112 fpState->fPhysicalStep, 1106 safet 1113 safetyProposedToAndByProcess, 1107 &fGPI 1114 &fGPILSelection); 1108 1115 1109 #ifdef G4VERBOSE 1116 #ifdef G4VERBOSE 1110 // !!!!! Verbose 1117 // !!!!! Verbose 1111 if(fpVerbose != nullptr) fpVerbose->DPSLA << 1118 if(fpVerbose) fpVerbose->DPSLAlongStep(); 1112 #endif 1119 #endif 1113 1120 1114 if(fPhysIntLength < fpState->fPhysicalSte 1121 if(fPhysIntLength < fpState->fPhysicalStep) 1115 { 1122 { 1116 fpState->fPhysicalStep = fPhysIntLength 1123 fpState->fPhysicalStep = fPhysIntLength; 1117 // Should save PS and TS in IT 1124 // Should save PS and TS in IT 1118 1125 1119 // Check if the process wants to be the 1126 // Check if the process wants to be the GPIL winner. For example, 1120 // multi-scattering proposes Step limit 1127 // multi-scattering proposes Step limit, but won't be the winner. 1121 if(fGPILSelection == CandidateForSelect 1128 if(fGPILSelection == CandidateForSelection) 1122 { 1129 { 1123 fpState->fStepStatus = fAlongStepDoIt 1130 fpState->fStepStatus = fAlongStepDoItProc; 1124 fpStep->GetPostStepPoint()->SetProces 1131 fpStep->GetPostStepPoint()->SetProcessDefinedStep(fpCurrentProcess); 1125 } 1132 } 1126 1133 1127 // Transportation is assumed to be the 1134 // Transportation is assumed to be the last process in the vector 1128 if(kp == fpProcessInfo->MAXofAlongStepL 1135 if(kp == fpProcessInfo->MAXofAlongStepLoops - 1) 1129 { 1136 { 1130 fpTransportation = dynamic_cast<G4ITT 1137 fpTransportation = dynamic_cast<G4ITTransportation*>(fpCurrentProcess); 1131 1138 1132 if(fpTransportation == nullptr) << 1139 if(!fpTransportation) 1133 { 1140 { 1134 G4ExceptionDescription exceptionDes 1141 G4ExceptionDescription exceptionDescription; 1135 exceptionDescription << "No transpo 1142 exceptionDescription << "No transportation process found "; 1136 G4Exception("G4ITStepProcessor::DoD 1143 G4Exception("G4ITStepProcessor::DoDefinePhysicalStepLength", 1137 "ITStepProcessor0009", 1144 "ITStepProcessor0009", 1138 FatalErrorInArgument, 1145 FatalErrorInArgument, 1139 exceptionDescription); 1146 exceptionDescription); 1140 } 1147 } 1141 1148 1142 fTimeStep = fpTransportation->GetInte 1149 fTimeStep = fpTransportation->GetInteractionTimeLeft(); 1143 1150 1144 if(fpTrack->GetNextVolume() != nullpt << 1151 if(fpTrack->GetNextVolume() != 0) fpState->fStepStatus = fGeomBoundary; 1145 else fpState->fStepStatus = fWorldBou 1152 else fpState->fStepStatus = fWorldBoundary; 1146 } 1153 } 1147 } 1154 } 1148 else 1155 else 1149 { 1156 { 1150 if(kp == fpProcessInfo->MAXofAlongStepL 1157 if(kp == fpProcessInfo->MAXofAlongStepLoops - 1) 1151 { 1158 { 1152 fpTransportation = dynamic_cast<G4ITT 1159 fpTransportation = dynamic_cast<G4ITTransportation*>(fpCurrentProcess); 1153 1160 1154 if(fpTransportation == nullptr) << 1161 if(!fpTransportation) 1155 { 1162 { 1156 G4ExceptionDescription exceptionDes 1163 G4ExceptionDescription exceptionDescription; 1157 exceptionDescription << "No transpo 1164 exceptionDescription << "No transportation process found "; 1158 G4Exception("G4ITStepProcessor::DoD 1165 G4Exception("G4ITStepProcessor::DoDefinePhysicalStepLength", 1159 "ITStepProcessor0010", 1166 "ITStepProcessor0010", 1160 FatalErrorInArgument, 1167 FatalErrorInArgument, 1161 exceptionDescription); 1168 exceptionDescription); 1162 } 1169 } 1163 1170 1164 fTimeStep = fpTransportation->GetInte 1171 fTimeStep = fpTransportation->GetInteractionTimeLeft(); 1165 } 1172 } 1166 } 1173 } 1167 1174 1168 // Handle PostStep processes sending back 1175 // Handle PostStep processes sending back time steps rather than space length 1169 if(proposedTimeStep < fTimeStep) 1176 if(proposedTimeStep < fTimeStep) 1170 { 1177 { 1171 if(fPostStepAtTimeDoItProcTriggered < f 1178 if(fPostStepAtTimeDoItProcTriggered < fpProcessInfo->MAXofPostStepLoops) 1172 { 1179 { 1173 if((fpState->fSelectedPostStepDoItVec 1180 if((fpState->fSelectedPostStepDoItVector)[fPostStepAtTimeDoItProcTriggered] == InActivated) 1174 { 1181 { 1175 (fpState->fSelectedPostStepDoItVect 1182 (fpState->fSelectedPostStepDoItVector)[fPostStepAtTimeDoItProcTriggered] = 1176 NotForced; 1183 NotForced; 1177 // (fpState->fSelectedPostStepDoItV 1184 // (fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] = InActivated; 1178 1185 1179 fpState->fStepStatus = fPostStepDoI 1186 fpState->fStepStatus = fPostStepDoItProc; 1180 fpStep->GetPostStepPoint()->SetProc 1187 fpStep->GetPostStepPoint()->SetProcessDefinedStep(processWithPostStepGivenByTimeStep); 1181 1188 1182 fTimeStep = proposedTimeStep; 1189 fTimeStep = proposedTimeStep; 1183 1190 1184 fpTransportation->ComputeStep(*fpTr 1191 fpTransportation->ComputeStep(*fpTrack, 1185 *fpSt 1192 *fpStep, 1186 fTime 1193 fTimeStep, 1187 fpSta 1194 fpState->fPhysicalStep); 1188 } 1195 } 1189 } 1196 } 1190 } 1197 } 1191 else 1198 else 1192 { 1199 { 1193 if(fPostStepDoItProcTriggered < fpProce 1200 if(fPostStepDoItProcTriggered < fpProcessInfo->MAXofPostStepLoops) 1194 { 1201 { 1195 if((fpState->fSelectedPostStepDoItVec 1202 if((fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] == InActivated) 1196 { 1203 { 1197 (fpState->fSelectedPostStepDoItVect 1204 (fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] = 1198 NotForced; 1205 NotForced; 1199 } 1206 } 1200 } 1207 } 1201 } 1208 } 1202 1209 1203 // fpCurrentProcess->SetProcessState(0); 1210 // fpCurrentProcess->SetProcessState(0); 1204 fpCurrentProcess->ResetProcessState(); 1211 fpCurrentProcess->ResetProcessState(); 1205 1212 1206 // Make sure to check the safety, even if 1213 // Make sure to check the safety, even if Step is not limited 1207 // by this process. 1214 // by this process. J. Apostolakis, June 20, 1998 1208 // 1215 // 1209 if(safetyProposedToAndByProcess < fpState 1216 if(safetyProposedToAndByProcess < fpState->fProposedSafety) 1210 // proposedSafety keeps the smallest valu 1217 // proposedSafety keeps the smallest value: 1211 fpState->fProposedSafety = safetyProposed 1218 fpState->fProposedSafety = safetyProposedToAndByProcess; 1212 else 1219 else 1213 // safetyProposedToAndByProcess always pr 1220 // safetyProposedToAndByProcess always proposes a valid safety: 1214 safetyProposedToAndByProcess = fpState->f 1221 safetyProposedToAndByProcess = fpState->fProposedSafety; 1215 1222 1216 } 1223 } 1217 1224 1218 fpITrack->GetTrackingInfo()->SetNavigatorSt 1225 fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator->GetNavigatorState()); 1219 fpNavigator->ResetNavigatorState(); 1226 fpNavigator->ResetNavigatorState(); 1220 } 1227 } 1221 1228 1222 //___________________________________________ 1229 //______________________________________________________________________________ 1223 1230