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