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 // 27 // 28 // 28 // 29 29 >> 30 #include "G4ios.hh" 30 #include "G4ParallelWorldProcess.hh" 31 #include "G4ParallelWorldProcess.hh" 31 << 32 #include "G4FieldTrackUpdator.hh" << 33 #include "G4Material.hh" << 34 #include "G4Navigator.hh" << 35 #include "G4ParallelWorldProcessStore.hh" 32 #include "G4ParallelWorldProcessStore.hh" >> 33 #include "G4Step.hh" >> 34 #include "G4StepPoint.hh" >> 35 #include "G4Navigator.hh" >> 36 #include "G4VTouchable.hh" >> 37 #include "G4VPhysicalVolume.hh" 36 #include "G4ParticleChange.hh" 38 #include "G4ParticleChange.hh" 37 #include "G4PathFinder.hh" 39 #include "G4PathFinder.hh" >> 40 #include "G4TransportationManager.hh" >> 41 #include "G4ParticleChange.hh" >> 42 #include "G4StepPoint.hh" >> 43 #include "G4FieldTrackUpdator.hh" >> 44 #include "G4Material.hh" 38 #include "G4ProductionCuts.hh" 45 #include "G4ProductionCuts.hh" 39 #include "G4ProductionCutsTable.hh" 46 #include "G4ProductionCutsTable.hh" >> 47 40 #include "G4SDManager.hh" 48 #include "G4SDManager.hh" 41 #include "G4Step.hh" << 42 #include "G4StepPoint.hh" << 43 #include "G4TransportationManager.hh" << 44 #include "G4TransportationProcessType.hh" << 45 #include "G4VPhysicalVolume.hh" << 46 #include "G4VSensitiveDetector.hh" 49 #include "G4VSensitiveDetector.hh" 47 #include "G4VTouchable.hh" << 48 #include "G4ios.hh" << 49 << 50 G4ThreadLocal G4Step* G4ParallelWorldProcess:: << 51 G4ThreadLocal G4int G4ParallelWorldProcess::nP << 52 G4ThreadLocal G4int G4ParallelWorldProcess::fN << 53 50 >> 51 G4ThreadLocal G4Step* G4ParallelWorldProcess::fpHyperStep = 0; >> 52 G4ThreadLocal G4int G4ParallelWorldProcess::nParallelWorlds = 0; >> 53 G4ThreadLocal G4int G4ParallelWorldProcess::fNavIDHyp = 0; 54 const G4Step* G4ParallelWorldProcess::GetHyper 54 const G4Step* G4ParallelWorldProcess::GetHyperStep() 55 { << 55 { return fpHyperStep; } 56 return fpHyperStep; << 57 } << 58 << 59 G4int G4ParallelWorldProcess::GetHypNavigatorI 56 G4int G4ParallelWorldProcess::GetHypNavigatorID() 60 { << 57 { return fNavIDHyp; } 61 return fNavIDHyp; << 62 } << 63 58 64 G4ParallelWorldProcess::G4ParallelWorldProcess << 59 G4ParallelWorldProcess:: 65 : G4VProcess(processName, theType), fFieldTr << 60 G4ParallelWorldProcess(const G4String& processName,G4ProcessType theType) >> 61 :G4VProcess(processName,theType),fGhostWorld(nullptr),fGhostNavigator(nullptr), >> 62 fNavigatorID(-1),fFieldTrack('0'),fGhostSafety(0.),fOnBoundary(false), >> 63 layeredMaterialFlag(false) 66 { 64 { 67 SetProcessSubType(PARALLEL_WORLD_PROCESS); << 65 SetProcessSubType(491); 68 if (fpHyperStep == nullptr) fpHyperStep = ne << 66 if(!fpHyperStep) fpHyperStep = new G4Step(); 69 iParallelWorld = ++nParallelWorlds; 67 iParallelWorld = ++nParallelWorlds; 70 68 71 pParticleChange = &aDummyParticleChange; 69 pParticleChange = &aDummyParticleChange; 72 70 73 fGhostStep = new G4Step(); 71 fGhostStep = new G4Step(); 74 fGhostPreStepPoint = fGhostStep->GetPreStepP 72 fGhostPreStepPoint = fGhostStep->GetPreStepPoint(); 75 fGhostPostStepPoint = fGhostStep->GetPostSte 73 fGhostPostStepPoint = fGhostStep->GetPostStepPoint(); 76 74 77 fTransportationManager = G4TransportationMan 75 fTransportationManager = G4TransportationManager::GetTransportationManager(); 78 fTransportationManager->GetNavigatorForTrack 76 fTransportationManager->GetNavigatorForTracking()->SetPushVerbosity(false); 79 fPathFinder = G4PathFinder::GetInstance(); 77 fPathFinder = G4PathFinder::GetInstance(); 80 78 81 fGhostWorldName = "** NotDefined **"; 79 fGhostWorldName = "** NotDefined **"; 82 G4ParallelWorldProcessStore::GetInstance()-> << 80 G4ParallelWorldProcessStore::GetInstance()->SetParallelWorld(this,processName); 83 81 84 if (verboseLevel > 0) { << 82 if (verboseLevel>0) >> 83 { 85 G4cout << GetProcessName() << " is created 84 G4cout << GetProcessName() << " is created " << G4endl; 86 } 85 } 87 } 86 } 88 87 89 G4ParallelWorldProcess::~G4ParallelWorldProces 88 G4ParallelWorldProcess::~G4ParallelWorldProcess() 90 { 89 { 91 delete fGhostStep; 90 delete fGhostStep; 92 nParallelWorlds--; 91 nParallelWorlds--; 93 if (nParallelWorlds == 0) { << 92 if(nParallelWorlds==0) >> 93 { 94 delete fpHyperStep; 94 delete fpHyperStep; 95 fpHyperStep = nullptr; << 95 fpHyperStep = 0; 96 } 96 } 97 } 97 } 98 98 99 void G4ParallelWorldProcess::SetParallelWorld( << 99 void G4ParallelWorldProcess:: >> 100 SetParallelWorld(G4String parallelWorldName) 100 { 101 { 101 fGhostWorldName = parallelWorldName; 102 fGhostWorldName = parallelWorldName; 102 fGhostWorld = fTransportationManager->GetPar 103 fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName); 103 fGhostNavigator = fTransportationManager->Ge 104 fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld); 104 fGhostNavigator->SetPushVerbosity(false); 105 fGhostNavigator->SetPushVerbosity(false); 105 } 106 } 106 107 107 void G4ParallelWorldProcess::SetParallelWorld( << 108 void G4ParallelWorldProcess:: >> 109 SetParallelWorld(G4VPhysicalVolume* parallelWorld) 108 { 110 { 109 fGhostWorldName = parallelWorld->GetName(); 111 fGhostWorldName = parallelWorld->GetName(); 110 fGhostWorld = parallelWorld; 112 fGhostWorld = parallelWorld; 111 fGhostNavigator = fTransportationManager->Ge 113 fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld); 112 fGhostNavigator->SetPushVerbosity(false); 114 fGhostNavigator->SetPushVerbosity(false); 113 } 115 } 114 116 115 void G4ParallelWorldProcess::StartTracking(G4T 117 void G4ParallelWorldProcess::StartTracking(G4Track* trk) 116 { 118 { 117 if (fGhostNavigator != nullptr) { << 119 if(fGhostNavigator) 118 fNavigatorID = fTransportationManager->Act << 120 { fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); } >> 121 else >> 122 { >> 123 G4Exception("G4ParallelWorldProcess::StartTracking", >> 124 "ProcParaWorld000",FatalException, >> 125 "G4ParallelWorldProcess is used for tracking without having a parallel world assigned"); 119 } 126 } 120 else { << 127 fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection()); 121 G4Exception( << 122 "G4ParallelWorldProcess::StartTracking", << 123 "G4ParallelWorldProcess is used for trac << 124 } << 125 fPathFinder->PrepareNewTrack(trk->GetPositio << 126 128 127 fOldGhostTouchable = fPathFinder->CreateTouc 129 fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID); 128 fGhostPreStepPoint->SetTouchableHandle(fOldG 130 fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable); 129 fNewGhostTouchable = fOldGhostTouchable; 131 fNewGhostTouchable = fOldGhostTouchable; 130 fGhostPostStepPoint->SetTouchableHandle(fNew 132 fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable); 131 133 132 fGhostSafety = -1.; 134 fGhostSafety = -1.; 133 fOnBoundary = false; 135 fOnBoundary = false; 134 fGhostPreStepPoint->SetStepStatus(fUndefined 136 fGhostPreStepPoint->SetStepStatus(fUndefined); 135 fGhostPostStepPoint->SetStepStatus(fUndefine 137 fGhostPostStepPoint->SetStepStatus(fUndefined); 136 138 >> 139 // G4VPhysicalVolume* thePhys = fNewGhostTouchable->GetVolume(); >> 140 // if(thePhys) >> 141 // { >> 142 // G4Material* ghostMaterial = thePhys->GetLogicalVolume()->GetMaterial(); >> 143 // if(ghostMaterial) >> 144 // { G4cout << " --- Material : " << ghostMaterial->GetName() << G4endl; } >> 145 // } >> 146 137 *(fpHyperStep->GetPostStepPoint()) = *(trk-> 147 *(fpHyperStep->GetPostStepPoint()) = *(trk->GetStep()->GetPostStepPoint()); 138 if (layeredMaterialFlag) { << 148 if(layeredMaterialFlag) >> 149 { 139 G4StepPoint* realWorldPostStepPoint = trk- 150 G4StepPoint* realWorldPostStepPoint = trk->GetStep()->GetPostStepPoint(); 140 SwitchMaterial(realWorldPostStepPoint); 151 SwitchMaterial(realWorldPostStepPoint); 141 G4StepPoint* realWorldPreStepPoint = trk-> << 152 G4StepPoint *realWorldPreStepPoint = trk->GetStep()->GetPreStepPoint(); 142 SwitchMaterial(realWorldPreStepPoint); 153 SwitchMaterial(realWorldPreStepPoint); 143 G4double velocity = trk->CalculateVelocity 154 G4double velocity = trk->CalculateVelocity(); 144 realWorldPostStepPoint->SetVelocity(veloci 155 realWorldPostStepPoint->SetVelocity(velocity); 145 realWorldPreStepPoint->SetVelocity(velocit 156 realWorldPreStepPoint->SetVelocity(velocity); 146 trk->SetVelocity(velocity); 157 trk->SetVelocity(velocity); 147 } 158 } 148 *(fpHyperStep->GetPreStepPoint()) = *(fpHype 159 *(fpHyperStep->GetPreStepPoint()) = *(fpHyperStep->GetPostStepPoint()); 149 } 160 } 150 161 151 G4double G4ParallelWorldProcess::AtRestGetPhys << 162 G4double 152 << 163 G4ParallelWorldProcess::AtRestGetPhysicalInteractionLength( 153 { << 164 const G4Track& /*track*/, 154 //++++++++++++++++++++++++++++++++++++++++++ << 165 G4ForceCondition* condition) 155 // At Rest must be registered ONLY for the p << 166 { 156 // process(es). << 167 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 157 //++++++++++++++++++++++++++++++++++++++++++ << 168 // At Rest must be registered ONLY for the particle which has other At Rest >> 169 // process(es). >> 170 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 158 *condition = Forced; 171 *condition = Forced; 159 return DBL_MAX; 172 return DBL_MAX; 160 } 173 } 161 174 162 G4VParticleChange* G4ParallelWorldProcess::AtR << 175 G4VParticleChange* G4ParallelWorldProcess::AtRestDoIt( 163 { << 176 const G4Track& track, 164 //++++++++++++++++++++++++++++++++++++++++++ << 177 const G4Step& step) 165 // At Rest must be registered ONLY for the p << 178 { 166 // process(es). << 179 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 167 //++++++++++++++++++++++++++++++++++++++++++ << 180 // At Rest must be registered ONLY for the particle which has other At Rest >> 181 // process(es). >> 182 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 168 fOldGhostTouchable = fGhostPostStepPoint->Ge 183 fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle(); 169 G4VSensitiveDetector* aSD = nullptr; << 184 G4VSensitiveDetector* aSD = 0; 170 if (fOldGhostTouchable->GetVolume() != nullp << 185 if(fOldGhostTouchable->GetVolume()) 171 aSD = fOldGhostTouchable->GetVolume()->Get << 186 { aSD = fOldGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector(); } 172 } << 173 fOnBoundary = false; 187 fOnBoundary = false; 174 if (aSD != nullptr) { << 188 if(aSD) >> 189 { 175 CopyStep(step); 190 CopyStep(step); 176 fGhostPreStepPoint->SetSensitiveDetector(a 191 fGhostPreStepPoint->SetSensitiveDetector(aSD); 177 192 178 fNewGhostTouchable = fOldGhostTouchable; 193 fNewGhostTouchable = fOldGhostTouchable; 179 << 194 180 fGhostPreStepPoint->SetTouchableHandle(fOl 195 fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable); 181 fGhostPostStepPoint->SetTouchableHandle(fN 196 fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable); 182 if (fNewGhostTouchable->GetVolume() != nul << 197 if(fNewGhostTouchable->GetVolume()) >> 198 { 183 fGhostPostStepPoint->SetSensitiveDetecto 199 fGhostPostStepPoint->SetSensitiveDetector( 184 fNewGhostTouchable->GetVolume()->GetLo 200 fNewGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector()); 185 } 201 } 186 else { << 202 else 187 fGhostPostStepPoint->SetSensitiveDetecto << 203 { fGhostPostStepPoint->SetSensitiveDetector(0); } 188 } << 189 204 190 aSD->Hit(fGhostStep); 205 aSD->Hit(fGhostStep); 191 } 206 } 192 207 193 pParticleChange->Initialize(track); 208 pParticleChange->Initialize(track); 194 return pParticleChange; 209 return pParticleChange; 195 } 210 } 196 211 197 G4double G4ParallelWorldProcess::PostStepGetPh << 212 G4double 198 << 213 G4ParallelWorldProcess::PostStepGetPhysicalInteractionLength( 199 << 214 const G4Track& /*track*/, >> 215 G4double /*previousStepSize*/, >> 216 G4ForceCondition* condition) 200 { 217 { 201 *condition = StronglyForced; 218 *condition = StronglyForced; 202 return DBL_MAX; 219 return DBL_MAX; 203 } 220 } 204 221 205 G4VParticleChange* G4ParallelWorldProcess::Pos << 222 G4VParticleChange* G4ParallelWorldProcess::PostStepDoIt( 206 { << 223 const G4Track& track, >> 224 const G4Step& step) >> 225 { 207 fOldGhostTouchable = fGhostPostStepPoint->Ge 226 fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle(); 208 G4VSensitiveDetector* aSD = nullptr; << 227 G4VSensitiveDetector* aSD = 0; 209 if (fOldGhostTouchable->GetVolume() != nullp << 228 if(fOldGhostTouchable->GetVolume()) 210 aSD = fOldGhostTouchable->GetVolume()->Get << 229 { aSD = fOldGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector(); } 211 } << 212 CopyStep(step); 230 CopyStep(step); 213 fGhostPreStepPoint->SetSensitiveDetector(aSD 231 fGhostPreStepPoint->SetSensitiveDetector(aSD); 214 232 215 if (fOnBoundary) { << 233 if(fOnBoundary) >> 234 { 216 fNewGhostTouchable = fPathFinder->CreateTo 235 fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID); 217 } 236 } 218 else { << 237 else >> 238 { 219 fNewGhostTouchable = fOldGhostTouchable; 239 fNewGhostTouchable = fOldGhostTouchable; 220 } 240 } 221 << 241 222 fGhostPreStepPoint->SetTouchableHandle(fOldG 242 fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable); 223 fGhostPostStepPoint->SetTouchableHandle(fNew 243 fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable); 224 244 225 if (fNewGhostTouchable->GetVolume() != nullp << 245 if(fNewGhostTouchable->GetVolume()) >> 246 { 226 fGhostPostStepPoint->SetSensitiveDetector( 247 fGhostPostStepPoint->SetSensitiveDetector( 227 fNewGhostTouchable->GetVolume()->GetLogi 248 fNewGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector()); 228 } 249 } 229 else { << 250 else 230 fGhostPostStepPoint->SetSensitiveDetector( << 251 { fGhostPostStepPoint->SetSensitiveDetector(0); } 231 } << 232 252 233 G4VSensitiveDetector* sd = fGhostPreStepPoin 253 G4VSensitiveDetector* sd = fGhostPreStepPoint->GetSensitiveDetector(); 234 if (sd != nullptr) { << 254 if(sd) >> 255 { 235 sd->Hit(fGhostStep); 256 sd->Hit(fGhostStep); 236 } 257 } 237 258 238 pParticleChange->Initialize(track); << 259 pParticleChange->Initialize(track); 239 if (layeredMaterialFlag) { << 260 if(layeredMaterialFlag) 240 G4StepPoint* realWorldPostStepPoint = ((G4 << 261 { >> 262 G4StepPoint* realWorldPostStepPoint = >> 263 ((G4Step*)(track.GetStep()))->GetPostStepPoint(); 241 SwitchMaterial(realWorldPostStepPoint); 264 SwitchMaterial(realWorldPostStepPoint); 242 } 265 } 243 return pParticleChange; 266 return pParticleChange; 244 } 267 } 245 268 246 G4double G4ParallelWorldProcess::AlongStepGetP << 269 G4double G4ParallelWorldProcess::AlongStepGetPhysicalInteractionLength( 247 << 270 const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, 248 << 271 G4double& proposedSafety, G4GPILSelection* selection) 249 << 272 { 250 << 273 static G4ThreadLocal G4FieldTrack *endTrack_G4MT_TLS_ = 0 ; if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ = new G4FieldTrack ('0') ; G4FieldTrack &endTrack = *endTrack_G4MT_TLS_; 251 { << 274 //static ELimited eLimited; 252 static G4ThreadLocal G4FieldTrack* endTrack_ << 253 if (endTrack_G4MT_TLS_ == nullptr) endTrack_ << 254 G4FieldTrack& endTrack = *endTrack_G4MT_TLS_ << 255 // static ELimited eLimited; << 256 ELimited eLimited; 275 ELimited eLimited; 257 ELimited eLim = kUndefLimited; 276 ELimited eLim = kUndefLimited; 258 << 277 259 *selection = NotCandidateForSelection; 278 *selection = NotCandidateForSelection; 260 G4double returnedStep = DBL_MAX; 279 G4double returnedStep = DBL_MAX; 261 280 262 if (previousStepSize > 0.) { << 281 if (previousStepSize > 0.) 263 fGhostSafety -= previousStepSize; << 282 { fGhostSafety -= previousStepSize; } 264 } << 265 if (fGhostSafety < 0.) fGhostSafety = 0.0; 283 if (fGhostSafety < 0.) fGhostSafety = 0.0; 266 << 284 267 if (currentMinimumStep <= fGhostSafety && cu << 285 if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.) >> 286 { 268 // I have no chance to limit 287 // I have no chance to limit 269 returnedStep = currentMinimumStep; 288 returnedStep = currentMinimumStep; 270 fOnBoundary = false; 289 fOnBoundary = false; 271 proposedSafety = fGhostSafety - currentMin 290 proposedSafety = fGhostSafety - currentMinimumStep; 272 eLim = kDoNot; 291 eLim = kDoNot; 273 } 292 } 274 else { << 293 else 275 G4FieldTrackUpdator::Update(&fFieldTrack, << 294 { 276 << 295 G4FieldTrackUpdator::Update(&fFieldTrack,&track); 277 #ifdef G4DEBUG_PARALLEL_WORLD_PROCESS << 296 278 if (verboseLevel > 0) { << 297 #ifdef G4DEBUG_PARALLEL_WORLD_PROCESS 279 int localVerb = verboseLevel - 1; << 298 if( verboseLevel > 0 ){ 280 << 299 int localVerb = verboseLevel-1; 281 if (localVerb == 1) { << 300 282 G4cout << " Pll Wrl proc::AlongStepGP << 301 if( localVerb == 1 ) { 283 } << 302 G4cout << " Pll Wrl proc::AlongStepGPIL " << this->GetProcessName() << G4endl; 284 else if (localVerb > 1) { << 303 }else if( localVerb > 1 ) { 285 G4cout << "--------------------------- << 304 G4cout << "----------------------------------------------" << G4endl; 286 G4cout << " ParallelWorldProcess: fiel << 305 G4cout << " ParallelWorldProcess: field Track set to : " << G4endl; 287 G4cout << "--------------------------- << 306 G4cout << "----------------------------------------------" << G4endl; 288 G4cout << fFieldTrack << G4endl; << 307 G4cout << fFieldTrack << G4endl; 289 G4cout << "--------------------------- << 308 G4cout << "----------------------------------------------" << G4endl; 290 } << 309 } 291 } 310 } 292 #endif 311 #endif 293 << 312 294 returnedStep = fPathFinder->ComputeStep(fF << 313 returnedStep 295 tr << 314 = fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID, 296 en << 315 track.GetCurrentStepNumber(),fGhostSafety,eLimited, 297 if (eLimited == kDoNot) { << 316 endTrack,track.GetVolume()); >> 317 if(eLimited == kDoNot) >> 318 { 298 fOnBoundary = false; 319 fOnBoundary = false; 299 fGhostSafety = fGhostNavigator->ComputeS << 320 fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition()); 300 } 321 } 301 else { << 322 else >> 323 { 302 fOnBoundary = true; 324 fOnBoundary = true; 303 // fGhostSafetyEnd = 0.0; // At end-p 325 // fGhostSafetyEnd = 0.0; // At end-point of expected step only 304 } 326 } 305 proposedSafety = fGhostSafety; 327 proposedSafety = fGhostSafety; 306 if (eLimited == kUnique || eLimited == kSh << 328 if(eLimited == kUnique || eLimited == kSharedOther) { 307 *selection = CandidateForSelection; << 329 *selection = CandidateForSelection; 308 } 330 } 309 else if (eLimited == kSharedTransport) { << 331 else if (eLimited == kSharedTransport) { 310 returnedStep *= (1.0 + 1.0e-9); << 332 returnedStep *= (1.0 + 1.0e-9); 311 } 333 } 312 eLim = eLimited; 334 eLim = eLimited; 313 } 335 } 314 336 315 if (iParallelWorld == nParallelWorlds) fNavI << 337 if(iParallelWorld==nParallelWorlds) fNavIDHyp = 0; 316 if (eLim == kUnique || eLim == kSharedOther) << 338 if(eLim == kUnique || eLim == kSharedOther) fNavIDHyp = fNavigatorID; 317 return returnedStep; 339 return returnedStep; 318 } 340 } 319 341 320 G4VParticleChange* G4ParallelWorldProcess::Alo << 342 G4VParticleChange* G4ParallelWorldProcess::AlongStepDoIt( >> 343 const G4Track& track, const G4Step& ) 321 { 344 { 322 pParticleChange->Initialize(track); 345 pParticleChange->Initialize(track); 323 return pParticleChange; << 346 return pParticleChange; 324 } 347 } 325 348 326 void G4ParallelWorldProcess::CopyStep(const G4 << 349 void G4ParallelWorldProcess::CopyStep(const G4Step & step) 327 { 350 { 328 G4StepStatus prevStat = fGhostPostStepPoint- 351 G4StepStatus prevStat = fGhostPostStepPoint->GetStepStatus(); 329 352 330 fGhostStep->SetTrack(step.GetTrack()); 353 fGhostStep->SetTrack(step.GetTrack()); 331 fGhostStep->SetStepLength(step.GetStepLength 354 fGhostStep->SetStepLength(step.GetStepLength()); 332 fGhostStep->SetTotalEnergyDeposit(step.GetTo 355 fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit()); 333 fGhostStep->SetNonIonizingEnergyDeposit(step 356 fGhostStep->SetNonIonizingEnergyDeposit(step.GetNonIonizingEnergyDeposit()); 334 fGhostStep->SetControlFlag(step.GetControlFl 357 fGhostStep->SetControlFlag(step.GetControlFlag()); 335 fGhostStep->SetSecondary((const_cast<G4Step& 358 fGhostStep->SetSecondary((const_cast<G4Step&>(step)).GetfSecondary()); 336 359 337 *fGhostPreStepPoint = *(step.GetPreStepPoint 360 *fGhostPreStepPoint = *(step.GetPreStepPoint()); 338 *fGhostPostStepPoint = *(step.GetPostStepPoi 361 *fGhostPostStepPoint = *(step.GetPostStepPoint()); 339 362 340 fGhostPreStepPoint->SetStepStatus(prevStat); 363 fGhostPreStepPoint->SetStepStatus(prevStat); 341 if (fOnBoundary) { << 364 if(fOnBoundary) 342 fGhostPostStepPoint->SetStepStatus(fGeomBo << 365 { fGhostPostStepPoint->SetStepStatus(fGeomBoundary); } 343 } << 366 else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary) 344 else if (fGhostPostStepPoint->GetStepStatus( << 367 { fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); } 345 fGhostPostStepPoint->SetStepStatus(fPostSt << 346 } << 347 368 348 if (iParallelWorld == 1) { << 369 if(iParallelWorld==1) >> 370 { 349 G4StepStatus prevStatHyp = fpHyperStep->Ge 371 G4StepStatus prevStatHyp = fpHyperStep->GetPostStepPoint()->GetStepStatus(); 350 372 351 fpHyperStep->SetTrack(step.GetTrack()); 373 fpHyperStep->SetTrack(step.GetTrack()); 352 fpHyperStep->SetStepLength(step.GetStepLen 374 fpHyperStep->SetStepLength(step.GetStepLength()); 353 fpHyperStep->SetTotalEnergyDeposit(step.Ge 375 fpHyperStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit()); 354 fpHyperStep->SetNonIonizingEnergyDeposit(s 376 fpHyperStep->SetNonIonizingEnergyDeposit(step.GetNonIonizingEnergyDeposit()); 355 fpHyperStep->SetControlFlag(step.GetContro 377 fpHyperStep->SetControlFlag(step.GetControlFlag()); 356 378 357 *(fpHyperStep->GetPreStepPoint()) = *(fpHy 379 *(fpHyperStep->GetPreStepPoint()) = *(fpHyperStep->GetPostStepPoint()); 358 *(fpHyperStep->GetPostStepPoint()) = *(ste 380 *(fpHyperStep->GetPostStepPoint()) = *(step.GetPostStepPoint()); 359 << 381 360 fpHyperStep->GetPreStepPoint()->SetStepSta 382 fpHyperStep->GetPreStepPoint()->SetStepStatus(prevStatHyp); 361 } 383 } 362 384 363 if (fOnBoundary) { << 385 if(fOnBoundary) 364 fpHyperStep->GetPostStepPoint()->SetStepSt << 386 { fpHyperStep->GetPostStepPoint()->SetStepStatus(fGeomBoundary); } 365 } << 366 } 387 } 367 388 368 void G4ParallelWorldProcess::SwitchMaterial(G4 389 void G4ParallelWorldProcess::SwitchMaterial(G4StepPoint* realWorldStepPoint) 369 { 390 { 370 if (realWorldStepPoint->GetStepStatus() == f << 391 if(realWorldStepPoint->GetStepStatus()==fWorldBoundary) return; 371 G4VPhysicalVolume* thePhys = fNewGhostToucha 392 G4VPhysicalVolume* thePhys = fNewGhostTouchable->GetVolume(); 372 if (thePhys != nullptr) { << 393 if(thePhys) >> 394 { 373 G4Material* ghostMaterial = thePhys->GetLo 395 G4Material* ghostMaterial = thePhys->GetLogicalVolume()->GetMaterial(); 374 if (ghostMaterial != nullptr) { << 396 if(ghostMaterial) >> 397 { 375 G4Region* ghostRegion = thePhys->GetLogi 398 G4Region* ghostRegion = thePhys->GetLogicalVolume()->GetRegion(); 376 G4ProductionCuts* prodCuts = realWorldSt << 399 G4ProductionCuts* prodCuts = 377 if (ghostRegion != nullptr) { << 400 realWorldStepPoint->GetMaterialCutsCouple()->GetProductionCuts(); >> 401 if(ghostRegion) >> 402 { 378 G4ProductionCuts* ghostProdCuts = ghos 403 G4ProductionCuts* ghostProdCuts = ghostRegion->GetProductionCuts(); 379 if (ghostProdCuts != nullptr) prodCuts << 404 if(ghostProdCuts) prodCuts = ghostProdCuts; 380 } 405 } 381 const G4MaterialCutsCouple* ghostMCCoupl 406 const G4MaterialCutsCouple* ghostMCCouple = 382 G4ProductionCutsTable::GetProductionCu << 407 G4ProductionCutsTable::GetProductionCutsTable() 383 << 408 ->GetMaterialCutsCouple(ghostMaterial,prodCuts); 384 if (ghostMCCouple != nullptr) { << 409 if(ghostMCCouple) >> 410 { 385 realWorldStepPoint->SetMaterial(ghostM 411 realWorldStepPoint->SetMaterial(ghostMaterial); 386 realWorldStepPoint->SetMaterialCutsCou 412 realWorldStepPoint->SetMaterialCutsCouple(ghostMCCouple); 387 *(fpHyperStep->GetPostStepPoint()) = * 413 *(fpHyperStep->GetPostStepPoint()) = *(fGhostPostStepPoint); 388 fpHyperStep->GetPostStepPoint()->SetMa 414 fpHyperStep->GetPostStepPoint()->SetMaterial(ghostMaterial); 389 fpHyperStep->GetPostStepPoint()->SetMa 415 fpHyperStep->GetPostStepPoint()->SetMaterialCutsCouple(ghostMCCouple); 390 } 416 } 391 else { << 417 else 392 G4cout << "!!! MaterialCutsCouple is n << 418 { 393 << G4endl << " Material in r << 419 G4cout << "!!! MaterialCutsCouple is not found for " 394 << realWorldStepPoint->GetMater << 420 << ghostMaterial->GetName() << "." << G4endl >> 421 << " Material in real world (" >> 422 << realWorldStepPoint->GetMaterial()->GetName() >> 423 << ") is used." << G4endl; 395 } 424 } 396 } 425 } 397 } 426 } 398 } 427 } 399 428 400 G4bool G4ParallelWorldProcess::IsAtRestRequire 429 G4bool G4ParallelWorldProcess::IsAtRestRequired(G4ParticleDefinition* partDef) 401 { 430 { 402 G4int pdgCode = partDef->GetPDGEncoding(); 431 G4int pdgCode = partDef->GetPDGEncoding(); 403 if (pdgCode == 0) { << 432 if(pdgCode==0) >> 433 { 404 G4String partName = partDef->GetParticleNa 434 G4String partName = partDef->GetParticleName(); 405 if (partName == "geantino") return false; << 435 if(partName=="opticalphoton") return false; 406 if (partName == "chargedgeantino") return << 436 if(partName=="geantino") return false; 407 } << 437 if(partName=="chargedgeantino") return false; 408 else { << 438 } 409 if (pdgCode == 11 || pdgCode == 2212) retu << 439 else 410 pdgCode = std::abs(pdgCode); << 440 { 411 if (pdgCode == 22) return false; // gamma << 441 if(pdgCode==22) return false; // gamma 412 if (pdgCode == 12 || pdgCode == 14 || pdgC << 442 if(pdgCode==11) return false; // electron >> 443 if(pdgCode==2212) return false; // proton >> 444 if(pdgCode==-12) return false; // anti_nu_e >> 445 if(pdgCode==12) return false; // nu_e >> 446 if(pdgCode==-14) return false; // anti_nu_mu >> 447 if(pdgCode==14) return false; // nu_mu >> 448 if(pdgCode==-16) return false; // anti_nu_tau >> 449 if(pdgCode==16) return false; // nu_tau 413 } 450 } 414 return true; 451 return true; 415 } 452 } >> 453 416 454