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 // G4ImportanceProcess << 27 // 26 // 28 // Author: Michael Dressel, 2002 << 27 // $Id: G4ImportanceProcess.cc 88804 2015-03-10 17:12:21Z gcosmo $ 29 // ------------------------------------------- << 28 // >> 29 // ---------------------------------------------------------------------- >> 30 // GEANT 4 class source file >> 31 // >> 32 // G4ImportanceProcess.cc >> 33 // >> 34 // ---------------------------------------------------------------------- 30 35 31 #include "G4ImportanceProcess.hh" 36 #include "G4ImportanceProcess.hh" 32 #include "G4VImportanceAlgorithm.hh" 37 #include "G4VImportanceAlgorithm.hh" 33 #include "G4GeometryCell.hh" 38 #include "G4GeometryCell.hh" 34 #include "G4SamplingPostStepAction.hh" 39 #include "G4SamplingPostStepAction.hh" 35 #include "G4VTrackTerminator.hh" 40 #include "G4VTrackTerminator.hh" 36 #include "G4VIStore.hh" 41 #include "G4VIStore.hh" 37 42 38 #include "G4Step.hh" 43 #include "G4Step.hh" 39 #include "G4Navigator.hh" 44 #include "G4Navigator.hh" 40 #include "G4VTouchable.hh" 45 #include "G4VTouchable.hh" 41 #include "G4VPhysicalVolume.hh" 46 #include "G4VPhysicalVolume.hh" 42 #include "G4ParticleChange.hh" 47 #include "G4ParticleChange.hh" 43 #include "G4PathFinder.hh" 48 #include "G4PathFinder.hh" 44 #include "G4TransportationManager.hh" 49 #include "G4TransportationManager.hh" 45 #include "G4StepPoint.hh" 50 #include "G4StepPoint.hh" 46 #include "G4FieldTrackUpdator.hh" 51 #include "G4FieldTrackUpdator.hh" 47 52 48 53 49 G4ImportanceProcess:: 54 G4ImportanceProcess:: 50 G4ImportanceProcess(const G4VImportanceAlgorit 55 G4ImportanceProcess(const G4VImportanceAlgorithm &aImportanceAlgorithm, 51 const G4VIStore &aIstore, << 56 const G4VIStore &aIstore, 52 const G4VTrackTerminator * << 57 const G4VTrackTerminator *TrackTerminator, 53 const G4String &aName, G4b << 58 const G4String &aName, G4bool para) 54 : G4VProcess(aName, fParallel), << 59 : G4VProcess(aName), 55 fParticleChange(new G4ParticleChange), 60 fParticleChange(new G4ParticleChange), 56 fImportanceAlgorithm(aImportanceAlgorithm), 61 fImportanceAlgorithm(aImportanceAlgorithm), 57 fIStore(aIstore), 62 fIStore(aIstore), 58 fParaflag(para) << 63 fPostStepAction(0), >> 64 fGhostWorldName("NoParallelWorld"),fGhostWorld(0), >> 65 fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0'), >> 66 fParaflag(para), fEndTrack('0'), feLimited(kDoNot) 59 { 67 { 60 G4cout << "### G4ImportanceProcess:: Creatin << 68 G4cout << G4endl << G4endl << G4endl; 61 if (TrackTerminator != nullptr) << 69 G4cout << "G4ImportanceProcess:: Creating " << G4endl; >> 70 if (TrackTerminator) 62 { 71 { 63 fPostStepAction = new G4SamplingPostStepAc 72 fPostStepAction = new G4SamplingPostStepAction(*TrackTerminator); 64 } 73 } 65 else 74 else 66 { 75 { 67 fPostStepAction = new G4SamplingPostStepAc 76 fPostStepAction = new G4SamplingPostStepAction(*this); 68 } 77 } 69 if (fParticleChange == nullptr) << 78 if (!fParticleChange) 70 { 79 { 71 G4Exception("G4ImportanceProcess::G4Import 80 G4Exception("G4ImportanceProcess::G4ImportanceProcess()", 72 "FatalError", FatalException, 81 "FatalError", FatalException, 73 "Failed allocation of G4Partic 82 "Failed allocation of G4ParticleChange !"); 74 } 83 } 75 G4VProcess::pParticleChange = fParticleChang 84 G4VProcess::pParticleChange = fParticleChange; 76 85 77 86 78 fGhostStep = new G4Step(); 87 fGhostStep = new G4Step(); 79 fGhostPreStepPoint = fGhostStep->GetPreStepP 88 fGhostPreStepPoint = fGhostStep->GetPreStepPoint(); 80 fGhostPostStepPoint = fGhostStep->GetPostSte 89 fGhostPostStepPoint = fGhostStep->GetPostStepPoint(); 81 90 82 fTransportationManager = G4TransportationMan 91 fTransportationManager = G4TransportationManager::GetTransportationManager(); 83 fPathFinder = G4PathFinder::GetInstance(); 92 fPathFinder = G4PathFinder::GetInstance(); 84 93 85 if (verboseLevel>0) 94 if (verboseLevel>0) 86 { 95 { 87 G4cout << GetProcessName() << " is created 96 G4cout << GetProcessName() << " is created " << G4endl; 88 } 97 } 89 98 90 G4cout << "G4ImportanceProcess:: importance 99 G4cout << "G4ImportanceProcess:: importance process paraflag is: " << fParaflag << G4endl; 91 100 92 } 101 } 93 102 94 G4ImportanceProcess::~G4ImportanceProcess() 103 G4ImportanceProcess::~G4ImportanceProcess() 95 { 104 { >> 105 96 delete fPostStepAction; 106 delete fPostStepAction; 97 delete fParticleChange; 107 delete fParticleChange; >> 108 // delete fGhostStep; >> 109 // delete fGhostWorld; >> 110 // delete fGhostNavigator; >> 111 98 } 112 } 99 113 >> 114 >> 115 100 //-------------------------------------------- 116 //------------------------------------------------------ 101 // 117 // 102 // SetParallelWorld 118 // SetParallelWorld 103 // 119 // 104 //-------------------------------------------- 120 //------------------------------------------------------ 105 void G4ImportanceProcess::SetParallelWorld(con << 121 void G4ImportanceProcess:: >> 122 SetParallelWorld(const G4String ¶llelWorldName) 106 { 123 { 107 G4cout << G4endl << G4endl << G4endl; 124 G4cout << G4endl << G4endl << G4endl; 108 G4cout << "G4ImportanceProcess:: SetParallel 125 G4cout << "G4ImportanceProcess:: SetParallelWorld name = " << parallelWorldName << G4endl; 109 //++++++++++++++++++++++++++++++++++++++++++++ 126 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 110 // Get pointers of the parallel world and its 127 // Get pointers of the parallel world and its navigator 111 //++++++++++++++++++++++++++++++++++++++++++++ 128 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 112 fGhostWorldName = parallelWorldName; 129 fGhostWorldName = parallelWorldName; 113 fGhostWorld = fTransportationManager->GetPar 130 fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName); 114 fGhostNavigator = fTransportationManager->Ge 131 fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld); 115 //++++++++++++++++++++++++++++++++++++++++++++ 132 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 116 } 133 } 117 134 >> 135 // void G4ImportanceProcess:: >> 136 // SetParallelWorld(const G4VPhysicalVolume* parallelWorld) >> 137 // { >> 138 // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 139 // // Get pointer of navigator >> 140 // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 141 // // G4cout << " G4ImportanceProcess:: Got here 1 " << G4endl; >> 142 // // fGhostWorldName = parallelWorld->GetName(); >> 143 // // G4cout << " G4ImportanceProcess:: Got here 2 ghostName:" << fGhostWorldName << G4endl; >> 144 // fGhostWorld = parallelWorld; >> 145 // G4cout << " G4ImportanceProcess:: Got here 3 " << G4endl; >> 146 // fGhostNavigator = fTransportationManager->GetNavigator(parallelWorld); >> 147 // G4cout << " G4ImportanceProcess:: Got here 4 " << G4endl; >> 148 // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 149 // } >> 150 118 //-------------------------------------------- 151 //------------------------------------------------------ 119 // 152 // 120 // StartTracking 153 // StartTracking 121 // 154 // 122 //-------------------------------------------- 155 //------------------------------------------------------ 123 void G4ImportanceProcess::StartTracking(G4Trac 156 void G4ImportanceProcess::StartTracking(G4Track* trk) 124 { 157 { 125 //++++++++++++++++++++++++++++++++++++++++++++ 158 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 126 // Activate navigator and get the navigator ID 159 // Activate navigator and get the navigator ID 127 //++++++++++++++++++++++++++++++++++++++++++++ 160 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 161 // G4cout << " G4ParallelWorldScoringProcess::StartTracking" << G4endl; 128 162 129 if(fParaflag) << 163 if(fParaflag) { 130 { << 164 if(fGhostNavigator) 131 if(fGhostNavigator != nullptr) << 165 { fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); } 132 { << 133 fNavigatorID = fTransportationManager->A << 134 } << 135 else 166 else 136 { << 167 { 137 G4Exception("G4ImportanceProcess::StartT << 168 G4Exception("G4ImportanceProcess::StartTracking", 138 "ProcParaWorld000",FatalExce << 169 "ProcParaWorld000",FatalException, 139 "G4ImportanceProcess is used << 170 "G4ImportanceProcess is used for tracking without having a parallel world assigned"); 140 } << 171 } >> 172 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 141 173 >> 174 // G4cout << "G4ParallelWorldScoringProcess::StartTracking <<<<<<<<<<<<<<<<<< " << G4endl; 142 //++++++++++++++++++++++++++++++++++++++++++++ 175 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 143 // Let PathFinder initialize 176 // Let PathFinder initialize 144 //++++++++++++++++++++++++++++++++++++++++++++ 177 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 145 fPathFinder->PrepareNewTrack(trk->GetPosit 178 fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection()); >> 179 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 146 180 147 //++++++++++++++++++++++++++++++++++++++++++++ 181 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 148 // Setup initial touchables for the first step 182 // Setup initial touchables for the first step 149 //++++++++++++++++++++++++++++++++++++++++++++ 183 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 150 fOldGhostTouchable = fPathFinder->CreateTo 184 fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID); 151 fGhostPreStepPoint->SetTouchableHandle(fOl 185 fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable); 152 fNewGhostTouchable = fOldGhostTouchable; 186 fNewGhostTouchable = fOldGhostTouchable; 153 fGhostPostStepPoint->SetTouchableHandle(fN 187 fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable); 154 188 155 // Initialize 189 // Initialize 156 fGhostSafety = -1.; 190 fGhostSafety = -1.; 157 fOnBoundary = false; 191 fOnBoundary = false; 158 } 192 } >> 193 159 } 194 } 160 195 >> 196 161 G4double G4ImportanceProcess:: 197 G4double G4ImportanceProcess:: 162 PostStepGetPhysicalInteractionLength(const G4T << 198 PostStepGetPhysicalInteractionLength(const G4Track& , >> 199 G4double , 163 G4ForceCo 200 G4ForceCondition* condition) 164 { 201 { >> 202 // *condition = Forced; >> 203 // return kInfinity; >> 204 >> 205 // *condition = StronglyForced; 165 *condition = Forced; 206 *condition = Forced; 166 return DBL_MAX; 207 return DBL_MAX; 167 } 208 } 168 209 169 G4VParticleChange * 210 G4VParticleChange * 170 G4ImportanceProcess::PostStepDoIt(const G4Trac 211 G4ImportanceProcess::PostStepDoIt(const G4Track &aTrack, 171 const G4 212 const G4Step &aStep) 172 { 213 { 173 fParticleChange->Initialize(aTrack); 214 fParticleChange->Initialize(aTrack); 174 215 175 if(aTrack.GetNextVolume() == nullptr) << 216 if(fParaflag) { 176 { << 177 return fParticleChange; << 178 } << 179 << 180 if(fParaflag) << 181 { << 182 fOldGhostTouchable = fGhostPostStepPoint-> 217 fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle(); 183 //xbug? fOnBoundary = false; 218 //xbug? fOnBoundary = false; 184 CopyStep(aStep); 219 CopyStep(aStep); 185 220 186 if(fOnBoundary) 221 if(fOnBoundary) 187 { << 222 { 188 //++++++++++++++++++++++++++++++++++++++++++++ 223 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 189 // Locate the point and get new touchable 224 // Locate the point and get new touchable 190 //++++++++++++++++++++++++++++++++++++++++++++ 225 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 191 //?? fPathFinder->Locate(step.GetPostStepPo 226 //?? fPathFinder->Locate(step.GetPostStepPoint()->GetPosition(), 192 //?? step.GetPostStepPo 227 //?? step.GetPostStepPoint()->GetMomentumDirection()); 193 fNewGhostTouchable = fPathFinder->CreateTouc 228 fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID); 194 } << 229 //AH G4cout << " on boundary " << G4endl; >> 230 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 231 } 195 else 232 else 196 { << 233 { 197 // reuse the touchable << 234 // Do I need this ?????????????????????????????????????????????????????????? 198 fNewGhostTouchable = fOldGhostTouchable; << 235 // fGhostNavigator->LocateGlobalPointWithinVolume(track.GetPosition()); 199 } << 236 // ????????????????????????????????????????????????????????????????????????? >> 237 >> 238 // fPathFinder->ReLocate(track.GetPosition()); >> 239 >> 240 // reuse the touchable >> 241 fNewGhostTouchable = fOldGhostTouchable; >> 242 //AH G4cout << " NOT on boundary " << G4endl; >> 243 } 200 244 201 fGhostPreStepPoint->SetTouchableHandle(fOl 245 fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable); 202 fGhostPostStepPoint->SetTouchableHandle(fN 246 fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable); 203 247 >> 248 // if ( (aStep.GetPostStepPoint()->GetStepStatus() == fGeomBoundary) >> 249 // && (aStep.GetStepLength() > kCarTolerance) ) >> 250 // { >> 251 // if (aTrack.GetTrackStatus()==fStopAndKill) >> 252 // { >> 253 // G4cout << "WARNING - G4ImportanceProcess::PostStepDoIt()" >> 254 // << " StopAndKill track." << G4endl; >> 255 // } >> 256 >> 257 // G4StepPoint *prepoint = aStep.GetPreStepPoint(); >> 258 // G4StepPoint *postpoint = aStep.GetPostStepPoint(); >> 259 // G4GeometryCell prekey(*(prepoint->GetPhysicalVolume()), >> 260 // prepoint->GetTouchable()->GetReplicaNumber()); >> 261 // G4GeometryCell postkey(*(postpoint->GetPhysicalVolume()), >> 262 // postpoint->GetTouchable()->GetReplicaNumber()); >> 263 >> 264 204 if ( (fGhostPostStepPoint->GetStepStatus() 265 if ( (fGhostPostStepPoint->GetStepStatus() == fGeomBoundary) 205 && (aStep.GetStepLength() > kCarTolerance) 266 && (aStep.GetStepLength() > kCarTolerance) ) 206 { << 207 if (aTrack.GetTrackStatus()==fStopAndKil << 208 { 267 { 209 G4cout << "WARNING - G4ImportanceProce << 268 if (aTrack.GetTrackStatus()==fStopAndKill) 210 << " StopAndKill track << 269 { >> 270 G4cout << "WARNING - G4ImportanceProcess::PostStepDoIt()" >> 271 << " StopAndKill track. on boundary" << G4endl; >> 272 } >> 273 >> 274 G4GeometryCell prekey(*(fGhostPreStepPoint->GetPhysicalVolume()), >> 275 fGhostPreStepPoint->GetTouchable()->GetReplicaNumber()); >> 276 G4GeometryCell postkey(*(fGhostPostStepPoint->GetPhysicalVolume()), >> 277 fGhostPostStepPoint->GetTouchable()->GetReplicaNumber()); >> 278 >> 279 //AH >> 280 /* >> 281 G4cout << G4endl; >> 282 G4cout << G4endl; >> 283 G4cout << " inside parallel importance process " << aTrack.GetCurrentStepNumber() << G4endl; >> 284 G4cout << G4endl; >> 285 G4cout << G4endl; >> 286 G4cout << " prekey: " << fGhostPreStepPoint->GetPhysicalVolume()->GetName() << " replica:" >> 287 << fGhostPreStepPoint->GetTouchable()->GetReplicaNumber() << G4endl; >> 288 G4cout << " prekey ISTORE: " << fIStore.GetImportance(prekey) << G4endl; >> 289 G4cout << " postkey: " << G4endl; >> 290 G4cout << " postkey ISTORE: " << fIStore.GetImportance(postkey) << G4endl; >> 291 */ >> 292 //AH >> 293 G4Nsplit_Weight nw = fImportanceAlgorithm. >> 294 Calculate(fIStore.GetImportance(prekey), >> 295 fIStore.GetImportance(postkey), >> 296 aTrack.GetWeight()); >> 297 //AH >> 298 /* >> 299 G4cout << " prekey weight: " << fIStore.GetImportance(prekey) >> 300 << " postkey weight: " << fIStore.GetImportance(postkey) >> 301 << " split weight: " << nw << G4endl; >> 302 G4cout << " before poststepaction " << G4endl; >> 303 */ >> 304 //AH >> 305 fPostStepAction->DoIt(aTrack, fParticleChange, nw); >> 306 //AH G4cout << " after post step do it " << G4endl; 211 } 307 } 212 << 308 } else { 213 G4GeometryCell prekey(*(fGhostPreStepPoi << 214 fGhostPreStepPoint << 215 G4GeometryCell postkey(*(fGhostPostStepP << 216 fGhostPostStepPoi << 217 << 218 G4Nsplit_Weight nw = << 219 fImportanceAlgorithm.Calculate(fISto << 220 fIStore.GetImport << 221 aTrack.GetWeight( << 222 fPostStepAction->DoIt(aTrack, fParticleC << 223 } << 224 } << 225 else << 226 { << 227 if ( (aStep.GetPostStepPoint()->GetStepSta 309 if ( (aStep.GetPostStepPoint()->GetStepStatus() == fGeomBoundary) 228 && (aStep.GetStepLength() > kCarToler << 310 && (aStep.GetStepLength() > kCarTolerance) ) 229 { << 230 if (aTrack.GetTrackStatus()==fStopAndKil << 231 { 311 { 232 G4cout << "WARNING - G4ImportanceProce << 312 //AH G4cout << " inside non-parallel importance process " << G4endl; 233 << " StopAndKill track << 313 if (aTrack.GetTrackStatus()==fStopAndKill) 234 << G4endl; << 314 { 235 } << 315 G4cout << "WARNING - G4ImportanceProcess::PostStepDoIt()" >> 316 << " StopAndKill track. on boundary non-parallel" << G4endl; >> 317 } 236 318 237 G4StepPoint *prepoint = aStep.GetPreSte << 319 G4StepPoint *prepoint = aStep.GetPreStepPoint(); 238 G4StepPoint *postpoint = aStep.GetPostSt << 320 G4StepPoint *postpoint = aStep.GetPostStepPoint(); 239 << 321 240 G4GeometryCell prekey(*(prepoint->GetPhy << 322 G4GeometryCell prekey(*(prepoint->GetPhysicalVolume()), 241 prepoint->GetTouch << 323 prepoint->GetTouchable()->GetReplicaNumber()); 242 G4GeometryCell postkey(*(postpoint->GetP << 324 G4GeometryCell postkey(*(postpoint->GetPhysicalVolume()), 243 postpoint->GetTou << 325 postpoint->GetTouchable()->GetReplicaNumber()); 244 << 326 245 G4Nsplit_Weight nw = << 327 G4Nsplit_Weight nw = fImportanceAlgorithm. 246 fImportanceAlgorithm.Calculate(fISto << 328 Calculate(fIStore.GetImportance(prekey), 247 fISto << 329 fIStore.GetImportance(postkey), 248 aTrac << 330 aTrack.GetWeight()); >> 331 //AH >> 332 /* >> 333 G4cout << " prekey weight: " << fIStore.GetImportance(prekey) >> 334 << " postkey weight: " << fIStore.GetImportance(postkey) >> 335 << " split weight: " << nw << G4endl; >> 336 G4cout << " before poststepaction 2 " << G4endl; >> 337 */ >> 338 //AH 249 fPostStepAction->DoIt(aTrack, fParticleChang 339 fPostStepAction->DoIt(aTrack, fParticleChange, nw); 250 } << 340 //AH G4cout << " after poststepaction 2 " << G4endl; >> 341 } 251 } 342 } 252 return fParticleChange; 343 return fParticleChange; 253 } 344 } 254 345 255 void G4ImportanceProcess::KillTrack() const 346 void G4ImportanceProcess::KillTrack() const 256 { 347 { 257 fParticleChange->ProposeTrackStatus(fStopAnd 348 fParticleChange->ProposeTrackStatus(fStopAndKill); 258 } 349 } 259 350 260 const G4String& G4ImportanceProcess::GetName() << 351 const G4String &G4ImportanceProcess::GetName() const 261 { 352 { 262 return theProcessName; 353 return theProcessName; 263 } 354 } 264 355 265 G4double G4ImportanceProcess:: 356 G4double G4ImportanceProcess:: 266 AlongStepGetPhysicalInteractionLength( 357 AlongStepGetPhysicalInteractionLength( 267 const G4Track& track, G4do << 358 const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, 268 G4double currentMinimumSte << 359 G4double& proposedSafety, G4GPILSelection* selection) 269 G4double& proposedSafety, << 270 { 360 { 271 if(fParaflag) << 361 if(fParaflag) { 272 { << 273 *selection = NotCandidateForSelection; 362 *selection = NotCandidateForSelection; 274 G4double returnedStep = DBL_MAX; 363 G4double returnedStep = DBL_MAX; 275 364 276 if (previousStepSize > 0.) 365 if (previousStepSize > 0.) 277 { fGhostSafety -= previousStepSize; } 366 { fGhostSafety -= previousStepSize; } 278 // else 367 // else 279 // { fGhostSafety = -1.; } 368 // { fGhostSafety = -1.; } 280 if (fGhostSafety < 0.) { fGhostSafety = 0. << 369 if (fGhostSafety < 0.) fGhostSafety = 0.0; 281 370 282 // --------------------------------------- 371 // ------------------------------------------ 283 // Determination of the proposed STEP LENG 372 // Determination of the proposed STEP LENGTH: 284 // --------------------------------------- 373 // ------------------------------------------ 285 if (currentMinimumStep <= fGhostSafety && 374 if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.) 286 { << 287 // I have no chance to limit << 288 returnedStep = currentMinimumStep; << 289 fOnBoundary = false; << 290 proposedSafety = fGhostSafety - currentM << 291 } << 292 else // (currentMinimumStep > fGhostSafety << 293 { << 294 G4FieldTrackUpdator::Update(&fFieldTrack << 295 //++++++++++++++++++++++++++++++++++++++ << 296 // ComputeStep << 297 //++++++++++++++++++++++++++++++++++++++ << 298 returnedStep << 299 = fPathFinder->ComputeStep(fFieldTrack,cur << 300 track.Get << 301 fEndTrack << 302 //++++++++++++++++++++++++++++++++++++++ << 303 if(feLimited == kDoNot) << 304 { << 305 // Track is not on the boundary << 306 fOnBoundary = false; << 307 fGhostSafety = fGhostNavigator->Comput << 308 } << 309 else << 310 { 375 { 311 // Track is on the boundary << 376 // I have no chance to limit 312 fOnBoundary = true; << 377 returnedStep = currentMinimumStep; >> 378 fOnBoundary = false; >> 379 proposedSafety = fGhostSafety - currentMinimumStep; >> 380 //AH G4cout << " step not limited, why? " << G4endl; 313 } 381 } 314 proposedSafety = fGhostSafety; << 382 else // (currentMinimumStep > fGhostSafety: I may limit the Step) 315 if(feLimited == kUnique || feLimited == << 316 { 383 { 317 *selection = CandidateForSelection; << 384 G4FieldTrackUpdator::Update(&fFieldTrack,&track); 318 } << 385 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 319 else if (feLimited == kSharedTransport) << 386 // ComputeStep 320 { << 387 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 321 returnedStep *= (1.0 + 1.0e-9); << 388 returnedStep 322 // Expand to disable its selection in << 389 = fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID, >> 390 track.GetCurrentStepNumber(),fGhostSafety,feLimited, >> 391 fEndTrack,track.GetVolume()); >> 392 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 393 if(feLimited == kDoNot) >> 394 { >> 395 //AH G4cout << " computestep came back with not-boundary " << G4endl; >> 396 // Track is not on the boundary >> 397 fOnBoundary = false; >> 398 fGhostSafety = fGhostNavigator->ComputeSafety(fEndTrack.GetPosition()); >> 399 } >> 400 else >> 401 { >> 402 // Track is on the boundary >> 403 //AH G4cout << " FOUND A BOUNDARY ! " << track.GetCurrentStepNumber() << G4endl; >> 404 fOnBoundary = true; >> 405 // proposedSafety = fGhostSafety; >> 406 } >> 407 proposedSafety = fGhostSafety; >> 408 if(feLimited == kUnique || feLimited == kSharedOther) { >> 409 *selection = CandidateForSelection; >> 410 }else if (feLimited == kSharedTransport) { >> 411 returnedStep *= (1.0 + 1.0e-9); >> 412 // Expand to disable its selection in Step Manager comparison >> 413 } >> 414 323 } 415 } 324 } << 325 416 326 // --------------------------------------- << 417 // ---------------------------------------------- 327 // Returns the fGhostSafety as the propose << 418 // Returns the fGhostSafety as the proposedSafety 328 // The SteppingManager will take care of k << 419 // The SteppingManager will take care of keeping 329 // the smallest one. << 420 // the smallest one. 330 // --------------------------------------- << 421 // ---------------------------------------------- 331 return returnedStep; 422 return returnedStep; 332 } << 423 333 else << 424 } else { 334 { << 425 335 return DBL_MAX; 426 return DBL_MAX; >> 427 336 } 428 } >> 429 337 } 430 } 338 431 339 G4double G4ImportanceProcess:: 432 G4double G4ImportanceProcess:: 340 AtRestGetPhysicalInteractionLength(const G4Tra 433 AtRestGetPhysicalInteractionLength(const G4Track& , 341 G4ForceCond 434 G4ForceCondition*) 342 { 435 { 343 return -1.0; 436 return -1.0; 344 } 437 } 345 438 346 G4VParticleChange* G4ImportanceProcess:: 439 G4VParticleChange* G4ImportanceProcess:: 347 AtRestDoIt(const G4Track&, const G4Step&) 440 AtRestDoIt(const G4Track&, const G4Step&) 348 { 441 { 349 return nullptr; << 442 return 0; 350 } 443 } 351 444 352 G4VParticleChange* G4ImportanceProcess:: 445 G4VParticleChange* G4ImportanceProcess:: 353 AlongStepDoIt(const G4Track& aTrack, const G4S 446 AlongStepDoIt(const G4Track& aTrack, const G4Step& ) 354 { 447 { 355 // Dummy ParticleChange ie: does nothing 448 // Dummy ParticleChange ie: does nothing 356 // Expecting G4Transportation to move the tr 449 // Expecting G4Transportation to move the track >> 450 //AH G4cout << " along step do it " << G4endl; 357 pParticleChange->Initialize(aTrack); 451 pParticleChange->Initialize(aTrack); 358 return pParticleChange; 452 return pParticleChange; >> 453 // return 0; 359 } 454 } 360 455 361 void G4ImportanceProcess::CopyStep(const G4Ste << 456 void G4ImportanceProcess::CopyStep(const G4Step & step) 362 { 457 { 363 fGhostStep->SetTrack(step.GetTrack()); 458 fGhostStep->SetTrack(step.GetTrack()); 364 fGhostStep->SetStepLength(step.GetStepLength 459 fGhostStep->SetStepLength(step.GetStepLength()); 365 fGhostStep->SetTotalEnergyDeposit(step.GetTo 460 fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit()); 366 fGhostStep->SetControlFlag(step.GetControlFl 461 fGhostStep->SetControlFlag(step.GetControlFlag()); 367 462 368 *fGhostPreStepPoint = *(step.GetPreStepPoint 463 *fGhostPreStepPoint = *(step.GetPreStepPoint()); 369 *fGhostPostStepPoint = *(step.GetPostStepPoi 464 *fGhostPostStepPoint = *(step.GetPostStepPoint()); 370 465 371 //++++++++++++++++++++++++++++++++++++++++++++ 466 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 372 // Set StepStatus for ghost world 467 // Set StepStatus for ghost world 373 //++++++++++++++++++++++++++++++++++++++++++++ 468 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 374 if(fOnBoundary) 469 if(fOnBoundary) 375 { fGhostPostStepPoint->SetStepStatus(fGeomBo 470 { fGhostPostStepPoint->SetStepStatus(fGeomBoundary); } 376 else if(fGhostPostStepPoint->GetStepStatus() 471 else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary) 377 { fGhostPostStepPoint->SetStepStatus(fPostSt 472 { fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); } 378 //++++++++++++++++++++++++++++++++++++++++++++ 473 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 379 } 474 } 380 475