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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/scoring/src/G4ParallelWorldProcess.cc (Version 11.3.0) and /processes/scoring/src/G4ParallelWorldProcess.cc (Version 9.2.p3)


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