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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/biasing/importance/src/G4WeightCutOffProcess.cc (Version 11.3.0) and /processes/biasing/importance/src/G4WeightCutOffProcess.cc (Version 11.0.p3,)


** Warning: Cannot open xref database.

  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 // G4WeightCutOffProcess                          
 27 //                                                
 28 // Author: Michael Dressel, 2002                  
 29 // -------------------------------------------    
 30                                                   
 31 #include "G4WeightCutOffProcess.hh"               
 32 #include "G4GeometryCellStep.hh"                  
 33 #include "G4TouchableHandle.hh"                   
 34 #include "G4VIStore.hh"                           
 35                                                   
 36 #include "G4Step.hh"                              
 37 #include "G4Navigator.hh"                         
 38 #include "G4VTouchable.hh"                        
 39 #include "G4VPhysicalVolume.hh"                   
 40 #include "G4ParticleChange.hh"                    
 41 #include "G4PathFinder.hh"                        
 42 #include "G4TransportationManager.hh"             
 43 #include "G4StepPoint.hh"                         
 44 #include "G4FieldTrackUpdator.hh"                 
 45                                                   
 46                                                   
 47 G4WeightCutOffProcess::                           
 48 G4WeightCutOffProcess(G4double wsurvival,         
 49                       G4double wlimit,            
 50                       G4double isource,           
 51                       G4VIStore *istore,          
 52                       const G4String &aName, G    
 53   : G4VProcess(aName),                            
 54     fParticleChange(new G4ParticleChange),        
 55     fWeightSurvival(wsurvival),                   
 56     fWeightLimit(wlimit),                         
 57     fSourceImportance(isource),                   
 58     fIStore(istore),                              
 59     fParaflag(para)                               
 60 {                                                 
 61   if (!fParticleChange)                           
 62   {                                               
 63     G4Exception("G4WeightCutOffProcess::G4Weig    
 64                 "FatalError", FatalException,     
 65                 "Failed to allocate G4Particle    
 66   }                                               
 67                                                   
 68   G4VProcess::pParticleChange = fParticleChang    
 69                                                   
 70   fGhostStep = new G4Step();                      
 71   fGhostPreStepPoint = fGhostStep->GetPreStepP    
 72   fGhostPostStepPoint = fGhostStep->GetPostSte    
 73                                                   
 74   fTransportationManager = G4TransportationMan    
 75   fPathFinder = G4PathFinder::GetInstance();      
 76                                                   
 77   if (verboseLevel>0)                             
 78   {                                               
 79     G4cout << GetProcessName() << " is created    
 80   }                                               
 81 }                                                 
 82                                                   
 83 G4WeightCutOffProcess::~G4WeightCutOffProcess(    
 84 {                                                 
 85   delete fParticleChange;                         
 86   // delete fGhostStep;                           
 87 }                                                 
 88                                                   
 89                                                   
 90 //--------------------------------------------    
 91 //                                                
 92 // SetParallelWorld                               
 93 //                                                
 94 //--------------------------------------------    
 95 void G4WeightCutOffProcess::                      
 96 SetParallelWorld(const G4String &parallelWorld    
 97 {                                                 
 98 //++++++++++++++++++++++++++++++++++++++++++++    
 99 // Get pointers of the parallel world and its     
100 //++++++++++++++++++++++++++++++++++++++++++++    
101   fGhostWorldName = parallelWorldName;            
102   fGhostWorld = fTransportationManager->GetPar    
103   fGhostNavigator = fTransportationManager->Ge    
104 //++++++++++++++++++++++++++++++++++++++++++++    
105 }                                                 
106                                                   
107 void G4WeightCutOffProcess::                      
108 SetParallelWorld(G4VPhysicalVolume* parallelWo    
109 {                                                 
110 //++++++++++++++++++++++++++++++++++++++++++++    
111 // Get pointer of navigator                       
112 //++++++++++++++++++++++++++++++++++++++++++++    
113   fGhostWorldName = parallelWorld->GetName();     
114   fGhostWorld = parallelWorld;                    
115   fGhostNavigator = fTransportationManager->Ge    
116 //++++++++++++++++++++++++++++++++++++++++++++    
117 }                                                 
118                                                   
119 //--------------------------------------------    
120 //                                                
121 // StartTracking                                  
122 //                                                
123 //--------------------------------------------    
124 void G4WeightCutOffProcess::StartTracking(G4Tr    
125 {                                                 
126 //++++++++++++++++++++++++++++++++++++++++++++    
127 // Activate navigator and get the navigator ID    
128 //++++++++++++++++++++++++++++++++++++++++++++    
129 // G4cout << " G4ParallelWorldScoringProcess::    
130                                                   
131   if(fParaflag) {                                 
132     if(fGhostNavigator != nullptr)                
133       { fNavigatorID = fTransportationManager-    
134     else                                          
135       {                                           
136   G4Exception("G4WeightCutOffProcess::StartTra    
137         "ProcParaWorld000",FatalException,        
138         "G4WeightCutOffProcess is used for tra    
139       }                                           
140 //++++++++++++++++++++++++++++++++++++++++++++    
141                                                   
142 // G4cout << "G4ParallelWorldScoringProcess::S    
143 //++++++++++++++++++++++++++++++++++++++++++++    
144 // Let PathFinder initialize                      
145 //++++++++++++++++++++++++++++++++++++++++++++    
146     fPathFinder->PrepareNewTrack(trk->GetPosit    
147 //++++++++++++++++++++++++++++++++++++++++++++    
148                                                   
149 //++++++++++++++++++++++++++++++++++++++++++++    
150 // Setup initial touchables for the first step    
151 //++++++++++++++++++++++++++++++++++++++++++++    
152     fOldGhostTouchable = fPathFinder->CreateTo    
153     fGhostPreStepPoint->SetTouchableHandle(fOl    
154     fNewGhostTouchable = fOldGhostTouchable;      
155     fGhostPostStepPoint->SetTouchableHandle(fN    
156                                                   
157     // Initialize                                 
158     fGhostSafety = -1.;                           
159     fOnBoundary = false;                          
160   }                                               
161 }                                                 
162                                                   
163                                                   
164 G4double G4WeightCutOffProcess::                  
165 PostStepGetPhysicalInteractionLength(const G4T    
166                                      G4double,    
167 {                                                 
168 //   *condition = Forced;                         
169 //   return kInfinity;                            
170                                                   
171 //  *condition = StronglyForced;                  
172   *condition = Forced;                            
173   return DBL_MAX;                                 
174 }                                                 
175                                                   
176 G4VParticleChange *                               
177 G4WeightCutOffProcess::PostStepDoIt(const G4Tr    
178                                     const G4St    
179 {                                                 
180   fParticleChange->Initialize(aTrack);            
181                                                   
182   if(fParaflag) {                                 
183     fOldGhostTouchable = fGhostPostStepPoint->    
184     //xbug?    fOnBoundary = false;               
185     CopyStep(aStep);                              
186                                                   
187     if(fOnBoundary)                               
188       {                                           
189 //++++++++++++++++++++++++++++++++++++++++++++    
190 // Locate the point and get new touchable         
191 //++++++++++++++++++++++++++++++++++++++++++++    
192   //??  fPathFinder->Locate(step.GetPostStepPo    
193   //??                      step.GetPostStepPo    
194   fNewGhostTouchable = fPathFinder->CreateTouc    
195 //++++++++++++++++++++++++++++++++++++++++++++    
196       }                                           
197     else                                          
198       {                                           
199   // Do I need this ??????????????????????????    
200   // fGhostNavigator->LocateGlobalPointWithinV    
201   // ?????????????????????????????????????????    
202                                                   
203   // fPathFinder->ReLocate(track.GetPosition()    
204                                                   
205   // reuse the touchable                          
206   fNewGhostTouchable = fOldGhostTouchable;        
207       }                                           
208                                                   
209     fGhostPreStepPoint->SetTouchableHandle(fOl    
210     fGhostPostStepPoint->SetTouchableHandle(fN    
211                                                   
212   }                                               
213                                                   
214   if(fParaflag) {                                 
215     G4GeometryCell postCell(*(fGhostPostStepPo    
216           fGhostPostStepPoint->GetTouchable()-    
217                                                   
218                                                   
219     //  G4GeometryCell postCell = fGCellFinder    
220     //  G4GeometryCell postCell = fGCellFinder    
221     G4double R = fSourceImportance;               
222     if (fIStore != nullptr)                       
223       {                                           
224   G4double i = fIStore->GetImportance(postCell    
225   if (i>0)                                        
226     {                                             
227       R/=i;                                       
228     }                                             
229       }                                           
230     G4double w = aTrack.GetWeight();              
231     if (w<R*fWeightLimit)                         
232       {                                           
233   G4double ws = fWeightSurvival*R;                
234   G4double p = w/(ws);                            
235   if (G4UniformRand()<p)                          
236     {                                             
237       fParticleChange->ProposeTrackStatus(fSto    
238     }                                             
239   else                                            
240     {                                             
241       fParticleChange->ProposeWeight(ws);         
242     }                                             
243       }                                           
244   } else {                                        
245                                                   
246     G4GeometryCell postCell(*(aStep.GetPostSte    
247           aStep.GetPostStepPoint()->GetTouchab    
248                                                   
249     //  G4GeometryCell postCell = fGCellFinder    
250     //  G4GeometryCell postCell = fGCellFinder    
251     G4double R = fSourceImportance;               
252     if (fIStore != nullptr)                       
253       {                                           
254   G4double i = fIStore->GetImportance(postCell    
255   if (i>0)                                        
256     {                                             
257       R/=i;                                       
258     }                                             
259       }                                           
260     G4double w = aTrack.GetWeight();              
261     if (w<R*fWeightLimit)                         
262       {                                           
263   G4double ws = fWeightSurvival*R;                
264   G4double p = w/(ws);                            
265   if (G4UniformRand()<p)                          
266     {                                             
267       fParticleChange->ProposeTrackStatus(fSto    
268     }                                             
269   else                                            
270     {                                             
271       fParticleChange->ProposeWeight(ws);         
272     }                                             
273       }                                           
274   }                                               
275                                                   
276   return fParticleChange;                         
277                                                   
278 }                                                 
279                                                   
280 const G4String &G4WeightCutOffProcess::GetName    
281 {                                                 
282   return theProcessName;                          
283 }                                                 
284                                                   
285 G4double G4WeightCutOffProcess::                  
286 AlongStepGetPhysicalInteractionLength(            
287             const G4Track& track, G4double  pr    
288             G4double& proposedSafety, G4GPILSe    
289 {                                                 
290   if(fParaflag) {                                 
291                                                   
292     *selection = NotCandidateForSelection;        
293     G4double returnedStep = DBL_MAX;              
294                                                   
295     if (previousStepSize > 0.)                    
296       { fGhostSafety -= previousStepSize; }       
297     //  else                                      
298     //  { fGhostSafety = -1.; }                   
299     if (fGhostSafety < 0.) fGhostSafety = 0.0;    
300                                                   
301     // ---------------------------------------    
302     // Determination of the proposed STEP LENG    
303     // ---------------------------------------    
304     if (currentMinimumStep <= fGhostSafety &&     
305       {                                           
306   // I have no chance to limit                    
307   returnedStep = currentMinimumStep;              
308   fOnBoundary = false;                            
309   proposedSafety = fGhostSafety - currentMinim    
310       }                                           
311     else // (currentMinimumStep > fGhostSafety    
312       {                                           
313   G4FieldTrackUpdator::Update(&fFieldTrack,&tr    
314   //++++++++++++++++++++++++++++++++++++++++++    
315   // ComputeStep                                  
316   //++++++++++++++++++++++++++++++++++++++++++    
317   returnedStep                                    
318     = fPathFinder->ComputeStep(fFieldTrack,cur    
319              track.GetCurrentStepNumber(),fGho    
320              fEndTrack,track.GetVolume());        
321   //++++++++++++++++++++++++++++++++++++++++++    
322   if(feLimited == kDoNot)                         
323     {                                             
324       // Track is not on the boundary             
325       fOnBoundary = false;                        
326       fGhostSafety = fGhostNavigator->ComputeS    
327     }                                             
328   else                                            
329     {                                             
330       // Track is on the boundary                 
331       fOnBoundary = true;                         
332       proposedSafety = fGhostSafety;              
333     }                                             
334   //xbug? proposedSafety = fGhostSafety;          
335   if(feLimited == kUnique || feLimited == kSha    
336     *selection = CandidateForSelection;           
337   }else if (feLimited == kSharedTransport) {      
338     returnedStep *= (1.0 + 1.0e-9);               
339     // Expand to disable its selection in Step    
340   }                                               
341                                                   
342       }                                           
343                                                   
344   // -----------------------------------------    
345   // Returns the fGhostSafety as the proposedS    
346   // The SteppingManager will take care of kee    
347   // the smallest one.                            
348   // -----------------------------------------    
349     return returnedStep;                          
350                                                   
351   } else {                                        
352     return DBL_MAX;                               
353     //not sensible!    return -1.0;               
354   }                                               
355                                                   
356 }                                                 
357                                                   
358                                                   
359 G4double G4WeightCutOffProcess::                  
360 AtRestGetPhysicalInteractionLength(const G4Tra    
361                                    G4ForceCond    
362 {                                                 
363   return -1.0;                                    
364 }                                                 
365                                                   
366 G4VParticleChange*                                
367 G4WeightCutOffProcess::AtRestDoIt(const G4Trac    
368 {                                                 
369   return nullptr;                                 
370 }                                                 
371                                                   
372 G4VParticleChange*                                
373 G4WeightCutOffProcess::AlongStepDoIt(const G4T    
374 {                                                 
375   // Dummy ParticleChange ie: does nothing        
376   // Expecting G4Transportation to move the tr    
377   pParticleChange->Initialize(track);             
378   return pParticleChange;                         
379 }                                                 
380                                                   
381 void G4WeightCutOffProcess::CopyStep(const G4S    
382 {                                                 
383   fGhostStep->SetTrack(step.GetTrack());          
384   fGhostStep->SetStepLength(step.GetStepLength    
385   fGhostStep->SetTotalEnergyDeposit(step.GetTo    
386   fGhostStep->SetControlFlag(step.GetControlFl    
387                                                   
388   *fGhostPreStepPoint = *(step.GetPreStepPoint    
389   *fGhostPostStepPoint = *(step.GetPostStepPoi    
390                                                   
391 //++++++++++++++++++++++++++++++++++++++++++++    
392 // Set StepStatus for ghost world                 
393 //++++++++++++++++++++++++++++++++++++++++++++    
394   if(fOnBoundary)                                 
395   { fGhostPostStepPoint->SetStepStatus(fGeomBo    
396   else if(fGhostPostStepPoint->GetStepStatus()    
397   { fGhostPostStepPoint->SetStepStatus(fPostSt    
398 //++++++++++++++++++++++++++++++++++++++++++++    
399 }                                                 
400