Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/biasing/importance/src/G4WeightCutOffProcess.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 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 10.0.p4)


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