Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/dna/management/src/G4ITStepProcessor.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/electromagnetic/dna/management/src/G4ITStepProcessor.cc (Version 11.3.0) and /processes/electromagnetic/dna/management/src/G4ITStepProcessor.cc (Version 10.3.p1)


  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 // $Id: G4ITStepProcessor.cc 94289 2015-11-11 08:33:40Z gcosmo $
 26 //                                                 27 //
 27 // Author: Mathieu Karamitros (kara (AT) cenbg     28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 
 28 //                                                 29 //
 29 // History:                                        30 // History:
 30 // -----------                                     31 // -----------
 31 // 10 Oct 2011 M.Karamitros created                32 // 10 Oct 2011 M.Karamitros created
 32 //                                                 33 //
 33 // -------------------------------------------     34 // -------------------------------------------------------------------
 34                                                    35 
 35 #include "G4ITStepProcessor.hh"                    36 #include "G4ITStepProcessor.hh"
 36                                                <<  37 #include "G4UImanager.hh"
 37 #include "G4ForceCondition.hh"                     38 #include "G4ForceCondition.hh"
 38 #include "G4GPILSelection.hh"                      39 #include "G4GPILSelection.hh"
                                                   >>  40 #include "G4ITTransportationManager.hh"
                                                   >>  41 // #include "G4VSensitiveDetector.hh"    // Include from 'hits/digi'
 39 #include "G4GeometryTolerance.hh"                  42 #include "G4GeometryTolerance.hh"
                                                   >>  43 #include "G4ParticleTable.hh"
                                                   >>  44 #include "G4ITTrackingManager.hh"
                                                   >>  45 #include "G4TrackingInformation.hh"
 40 #include "G4IT.hh"                                 46 #include "G4IT.hh"
 41 #include "G4ITNavigator.hh"             // Inc     47 #include "G4ITNavigator.hh"             // Include from 'geometry'
 42 #include "G4ITSteppingVerbose.hh"              <<  48 
                                                   >>  49 #include "G4VITProcess.hh"
                                                   >>  50 #include "G4VProcess.hh"
                                                   >>  51 #include "G4ITTransportation.hh"
                                                   >>  52 
 43 #include "G4ITTrackHolder.hh"                      53 #include "G4ITTrackHolder.hh"
                                                   >>  54 
                                                   >>  55 #include "G4ITSteppingVerbose.hh"
                                                   >>  56 #include "G4VITSteppingVerbose.hh"
 44 #include "G4ITTrackingInteractivity.hh"            57 #include "G4ITTrackingInteractivity.hh"
 45 #include "G4ITTrackingManager.hh"              <<  58 
 46 #include "G4ITTransportation.hh"               << 
 47 #include "G4ITTransportationManager.hh"        << 
 48 #include "G4ParticleTable.hh"                  << 
 49 #include "G4TrackingInformation.hh"                59 #include "G4TrackingInformation.hh"
 50 #include "G4UImanager.hh"                      << 
 51 #include "G4VITProcess.hh"                     << 
 52 #include "G4VITSteppingVerbose.hh"             << 
 53 #include "G4VProcess.hh"                       << 
 54                                                    60 
 55 #include <iomanip>              // Include fro     61 #include <iomanip>              // Include from 'system'
 56 #include <vector>               // Include fro     62 #include <vector>               // Include from 'system'
 57                                                    63 
 58 using namespace std;                               64 using namespace std;
 59                                                    65 
 60 static const std::size_t SizeOfSelectedDoItVec <<  66 static const size_t SizeOfSelectedDoItVector = 100;
 61                                                    67 
 62 template<typename T>                               68 template<typename T>
 63   inline bool IsInf(T value)                       69   inline bool IsInf(T value)
 64   {                                                70   {
 65     return std::numeric_limits<T>::has_infinit     71     return std::numeric_limits<T>::has_infinity
 66         && value == std::numeric_limits<T>::in     72         && value == std::numeric_limits<T>::infinity();
 67   }                                                73   }
 68                                                    74 
 69 //____________________________________________     75 //______________________________________________________________________________
 70                                                    76 
 71 G4ITStepProcessor::G4ITStepProcessor()             77 G4ITStepProcessor::G4ITStepProcessor()
 72 {                                                  78 {
 73   fpVerbose = nullptr;                         <<  79   fpVerbose = 0;
 74   // fpUserSteppingAction = 0 ;                    80   // fpUserSteppingAction = 0 ;
 75   fStoreTrajectory = 0;                            81   fStoreTrajectory = 0;
 76   fpTrackingManager = nullptr;                 <<  82   fpTrackingManager = 0;
 77   fpNavigator = nullptr;                       <<  83   fpNavigator = 0;
 78   kCarTolerance = -1.;                             84   kCarTolerance = -1.;
 79   fInitialized = false;                            85   fInitialized = false;
 80   fPreviousTimeStep = DBL_MAX;                     86   fPreviousTimeStep = DBL_MAX;
 81   fILTimeStep = DBL_MAX;                           87   fILTimeStep = DBL_MAX;
 82   fpTrackContainer = nullptr;                  <<  88   fpTrackContainer = 0;
 83                                                    89 
 84   CleanProcessor();                                90   CleanProcessor();
 85   ResetSecondaries();                              91   ResetSecondaries();
 86 }                                                  92 }
 87                                                    93 
 88 //____________________________________________     94 //______________________________________________________________________________
 89                                                    95 
 90 //G4ITStepProcessor::                              96 //G4ITStepProcessor::
 91 G4ITStepProcessorState::G4ITStepProcessorState     97 G4ITStepProcessorState::G4ITStepProcessorState() :
 92     G4ITStepProcessorState_Lock(),                 98     G4ITStepProcessorState_Lock(),
 93     fSelectedAtRestDoItVector(G4VITProcess::Ge     99     fSelectedAtRestDoItVector(G4VITProcess::GetMaxProcessIndex(), 0),
 94     fSelectedPostStepDoItVector(G4VITProcess::    100     fSelectedPostStepDoItVector(G4VITProcess::GetMaxProcessIndex(), 0)
 95 {                                                 101 {
 96   fPhysicalStep = -1.;                            102   fPhysicalStep = -1.;
 97   fPreviousStepSize = -1.;                        103   fPreviousStepSize = -1.;
 98                                                   104 
 99   fSafety = -1.;                                  105   fSafety = -1.;
100   fProposedSafety = -1.;                          106   fProposedSafety = -1.;
101   fEndpointSafety = -1;                           107   fEndpointSafety = -1;
102                                                   108 
103   fStepStatus = fUndefined;                       109   fStepStatus = fUndefined;
104                                                   110 
105   fTouchableHandle = nullptr;                  << 111   fTouchableHandle = 0;
106 }                                                 112 }
107                                                   113 
108 //____________________________________________    114 //______________________________________________________________________________
109                                                   115 
110 //G4ITStepProcessor::                             116 //G4ITStepProcessor::
111 G4ITStepProcessorState::G4ITStepProcessorState    117 G4ITStepProcessorState::G4ITStepProcessorState(const G4ITStepProcessorState& right) :
112     G4ITStepProcessorState_Lock(),                118     G4ITStepProcessorState_Lock(),
113     fSelectedAtRestDoItVector(right.fSelectedA    119     fSelectedAtRestDoItVector(right.fSelectedAtRestDoItVector),
114     fSelectedPostStepDoItVector(right.fSelecte    120     fSelectedPostStepDoItVector(right.fSelectedPostStepDoItVector)
115 {                                                 121 {
116   fPhysicalStep = right.fPhysicalStep;            122   fPhysicalStep = right.fPhysicalStep;
117   fPreviousStepSize = right.fPreviousStepSize;    123   fPreviousStepSize = right.fPreviousStepSize;
118                                                   124 
119   fSafety = right.fSafety;                        125   fSafety = right.fSafety;
120   fProposedSafety = right.fProposedSafety;        126   fProposedSafety = right.fProposedSafety;
121   fEndpointSafety = right.fEndpointSafety;        127   fEndpointSafety = right.fEndpointSafety;
122                                                   128 
123   fStepStatus = right.fStepStatus;                129   fStepStatus = right.fStepStatus;
124                                                   130 
125   fTouchableHandle = right.fTouchableHandle;      131   fTouchableHandle = right.fTouchableHandle;
126 }                                                 132 }
127                                                   133 
128 //____________________________________________    134 //______________________________________________________________________________
129                                                   135 
130 //G4ITStepProcessor::                             136 //G4ITStepProcessor::
131 G4ITStepProcessorState&                           137 G4ITStepProcessorState&
132 //G4ITStepProcessor::                             138 //G4ITStepProcessor::
133 G4ITStepProcessorState::operator=(const G4ITSt    139 G4ITStepProcessorState::operator=(const G4ITStepProcessorState& right)
134 {                                                 140 {
135   if(this == &right) return *this;                141   if(this == &right) return *this;
136                                                   142 
137   fSelectedAtRestDoItVector.clear();              143   fSelectedAtRestDoItVector.clear();
138   fSelectedAtRestDoItVector = right.fSelectedA    144   fSelectedAtRestDoItVector = right.fSelectedAtRestDoItVector;
139   fSelectedPostStepDoItVector.clear();            145   fSelectedPostStepDoItVector.clear();
140   fSelectedPostStepDoItVector = right.fSelecte    146   fSelectedPostStepDoItVector = right.fSelectedPostStepDoItVector;
141                                                   147 
142   fPhysicalStep = right.fPhysicalStep;            148   fPhysicalStep = right.fPhysicalStep;
143   fPreviousStepSize = right.fPreviousStepSize;    149   fPreviousStepSize = right.fPreviousStepSize;
144                                                   150 
145   fSafety = right.fSafety;                        151   fSafety = right.fSafety;
146   fProposedSafety = right.fProposedSafety;        152   fProposedSafety = right.fProposedSafety;
147   fEndpointSafety = right.fEndpointSafety;        153   fEndpointSafety = right.fEndpointSafety;
148                                                   154 
149   fStepStatus = right.fStepStatus;                155   fStepStatus = right.fStepStatus;
150                                                   156 
151   fTouchableHandle = right.fTouchableHandle;      157   fTouchableHandle = right.fTouchableHandle;
152   return *this;                                   158   return *this;
153 }                                                 159 }
154                                                   160 
155 //____________________________________________    161 //______________________________________________________________________________
156                                                   162 
157 //G4ITStepProcessor::                             163 //G4ITStepProcessor::
158 G4ITStepProcessorState::~G4ITStepProcessorStat    164 G4ITStepProcessorState::~G4ITStepProcessorState()
159 {                                                 165 {
160   ;                                               166   ;
161 }                                                 167 }
162                                                   168 
163 //____________________________________________    169 //______________________________________________________________________________
164                                                   170 
165 void G4ITStepProcessor::ClearProcessInfo()        171 void G4ITStepProcessor::ClearProcessInfo()
166 {                                                 172 {
167   std::map<const G4ParticleDefinition*, Proces    173   std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it;
168                                                   174 
169   for(it = fProcessGeneralInfoMap.begin(); it     175   for(it = fProcessGeneralInfoMap.begin(); it != fProcessGeneralInfoMap.end();
170       it++)                                       176       it++)
171   {                                               177   {
172     if(it->second != nullptr)                  << 178     if(it->second)
173     {                                             179     {
174       delete it->second;                          180       delete it->second;
175       it->second = 0;                             181       it->second = 0;
176     }                                             182     }
177   }                                               183   }
178                                                   184 
179   fProcessGeneralInfoMap.clear();                 185   fProcessGeneralInfoMap.clear();
180 }                                                 186 }
181                                                   187 
182 //____________________________________________    188 //______________________________________________________________________________
183                                                   189 
184 void G4ITStepProcessor::ForceReInitialization(    190 void G4ITStepProcessor::ForceReInitialization()
185 {                                                 191 {
186   fInitialized = false;                           192   fInitialized = false;
187   ClearProcessInfo();                             193   ClearProcessInfo();
188   Initialize();                                   194   Initialize();
189 }                                                 195 }
190                                                   196 
191 //____________________________________________    197 //______________________________________________________________________________
192                                                   198 
193 void G4ITStepProcessor::Initialize()              199 void G4ITStepProcessor::Initialize()
194 {                                                 200 {
195   CleanProcessor();                               201   CleanProcessor();
196   if(fInitialized) return;                        202   if(fInitialized) return;
197   //    ActiveOnlyITProcess();                    203   //    ActiveOnlyITProcess();
198                                                   204 
199   SetNavigator(G4ITTransportationManager::GetT    205   SetNavigator(G4ITTransportationManager::GetTransportationManager()
200       ->GetNavigatorForTracking());               206       ->GetNavigatorForTracking());
201                                                   207 
202   fPhysIntLength = DBL_MAX;                       208   fPhysIntLength = DBL_MAX;
203   kCarTolerance = 0.5                             209   kCarTolerance = 0.5
204       * G4GeometryTolerance::GetInstance()->Ge    210       * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
205                                                   211 
206   if(fpVerbose == nullptr)                     << 212   if(fpVerbose == 0)
207   {                                               213   {
208     G4ITTrackingInteractivity* interactivity =    214     G4ITTrackingInteractivity* interactivity = fpTrackingManager->GetInteractivity();
209                                                   215 
210     if(interactivity != nullptr)               << 216     if(interactivity)
211     {                                             217     {
212       fpVerbose = interactivity->GetSteppingVe    218       fpVerbose = interactivity->GetSteppingVerbose();
213       fpVerbose->SetStepProcessor(this);          219       fpVerbose->SetStepProcessor(this);
214     }                                             220     }
215   }                                               221   }
216                                                   222 
217   fpTrackContainer = G4ITTrackHolder::Instance    223   fpTrackContainer = G4ITTrackHolder::Instance();
218                                                   224 
219   fInitialized = true;                            225   fInitialized = true;
220 }                                                 226 }
221 //____________________________________________    227 //______________________________________________________________________________
222                                                   228 
223 G4ITStepProcessor::~G4ITStepProcessor()           229 G4ITStepProcessor::~G4ITStepProcessor()
224 {                                                 230 {
225   if(fpStep != nullptr)                        << 231   if(fpStep)
226   {                                               232   {
227     fpStep->DeleteSecondaryVector();              233     fpStep->DeleteSecondaryVector();
228     delete fpStep;                                234     delete fpStep;
229   }                                               235   }
230                                                   236 
231   delete fpSecondary;                          << 237   if(fpSecondary) delete fpSecondary;
232   ClearProcessInfo();                             238   ClearProcessInfo();
233   //G4ITTransportationManager::DeleteInstance(    239   //G4ITTransportationManager::DeleteInstance();
234                                                   240 
235   //    if(fpUserSteppingAction)             d    241   //    if(fpUserSteppingAction)             delete fpUserSteppingAction;
236 }                                                 242 }
237 //____________________________________________    243 //______________________________________________________________________________
238 // should not be used                             244 // should not be used
239 G4ITStepProcessor::G4ITStepProcessor(const G4I    245 G4ITStepProcessor::G4ITStepProcessor(const G4ITStepProcessor& rhs)
240 {                                                 246 {
241   fpVerbose = rhs.fpVerbose;                      247   fpVerbose = rhs.fpVerbose;
242   fStoreTrajectory = rhs.fStoreTrajectory;        248   fStoreTrajectory = rhs.fStoreTrajectory;
243                                                   249 
244   //    fpUserSteppingAction = 0 ;                250   //    fpUserSteppingAction = 0 ;
245   fpTrackingManager = nullptr;                 << 251   fpTrackingManager = 0;
246   fpNavigator = nullptr;                       << 252   fpNavigator = 0;
247   fInitialized = false;                           253   fInitialized = false;
248                                                   254 
249   kCarTolerance = rhs.kCarTolerance;              255   kCarTolerance = rhs.kCarTolerance;
250   fInitialized = false;                           256   fInitialized = false;
251   fPreviousTimeStep = DBL_MAX;                    257   fPreviousTimeStep = DBL_MAX;
252                                                   258 
253   CleanProcessor();                               259   CleanProcessor();
254   ResetSecondaries();                             260   ResetSecondaries();
255   fpTrackContainer = nullptr;                  << 261   fpTrackContainer = 0;
256   fILTimeStep = DBL_MAX;                          262   fILTimeStep = DBL_MAX;
257 }                                                 263 }
258                                                   264 
259 //____________________________________________    265 //______________________________________________________________________________
260                                                   266 
261 void G4ITStepProcessor::ResetLeadingTracks()      267 void G4ITStepProcessor::ResetLeadingTracks()
262 {                                                 268 {
263   fLeadingTracks.Reset();                         269   fLeadingTracks.Reset();
264 }                                                 270 }
265                                                   271 
266 //____________________________________________    272 //______________________________________________________________________________
267                                                   273 
268 void G4ITStepProcessor::PrepareLeadingTracks()    274 void G4ITStepProcessor::PrepareLeadingTracks()
269 {                                                 275 {
270   fLeadingTracks.PrepareLeadingTracks();          276   fLeadingTracks.PrepareLeadingTracks();
271 }                                                 277 }
272                                                   278 
273 //____________________________________________    279 //______________________________________________________________________________
274                                                   280 
275 G4ITStepProcessor& G4ITStepProcessor::operator    281 G4ITStepProcessor& G4ITStepProcessor::operator=(const G4ITStepProcessor& rhs)
276 {                                                 282 {
277   if(this == &rhs) return *this; // handle sel    283   if(this == &rhs) return *this; // handle self assignment
278   //assignment operator                           284   //assignment operator
279   return *this;                                   285   return *this;
280 }                                                 286 }
281                                                   287 
282 //____________________________________________    288 //______________________________________________________________________________
283                                                   289 
284 void G4ITStepProcessor::ActiveOnlyITProcess()     290 void G4ITStepProcessor::ActiveOnlyITProcess()
285 {                                                 291 {
286   // Method not used for the time being           292   // Method not used for the time being
287 #ifdef debug                                      293 #ifdef debug
288   G4cout<<"G4ITStepProcessor::CloneProcesses:     294   G4cout<<"G4ITStepProcessor::CloneProcesses: is called"<<G4endl;
289 #endif                                            295 #endif
290                                                   296 
291   G4ParticleTable* theParticleTable = G4Partic    297   G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
292   G4ParticleTable::G4PTblDicIterator* theParti    298   G4ParticleTable::G4PTblDicIterator* theParticleIterator = theParticleTable
293       ->GetIterator();                            299       ->GetIterator();
294                                                   300 
295   theParticleIterator->reset();                   301   theParticleIterator->reset();
296   // TODO : Ne faire la boucle que sur les IT     302   // TODO : Ne faire la boucle que sur les IT **** !!!
297   while((*theParticleIterator)())                 303   while((*theParticleIterator)())
298   {                                               304   {
299     G4ParticleDefinition* particle = thePartic    305     G4ParticleDefinition* particle = theParticleIterator->value();
300     G4ProcessManager* pm = particle->GetProces    306     G4ProcessManager* pm = particle->GetProcessManager();
301                                                   307 
302     if(pm == nullptr)                          << 308     if(!pm)
303     {                                             309     {
304       G4cerr << "ERROR - G4ITStepProcessor::Ge    310       G4cerr << "ERROR - G4ITStepProcessor::GetProcessNumber()" << G4endl<< "        ProcessManager is NULL for particle = "
305       << particle->GetParticleName() << ", PDG    311       << particle->GetParticleName() << ", PDG_code = "
306       << particle->GetPDGEncoding() << G4endl;    312       << particle->GetPDGEncoding() << G4endl;
307       G4Exception("G4ITStepProcessor::GetProce    313       G4Exception("G4ITStepProcessor::GetProcessNumber()", "ITStepProcessor0001",
308           FatalException, "Process Manager is     314           FatalException, "Process Manager is not found.");
309       return;                                     315       return;
310     }                                             316     }
311                                                   317 
312     ActiveOnlyITProcess(pm);                      318     ActiveOnlyITProcess(pm);
313   }                                               319   }
314 }                                                 320 }
315                                                   321 
316 //____________________________________________    322 //______________________________________________________________________________
317                                                   323 
318 void G4ITStepProcessor::ActiveOnlyITProcess(G4    324 void G4ITStepProcessor::ActiveOnlyITProcess(G4ProcessManager* processManager)
319 {                                                 325 {
320   // Method not used for the time being           326   // Method not used for the time being
321   G4ProcessVector* processVector = processMana    327   G4ProcessVector* processVector = processManager->GetProcessList();
322                                                   328 
323   G4VITProcess* itProcess = nullptr;           << 329   G4VITProcess* itProcess = 0;
324   for(G4int i = 0; i < (G4int)processVector->s << 330   for(int i = 0; i < processVector->size(); i++)
325   {                                               331   {
326     G4VProcess* base_process = (*processVector    332     G4VProcess* base_process = (*processVector)[i];
327     itProcess = dynamic_cast<G4VITProcess*>(ba    333     itProcess = dynamic_cast<G4VITProcess*>(base_process);
328                                                   334 
329     if(itProcess == nullptr)                   << 335     if(!itProcess)
330     {                                             336     {
331       processManager->SetProcessActivation(bas    337       processManager->SetProcessActivation(base_process, false);
332     }                                             338     }
333   }                                               339   }
334 }                                                 340 }
335                                                   341 
336 //____________________________________________    342 //______________________________________________________________________________
337                                                   343 
338 void G4ITStepProcessor::SetupGeneralProcessInf    344 void G4ITStepProcessor::SetupGeneralProcessInfo(G4ParticleDefinition* particle,
339                                                   345                                                 G4ProcessManager* pm)
340 {                                                 346 {
341                                                   347 
342 #ifdef debug                                      348 #ifdef debug
343   G4cout<<"G4ITStepProcessor::GetProcessNumber    349   G4cout<<"G4ITStepProcessor::GetProcessNumber: is called track"<<G4endl;
344 #endif                                            350 #endif
345   if(pm == nullptr)                            << 351   if(!pm)
346   {                                               352   {
347     G4cerr << "ERROR - G4SteppingManager::GetP    353     G4cerr << "ERROR - G4SteppingManager::GetProcessNumber()" << G4endl<< "        ProcessManager is NULL for particle = "
348     << particle->GetParticleName() << ", PDG_c    354     << particle->GetParticleName() << ", PDG_code = "
349     << particle->GetPDGEncoding() << G4endl;      355     << particle->GetPDGEncoding() << G4endl;
350     G4Exception("G4SteppingManager::GetProcess    356     G4Exception("G4SteppingManager::GetProcessNumber()", "ITStepProcessor0002",
351         FatalException, "Process Manager is no    357         FatalException, "Process Manager is not found.");
352     return;                                       358     return;
353   }                                               359   }
354                                                   360 
355   auto it =                                    << 361   std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it =
356   fProcessGeneralInfoMap.find(particle);          362   fProcessGeneralInfoMap.find(particle);
357   if(it != fProcessGeneralInfoMap.end())          363   if(it != fProcessGeneralInfoMap.end())
358   {                                               364   {
359     G4Exception("G4SteppingManager::SetupGener    365     G4Exception("G4SteppingManager::SetupGeneralProcessInfo()",
360         "ITStepProcessor0003",                    366         "ITStepProcessor0003",
361         FatalException, "Process info already     367         FatalException, "Process info already registered.");
362     return;                                       368     return;
363   }                                               369   }
364                                                   370 
365   // here used as temporary                       371   // here used as temporary
366   fpProcessInfo = new ProcessGeneralInfo();       372   fpProcessInfo = new ProcessGeneralInfo();
367                                                   373 
368   // AtRestDoits                                  374   // AtRestDoits
369   fpProcessInfo->MAXofAtRestLoops = pm->GetAtR    375   fpProcessInfo->MAXofAtRestLoops = pm->GetAtRestProcessVector()->entries();
370   fpProcessInfo->fpAtRestDoItVector = pm->GetA    376   fpProcessInfo->fpAtRestDoItVector = pm->GetAtRestProcessVector(typeDoIt);
371   fpProcessInfo->fpAtRestGetPhysIntVector =       377   fpProcessInfo->fpAtRestGetPhysIntVector =
372   pm->GetAtRestProcessVector(typeGPIL);           378   pm->GetAtRestProcessVector(typeGPIL);
373 #ifdef debug                                      379 #ifdef debug
374   G4cout << "G4ITStepProcessor::GetProcessNumb    380   G4cout << "G4ITStepProcessor::GetProcessNumber: #ofAtRest="
375   << fpProcessInfo->MAXofAtRestLoops << G4endl    381   << fpProcessInfo->MAXofAtRestLoops << G4endl;
376 #endif                                            382 #endif
377                                                   383 
378   // AlongStepDoits                               384   // AlongStepDoits
379   fpProcessInfo->MAXofAlongStepLoops =            385   fpProcessInfo->MAXofAlongStepLoops =
380   pm->GetAlongStepProcessVector()->entries();     386   pm->GetAlongStepProcessVector()->entries();
381   fpProcessInfo->fpAlongStepDoItVector =          387   fpProcessInfo->fpAlongStepDoItVector =
382   pm->GetAlongStepProcessVector(typeDoIt);        388   pm->GetAlongStepProcessVector(typeDoIt);
383   fpProcessInfo->fpAlongStepGetPhysIntVector =    389   fpProcessInfo->fpAlongStepGetPhysIntVector =
384   pm->GetAlongStepProcessVector(typeGPIL);        390   pm->GetAlongStepProcessVector(typeGPIL);
385 #ifdef debug                                      391 #ifdef debug
386   G4cout << "G4ITStepProcessor::GetProcessNumb    392   G4cout << "G4ITStepProcessor::GetProcessNumber:#ofAlongStp="
387   << fpProcessInfo->MAXofAlongStepLoops << G4e    393   << fpProcessInfo->MAXofAlongStepLoops << G4endl;
388 #endif                                            394 #endif
389                                                   395 
390   // PostStepDoits                                396   // PostStepDoits
391   fpProcessInfo->MAXofPostStepLoops =             397   fpProcessInfo->MAXofPostStepLoops =
392   pm->GetPostStepProcessVector()->entries();      398   pm->GetPostStepProcessVector()->entries();
393   fpProcessInfo->fpPostStepDoItVector = pm->Ge    399   fpProcessInfo->fpPostStepDoItVector = pm->GetPostStepProcessVector(typeDoIt);
394   fpProcessInfo->fpPostStepGetPhysIntVector =     400   fpProcessInfo->fpPostStepGetPhysIntVector =
395   pm->GetPostStepProcessVector(typeGPIL);         401   pm->GetPostStepProcessVector(typeGPIL);
396 #ifdef debug                                      402 #ifdef debug
397   G4cout << "G4ITStepProcessor::GetProcessNumb    403   G4cout << "G4ITStepProcessor::GetProcessNumber: #ofPostStep="
398   << fpProcessInfo->MAXofPostStepLoops << G4en    404   << fpProcessInfo->MAXofPostStepLoops << G4endl;
399 #endif                                            405 #endif
400                                                   406 
401   if (SizeOfSelectedDoItVector<fpProcessInfo->    407   if (SizeOfSelectedDoItVector<fpProcessInfo->MAXofAtRestLoops ||
402       SizeOfSelectedDoItVector<fpProcessInfo->    408       SizeOfSelectedDoItVector<fpProcessInfo->MAXofAlongStepLoops ||
403       SizeOfSelectedDoItVector<fpProcessInfo->    409       SizeOfSelectedDoItVector<fpProcessInfo->MAXofPostStepLoops )
404   {                                               410   {
405     G4cerr << "ERROR - G4ITStepProcessor::GetP    411     G4cerr << "ERROR - G4ITStepProcessor::GetProcessNumber()" << G4endl
406     << "        SizeOfSelectedDoItVector= " <<    412     << "        SizeOfSelectedDoItVector= " << SizeOfSelectedDoItVector
407     << " ; is smaller then one of MAXofAtRestL    413     << " ; is smaller then one of MAXofAtRestLoops= "
408     << fpProcessInfo->MAXofAtRestLoops << G4en    414     << fpProcessInfo->MAXofAtRestLoops << G4endl
409     << "        or MAXofAlongStepLoops= " << f    415     << "        or MAXofAlongStepLoops= " << fpProcessInfo->MAXofAlongStepLoops
410     << " or MAXofPostStepLoops= " << fpProcess    416     << " or MAXofPostStepLoops= " << fpProcessInfo->MAXofPostStepLoops << G4endl;
411     G4Exception("G4ITStepProcessor::GetProcess    417     G4Exception("G4ITStepProcessor::GetProcessNumber()",
412         "ITStepProcessor0004", FatalException,    418         "ITStepProcessor0004", FatalException,
413         "The array size is smaller than the ac    419         "The array size is smaller than the actual No of processes.");
414   }                                               420   }
415                                                   421 
416   if((fpProcessInfo->fpAtRestDoItVector == nul << 422   if(!fpProcessInfo->fpAtRestDoItVector &&
417       (fpProcessInfo->fpAlongStepDoItVector == << 423       !fpProcessInfo->fpAlongStepDoItVector &&
418       (fpProcessInfo->fpPostStepDoItVector ==  << 424       !fpProcessInfo->fpPostStepDoItVector)
419   {                                               425   {
420     G4ExceptionDescription exceptionDescriptio    426     G4ExceptionDescription exceptionDescription;
421     exceptionDescription << "No DoIt process f    427     exceptionDescription << "No DoIt process found ";
422     G4Exception("G4ITStepProcessor::DoStepping    428     G4Exception("G4ITStepProcessor::DoStepping","ITStepProcessor0005",
423         FatalErrorInArgument,exceptionDescript    429         FatalErrorInArgument,exceptionDescription);
424     return;                                       430     return;
425   }                                               431   }
426                                                   432 
427   if((fpProcessInfo->fpAlongStepGetPhysIntVect << 433   if(fpProcessInfo->fpAlongStepGetPhysIntVector
428       && fpProcessInfo->MAXofAlongStepLoops>0)    434       && fpProcessInfo->MAXofAlongStepLoops>0)
429   {                                               435   {
430     fpProcessInfo->fpTransportation = dynamic_    436     fpProcessInfo->fpTransportation = dynamic_cast<G4ITTransportation*>
431     ((*fpProcessInfo->fpAlongStepGetPhysIntVec    437     ((*fpProcessInfo->fpAlongStepGetPhysIntVector)
432         [G4int(fpProcessInfo->MAXofAlongStepLo << 438         [fpProcessInfo->MAXofAlongStepLoops-1]);
433                                                   439 
434     if(fpProcessInfo->fpTransportation == null << 440     if(fpProcessInfo->fpTransportation == 0)
435     {                                             441     {
436       G4ExceptionDescription exceptionDescript    442       G4ExceptionDescription exceptionDescription;
437       exceptionDescription << "No transportati    443       exceptionDescription << "No transportation process found ";
438       G4Exception("G4ITStepProcessor::SetupGen    444       G4Exception("G4ITStepProcessor::SetupGeneralProcessInfo",
439           "ITStepProcessor0006",                  445           "ITStepProcessor0006",
440           FatalErrorInArgument,exceptionDescri    446           FatalErrorInArgument,exceptionDescription);
441     }                                             447     }
442   }                                               448   }
443   fProcessGeneralInfoMap[particle] = fpProcess    449   fProcessGeneralInfoMap[particle] = fpProcessInfo;
444   //    fpProcessInfo = 0;                        450   //    fpProcessInfo = 0;
445 }                                                 451 }
446                                                   452 
447 //____________________________________________    453 //______________________________________________________________________________
448                                                   454 
449 void G4ITStepProcessor::SetTrack(G4Track* trac    455 void G4ITStepProcessor::SetTrack(G4Track* track)
450 {                                                 456 {
451   fpTrack = track;                                457   fpTrack = track;
452   if(fpTrack != nullptr)                       << 458   if(fpTrack)
453   {                                               459   {
454     fpITrack = GetIT(fpTrack);                    460     fpITrack = GetIT(fpTrack);
455     fpStep = const_cast<G4Step*>(fpTrack->GetS    461     fpStep = const_cast<G4Step*>(fpTrack->GetStep());
456                                                   462 
457     if(fpITrack != nullptr)                    << 463     if(fpITrack)
458     {                                             464     {
459       fpTrackingInfo = fpITrack->GetTrackingIn    465       fpTrackingInfo = fpITrack->GetTrackingInfo();
460     }                                             466     }
461     else                                          467     else
462     {                                             468     {
463       fpTrackingInfo = nullptr;                << 469       fpTrackingInfo = 0;
464       G4cerr << "Track ID : " << fpTrack->GetT    470       G4cerr << "Track ID : " << fpTrack->GetTrackID() << G4endl;
465                                                   471 
466       G4ExceptionDescription errMsg;              472       G4ExceptionDescription errMsg;
467       errMsg << "No IT pointer was attached to    473       errMsg << "No IT pointer was attached to the track you try to process.";
468       G4Exception("G4ITStepProcessor::SetTrack    474       G4Exception("G4ITStepProcessor::SetTrack",
469                   "ITStepProcessor0007",          475                   "ITStepProcessor0007",
470                   FatalErrorInArgument,           476                   FatalErrorInArgument,
471                   errMsg);                        477                   errMsg);
472     }                                             478     }
473   }                                               479   }
474   else                                            480   else
475   {                                               481   {
476     fpITrack = nullptr;                        << 482     fpITrack = 0;
477     fpStep = nullptr;                          << 483     fpStep = 0;
478   }                                               484   }
479 }                                                 485 }
480 //____________________________________________    486 //______________________________________________________________________________
481                                                   487 
482 void G4ITStepProcessor::GetProcessInfo()          488 void G4ITStepProcessor::GetProcessInfo()
483 {                                                 489 {
484   G4ParticleDefinition* particle = fpTrack->Ge    490   G4ParticleDefinition* particle = fpTrack->GetDefinition();
485   auto it =                                    << 491   std::map<const G4ParticleDefinition*, ProcessGeneralInfo*>::iterator it =
486       fProcessGeneralInfoMap.find(particle);      492       fProcessGeneralInfoMap.find(particle);
487                                                   493 
488   if(it == fProcessGeneralInfoMap.end())          494   if(it == fProcessGeneralInfoMap.end())
489   {                                               495   {
490     SetupGeneralProcessInfo(particle,             496     SetupGeneralProcessInfo(particle,
491                             fpTrack->GetDefini    497                             fpTrack->GetDefinition()->GetProcessManager());
492     if(fpProcessInfo == nullptr)               << 498     if(fpProcessInfo == 0)
493     {                                             499     {
494       G4ExceptionDescription exceptionDescript    500       G4ExceptionDescription exceptionDescription("...");
495       G4Exception("G4ITStepProcessor::GetProce    501       G4Exception("G4ITStepProcessor::GetProcessNumber",
496                   "ITStepProcessor0008",          502                   "ITStepProcessor0008",
497                   FatalErrorInArgument,           503                   FatalErrorInArgument,
498                   exceptionDescription);          504                   exceptionDescription);
499       return;                                     505       return;
500     }                                             506     }
501   }                                               507   }
502   else                                            508   else
503   {                                               509   {
504     fpProcessInfo = it->second;                   510     fpProcessInfo = it->second;
505   }                                               511   }
506 }                                                 512 }
507                                                   513 
508 //____________________________________________    514 //______________________________________________________________________________
509                                                   515 
510 void G4ITStepProcessor::SetupMembers()            516 void G4ITStepProcessor::SetupMembers()
511 {                                                 517 {
512   fpSecondary = fpStep->GetfSecondary();          518   fpSecondary = fpStep->GetfSecondary();
513   fpPreStepPoint = fpStep->GetPreStepPoint();     519   fpPreStepPoint = fpStep->GetPreStepPoint();
514   fpPostStepPoint = fpStep->GetPostStepPoint()    520   fpPostStepPoint = fpStep->GetPostStepPoint();
515                                                   521 
516   fpState = (G4ITStepProcessorState*) fpITrack    522   fpState = (G4ITStepProcessorState*) fpITrack->GetTrackingInfo()
517       ->GetStepProcessorState();                  523       ->GetStepProcessorState();
518                                                   524 
519   GetProcessInfo();                               525   GetProcessInfo();
520   ResetSecondaries();                             526   ResetSecondaries();
521 }                                                 527 }
522                                                   528 
523 //____________________________________________    529 //______________________________________________________________________________
524                                                   530 
525 void G4ITStepProcessor::ResetSecondaries()        531 void G4ITStepProcessor::ResetSecondaries()
526 {                                                 532 {
527   // Reset the secondary particles                533   // Reset the secondary particles
528   fN2ndariesAtRestDoIt = 0;                       534   fN2ndariesAtRestDoIt = 0;
529   fN2ndariesAlongStepDoIt = 0;                    535   fN2ndariesAlongStepDoIt = 0;
530   fN2ndariesPostStepDoIt = 0;                     536   fN2ndariesPostStepDoIt = 0;
531 }                                                 537 }
532                                                   538 
533 //____________________________________________    539 //______________________________________________________________________________
534                                                   540 
535 void G4ITStepProcessor::GetAtRestIL()             541 void G4ITStepProcessor::GetAtRestIL()
536 {                                                 542 {
537   // Select the rest process which has the sho    543   // Select the rest process which has the shortest time before
538   // it is invoked. In rest processes, GPIL()     544   // it is invoked. In rest processes, GPIL()
539   // returns the time before a process occurs.    545   // returns the time before a process occurs.
540   G4double lifeTime(DBL_MAX), shortestLifeTime    546   G4double lifeTime(DBL_MAX), shortestLifeTime (DBL_MAX);
541                                                   547 
542   fAtRestDoItProcTriggered = 0;                   548   fAtRestDoItProcTriggered = 0;
543   shortestLifeTime = DBL_MAX;                     549   shortestLifeTime = DBL_MAX;
544                                                   550 
545   unsigned int NofInactiveProc=0;                 551   unsigned int NofInactiveProc=0;
546                                                   552 
547   for( G4int ri=0; ri < (G4int)fpProcessInfo-> << 553   for( size_t ri=0; ri < fpProcessInfo->MAXofAtRestLoops; ri++ )
548   {                                               554   {
549     fpCurrentProcess = dynamic_cast<G4VITProce    555     fpCurrentProcess = dynamic_cast<G4VITProcess*>((*fpProcessInfo->fpAtRestGetPhysIntVector)[ri]);
550     if (fpCurrentProcess== nullptr)            << 556     if (fpCurrentProcess== 0)
551     {                                             557     {
552       (fpState->fSelectedAtRestDoItVector)[ri]    558       (fpState->fSelectedAtRestDoItVector)[ri] = InActivated;
553       NofInactiveProc++;                          559       NofInactiveProc++;
554       continue;                                   560       continue;
555     } // NULL means the process is inactivated    561     } // NULL means the process is inactivated by a user on fly.
556                                                   562 
557     fCondition=NotForced;                         563     fCondition=NotForced;
558     fpCurrentProcess->SetProcessState(            564     fpCurrentProcess->SetProcessState(
559         fpTrackingInfo->GetProcessState(fpCurr    565         fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID()));
560                                                   566 
561     lifeTime = fpCurrentProcess->AtRestGPIL( *    567     lifeTime = fpCurrentProcess->AtRestGPIL( *fpTrack, &fCondition );
562     fpCurrentProcess->ResetProcessState();        568     fpCurrentProcess->ResetProcessState();
563                                                   569 
564     if(fCondition==Forced)                        570     if(fCondition==Forced)
565     {                                             571     {
566       (fpState->fSelectedAtRestDoItVector)[ri]    572       (fpState->fSelectedAtRestDoItVector)[ri] = Forced;
567     }                                             573     }
568     else                                          574     else
569     {                                             575     {
570       (fpState->fSelectedAtRestDoItVector)[ri]    576       (fpState->fSelectedAtRestDoItVector)[ri] = InActivated;
571       if(lifeTime < shortestLifeTime )            577       if(lifeTime < shortestLifeTime )
572       {                                           578       {
573         shortestLifeTime = lifeTime;              579         shortestLifeTime = lifeTime;
574         fAtRestDoItProcTriggered = G4int(ri);     580         fAtRestDoItProcTriggered = G4int(ri);
575       }                                           581       }
576     }                                             582     }
577   }                                               583   }
578                                                   584 
579   (fpState->fSelectedAtRestDoItVector)[fAtRest    585   (fpState->fSelectedAtRestDoItVector)[fAtRestDoItProcTriggered] = NotForced;
580                                                   586 
581 //  G4cout << " --> Selected at rest process :    587 //  G4cout << " --> Selected at rest process : "
582 //         << (*fpProcessInfo->fpAtRestGetPhys    588 //         << (*fpProcessInfo->fpAtRestGetPhysIntVector)[fAtRestDoItProcTriggered]
583 //            ->GetProcessName()                  589 //            ->GetProcessName()
584 //         << G4endl;                             590 //         << G4endl;
585                                                   591 
586   fTimeStep = shortestLifeTime;                   592   fTimeStep = shortestLifeTime;
587                                                   593 
588   // at least one process is necessary to dest    594   // at least one process is necessary to destroy the particle
589   // exit with warning                            595   // exit with warning
590   if(NofInactiveProc==fpProcessInfo->MAXofAtRe    596   if(NofInactiveProc==fpProcessInfo->MAXofAtRestLoops)
591   {                                               597   {
592     G4cerr << "ERROR - G4ITStepProcessor::Invo    598     G4cerr << "ERROR - G4ITStepProcessor::InvokeAtRestDoItProcs()" << G4endl
593     << "        No AtRestDoIt process is activ    599     << "        No AtRestDoIt process is active!" << G4endl;
594   }                                               600   }
595 }                                                 601 }
596                                                   602 
597 //____________________________________________    603 //_________________________________________________________________________
598 G4double G4ITStepProcessor::ComputeInteraction    604 G4double G4ITStepProcessor::ComputeInteractionLength(double previousTimeStep)
599 {                                                 605 {
600   G4TrackManyList* mainList = fpTrackContainer    606   G4TrackManyList* mainList = fpTrackContainer->GetMainList();
601   G4TrackManyList::iterator it = mainList ->be    607   G4TrackManyList::iterator it = mainList ->begin();
602   G4TrackManyList::iterator end = mainList ->e    608   G4TrackManyList::iterator end = mainList ->end();
603                                                   609 
604   SetPreviousStepTime(previousTimeStep);          610   SetPreviousStepTime(previousTimeStep);
605                                                   611 
606   fILTimeStep = DBL_MAX;                          612   fILTimeStep = DBL_MAX;
607                                                   613 
608   for (; it != end; )                             614   for (; it != end; )
609   {                                               615   {
610     G4Track * track = *it;                        616     G4Track * track = *it;
611                                                   617 
612 #ifdef DEBUG                                      618 #ifdef DEBUG
613     G4cout << "*CIL* " << GetIT(track)->GetNam    619     G4cout << "*CIL* " << GetIT(track)->GetName()
614         << " ID: " << track->GetTrackID()         620         << " ID: " << track->GetTrackID()
615         <<  " at time : " << track->GetGlobalT    621         <<  " at time : " << track->GetGlobalTime()
616         << G4endl;                                622         << G4endl;
617 #endif                                            623 #endif
618                                                   624 
619     ++it;                                         625     ++it;
620     DefinePhysicalStepLength(track);              626     DefinePhysicalStepLength(track);
621                                                   627 
622     ExtractILData();                              628     ExtractILData();
623   }                                               629   }
624                                                   630 
625   return fILTimeStep;                             631   return fILTimeStep;
626 }                                                 632 }
627                                                   633 
628 //____________________________________________    634 //_________________________________________________________________________
629                                                   635 
630 void G4ITStepProcessor::ExtractILData()           636 void G4ITStepProcessor::ExtractILData()
631 {                                                 637 {
632   assert(fpTrack != 0);                           638   assert(fpTrack != 0);
633   if (fpTrack == nullptr)                      << 639   if (fpTrack == 0)
634   {                                               640   {
635     CleanProcessor();                             641     CleanProcessor();
636     return;                                       642     return;
637   }                                               643   }
638                                                   644 
639   // assert(fpTrack->GetTrackStatus() != fStop    645   // assert(fpTrack->GetTrackStatus() != fStopAndKill);
640                                                   646 
641   if (fpTrack->GetTrackStatus() == fStopAndKil    647   if (fpTrack->GetTrackStatus() == fStopAndKill)
642   {                                               648   {
643 //    trackContainer->GetMainList()->pop(fpTra    649 //    trackContainer->GetMainList()->pop(fpTrack);
644     fpTrackingManager->EndTracking(fpTrack);      650     fpTrackingManager->EndTracking(fpTrack);
645     CleanProcessor();                             651     CleanProcessor();
646     return;                                       652     return;
647   }                                               653   }
648                                                   654 
649   if (IsInf(fTimeStep))                           655   if (IsInf(fTimeStep))
650   {                                               656   {
651     // G4cout << "!!!!!!!!!!!! IS INF " << tra    657     // G4cout << "!!!!!!!!!!!! IS INF " << track->GetTrackID() << G4endl;
652     CleanProcessor();                             658     CleanProcessor();
653     return;                                       659     return;
654   }                                               660   }
655   if (fTimeStep < fILTimeStep - DBL_EPSILON)   << 661   else if (fTimeStep < fILTimeStep - DBL_EPSILON)
656   {                                               662   {
657     // G4cout << "!!!!!!!!!!!! TEMPS DIFFERENT    663     // G4cout << "!!!!!!!!!!!! TEMPS DIFFERENTS "
658     //    << track->GetTrackID() << G4endl;       664     //    << track->GetTrackID() << G4endl;
659                                                   665 
660     fLeadingTracks.Reset();                       666     fLeadingTracks.Reset();
661                                                   667 
662     fILTimeStep = GetInteractionTime();           668     fILTimeStep = GetInteractionTime();
663                                                   669 
664 //    G4cout << "Will set leading step to true    670 //    G4cout << "Will set leading step to true for time  :"
665 //           << SP -> GetInteractionTime() <<     671 //           << SP -> GetInteractionTime() << " against fTimeStep : "
666 //           << G4BestUnit(fILTimeStep, "Time"    672 //           << G4BestUnit(fILTimeStep, "Time") << " the trackID is : " << track->GetTrackID()
667 //           << G4endl;                           673 //           << G4endl;
668                                                   674 
669 //    GetIT(fpTrack)->GetTrackingInfo()->SetLe    675 //    GetIT(fpTrack)->GetTrackingInfo()->SetLeadingStep(true);
670     fLeadingTracks.Push(fpTrack);                 676     fLeadingTracks.Push(fpTrack);
671   }                                               677   }
672   else if(fabs(fILTimeStep - fTimeStep) < DBL_    678   else if(fabs(fILTimeStep - fTimeStep) < DBL_EPSILON )
673   {                                               679   {
674                                                   680 
675     // G4cout << "!!!!!!!!!!!! MEME TEMPS " <<    681     // G4cout << "!!!!!!!!!!!! MEME TEMPS " << track->GetTrackID() << G4endl;
676     // G4cout << "Will set leading step to tru    682     // G4cout << "Will set leading step to true for time  :"
677     //        << SP -> GetInteractionTime() <<    683     //        << SP -> GetInteractionTime() << " against fTimeStep : "
678     //        << fTimeStep << " the trackID is    684     //        << fTimeStep << " the trackID is : " << track->GetTrackID()<< G4endl;
679 //    GetIT(fpTrack)->GetTrackingInfo()->SetLe    685 //    GetIT(fpTrack)->GetTrackingInfo()->SetLeadingStep(true);
680     fLeadingTracks.Push(fpTrack);                 686     fLeadingTracks.Push(fpTrack);
681   }                                               687   }
682   // else                                         688   // else
683   // {                                            689   // {
684   //     G4cout << "!!!! Bigger time : " << "c    690   //     G4cout << "!!!! Bigger time : " << "currentTime : "<<fILTimeStep
685   //  << " proposedTime : " << SP -> GetIntera    691   //  << " proposedTime : " << SP -> GetInteractionTime() << G4endl;
686   // }                                            692   // }
687                                                   693 
688   CleanProcessor();                               694   CleanProcessor();
689 }                                                 695 }
690                                                   696 
691 //____________________________________________    697 //___________________________________________________________________________
692                                                   698 
693 void G4ITStepProcessor::DefinePhysicalStepLeng    699 void G4ITStepProcessor::DefinePhysicalStepLength(G4Track* track)
694 {                                                 700 {
695   SetTrack(track);                                701   SetTrack(track);
696   DoDefinePhysicalStepLength();                   702   DoDefinePhysicalStepLength();
697 }                                                 703 }
698                                                   704 
699 //____________________________________________    705 //______________________________________________________________________________
700                                                   706 
701 void G4ITStepProcessor::SetInitialStep()          707 void G4ITStepProcessor::SetInitialStep()
702 {                                                 708 {
703   // DEBUG                                        709   // DEBUG
704   //    G4cout << "SetInitialStep for : " << f    710   //    G4cout << "SetInitialStep for : " << fpITrack-> GetName() << G4endl;
705   //__________________________________________    711   //________________________________________________________
706   // Initialize geometry                          712   // Initialize geometry
707                                                   713 
708   if(!fpTrack->GetTouchableHandle())              714   if(!fpTrack->GetTouchableHandle())
709   {                                               715   {
710     //========================================    716     //==========================================================================
711     // Create navigator state and Locate parti    717     // Create navigator state and Locate particle in geometry
712     //========================================    718     //==========================================================================
713     /*                                            719     /*
714      fpNavigator->NewNavigatorStateAndLocate(f    720      fpNavigator->NewNavigatorStateAndLocate(fpTrack->GetPosition(),
715      fpTrack->GetMomentumDirection());            721      fpTrack->GetMomentumDirection());
716                                                   722 
717      fpITrack->GetTrackingInfo()->                723      fpITrack->GetTrackingInfo()->
718      SetNavigatorState(fpNavigator->GetNavigat    724      SetNavigatorState(fpNavigator->GetNavigatorState());
719      */                                           725      */
720     fpNavigator->NewNavigatorState();             726     fpNavigator->NewNavigatorState();
721     fpITrack->GetTrackingInfo()->SetNavigatorS    727     fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator
722         ->GetNavigatorState());                   728         ->GetNavigatorState());
723                                                   729 
724     G4ThreeVector direction = fpTrack->GetMome    730     G4ThreeVector direction = fpTrack->GetMomentumDirection();
725     fpNavigator->LocateGlobalPointAndSetup(fpT    731     fpNavigator->LocateGlobalPointAndSetup(fpTrack->GetPosition(),
726                                            &di    732                                            &direction,
727                                            fal    733                                            false,
728                                            fal    734                                            false); // was false, false
729                                                   735 
730     fpState->fTouchableHandle = fpNavigator->C    736     fpState->fTouchableHandle = fpNavigator->CreateTouchableHistory();
731                                                   737 
732     fpTrack->SetTouchableHandle(fpState->fTouc    738     fpTrack->SetTouchableHandle(fpState->fTouchableHandle);
733     fpTrack->SetNextTouchableHandle(fpState->f    739     fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle);
734   }                                               740   }
735   else                                            741   else
736   {                                               742   {
737     fpState->fTouchableHandle = fpTrack->GetTo    743     fpState->fTouchableHandle = fpTrack->GetTouchableHandle();
738     fpTrack->SetNextTouchableHandle(fpState->f    744     fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle);
739                                                   745 
740     //========================================    746     //==========================================================================
741     // Create OR set navigator state              747     // Create OR set navigator state
742     //========================================    748     //==========================================================================
743                                                   749 
744     if(fpITrack->GetTrackingInfo()->GetNavigat << 750     if(fpITrack->GetTrackingInfo()->GetNavigatorState())
745     {                                             751     {
746       fpNavigator->SetNavigatorState(fpITrack-    752       fpNavigator->SetNavigatorState(fpITrack->GetTrackingInfo()
747           ->GetNavigatorState());                 753           ->GetNavigatorState());
748       fpITrack->GetTrackingInfo()->SetNavigato    754       fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator
749           ->GetNavigatorState());                 755           ->GetNavigatorState());
750     }                                             756     }
751     else                                          757     else
752     {                                             758     {
753       fpNavigator->NewNavigatorState(*((G4Touc    759       fpNavigator->NewNavigatorState(*((G4TouchableHistory*) fpState
754           ->fTouchableHandle()));                 760           ->fTouchableHandle()));
755       fpITrack->GetTrackingInfo()->SetNavigato    761       fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator
756           ->GetNavigatorState());                 762           ->GetNavigatorState());
757     }                                             763     }
758                                                   764 
759     G4VPhysicalVolume* oldTopVolume =             765     G4VPhysicalVolume* oldTopVolume =
760         fpTrack->GetTouchableHandle()->GetVolu    766         fpTrack->GetTouchableHandle()->GetVolume();
761                                                   767 
762     //========================================    768     //==========================================================================
763     // Locate particle in geometry                769     // Locate particle in geometry
764     //========================================    770     //==========================================================================
765                                                   771 
766 //    G4VPhysicalVolume* newTopVolume =           772 //    G4VPhysicalVolume* newTopVolume =
767 //        fpNavigator->LocateGlobalPointAndSet    773 //        fpNavigator->LocateGlobalPointAndSetup(
768 //            fpTrack->GetPosition(),             774 //            fpTrack->GetPosition(),
769 //            &fpTrack->GetMomentumDirection()    775 //            &fpTrack->GetMomentumDirection(),
770 //            true, false);                       776 //            true, false);
771                                                   777 
772     G4VPhysicalVolume* newTopVolume =             778     G4VPhysicalVolume* newTopVolume =
773         fpNavigator->ResetHierarchyAndLocate(f    779         fpNavigator->ResetHierarchyAndLocate(fpTrack->GetPosition(),
774                                              f    780                                              fpTrack->GetMomentumDirection(),
775                                              *    781                                              *((G4TouchableHistory*) fpTrack
776                                                   782                                                  ->GetTouchableHandle()()));
777                                                   783 
778     if(newTopVolume != oldTopVolume || oldTopV    784     if(newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId()
779         == 1)                                     785         == 1)
780     {                                             786     {
781       fpState->fTouchableHandle = fpNavigator-    787       fpState->fTouchableHandle = fpNavigator->CreateTouchableHistory();
782       fpTrack->SetTouchableHandle(fpState->fTo    788       fpTrack->SetTouchableHandle(fpState->fTouchableHandle);
783       fpTrack->SetNextTouchableHandle(fpState-    789       fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle);
784     }                                             790     }
785   }                                               791   }
786                                                   792 
787   fpCurrentVolume = fpState->fTouchableHandle-    793   fpCurrentVolume = fpState->fTouchableHandle->GetVolume();
788                                                   794 
789   //__________________________________________    795   //________________________________________________________
790   // If the primary track has 'Suspend' or 'Po    796   // If the primary track has 'Suspend' or 'PostponeToNextEvent' state,
791   // set the track state to 'Alive'.              797   // set the track state to 'Alive'.
792   if((fpTrack->GetTrackStatus() == fSuspend) |    798   if((fpTrack->GetTrackStatus() == fSuspend) || (fpTrack->GetTrackStatus()
793       == fPostponeToNextEvent))                   799       == fPostponeToNextEvent))
794   {                                               800   {
795     fpTrack->SetTrackStatus(fAlive);              801     fpTrack->SetTrackStatus(fAlive);
796   }                                               802   }
797                                                   803 
798   //HoangTRAN: it's better to check the status << 
799   if(fpTrack->GetTrackStatus() == fStopAndKill << 
800                                                << 
801   // If the primary track has 'zero' kinetic e    804   // If the primary track has 'zero' kinetic energy, set the track
802   // state to 'StopButAlive'.                     805   // state to 'StopButAlive'.
803   if(fpTrack->GetKineticEnergy() <= 0.0)          806   if(fpTrack->GetKineticEnergy() <= 0.0)
804   {                                               807   {
805     fpTrack->SetTrackStatus(fStopButAlive);       808     fpTrack->SetTrackStatus(fStopButAlive);
806   }                                               809   }
807   //__________________________________________    810   //________________________________________________________
808   // Set vertex information of G4Track at here    811   // Set vertex information of G4Track at here
809   if(fpTrack->GetCurrentStepNumber() == 0)        812   if(fpTrack->GetCurrentStepNumber() == 0)
810   {                                               813   {
811     fpTrack->SetVertexPosition(fpTrack->GetPos    814     fpTrack->SetVertexPosition(fpTrack->GetPosition());
812     fpTrack->SetVertexMomentumDirection(fpTrac    815     fpTrack->SetVertexMomentumDirection(fpTrack->GetMomentumDirection());
813     fpTrack->SetVertexKineticEnergy(fpTrack->G    816     fpTrack->SetVertexKineticEnergy(fpTrack->GetKineticEnergy());
814     fpTrack->SetLogicalVolumeAtVertex(fpTrack-    817     fpTrack->SetLogicalVolumeAtVertex(fpTrack->GetVolume()->GetLogicalVolume());
815   }                                               818   }
816   //__________________________________________    819   //________________________________________________________
817   // If track is already outside the world bou    820   // If track is already outside the world boundary, kill it
818   if(fpCurrentVolume == nullptr)               << 821   if(fpCurrentVolume == 0)
819   {                                               822   {
820     // If the track is a primary, stop process    823     // If the track is a primary, stop processing
821     if(fpTrack->GetParentID() == 0)               824     if(fpTrack->GetParentID() == 0)
822     {                                             825     {
823       G4cerr << "ERROR - G4ITStepProcessor::Se    826       G4cerr << "ERROR - G4ITStepProcessor::SetInitialStep()" << G4endl<< "        Primary particle starting at - "
824       << fpTrack->GetPosition()                   827       << fpTrack->GetPosition()
825       << " - is outside of the world volume."     828       << " - is outside of the world volume." << G4endl;
826       G4Exception("G4ITStepProcessor::SetIniti    829       G4Exception("G4ITStepProcessor::SetInitialStep()", "ITStepProcessor0011",
827           FatalException, "Primary vertex outs    830           FatalException, "Primary vertex outside of the world!");
828     }                                             831     }
829                                                   832 
830     fpTrack->SetTrackStatus( fStopAndKill );      833     fpTrack->SetTrackStatus( fStopAndKill );
831     G4cout << "WARNING - G4ITStepProcessor::Se    834     G4cout << "WARNING - G4ITStepProcessor::SetInitialStep()" << G4endl
832     << "          Initial track position is ou    835     << "          Initial track position is outside world! - "
833     << fpTrack->GetPosition() << G4endl;          836     << fpTrack->GetPosition() << G4endl;
834   }                                               837   }
835   else                                            838   else
836   {                                               839   {
837     // Initial set up for attribues of 'Step'     840     // Initial set up for attribues of 'Step'
838     fpStep->InitializeStep( fpTrack );            841     fpStep->InitializeStep( fpTrack );
839   }                                               842   }
840                                                   843 
                                                   >> 844   if(fpTrack->GetTrackStatus() == fStopAndKill) return;
                                                   >> 845 
841   fpState->fStepStatus = fUndefined;              846   fpState->fStepStatus = fUndefined;
842 }                                                 847 }
843 //____________________________________________    848 //______________________________________________________________________________
844                                                   849 
845 void G4ITStepProcessor::InitDefineStep()          850 void G4ITStepProcessor::InitDefineStep()
846 {                                                 851 {
847                                                   852 
848   if(fpStep == nullptr)                        << 853   if(!fpStep)
849   {                                               854   {
850     // Create new Step and give it to the trac    855     // Create new Step and give it to the track
851     fpStep = new G4Step();                        856     fpStep = new G4Step();
852     fpTrack->SetStep(fpStep);                     857     fpTrack->SetStep(fpStep);
853     fpSecondary = fpStep->NewSecondaryVector()    858     fpSecondary = fpStep->NewSecondaryVector();
854                                                   859 
855     // Create new state and set it in the trac    860     // Create new state and set it in the trackingInfo
856     fpState = new G4ITStepProcessorState();       861     fpState = new G4ITStepProcessorState();
857     fpITrack->GetTrackingInfo()->SetStepProces    862     fpITrack->GetTrackingInfo()->SetStepProcessorState((G4ITStepProcessorState_Lock*) fpState);
858                                                   863 
859     SetupMembers();                               864     SetupMembers();
860     SetInitialStep();                             865     SetInitialStep();
861                                                   866 
862     fpTrackingManager->StartTracking(fpTrack);    867     fpTrackingManager->StartTracking(fpTrack);
863   }                                               868   }
864   else                                            869   else
865   {                                               870   {
866     SetupMembers();                               871     SetupMembers();
867                                                   872 
868     fpState->fPreviousStepSize = fpTrack->GetS    873     fpState->fPreviousStepSize = fpTrack->GetStepLength();
869     /***                                          874     /***
870      // Send G4Step information to Hit/Dig if     875      // Send G4Step information to Hit/Dig if the volume is sensitive
871      fpCurrentVolume = fpStep->GetPreStepPoint    876      fpCurrentVolume = fpStep->GetPreStepPoint()->GetPhysicalVolume();
872      StepControlFlag =  fpStep->GetControlFlag    877      StepControlFlag =  fpStep->GetControlFlag();
873      if( fpCurrentVolume != 0 && StepControlFl    878      if( fpCurrentVolume != 0 && StepControlFlag != AvoidHitInvocation)
874      {                                            879      {
875      fpSensitive = fpStep->GetPreStepPoint()->    880      fpSensitive = fpStep->GetPreStepPoint()->
876      GetSensitiveDetector();                      881      GetSensitiveDetector();
877                                                   882 
878      //            if( fSensitive != 0 ) {        883      //            if( fSensitive != 0 ) {
879      //              fSensitive->Hit(fStep);      884      //              fSensitive->Hit(fStep);
880      //            }                              885      //            }
881      }                                            886      }
882      ***/                                         887      ***/
883     // Store last PostStepPoint to PreStepPoin    888     // Store last PostStepPoint to PreStepPoint, and swap current and next
884     // volume information of G4Track. Reset to    889     // volume information of G4Track. Reset total energy deposit in one Step.
885     fpStep->CopyPostToPreStepPoint();             890     fpStep->CopyPostToPreStepPoint();
886     fpStep->ResetTotalEnergyDeposit();            891     fpStep->ResetTotalEnergyDeposit();
887                                                   892 
888     //JA Set the volume before it is used (in     893     //JA Set the volume before it is used (in DefineStepLength() for User Limit)
889     fpCurrentVolume = fpStep->GetPreStepPoint(    894     fpCurrentVolume = fpStep->GetPreStepPoint()->GetPhysicalVolume();
890     /*                                            895     /*
891      G4cout << G4endl;                            896      G4cout << G4endl;
892      G4cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" <    897      G4cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!" << G4endl;
893      G4cout << "PreStepPoint Volume : "           898      G4cout << "PreStepPoint Volume : "
894      << fpCurrentVolume->GetName() << G4endl;     899      << fpCurrentVolume->GetName() << G4endl;
895      G4cout << "Track Touchable : "               900      G4cout << "Track Touchable : "
896      << fpTrack->GetTouchableHandle()->GetVolu    901      << fpTrack->GetTouchableHandle()->GetVolume()->GetName() << G4endl;
897      G4cout << "Track NextTouchable : "           902      G4cout << "Track NextTouchable : "
898      << fpTrack->GetNextTouchableHandle()->Get    903      << fpTrack->GetNextTouchableHandle()->GetVolume()->GetName()
899      << G4endl;                                   904      << G4endl;
900      */                                           905      */
901     // Reset the step's auxiliary points vecto    906     // Reset the step's auxiliary points vector pointer
902     fpStep->SetPointerToVectorOfAuxiliaryPoint << 907     fpStep->SetPointerToVectorOfAuxiliaryPoints(0);
903                                                   908 
904     // Switch next touchable in track to curre    909     // Switch next touchable in track to current one
905     fpTrack->SetTouchableHandle(fpTrack->GetNe    910     fpTrack->SetTouchableHandle(fpTrack->GetNextTouchableHandle());
906     fpState->fTouchableHandle = fpTrack->GetTo    911     fpState->fTouchableHandle = fpTrack->GetTouchableHandle();
907     fpTrack->SetNextTouchableHandle(fpState->f    912     fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle);
908                                                   913 
909     //! ADDED BACK                                914     //! ADDED BACK
910     /*                                            915     /*
911      G4VPhysicalVolume* oldTopVolume =            916      G4VPhysicalVolume* oldTopVolume =
912      fpTrack->GetTouchableHandle()->GetVolume(    917      fpTrack->GetTouchableHandle()->GetVolume();
913      fpNavigator->SetNavigatorState(              918      fpNavigator->SetNavigatorState(
914      fpITrack->GetTrackingInfo()->GetNavigator    919      fpITrack->GetTrackingInfo()->GetNavigatorState());
915                                                   920 
916      G4VPhysicalVolume* newTopVolume = fpNavig    921      G4VPhysicalVolume* newTopVolume = fpNavigator->ResetHierarchyAndLocate(
917      fpTrack->GetPosition(), fpTrack->GetMomen    922      fpTrack->GetPosition(), fpTrack->GetMomentumDirection(),
918      *((G4TouchableHistory*) fpTrack->GetTouch    923      *((G4TouchableHistory*) fpTrack->GetTouchableHandle()()));
919                                                   924 
920      //  G4VPhysicalVolume* newTopVolume=         925      //  G4VPhysicalVolume* newTopVolume=
921      //     fpNavigator->LocateGlobalPointAndS    926      //     fpNavigator->LocateGlobalPointAndSetup(fpTrack->GetPosition(),
922      //                                           927      //                                            &fpTrack->GetMomentumDirection(),
923      //                                           928      //                                            true, false);
924                                                   929 
925      //        G4cout << "New Top Volume : " <    930      //        G4cout << "New Top Volume : " << newTopVolume->GetName() << G4endl;
926                                                   931 
927      if (newTopVolume != oldTopVolume || oldTo    932      if (newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId()
928      == 1)                                        933      == 1)
929      {                                            934      {
930      fpState->fTouchableHandle = fpNavigator->    935      fpState->fTouchableHandle = fpNavigator->CreateTouchableHistory();
931      fpTrack->SetTouchableHandle(fpState->fTou    936      fpTrack->SetTouchableHandle(fpState->fTouchableHandle);
932      fpTrack->SetNextTouchableHandle(fpState->    937      fpTrack->SetNextTouchableHandle(fpState->fTouchableHandle);
933      }                                            938      }
934                                                   939 
935      */                                           940      */
936     //! ADDED BACK                                941     //! ADDED BACK
937     //========================================    942     //==========================================================================
938     // Only reset navigator state + reset volu    943     // Only reset navigator state + reset volume hierarchy (internal)
939     // No need to relocate                        944     // No need to relocate
940     //========================================    945     //==========================================================================
941     fpNavigator->SetNavigatorState(fpITrack->G    946     fpNavigator->SetNavigatorState(fpITrack->GetTrackingInfo()
942         ->GetNavigatorState());                   947         ->GetNavigatorState());
943   }                                               948   }
944 }                                                 949 }
945                                                   950 
946 //____________________________________________    951 //______________________________________________________________________________
947                                                   952 
948 // -------------------------------------------    953 // ------------------------------------------------------------------------
949 //  Compute Interaction Length                    954 //  Compute Interaction Length
950 // -------------------------------------------    955 // ------------------------------------------------------------------------
951 void G4ITStepProcessor::DoDefinePhysicalStepLe    956 void G4ITStepProcessor::DoDefinePhysicalStepLength()
952 {                                                 957 {
953                                                   958 
954   InitDefineStep();                               959   InitDefineStep();
955                                                   960 
956 #ifdef G4VERBOSE                                  961 #ifdef G4VERBOSE
957   // !!!!! Verbose                                962   // !!!!! Verbose
958   if(fpVerbose != nullptr) fpVerbose->DPSLStar << 963   if(fpVerbose) fpVerbose->DPSLStarted();
959 #endif                                            964 #endif
960                                                   965 
961   G4TrackStatus trackStatus = fpTrack->GetTrac    966   G4TrackStatus trackStatus = fpTrack->GetTrackStatus();
962                                                   967 
963   if(trackStatus == fStopAndKill)                 968   if(trackStatus == fStopAndKill)
964   {                                               969   {
965     return;                                       970     return;
966   }                                               971   }
967                                                   972 
968   if(trackStatus == fStopButAlive)                973   if(trackStatus == fStopButAlive)
969   {                                               974   {
970     fpITrack->GetTrackingInfo()->SetNavigatorS    975     fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator
971         ->GetNavigatorState());                   976         ->GetNavigatorState());
972     fpNavigator->ResetNavigatorState();           977     fpNavigator->ResetNavigatorState();
973     return GetAtRestIL();                         978     return GetAtRestIL();
974   }                                               979   }
975                                                   980 
976   // Find minimum Step length and correspondin    981   // Find minimum Step length and corresponding time
977   // demanded by active disc./cont. processes     982   // demanded by active disc./cont. processes
978                                                   983 
979   // ReSet the counter etc.                       984   // ReSet the counter etc.
980   fpState->fPhysicalStep = DBL_MAX; // Initial    985   fpState->fPhysicalStep = DBL_MAX; // Initialize by a huge number
981   fPhysIntLength = DBL_MAX; // Initialize by a    986   fPhysIntLength = DBL_MAX; // Initialize by a huge number
982                                                   987 
983   G4double proposedTimeStep = DBL_MAX;         << 988   double proposedTimeStep = DBL_MAX;
984   G4VProcess* processWithPostStepGivenByTimeSt << 989   G4VProcess* processWithPostStepGivenByTimeStep(0);
985                                                   990 
986   // GPIL for PostStep                            991   // GPIL for PostStep
987   fPostStepDoItProcTriggered = fpProcessInfo->    992   fPostStepDoItProcTriggered = fpProcessInfo->MAXofPostStepLoops;
988   fPostStepAtTimeDoItProcTriggered = fpProcess    993   fPostStepAtTimeDoItProcTriggered = fpProcessInfo->MAXofPostStepLoops;
989                                                   994 
990   //  G4cout << "fpProcessInfo->MAXofPostStepL    995   //  G4cout << "fpProcessInfo->MAXofPostStepLoops : "
991   //         << fpProcessInfo->MAXofPostStepLo    996   //         << fpProcessInfo->MAXofPostStepLoops
992   //         << " mol : " << fpITrack -> GetNa    997   //         << " mol : " << fpITrack -> GetName()
993   //         << " id : " << fpTrack->GetTrackI    998   //         << " id : " << fpTrack->GetTrackID()
994   //         << G4endl;                           999   //         << G4endl;
995                                                   1000 
996   for(std::size_t np = 0; np < fpProcessInfo-> << 1001   for(size_t np = 0; np < fpProcessInfo->MAXofPostStepLoops; np++)
997   {                                               1002   {
998     fpCurrentProcess = dynamic_cast<G4VITProce    1003     fpCurrentProcess = dynamic_cast<G4VITProcess*>((*fpProcessInfo
999         ->fpPostStepGetPhysIntVector)[(G4int)n << 1004         ->fpPostStepGetPhysIntVector)[np]);
1000     if(fpCurrentProcess == nullptr)           << 1005     if(fpCurrentProcess == 0)
1001     {                                            1006     {
1002       (fpState->fSelectedPostStepDoItVector)[    1007       (fpState->fSelectedPostStepDoItVector)[np] = InActivated;
1003       continue;                                  1008       continue;
1004     } // NULL means the process is inactivate    1009     } // NULL means the process is inactivated by a user on fly.
1005                                                  1010 
1006     fCondition = NotForced;                      1011     fCondition = NotForced;
1007     fpCurrentProcess->SetProcessState(fpTrack    1012     fpCurrentProcess->SetProcessState(fpTrackingInfo->GetProcessState(fpCurrentProcess
1008         ->GetProcessID()));                      1013         ->GetProcessID()));
1009                                                  1014 
1010     // G4cout << "Is going to call : "           1015     // G4cout << "Is going to call : "
1011     //        << fpCurrentProcess -> GetProce    1016     //        << fpCurrentProcess -> GetProcessName()
1012     //        << G4endl;                         1017     //        << G4endl;
1013     fPhysIntLength = fpCurrentProcess->PostSt    1018     fPhysIntLength = fpCurrentProcess->PostStepGPIL(*fpTrack,
1014                                                  1019                                                     fpState->fPreviousStepSize,
1015                                                  1020                                                     &fCondition);
1016                                                  1021 
1017 #ifdef G4VERBOSE                                 1022 #ifdef G4VERBOSE
1018     // !!!!! Verbose                             1023     // !!!!! Verbose
1019     if(fpVerbose != nullptr) fpVerbose->DPSLP << 1024     if(fpVerbose) fpVerbose->DPSLPostStep();
1020 #endif                                           1025 #endif
1021                                                  1026 
1022     fpCurrentProcess->ResetProcessState();       1027     fpCurrentProcess->ResetProcessState();
1023     //fpCurrentProcess->SetProcessState(0);      1028     //fpCurrentProcess->SetProcessState(0);
1024                                                  1029 
1025     switch(fCondition)                           1030     switch(fCondition)
1026     {                                            1031     {
1027       case ExclusivelyForced: // Will need sp    1032       case ExclusivelyForced: // Will need special treatment
1028         (fpState->fSelectedPostStepDoItVector    1033         (fpState->fSelectedPostStepDoItVector)[np] = ExclusivelyForced;
1029         fpState->fStepStatus = fExclusivelyFo    1034         fpState->fStepStatus = fExclusivelyForcedProc;
1030         fpStep->GetPostStepPoint()->SetProces    1035         fpStep->GetPostStepPoint()->SetProcessDefinedStep(fpCurrentProcess);
1031         break;                                   1036         break;
1032                                                  1037 
1033       case Conditionally:                        1038       case Conditionally:
1034         //       (fpState->fSelectedPostStepD    1039         //       (fpState->fSelectedPostStepDoItVector)[np] = Conditionally;
1035         G4Exception("G4ITStepProcessor::Defin    1040         G4Exception("G4ITStepProcessor::DefinePhysicalStepLength()",
1036                     "ITStepProcessor0008",       1041                     "ITStepProcessor0008",
1037                     FatalException,              1042                     FatalException,
1038                     "This feature is no more     1043                     "This feature is no more supported");
1039         break;                                   1044         break;
1040                                                  1045 
1041       case Forced:                               1046       case Forced:
1042         (fpState->fSelectedPostStepDoItVector    1047         (fpState->fSelectedPostStepDoItVector)[np] = Forced;
1043         break;                                   1048         break;
1044                                                  1049 
1045       case StronglyForced:                       1050       case StronglyForced:
1046         (fpState->fSelectedPostStepDoItVector    1051         (fpState->fSelectedPostStepDoItVector)[np] = StronglyForced;
1047         break;                                   1052         break;
1048                                                  1053 
1049       default:                                   1054       default:
1050         (fpState->fSelectedPostStepDoItVector    1055         (fpState->fSelectedPostStepDoItVector)[np] = InActivated;
1051         break;                                   1056         break;
1052     }                                            1057     }
1053                                                  1058 
1054     if(fCondition == ExclusivelyForced)          1059     if(fCondition == ExclusivelyForced)
1055     {                                            1060     {
1056       for(std::size_t nrest = np + 1; nrest < << 1061       for(size_t nrest = np + 1; nrest < fpProcessInfo->MAXofPostStepLoops;
1057           ++nrest)                            << 1062           nrest++)
1058       {                                          1063       {
1059         (fpState->fSelectedPostStepDoItVector    1064         (fpState->fSelectedPostStepDoItVector)[nrest] = InActivated;
1060       }                                          1065       }
1061       return; // Please note the 'return' at     1066       return; // Please note the 'return' at here !!!
1062     }                                            1067     }
1063                                               << 1068     else
1064     if(fPhysIntLength < fpState->fPhysicalSte << 
1065     {                                            1069     {
1066       // To avoid checking whether the proces << 1070       if(fPhysIntLength < fpState->fPhysicalStep)
1067       // proposing a time step, the returned  << 
1068       // negative (just for tagging)          << 
1069       if(fpCurrentProcess->ProposesTimeStep() << 
1070       {                                          1071       {
1071         fPhysIntLength *= -1;                 << 1072         // To avoid checking whether the process is actually
1072         if(fPhysIntLength < proposedTimeStep) << 1073         // proposing a time step, the returned time steps are
                                                   >> 1074         // negative (just for tagging)
                                                   >> 1075         if(fpCurrentProcess->ProposesTimeStep())
1073         {                                        1076         {
1074           proposedTimeStep = fPhysIntLength;  << 1077           fPhysIntLength *= -1;
1075           fPostStepAtTimeDoItProcTriggered =  << 1078           if(fPhysIntLength < proposedTimeStep)
1076           processWithPostStepGivenByTimeStep  << 1079           {
                                                   >> 1080             proposedTimeStep = fPhysIntLength;
                                                   >> 1081             fPostStepAtTimeDoItProcTriggered = np;
                                                   >> 1082             processWithPostStepGivenByTimeStep = fpCurrentProcess;
                                                   >> 1083           }
                                                   >> 1084         }
                                                   >> 1085         else
                                                   >> 1086         {
                                                   >> 1087           fpState->fPhysicalStep = fPhysIntLength;
                                                   >> 1088           fpState->fStepStatus = fPostStepDoItProc;
                                                   >> 1089           fPostStepDoItProcTriggered = G4int(np);
                                                   >> 1090           fpStep->GetPostStepPoint()->SetProcessDefinedStep(fpCurrentProcess);
1077         }                                        1091         }
1078       }                                       << 
1079       else                                    << 
1080       {                                       << 
1081         fpState->fPhysicalStep = fPhysIntLeng << 
1082         fpState->fStepStatus = fPostStepDoItP << 
1083         fPostStepDoItProcTriggered = G4int(np << 
1084         fpStep->GetPostStepPoint()->SetProces << 
1085       }                                          1092       }
1086     }                                            1093     }
1087   }                                              1094   }
1088                                                  1095 
1089   // GPIL for AlongStep                          1096   // GPIL for AlongStep
1090   fpState->fProposedSafety = DBL_MAX;            1097   fpState->fProposedSafety = DBL_MAX;
1091   G4double safetyProposedToAndByProcess = fpS    1098   G4double safetyProposedToAndByProcess = fpState->fProposedSafety;
1092                                                  1099 
1093   for(std::size_t kp = 0; kp < fpProcessInfo- << 1100   for(size_t kp = 0; kp < fpProcessInfo->MAXofAlongStepLoops; kp++)
1094   {                                              1101   {
1095     fpCurrentProcess = dynamic_cast<G4VITProc    1102     fpCurrentProcess = dynamic_cast<G4VITProcess*>((*fpProcessInfo
1096         ->fpAlongStepGetPhysIntVector)[(G4int << 1103         ->fpAlongStepGetPhysIntVector)[kp]);
1097     if(fpCurrentProcess == nullptr) continue; << 1104     if(fpCurrentProcess == 0) continue;
1098     // NULL means the process is inactivated     1105     // NULL means the process is inactivated by a user on fly.
1099                                                  1106 
1100     fpCurrentProcess->SetProcessState(           1107     fpCurrentProcess->SetProcessState(
1101         fpTrackingInfo->GetProcessState(fpCur    1108         fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID()));
1102     fPhysIntLength =                             1109     fPhysIntLength =
1103         fpCurrentProcess->AlongStepGPIL(*fpTr    1110         fpCurrentProcess->AlongStepGPIL(*fpTrack,
1104                                         fpSta    1111                                         fpState->fPreviousStepSize,
1105                                         fpSta    1112                                         fpState->fPhysicalStep,
1106                                         safet    1113                                         safetyProposedToAndByProcess,
1107                                         &fGPI    1114                                         &fGPILSelection);
1108                                                  1115 
1109 #ifdef G4VERBOSE                                 1116 #ifdef G4VERBOSE
1110     // !!!!! Verbose                             1117     // !!!!! Verbose
1111     if(fpVerbose != nullptr) fpVerbose->DPSLA << 1118     if(fpVerbose) fpVerbose->DPSLAlongStep();
1112 #endif                                           1119 #endif
1113                                                  1120 
1114     if(fPhysIntLength < fpState->fPhysicalSte    1121     if(fPhysIntLength < fpState->fPhysicalStep)
1115     {                                            1122     {
1116       fpState->fPhysicalStep = fPhysIntLength    1123       fpState->fPhysicalStep = fPhysIntLength;
1117       // Should save PS and TS in IT             1124       // Should save PS and TS in IT
1118                                                  1125 
1119       // Check if the process wants to be the    1126       // Check if the process wants to be the GPIL winner. For example,
1120       // multi-scattering proposes Step limit    1127       // multi-scattering proposes Step limit, but won't be the winner.
1121       if(fGPILSelection == CandidateForSelect    1128       if(fGPILSelection == CandidateForSelection)
1122       {                                          1129       {
1123         fpState->fStepStatus = fAlongStepDoIt    1130         fpState->fStepStatus = fAlongStepDoItProc;
1124         fpStep->GetPostStepPoint()->SetProces    1131         fpStep->GetPostStepPoint()->SetProcessDefinedStep(fpCurrentProcess);
1125       }                                          1132       }
1126                                                  1133 
1127       // Transportation is assumed to be the     1134       // Transportation is assumed to be the last process in the vector
1128       if(kp == fpProcessInfo->MAXofAlongStepL    1135       if(kp == fpProcessInfo->MAXofAlongStepLoops - 1)
1129       {                                          1136       {
1130         fpTransportation = dynamic_cast<G4ITT    1137         fpTransportation = dynamic_cast<G4ITTransportation*>(fpCurrentProcess);
1131                                                  1138 
1132         if(fpTransportation == nullptr)       << 1139         if(!fpTransportation)
1133         {                                        1140         {
1134           G4ExceptionDescription exceptionDes    1141           G4ExceptionDescription exceptionDescription;
1135           exceptionDescription << "No transpo    1142           exceptionDescription << "No transportation process found ";
1136           G4Exception("G4ITStepProcessor::DoD    1143           G4Exception("G4ITStepProcessor::DoDefinePhysicalStepLength",
1137                       "ITStepProcessor0009",     1144                       "ITStepProcessor0009",
1138                       FatalErrorInArgument,      1145                       FatalErrorInArgument,
1139                       exceptionDescription);     1146                       exceptionDescription);
1140         }                                        1147         }
1141                                                  1148 
1142         fTimeStep = fpTransportation->GetInte    1149         fTimeStep = fpTransportation->GetInteractionTimeLeft();
1143                                                  1150 
1144         if(fpTrack->GetNextVolume() != nullpt << 1151         if(fpTrack->GetNextVolume() != 0) fpState->fStepStatus = fGeomBoundary;
1145         else fpState->fStepStatus = fWorldBou    1152         else fpState->fStepStatus = fWorldBoundary;
1146       }                                          1153       }
1147     }                                            1154     }
1148     else                                         1155     else
1149     {                                            1156     {
1150       if(kp == fpProcessInfo->MAXofAlongStepL    1157       if(kp == fpProcessInfo->MAXofAlongStepLoops - 1)
1151       {                                          1158       {
1152         fpTransportation = dynamic_cast<G4ITT    1159         fpTransportation = dynamic_cast<G4ITTransportation*>(fpCurrentProcess);
1153                                                  1160 
1154         if(fpTransportation == nullptr)       << 1161         if(!fpTransportation)
1155         {                                        1162         {
1156           G4ExceptionDescription exceptionDes    1163           G4ExceptionDescription exceptionDescription;
1157           exceptionDescription << "No transpo    1164           exceptionDescription << "No transportation process found ";
1158           G4Exception("G4ITStepProcessor::DoD    1165           G4Exception("G4ITStepProcessor::DoDefinePhysicalStepLength",
1159                       "ITStepProcessor0010",     1166                       "ITStepProcessor0010",
1160                       FatalErrorInArgument,      1167                       FatalErrorInArgument,
1161                       exceptionDescription);     1168                       exceptionDescription);
1162         }                                        1169         }
1163                                                  1170 
1164         fTimeStep = fpTransportation->GetInte    1171         fTimeStep = fpTransportation->GetInteractionTimeLeft();
1165       }                                          1172       }
1166     }                                            1173     }
1167                                                  1174 
1168     // Handle PostStep processes sending back    1175     // Handle PostStep processes sending back time steps rather than space length
1169     if(proposedTimeStep < fTimeStep)             1176     if(proposedTimeStep < fTimeStep)
1170     {                                            1177     {
1171       if(fPostStepAtTimeDoItProcTriggered < f    1178       if(fPostStepAtTimeDoItProcTriggered < fpProcessInfo->MAXofPostStepLoops)
1172       {                                          1179       {
1173         if((fpState->fSelectedPostStepDoItVec    1180         if((fpState->fSelectedPostStepDoItVector)[fPostStepAtTimeDoItProcTriggered] == InActivated)
1174         {                                        1181         {
1175           (fpState->fSelectedPostStepDoItVect    1182           (fpState->fSelectedPostStepDoItVector)[fPostStepAtTimeDoItProcTriggered] =
1176               NotForced;                         1183               NotForced;
1177           // (fpState->fSelectedPostStepDoItV    1184           // (fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] = InActivated;
1178                                                  1185 
1179           fpState->fStepStatus = fPostStepDoI    1186           fpState->fStepStatus = fPostStepDoItProc;
1180           fpStep->GetPostStepPoint()->SetProc    1187           fpStep->GetPostStepPoint()->SetProcessDefinedStep(processWithPostStepGivenByTimeStep);
1181                                                  1188 
1182           fTimeStep = proposedTimeStep;          1189           fTimeStep = proposedTimeStep;
1183                                                  1190 
1184           fpTransportation->ComputeStep(*fpTr    1191           fpTransportation->ComputeStep(*fpTrack,
1185                                         *fpSt    1192                                         *fpStep,
1186                                         fTime    1193                                         fTimeStep,
1187                                         fpSta    1194                                         fpState->fPhysicalStep);
1188         }                                        1195         }
1189       }                                          1196       }
1190     }                                            1197     }
1191     else                                         1198     else
1192     {                                            1199     {
1193       if(fPostStepDoItProcTriggered < fpProce    1200       if(fPostStepDoItProcTriggered < fpProcessInfo->MAXofPostStepLoops)
1194       {                                          1201       {
1195         if((fpState->fSelectedPostStepDoItVec    1202         if((fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] == InActivated)
1196         {                                        1203         {
1197           (fpState->fSelectedPostStepDoItVect    1204           (fpState->fSelectedPostStepDoItVector)[fPostStepDoItProcTriggered] =
1198               NotForced;                         1205               NotForced;
1199         }                                        1206         }
1200       }                                          1207       }
1201     }                                            1208     }
1202                                                  1209 
1203 //  fpCurrentProcess->SetProcessState(0);        1210 //  fpCurrentProcess->SetProcessState(0);
1204     fpCurrentProcess->ResetProcessState();       1211     fpCurrentProcess->ResetProcessState();
1205                                                  1212 
1206     // Make sure to check the safety, even if    1213     // Make sure to check the safety, even if Step is not limited
1207     //  by this process.                         1214     //  by this process.                      J. Apostolakis, June 20, 1998
1208     //                                           1215     //
1209     if(safetyProposedToAndByProcess < fpState    1216     if(safetyProposedToAndByProcess < fpState->fProposedSafety)
1210     // proposedSafety keeps the smallest valu    1217     // proposedSafety keeps the smallest value:
1211     fpState->fProposedSafety = safetyProposed    1218     fpState->fProposedSafety = safetyProposedToAndByProcess;
1212     else                                         1219     else
1213     // safetyProposedToAndByProcess always pr    1220     // safetyProposedToAndByProcess always proposes a valid safety:
1214     safetyProposedToAndByProcess = fpState->f    1221     safetyProposedToAndByProcess = fpState->fProposedSafety;
1215                                                  1222 
1216   }                                              1223   }
1217                                                  1224 
1218   fpITrack->GetTrackingInfo()->SetNavigatorSt    1225   fpITrack->GetTrackingInfo()->SetNavigatorState(fpNavigator->GetNavigatorState());
1219   fpNavigator->ResetNavigatorState();            1226   fpNavigator->ResetNavigatorState();
1220 }                                                1227 }
1221                                                  1228 
1222 //___________________________________________    1229 //______________________________________________________________________________
1223                                                  1230