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