Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // G4WeightWindowProcess 27 // 28 // Author: Michael Dressel, 2002 29 // ------------------------------------------- 30 31 #include "G4WeightWindowProcess.hh" 32 #include "G4VWeightWindowAlgorithm.hh" 33 #include "G4GeometryCell.hh" 34 #include "G4SamplingPostStepAction.hh" 35 #include "G4VTrackTerminator.hh" 36 #include "G4PlaceOfAction.hh" 37 #include "G4VWeightWindowStore.hh" 38 39 #include "G4Step.hh" 40 #include "G4Navigator.hh" 41 #include "G4VTouchable.hh" 42 #include "G4VPhysicalVolume.hh" 43 #include "G4ParticleChange.hh" 44 #include "G4PathFinder.hh" 45 #include "G4TransportationManager.hh" 46 #include "G4StepPoint.hh" 47 #include "G4FieldTrackUpdator.hh" 48 49 50 G4WeightWindowProcess::G4WeightWindowProcess( 51 const G4VWeightWindowAlgor 52 const G4VWeightWindowStore 53 const G4VTrackTerminator * 54 G4PlaceOfAction plac 55 const G4String &aName, G4b 56 : G4VProcess(aName), 57 fParticleChange(new G4ParticleChange), 58 fWeightWindowAlgorithm(aWeightWindowAlgorit 59 fWeightWindowStore(aWWStore), 60 fPlaceOfAction(placeOfAction) 61 { 62 if (TrackTerminator != nullptr) 63 { 64 fPostStepAction = new G4SamplingPostStepAc 65 } 66 else 67 { 68 fPostStepAction = new G4SamplingPostStepAc 69 } 70 if (fParticleChange == nullptr) 71 { 72 G4Exception("G4WeightWindowProcess::G4Weig 73 "FatalError", FatalException, 74 "Failed allocation of G4Partic 75 } 76 G4VProcess::pParticleChange = fParticleChang 77 78 fGhostStep = new G4Step(); 79 fGhostPreStepPoint = fGhostStep->GetPreStepP 80 fGhostPostStepPoint = fGhostStep->GetPostSte 81 82 fTransportationManager = G4TransportationMan 83 fPathFinder = G4PathFinder::GetInstance(); 84 85 if (verboseLevel>0) 86 { 87 G4cout << GetProcessName() << " is created 88 } 89 90 fParaflag = para; 91 92 } 93 94 G4WeightWindowProcess::~G4WeightWindowProcess( 95 { 96 97 delete fPostStepAction; 98 delete fParticleChange; 99 // delete fGhostStep; 100 101 } 102 103 104 //-------------------------------------------- 105 // 106 // SetParallelWorld 107 // 108 //-------------------------------------------- 109 void G4WeightWindowProcess:: 110 SetParallelWorld(const G4String ¶llelWorld 111 { 112 //++++++++++++++++++++++++++++++++++++++++++++ 113 // Get pointers of the parallel world and its 114 //++++++++++++++++++++++++++++++++++++++++++++ 115 fGhostWorldName = parallelWorldName; 116 fGhostWorld = fTransportationManager->GetPar 117 fGhostNavigator = fTransportationManager->Ge 118 //++++++++++++++++++++++++++++++++++++++++++++ 119 } 120 121 void G4WeightWindowProcess:: 122 SetParallelWorld(G4VPhysicalVolume* parallelWo 123 { 124 //++++++++++++++++++++++++++++++++++++++++++++ 125 // Get pointer of navigator 126 //++++++++++++++++++++++++++++++++++++++++++++ 127 fGhostWorldName = parallelWorld->GetName(); 128 fGhostWorld = parallelWorld; 129 fGhostNavigator = fTransportationManager->Ge 130 //++++++++++++++++++++++++++++++++++++++++++++ 131 } 132 133 //-------------------------------------------- 134 // 135 // StartTracking 136 // 137 //-------------------------------------------- 138 void G4WeightWindowProcess::StartTracking(G4Tr 139 { 140 //++++++++++++++++++++++++++++++++++++++++++++ 141 // Activate navigator and get the navigator ID 142 //++++++++++++++++++++++++++++++++++++++++++++ 143 // G4cout << " G4ParallelWorldScoringProcess:: 144 145 if(fParaflag) { 146 if(fGhostNavigator != nullptr) 147 { fNavigatorID = fTransportationManager- 148 else 149 { 150 G4Exception("G4WeightWindowProcess::StartTra 151 "ProcParaWorld000",FatalException, 152 "G4WeightWindowProcess is used for tra 153 } 154 //++++++++++++++++++++++++++++++++++++++++++++ 155 156 // G4cout << "G4ParallelWorldScoringProcess::S 157 //++++++++++++++++++++++++++++++++++++++++++++ 158 // Let PathFinder initialize 159 //++++++++++++++++++++++++++++++++++++++++++++ 160 fPathFinder->PrepareNewTrack(trk->GetPosit 161 //++++++++++++++++++++++++++++++++++++++++++++ 162 163 //++++++++++++++++++++++++++++++++++++++++++++ 164 // Setup initial touchables for the first step 165 //++++++++++++++++++++++++++++++++++++++++++++ 166 fOldGhostTouchable = fPathFinder->CreateTo 167 fGhostPreStepPoint->SetTouchableHandle(fOl 168 fNewGhostTouchable = fOldGhostTouchable; 169 fGhostPostStepPoint->SetTouchableHandle(fN 170 171 // Initialize 172 fGhostSafety = -1.; 173 fOnBoundary = false; 174 } 175 } 176 177 178 G4double G4WeightWindowProcess:: 179 PostStepGetPhysicalInteractionLength(const G4T 180 G4double 181 G4ForceCo 182 { 183 // *condition = Forced; 184 // return kInfinity; 185 186 // *condition = StronglyForced; 187 *condition = Forced; 188 return DBL_MAX; 189 } 190 191 G4VParticleChange * 192 G4WeightWindowProcess::PostStepDoIt(const G4Tr 193 const 194 { 195 196 fParticleChange->Initialize(aTrack); 197 198 if(fParaflag) { 199 fOldGhostTouchable = fGhostPostStepPoint-> 200 //xbug? fOnBoundary = false; 201 CopyStep(aStep); 202 203 if(fOnBoundary) 204 { 205 //++++++++++++++++++++++++++++++++++++++++++++ 206 // Locate the point and get new touchable 207 //++++++++++++++++++++++++++++++++++++++++++++ 208 //?? fPathFinder->Locate(step.GetPostStepPo 209 //?? step.GetPostStepPo 210 fNewGhostTouchable = fPathFinder->CreateTouc 211 //++++++++++++++++++++++++++++++++++++++++++++ 212 } 213 else 214 { 215 // Do I need this ?????????????????????????? 216 // fGhostNavigator->LocateGlobalPointWithinV 217 // ????????????????????????????????????????? 218 219 // fPathFinder->ReLocate(track.GetPosition() 220 221 // reuse the touchable 222 fNewGhostTouchable = fOldGhostTouchable; 223 } 224 225 fGhostPreStepPoint->SetTouchableHandle(fOl 226 fGhostPostStepPoint->SetTouchableHandle(fN 227 228 } 229 230 if (aStep.GetStepLength() > kCarTolerance) 231 { 232 // if ( ( fPlaceOfAction == onBoundaryAndC 233 // || ( (fPlaceOfAction == onBoundary) & 234 // (aStep.GetPostStepPoint()->GetSt 235 // || ( (fPlaceOfAction == onCollision) 236 // (aStep.GetPostStepPoint()->GetSt 237 if(fParaflag) { 238 if ( ( fPlaceOfAction == onBoundaryAndCo 239 || ( (fPlaceOfAction == onBoundary) && 240 (fGhostPostStepPoint->GetStepStatus() == f 241 || ( (fPlaceOfAction == onCollision) && 242 (fGhostPostStepPoint->GetStepStatus() != f 243 { 244 245 // G4StepPoint *postpoint = aStep.GetPos 246 247 // G4GeometryCell postCell(*(postpoint-> 248 // postpoint->Get 249 250 G4GeometryCell postCell(*(fGhostPostStepPo 251 fGhostPostStepPoint->GetTouchable()- 252 G4Nsplit_Weight nw = 253 fWeightWindowAlgorithm.Calculate(aTrack. 254 fWeightWindowStore.GetLowerWeig 255 256 fPostStepAction->DoIt(aTrack, fParticleCha 257 } 258 } else { 259 if ( ( fPlaceOfAction == onBoundaryAndCo 260 || ( (fPlaceOfAction == onBoundary) && 261 (aStep.GetPostStepPoint()->GetStepStatus() 262 || ( (fPlaceOfAction == onCollision) && 263 (aStep.GetPostStepPoint()->GetStepStatus() 264 { 265 266 G4StepPoint *postpoint = aStep.GetPostStep 267 268 G4GeometryCell postCell(*(postpoint->GetPh 269 postpoint->GetTouchable()->GetReplic 270 271 G4Nsplit_Weight nw = 272 fWeightWindowAlgorithm.Calculate(aTrack. 273 fWeightWindowStore.GetLowerWeig 274 aTrack.GetKineticEner 275 fPostStepAction->DoIt(aTrack, fParticleCha 276 } 277 } 278 } 279 return fParticleChange; 280 } 281 282 void G4WeightWindowProcess::KillTrack() const 283 { 284 fParticleChange->ProposeTrackStatus(fStopAnd 285 } 286 287 const G4String &G4WeightWindowProcess::GetName 288 { 289 return G4VProcess::GetProcessName(); 290 } 291 292 G4double G4WeightWindowProcess:: 293 AlongStepGetPhysicalInteractionLength( 294 const G4Track& track, G4double pr 295 G4double& proposedSafety, G4GPILSe 296 { 297 if(fParaflag) 298 { 299 *selection = NotCandidateForSelection; 300 G4double returnedStep = DBL_MAX; 301 302 if (previousStepSize > 0.) 303 { fGhostSafety -= previousStepSize; } 304 // else 305 // { fGhostSafety = -1.; } 306 if (fGhostSafety < 0.) fGhostSafety = 0.0; 307 308 // --------------------------------------- 309 // Determination of the proposed STEP LENG 310 // --------------------------------------- 311 if (currentMinimumStep <= fGhostSafety && 312 { 313 // I have no chance to limit 314 returnedStep = currentMinimumStep; 315 fOnBoundary = false; 316 proposedSafety = fGhostSafety - currentMinim 317 } 318 else // (currentMinimumStep > fGhostSafety 319 { 320 G4FieldTrackUpdator::Update(&fFieldTrack,&tr 321 //++++++++++++++++++++++++++++++++++++++++++ 322 // ComputeStep 323 //++++++++++++++++++++++++++++++++++++++++++ 324 returnedStep 325 = fPathFinder->ComputeStep(fFieldTrack,cur 326 track.GetCurrentStepNumber(),fGho 327 fEndTrack,track.GetVolume()); 328 //++++++++++++++++++++++++++++++++++++++++++ 329 if(feLimited == kDoNot) 330 { 331 // Track is not on the boundary 332 fOnBoundary = false; 333 fGhostSafety = fGhostNavigator->ComputeS 334 // fGhostSafety = fGhostNavigator- 335 } 336 else 337 { 338 // Track is on the boundary 339 fOnBoundary = true; 340 proposedSafety = fGhostSafety; 341 } 342 //xbug? proposedSafety = fGhostSafety; 343 if(feLimited == kUnique || feLimited == kSha 344 *selection = CandidateForSelection; 345 }else if (feLimited == kSharedTransport) { 346 returnedStep *= (1.0 + 1.0e-9); 347 // Expand to disable its selection in Step 348 } 349 350 } 351 352 // ----------------------------------------- 353 // Returns the fGhostSafety as the proposedS 354 // The SteppingManager will take care of kee 355 // the smallest one. 356 // ----------------------------------------- 357 return returnedStep; 358 359 } else { 360 return DBL_MAX; 361 // not sensible - time goes backwards! 362 } 363 364 } 365 366 G4double G4WeightWindowProcess:: 367 AtRestGetPhysicalInteractionLength(const G4Tra 368 G4ForceCond 369 { 370 return -1.0; 371 } 372 373 G4VParticleChange* G4WeightWindowProcess:: 374 AtRestDoIt(const G4Track&, const G4Step&) 375 { 376 return nullptr; 377 } 378 379 G4VParticleChange* G4WeightWindowProcess:: 380 AlongStepDoIt(const G4Track& track, const G4St 381 { 382 // Dummy ParticleChange ie: does nothing 383 // Expecting G4Transportation to move the tr 384 pParticleChange->Initialize(track); 385 return pParticleChange; 386 } 387 388 void G4WeightWindowProcess::CopyStep(const G4S 389 { 390 fGhostStep->SetTrack(step.GetTrack()); 391 fGhostStep->SetStepLength(step.GetStepLength 392 fGhostStep->SetTotalEnergyDeposit(step.GetTo 393 fGhostStep->SetControlFlag(step.GetControlFl 394 395 *fGhostPreStepPoint = *(step.GetPreStepPoint 396 *fGhostPostStepPoint = *(step.GetPostStepPoi 397 398 //++++++++++++++++++++++++++++++++++++++++++++ 399 // Set StepStatus for ghost world 400 //++++++++++++++++++++++++++++++++++++++++++++ 401 if(fOnBoundary) 402 { fGhostPostStepPoint->SetStepStatus(fGeomBo 403 else if(fGhostPostStepPoint->GetStepStatus() 404 { fGhostPostStepPoint->SetStepStatus(fPostSt 405 //++++++++++++++++++++++++++++++++++++++++++++ 406 } 407