Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/dna/management/src/G4ITStepProcessor2.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/G4ITStepProcessor2.cc (Version 11.3.0) and /processes/electromagnetic/dna/management/src/G4ITStepProcessor2.cc (Version 10.1.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: G4ITStepProcessor2.cc 87375 2014-12-02 08:17:28Z 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 #include "G4LossTableManager.hh"                   37 #include "G4LossTableManager.hh"
 37 #include "G4EnergyLossTables.hh"                   38 #include "G4EnergyLossTables.hh"
 38 #include "G4ProductionCuts.hh"                     39 #include "G4ProductionCuts.hh"
 39 #include "G4ProductionCutsTable.hh"                40 #include "G4ProductionCutsTable.hh"
 40 #include "G4VITProcess.hh"                         41 #include "G4VITProcess.hh"
 41 #include "G4TrackingInformation.hh"                42 #include "G4TrackingInformation.hh"
 42 #include "G4IT.hh"                                 43 #include "G4IT.hh"
 43 #include "G4ITTrackingManager.hh"                  44 #include "G4ITTrackingManager.hh"
 44 #include "G4ITTransportation.hh"                   45 #include "G4ITTransportation.hh"
 45                                                    46 
 46 #include "G4ITNavigator.hh"             // Inc     47 #include "G4ITNavigator.hh"             // Include from 'geometry'
 47                                                    48 
 48 #include "G4ITSteppingVerbose.hh"              << 
 49 #include "G4VITSteppingVerbose.hh"             << 
 50                                                << 
 51 #include "G4ITTrackHolder.hh"                  << 
 52 #include "G4ITReaction.hh"                     << 
 53                                                << 
 54                                                << 
 55 //#define DEBUG_MEM 1                              49 //#define DEBUG_MEM 1
 56                                                    50 
 57 #ifdef DEBUG_MEM                                   51 #ifdef DEBUG_MEM
 58 #include "G4MemStat.hh"                            52 #include "G4MemStat.hh"
 59 using namespace G4MemStat;                         53 using namespace G4MemStat;
 60 using G4MemStat::MemStat;                          54 using G4MemStat::MemStat;
 61 #endif                                             55 #endif
 62                                                    56 
 63 void G4ITStepProcessor::DealWithSecondaries(G4     57 void G4ITStepProcessor::DealWithSecondaries(G4int& counter)
 64 {                                                  58 {
 65   // Now Store the secondaries from ParticleCh <<  59     // Now Store the secondaries from ParticleChange to SecondaryList
 66   G4Track* tempSecondaryTrack;                 <<  60     G4Track* tempSecondaryTrack;
 67                                                << 
 68   for(G4int DSecLoop = 0; DSecLoop < fpParticl << 
 69       DSecLoop++)                              << 
 70   {                                            << 
 71     tempSecondaryTrack = fpParticleChange->Get << 
 72                                                << 
 73     if(tempSecondaryTrack->GetDefinition()->Ge << 
 74     {                                          << 
 75       ApplyProductionCut(tempSecondaryTrack);  << 
 76     }                                          << 
 77                                                << 
 78     // Set parentID                            << 
 79     tempSecondaryTrack->SetParentID(fpTrack->G << 
 80                                                << 
 81     // Set the process pointer which created t << 
 82     tempSecondaryTrack->SetCreatorProcess(fpCu << 
 83                                                << 
 84     // If this 2ndry particle has 'zero' kinet << 
 85     // it invokes a rest process at the beginn << 
 86     if(tempSecondaryTrack->GetKineticEnergy()  << 
 87     {                                          << 
 88       G4ProcessManager* pm = tempSecondaryTrac << 
 89       if (pm->GetAtRestProcessVector()->entrie << 
 90       {                                        << 
 91         tempSecondaryTrack->SetTrackStatus( fS << 
 92         fpSecondary->push_back( tempSecondaryT << 
 93         fN2ndariesAtRestDoIt++;                << 
 94       }                                        << 
 95       else                                     << 
 96       {                                        << 
 97         delete tempSecondaryTrack;             << 
 98       }                                        << 
 99     }                                          << 
100     else                                       << 
101     {                                          << 
102       fpSecondary->push_back( tempSecondaryTra << 
103       counter++;                               << 
104     }                                          << 
105   } //end of loop on secondary                 << 
106 }                                              << 
107                                                << 
108 //____________________________________________ << 
109                                                << 
110 void G4ITStepProcessor::DoIt(double timeStep)  << 
111                                                << 
112 // Call the process having the min step length << 
113                                                << 
114 // If the track is "leading the step" (ie one  << 
115 // as the one having the minimum time step ove << 
116 // it will undergo its selected processes. Oth << 
117 // on the given time step.                     << 
118                                                << 
119 {                                              << 
120   if(fpVerbose != nullptr) fpVerbose->DoItStar << 
121                                                << 
122   G4TrackManyList* mainList = fpTrackContainer << 
123   G4TrackManyList::iterator it = mainList->end << 
124   it--;                                        << 
125   std::size_t initialSize = mainList->size();  << 
126                                                << 
127 //    G4cout << "initialSize = " << initialSiz << 
128                                                << 
129   for(std::size_t i = 0 ; i < initialSize ; ++ << 
130   {                                            << 
131                                                << 
132 //      G4cout << "i = " << i << G4endl;       << 
133                                                << 
134     G4Track* track = *it;                      << 
135     if (track == nullptr)                      << 
136     {                                          << 
137       G4ExceptionDescription exceptionDescript << 
138       exceptionDescription << "No track was po << 
139       G4Exception("G4ITStepProcessor::DoIt", " << 
140                   FatalException, exceptionDes << 
141     }                                          << 
142     // G4TrackManyList::iterator next_it (it); << 
143     // next_it--;                              << 
144     // it = next_it;                           << 
145                                                << 
146     it--;                                      << 
147     // Must be called before EndTracking(track << 
148     // Otherwise the iterator will point to th << 
149                                                    61 
150     if(track->GetTrackStatus() == fStopAndKill <<  62     for(G4int DSecLoop=0 ;
                                                   >>  63         DSecLoop<fpParticleChange->GetNumberOfSecondaries() ;
                                                   >>  64         DSecLoop++)
151     {                                              65     {
152       fpTrackingManager->EndTracking(track);   <<  66         tempSecondaryTrack = fpParticleChange->GetSecondary(DSecLoop);
153 //      G4cout << GetIT(track)->GetName() << G << 
154 //      G4cout << " ************************ C << 
155       continue;                                << 
156     }                                          << 
157                                                    67 
158 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_ <<  68         if(tempSecondaryTrack->GetDefinition()->GetApplyCutsFlag())
159     MemStat mem_first, mem_second, mem_diff;   << 
160     mem_first = MemoryUsage();                 << 
161 #endif                                         << 
162                                                << 
163     Stepping(track, timeStep);                 << 
164                                                << 
165 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_ << 
166     MemStat mem_intermediaire = MemoryUsage(); << 
167     mem_diff = mem_intermediaire-mem_first;    << 
168     G4cout << "\t\t >> || MEM || In DoIT with  << 
169         << track->GetTrackID() << ", diff is : << 
170 #endif                                         << 
171                                                << 
172     ExtractDoItData();                         << 
173                                                << 
174 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_ << 
175     mem_second = MemoryUsage();                << 
176     mem_diff = mem_second-mem_first;           << 
177     G4cout << "\t >> || MEM || In DoIT with tr << 
178         << track->GetTrackID()                 << 
179         << ", diff is : " << mem_diff << G4end << 
180 #endif                                         << 
181   }                                            << 
182                                                << 
183                                                << 
184   fpTrackContainer->MergeSecondariesWithMainLi << 
185   fpTrackContainer->KillTracks(); // (18-06-15 << 
186   fLeadingTracks.Reset();                      << 
187 }                                              << 
188                                                << 
189 //____________________________________________ << 
190                                                << 
191 void G4ITStepProcessor::ExtractDoItData()      << 
192 {                                              << 
193   if (fpTrack == nullptr)                      << 
194   {                                            << 
195     CleanProcessor();                          << 
196     return;                                    << 
197   }                                            << 
198                                                << 
199   G4TrackStatus status = fpTrack->GetTrackStat << 
200                                                << 
201   switch (status)                              << 
202   {                                            << 
203     case fAlive:                               << 
204     case fStopButAlive:                        << 
205     case fSuspend:                             << 
206     case fPostponeToNextEvent:                 << 
207     default:                                   << 
208       PushSecondaries();                       << 
209       break;                                   << 
210                                                << 
211     case fStopAndKill:                         << 
212       G4ITReactionSet::Instance()->RemoveReact << 
213       PushSecondaries();                       << 
214 //      G4TrackList::Pop(fpTrack);             << 
215       fpTrackingManager->EndTracking(fpTrack); << 
216 //      fTrackContainer->PushToKill(fpTrack);  << 
217       break;                                   << 
218                                                << 
219     case fKillTrackAndSecondaries:             << 
220       G4ITReactionSet::Instance()->RemoveReact << 
221       if (fpSecondary != nullptr)              << 
222       {                                        << 
223         for (auto & i : *fpSecondary)          << 
224         {                                          69         {
225           delete i;                            <<  70             ApplyProductionCut(tempSecondaryTrack);
226         }                                          71         }
227         fpSecondary->clear();                  << 
228       }                                        << 
229 //      G4TrackList::Pop(fpTrack);             << 
230       fpTrackingManager->EndTracking(fpTrack); << 
231 //      fTrackContainer->PushToKill(fpTrack);  << 
232       break;                                   << 
233   }                                            << 
234                                                    72 
235   CleanProcessor();                            <<  73         // Set parentID
236 }                                              <<  74         tempSecondaryTrack->SetParentID( fpTrack->GetTrackID() );
237                                                    75 
238 //____________________________________________ <<  76         // Set the process pointer which created this track
                                                   >>  77         tempSecondaryTrack->SetCreatorProcess( fpCurrentProcess );
239                                                    78 
240 void G4ITStepProcessor::PushSecondaries()      <<  79         // If this 2ndry particle has 'zero' kinetic energy, make sure
241 {                                              <<  80         // it invokes a rest process at the beginning of the tracking
242   if ((fpSecondary == nullptr) || fpSecondary- <<  81         if(tempSecondaryTrack->GetKineticEnergy() <= DBL_MIN)
243   {                                            <<  82         {
244     // DEBUG                                   <<  83             G4ProcessManager* pm = tempSecondaryTrack->GetDefinition()->GetProcessManager();
245     //      G4cout << "NO SECONDARIES !!! " << <<  84             if (pm->GetAtRestProcessVector()->entries()>0){
246     return;                                    <<  85                 tempSecondaryTrack->SetTrackStatus( fStopButAlive );
247   }                                            <<  86                 fpSecondary->push_back( tempSecondaryTrack );
248                                                <<  87                 fN2ndariesAtRestDoIt++;
249   // DEBUG                                     <<  88             } else {
250   //    G4cout << "There are secondaries : "<< <<  89                 delete tempSecondaryTrack;
251                                                <<  90             }
252   auto secondaries_i = fpSecondary->begin();   <<  91         }
253                                                <<  92         else
254   for (; secondaries_i != fpSecondary->end();  <<  93         {
255   {                                            <<  94             fpSecondary->push_back( tempSecondaryTrack );
256     G4Track* secondary = *secondaries_i;       <<  95             counter++;
257     fpTrackContainer->_PushTrack(secondary);   <<  96         }
258   }                                            <<  97     } //end of loop on secondary
259 }                                                  98 }
260                                                    99 
261 //____________________________________________    100 //______________________________________________________________________________
262                                                   101 
263 void G4ITStepProcessor::Stepping(G4Track* trac    102 void G4ITStepProcessor::Stepping(G4Track* track, const double & timeStep)
264 {                                                 103 {
265                                                   104 
266 #ifdef DEBUG_MEM                                  105 #ifdef DEBUG_MEM
267   MemStat mem_first, mem_second, mem_diff;     << 106     MemStat mem_first, mem_second, mem_diff;
268 #endif                                            107 #endif
269                                                   108 
270 #ifdef DEBUG_MEM                                  109 #ifdef DEBUG_MEM
271   mem_first = MemoryUsage();                   << 110     mem_first = MemoryUsage();
272 #endif                                            111 #endif
273                                                   112 
274   CleanProcessor();                            << 113     CleanProcessor();
275                                                   114 
276 #ifdef DEBUG_MEM                                  115 #ifdef DEBUG_MEM
277   MemStat mem_intermediaire = MemoryUsage();   << 116     MemStat mem_intermediaire = MemoryUsage();
278   mem_diff = mem_intermediaire-mem_first;      << 117     mem_diff = mem_intermediaire-mem_first;
279   G4cout << "\t\t\t >> || MEM || After CleanPr << 118     G4cout << "\t\t\t >> || MEM || After CleanProcessor " << track->GetTrackID() << ", diff is : " << mem_diff << G4endl;
280 #endif                                            119 #endif
281                                                   120 
282   if(track == nullptr) return; // maybe put an << 121     if(track == 0) return ; // maybe put an exception here
283   fTimeStep = timeStep;                        << 122     fTimeStep = timeStep ;
284   SetTrack(track);                             << 123     SetTrack(track);
285   DoStepping();                                << 124     DoStepping();
286 }                                                 125 }
287 //____________________________________________    126 //______________________________________________________________________________
288                                                   127 
289 // *******************************************    128 // ************************************************************************
290 //  Stepping                                   << 129 //  Stepping
291 // *******************************************    130 // ************************************************************************
292 void G4ITStepProcessor::DoStepping()              131 void G4ITStepProcessor::DoStepping()
293 {                                                 132 {
294   SetupMembers();                              << 133     SetupMembers() ;
295                                                   134 
296 #ifdef DEBUG_MEM                                  135 #ifdef DEBUG_MEM
297   MemStat mem_first, mem_second, mem_diff;     << 136     MemStat mem_first, mem_second, mem_diff;
298 #endif                                            137 #endif
299                                                   138 
300 #ifdef DEBUG_MEM                                  139 #ifdef DEBUG_MEM
301   mem_first = MemoryUsage();                   << 140     mem_first = MemoryUsage();
302 #endif                                            141 #endif
303                                                   142 
304 #ifdef G4VERBOSE                               << 143     if(!fpProcessInfo)
305     if(fpVerbose != nullptr) fpVerbose->PreSte << 144     {
306 #endif                                         << 145         G4ExceptionDescription exceptionDescription ;
307                                                << 146         exceptionDescription << "No process info found for particle :"
308   if(fpProcessInfo == nullptr)                 << 147                              << fpTrack->GetDefinition()->GetParticleName();
309   {                                            << 148         G4Exception("G4ITStepProcessor::DoStepping","ITStepProcessor0012",
310     G4ExceptionDescription exceptionDescriptio << 149                     FatalErrorInArgument,exceptionDescription);
311     exceptionDescription << "No process info f << 150         return ;
312                          << fpTrack->GetDefini << 151     }
313     G4Exception("G4ITStepProcessor::DoStepping << 152     else if(fpTrack->GetTrackStatus() == fStopAndKill )
314                 "ITStepProcessor0012",         << 153     {
315                 FatalErrorInArgument,          << 154         fpState->fStepStatus = fUndefined;
316                 exceptionDescription);         << 155         return ;
317     return;                                    << 156     }
318   }                                            << 157 
319 //  else if(fpTrack->GetTrackStatus() == fStop << 158     if(fpProcessInfo->MAXofPostStepLoops == 0
320 //  {                                          << 159             && fpProcessInfo->MAXofAlongStepLoops == 0
321 //    fpState->fStepStatus = fUndefined;       << 160             && fpProcessInfo->MAXofAtRestLoops == 0)
322 //    return;                                  << 161     {
323 //  }                                          << 162        G4ExceptionDescription exceptionDescription ;
324                                                << 163        exceptionDescription << "No process was found for particle :"
325   if(fpProcessInfo->MAXofPostStepLoops == 0 && << 164                              << fpTrack->GetDefinition()->GetParticleName();
326       fpProcessInfo->MAXofAlongStepLoops == 0  << 165        G4Exception("G4ITStepProcessor::DoStepping","ITStepProcessorNoProcess",
327      && fpProcessInfo->MAXofAtRestLoops == 0)  << 166                           JustWarning,exceptionDescription);
328   {/*                                          << 167 
329     G4ExceptionDescription exceptionDescriptio << 168         fpTrack -> SetTrackStatus(fStopAndKill) ;
330     exceptionDescription << "No process was fo << 169         fpState->fStepStatus = fUndefined;
331                          << fpTrack->GetDefini << 170         return ;
332     G4Exception("G4ITStepProcessor::DoStepping << 171     }
333                 "ITStepProcessorNoProcess",    << 172     //---------------------------------
334                 JustWarning,                   << 173     // AtRestStep, AlongStep and PostStep Processes
335                 exceptionDescription);         << 174     //---------------------------------
336                                                << 175     else
337     fpTrack->SetTrackStatus(fStopAndKill);     << 176     {
338     fpState->fStepStatus = fUndefined;*/       << 177         fpNavigator->SetNavigatorState(fpITrack->GetTrackingInfo()->GetNavigatorState());
339     return;                                    << 
340   }                                            << 
341                                                << 
342   //--------                                   << 
343   // Prelude                                   << 
344   //--------                                   << 
345 #ifdef G4VERBOSE                               << 
346   // !!!!! Verbose                             << 
347   if(fpVerbose != nullptr) fpVerbose->NewStep( << 
348 #endif                                         << 
349                                                << 
350   //---------------------------------          << 
351   // AtRestStep, AlongStep and PostStep Proces << 
352   //---------------------------------          << 
353                                                << 
354   fpNavigator->SetNavigatorState(fpITrack->Get << 
355 //        fpNavigator->ResetHierarchyAndLocate    178 //        fpNavigator->ResetHierarchyAndLocate( fpTrack->GetPosition(),
356 //                                                179 //                                              fpTrack->GetMomentumDirection(),
357 //                                                180 //                                              *((G4TouchableHistory*)fpTrack->GetTouchableHandle()()) );
358 //        fpNavigator->SetNavigatorState(fpITr    181 //        fpNavigator->SetNavigatorState(fpITrack->GetTrackingInfo()->GetNavigatorState());
359   // We reset the navigator state before check << 182         // We reset the navigator state before checking for AtRest
360   // in case a AtRest processe would use a nav << 183         // in case a AtRest processe would use a navigator info
361                                                   184 
362 #ifdef DEBUG_MEM                                  185 #ifdef DEBUG_MEM
363   MemStat mem_intermediaire = MemoryUsage();   << 186     MemStat mem_intermediaire = MemoryUsage();
364   mem_diff = mem_intermediaire-mem_first;      << 187     mem_diff = mem_intermediaire-mem_first;
365   G4cout << "\t\t\t >> || MEM || G4ITStepProce << 188     G4cout << "\t\t\t >> || MEM || G4ITStepProcessor::DoStepping || After dealing with navigator with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
366 #endif                                         << 
367                                                << 
368   if(fpTrack->GetTrackStatus() == fStopButAliv << 
369   {                                            << 
370     if(fpProcessInfo->MAXofAtRestLoops > 0 &&  << 
371         != nullptr) // second condition to mak << 
372     {                                          << 
373       //-----------------                      << 
374       // AtRestStepDoIt                        << 
375       //-----------------                      << 
376       InvokeAtRestDoItProcs();                 << 
377       fpState->fStepStatus = fAtRestDoItProc;  << 
378       fpStep->GetPostStepPoint()->SetStepStatu << 
379                                                << 
380 #ifdef G4VERBOSE                               << 
381             // !!!!! Verbose                   << 
382       if(fpVerbose != nullptr) fpVerbose->AtRe << 
383 #endif                                            189 #endif
384                                                   190 
385     }                                          << 191         if( fpTrack->GetTrackStatus() == fStopButAlive )
386     // Make sure the track is killed           << 192         {
387     // fpTrack->SetTrackStatus(fStopAndKill);  << 193             if( fpProcessInfo->MAXofAtRestLoops>0 &&
388   }                                            << 194                     fpProcessInfo->fpAtRestDoItVector != 0) // second condition to make coverity happy
389   else // if(fTimeStep > 0.) // Bye, because P << 195             {
390   {                                            << 196                 //-----------------
391     if(fpITrack == nullptr)                    << 197                 // AtRestStepDoIt
392     {                                          << 198                 //-----------------
393       G4ExceptionDescription exceptionDescript << 199                 InvokeAtRestDoItProcs();
394       exceptionDescription << " !!! TrackID :  << 200                 fpState->fStepStatus = fAtRestDoItProc;
395                            << G4endl<< " !!! T << 201                 fpStep->GetPostStepPoint()->SetStepStatus( fpState->fStepStatus );
396       << " !!! Particle Name : "<< fpTrack ->  << 202 
397       << "No G4ITStepProcessor::fpITrack found << 203             }
398                                                << 204             // Make sure the track is killed
399       G4Exception("G4ITStepProcessor::DoSteppi << 205             fpTrack->SetTrackStatus( fStopAndKill );
400                   "ITStepProcessor0013",       << 206         }
401                   FatalErrorInArgument,        << 207         else // if(fTimeStep > 0.) // Bye, because PostStepIL can return 0 => time =0
402                   exceptionDescription);       << 208         {
403       return; // to make coverity happy        << 209             if(fpITrack == 0)
404     }                                          << 210             {
405                                                << 211                 G4ExceptionDescription exceptionDescription ;
406     if(!fpITrack->GetTrackingInfo()->IsLeading << 212                 exceptionDescription
407     {                                          << 213                         << " !!! TrackID : "<<  fpTrack->GetTrackID() << G4endl
408       // In case the track has NOT the minimum << 214                         << " !!! Track status : "<<  fpTrack->GetTrackStatus() << G4endl
409       // Given the final step time, the transp << 215                         << " !!! Particle Name : "<< fpTrack -> GetDefinition() -> GetParticleName() << G4endl
410       // will compute the final position of th << 216                         << "No G4ITStepProcessor::fpITrack found" << G4endl;
411       fpState->fStepStatus = fPostStepDoItProc << 217 
412       fpStep->GetPostStepPoint()->SetProcessDe << 218                 G4Exception("G4ITStepProcessor::DoStepping","ITStepProcessor0013",
413       FindTransportationStep();                << 219                             FatalErrorInArgument,exceptionDescription);
414     }                                          << 220                 return ; // to make coverity happy
                                                   >> 221             }
                                                   >> 222 
                                                   >> 223             if(fpITrack->GetTrackingInfo()->IsLeadingStep() == false)
                                                   >> 224             {
                                                   >> 225                 // In case the track has NOT the minimum step length
                                                   >> 226                 // Given the final step time, the transportation
                                                   >> 227                 // will compute the final position of the particle
                                                   >> 228                 fpState->fStepStatus = fPostStepDoItProc;
                                                   >> 229                 fpStep->GetPostStepPoint()
                                                   >> 230                         ->SetProcessDefinedStep(fpTransportation);
                                                   >> 231                 FindTransportationStep();
                                                   >> 232             }
415                                                   233 
416 #ifdef DEBUG_MEM                                  234 #ifdef DEBUG_MEM
417     mem_intermediaire = MemoryUsage();            235     mem_intermediaire = MemoryUsage();
418     mem_diff = mem_intermediaire-mem_first;       236     mem_diff = mem_intermediaire-mem_first;
419     G4cout << "\t\t\t >> || MEM || G4ITStepPro    237     G4cout << "\t\t\t >> || MEM || G4ITStepProcessor::DoStepping || After FindTransportationStep() with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
420 #endif                                            238 #endif
421                                                   239 
422     // Store the Step length (geometrical leng << 240             // Store the Step length (geometrical length) to G4Step and G4Track
423     fpTrack->SetStepLength(fpState->fPhysicalS << 241             fpTrack->SetStepLength( fpState->fPhysicalStep );
424     fpStep->SetStepLength(fpState->fPhysicalSt << 242             fpStep->SetStepLength( fpState->fPhysicalStep );
425                                                   243 
426     G4double GeomStepLength = fpState->fPhysic << 244             G4double GeomStepLength = fpState->fPhysicalStep;
427                                                   245 
428     // Store StepStatus to PostStepPoint       << 246             // Store StepStatus to PostStepPoint
429     fpStep->GetPostStepPoint()->SetStepStatus( << 247             fpStep->GetPostStepPoint()->SetStepStatus( fpState->fStepStatus );
430                                                   248 
431     // Invoke AlongStepDoIt                    << 249             // Invoke AlongStepDoIt
432     InvokeAlongStepDoItProcs();                << 250             InvokeAlongStepDoItProcs();
433                                                   251 
434 #ifdef DEBUG_MEM                                  252 #ifdef DEBUG_MEM
435     mem_intermediaire = MemoryUsage();            253     mem_intermediaire = MemoryUsage();
436     mem_diff = mem_intermediaire-mem_first;       254     mem_diff = mem_intermediaire-mem_first;
437     G4cout << "\t\t\t >> || MEM || G4ITStepPro    255     G4cout << "\t\t\t >> || MEM || G4ITStepProcessor::DoStepping || After InvokeAlongStepDoItProcs() with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
438 #endif                                            256 #endif
439                                                   257 
440 #ifdef G4VERBOSE                               << 258             // Update track by taking into account all changes by AlongStepDoIt
441     // !!!!! Verbose                           << 259             // fpStep->UpdateTrack(); // done in InvokeAlongStepDoItProcs
442     if(fpVerbose != nullptr) fpVerbose->AlongS << 
443 #endif                                         << 
444                                                << 
445     // Update track by taking into account all << 
446     // fpStep->UpdateTrack(); // done in Invok << 
447                                                   260 
448     // Update safety after invocation of all A << 261             // Update safety after invocation of all AlongStepDoIts
449     fpState->fEndpointSafOrigin = fpPostStepPo << 262             fpState->endpointSafOrigin= fpPostStepPoint->GetPosition();
450                                                   263 
451     fpState->fEndpointSafety =                 << 264             fpState->endpointSafety=  std::max( fpState->proposedSafety - GeomStepLength, kCarTolerance);
452         std::max(fpState->fProposedSafety - Ge << 
453                                                   265 
454     fpStep->GetPostStepPoint()->SetSafety(fpSt << 266             fpStep->GetPostStepPoint()->SetSafety( fpState->endpointSafety );
455                                                   267 
456     if(GetIT(fpTrack)->GetTrackingInfo()->IsLe << 268             if(GetIT(fpTrack)->GetTrackingInfo()->IsLeadingStep())
457     {                                          << 269             {
458       // Invoke PostStepDoIt including G4ITTra << 270                 // Invoke PostStepDoIt including G4ITTransportation::PSDI
459       InvokePostStepDoItProcs();               << 271                 InvokePostStepDoItProcs();
460                                                   272 
461 #ifdef DEBUG_MEM                                  273 #ifdef DEBUG_MEM
462       mem_intermediaire = MemoryUsage();       << 274     mem_intermediaire = MemoryUsage();
463       mem_diff = mem_intermediaire-mem_first;  << 275     mem_diff = mem_intermediaire-mem_first;
464       G4cout << "\t\t\t >> || MEM || G4ITStepP << 276     G4cout << "\t\t\t >> || MEM || G4ITStepProcessor::DoStepping || After InvokePostStepDoItProcs() with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
465 #endif                                         << 
466 #ifdef G4VERBOSE                               << 
467     // !!!!! Verbose                           << 
468     if(fpVerbose != nullptr) fpVerbose->StepIn << 
469 #endif                                            277 #endif
470     }                                          << 278             }
471     else                                       << 279             else
472     {                                          << 280             {
473       // Only invoke transportation and all ot << 281                 // Only invoke transportation
474       InvokeTransportationProc();              << 282                 InvokeTransportationProc();
475       fpStep->GetPostStepPoint()->SetProcessDe << 
476                                                   283 
477 #ifdef DEBUG_MEM                                  284 #ifdef DEBUG_MEM
478       mem_intermediaire = MemoryUsage();       << 285     mem_intermediaire = MemoryUsage();
479       mem_diff = mem_intermediaire-mem_first;  << 286     mem_diff = mem_intermediaire-mem_first;
480       G4cout << "\t\t\t >> || MEM || G4ITStepP << 287     G4cout << "\t\t\t >> || MEM || G4ITStepProcessor::DoStepping || After InvokeTransportationProc() with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
481 #endif                                         << 
482     }                                          << 
483                                                << 
484 #ifdef G4VERBOSE                               << 
485     // !!!!! Verbose                           << 
486     if(fpVerbose != nullptr) fpVerbose->PostSt << 
487 #endif                                            288 #endif
488   }                                            << 289             }
                                                   >> 290         }
489                                                   291 
490   fpNavigator->ResetNavigatorState();          << 292         fpNavigator->ResetNavigatorState();
491                                                   293 
492 #ifdef DEBUG_MEM                                  294 #ifdef DEBUG_MEM
493   mem_intermediaire = MemoryUsage();           << 295     mem_intermediaire = MemoryUsage();
494   mem_diff = mem_intermediaire-mem_first;      << 296     mem_diff = mem_intermediaire-mem_first;
495   G4cout << "\t\t\t >> || MEM || G4ITStepProce << 297     G4cout << "\t\t\t >> || MEM || G4ITStepProcessor::DoStepping || After fpNavigator->SetNavigatorState with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
496 #endif                                            298 #endif
                                                   >> 299     }
                                                   >> 300     //-------
                                                   >> 301     // Finale
                                                   >> 302     //-------
497                                                   303 
498   //-------                                    << 304     // Update 'TrackLength' and remeber the Step length of the current Step
499   // Finale                                    << 305     fpTrack->AddTrackLength(fpStep->GetStepLength());
500   //-------                                    << 306     fpTrack->IncrementCurrentStepNumber();
501                                                   307 
502   // Update 'TrackLength' and remeber the Step << 308 //    G4cout << " G4ITStepProcessor::DoStepping  -- " <<fpTrack->GetTrackID() << " tps = " << fpTrack->GetGlobalTime() << G4endl;
503   fpTrack->AddTrackLength(fpStep->GetStepLengt << 
504   fpTrack->IncrementCurrentStepNumber();       << 
505                                                   309 
506 //#ifdef G4VERBOSE                             << 310     // Send G4Step information to Hit/Dig if the volume is sensitive
507 // //    !!!!! Verbose                         << 311 /***
508 //  if(fpVerbose) fpVerbose->StepInfo();       << 312     fpCurrentVolume = fpStep->GetPreStepPoint()->GetPhysicalVolume();
509 //#endif                                       << 313     StepControlFlag =  fpStep->GetControlFlag();
                                                   >> 314 
                                                   >> 315     if( fpCurrentVolume != 0 && StepControlFlag != AvoidHitInvocation)
                                                   >> 316     {
                                                   >> 317         fpSensitive = fpStep->GetPreStepPoint()->
                                                   >> 318                 GetSensitiveDetector();
                                                   >> 319         if( fpSensitive != 0 )
                                                   >> 320         {
                                                   >> 321             fpSensitive->Hit(fpStep);
                                                   >> 322         }
                                                   >> 323     }
510                                                   324 
511 #ifdef G4VERBOSE                               << 325      User intervention process.
512     if(fpVerbose != nullptr) fpVerbose->PostSt << 326     if( fpUserSteppingAction != 0 )
513 #endif                                         << 327     {
                                                   >> 328         fpUserSteppingAction->UserSteppingAction(fpStep);
                                                   >> 329     }
                                                   >> 330     G4UserSteppingAction* regionalAction
                                                   >> 331             = fpStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()
                                                   >> 332             ->GetRegionalSteppingAction();
                                                   >> 333     if( regionalAction ) regionalAction->UserSteppingAction(fpStep);
                                                   >> 334 ***/
                                                   >> 335     fpTrackingManager->AppendStep(fpTrack,fpStep);
                                                   >> 336     // Stepping process finish. Return the value of the StepStatus.
514                                                   337 
515 //    G4cout << " G4ITStepProcessor::DoSteppin << 
516                                                   338 
517   // Send G4Step information to Hit/Dig if the << 339 #ifdef DEBUG_MEM
518   /***                                         << 340     MemStat mem_intermediaire = MemoryUsage();
519    fpCurrentVolume = fpStep->GetPreStepPoint() << 341     mem_diff = mem_intermediaire-mem_first;
520    StepControlFlag =  fpStep->GetControlFlag() << 342     G4cout << "\t\t\t >> || MEM || End of DoStepping() with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
521                                                << 
522    if( fpCurrentVolume != 0 && StepControlFlag << 
523    {                                           << 
524    fpSensitive = fpStep->GetPreStepPoint()->   << 
525    GetSensitiveDetector();                     << 
526    if( fpSensitive != 0 )                      << 
527    {                                           << 
528    fpSensitive->Hit(fpStep);                   << 
529    }                                           << 
530    }                                           << 
531                                                << 
532    User intervention process.                  << 
533    if( fpUserSteppingAction != 0 )             << 
534    {                                           << 
535    fpUserSteppingAction->UserSteppingAction(fp << 
536    }                                           << 
537    G4UserSteppingAction* regionalAction        << 
538    = fpStep->GetPreStepPoint()->GetPhysicalVol << 
539    ->GetRegionalSteppingAction();              << 
540    if( regionalAction ) regionalAction->UserSt << 
541    ***/                                        << 
542   fpTrackingManager->AppendStep(fpTrack, fpSte << 
543   // Stepping process finish. Return the value << 
544                                                << 
545 #ifdef DEBUG_MEM                               << 
546   MemStat mem_intermediaire = MemoryUsage();   << 
547   mem_diff = mem_intermediaire-mem_first;      << 
548   G4cout << "\t\t\t >> || MEM || End of DoStep << 
549 #endif                                            343 #endif
550                                                   344 
551   //    return fpState->fStepStatus;           << 345 
                                                   >> 346     //    return fpState->fStepStatus;
552 }                                                 347 }
553                                                   348 
554 //____________________________________________    349 //______________________________________________________________________________
555                                                   350 
556 // *******************************************    351 // ************************************************************************
557 //  AtRestDoIt                                 << 352 //  AtRestDoIt
558 // *******************************************    353 // ************************************************************************
559                                                   354 
560 void G4ITStepProcessor::InvokeAtRestDoItProcs(    355 void G4ITStepProcessor::InvokeAtRestDoItProcs()
561 {                                                 356 {
562   fpStep->SetStepLength(0.);  //the particle h << 357     fpStep->SetStepLength( 0. );  //the particle has stopped
563   fpTrack->SetStepLength(0.);                  << 358     fpTrack->SetStepLength( 0. );
                                                   >> 359 
                                                   >> 360     G4SelectedAtRestDoItVector& selectedAtRestDoItVector = fpState->fSelectedAtRestDoItVector;
                                                   >> 361 
                                                   >> 362     // invoke selected process
                                                   >> 363     for(size_t np=0; np < fpProcessInfo->MAXofAtRestLoops; np++)
                                                   >> 364     {
                                                   >> 365         //
                                                   >> 366         // Note: DoItVector has inverse order against GetPhysIntVector
                                                   >> 367         //       and SelectedAtRestDoItVector.
                                                   >> 368         //
                                                   >> 369         if( selectedAtRestDoItVector[fpProcessInfo->MAXofAtRestLoops-np-1] != InActivated)
                                                   >> 370         {
                                                   >> 371             fpCurrentProcess = (G4VITProcess*) (*fpProcessInfo->fpAtRestDoItVector)[np];
                                                   >> 372 
                                                   >> 373             fpCurrentProcess->SetProcessState(
                                                   >> 374                         fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID()));
                                                   >> 375             fpParticleChange
                                                   >> 376                     = fpCurrentProcess->AtRestDoIt( *fpTrack, *fpStep);
                                                   >> 377 //            fpCurrentProcess->SetProcessState(0);
                                                   >> 378             fpCurrentProcess->ResetProcessState();
564                                                   379 
565   G4SelectedAtRestDoItVector& selectedAtRestDo << 380             // Set the current process as a process which defined this Step length
566       fpState->fSelectedAtRestDoItVector;      << 381             fpStep->GetPostStepPoint()
                                                   >> 382                     ->SetProcessDefinedStep(fpCurrentProcess);
567                                                   383 
568   // invoke selected process                   << 384             // Update Step
569   for(std::size_t np = 0; np < fpProcessInfo-> << 385             fpParticleChange->UpdateStepForAtRest(fpStep);
570   {                                            << 386 
571     //                                         << 387             // Now Store the secondaries from ParticleChange to SecondaryList
572     // Note: DoItVector has inverse order agai << 388             DealWithSecondaries(fN2ndariesAtRestDoIt) ;
573     //       and SelectedAtRestDoItVector.     << 389 
574     //                                         << 390             // clear ParticleChange
575     if(selectedAtRestDoItVector[fpProcessInfo- << 391             fpParticleChange->Clear();
576     {                                          << 392 
577       fpCurrentProcess =                       << 393         } //if(fSelectedAtRestDoItVector[np] != InActivated){
578           (G4VITProcess*) (*fpProcessInfo->fpA << 394     } //for(size_t np=0; np < MAXofAtRestLoops; np++){
579                                                << 395     fpStep->UpdateTrack();
580 //      G4cout << " Invoke : "                 << 396 
581 //             << fpCurrentProcess->GetProcess << 397     fpTrack->SetTrackStatus( fStopAndKill );
582 //             << G4endl;                      << 
583                                                << 
584       //  if(fpVerbose)                        << 
585       //  {                                    << 
586       //    fpVerbose->AtRestDoItOneByOne();   << 
587       //  }                                    << 
588                                                << 
589       fpCurrentProcess->SetProcessState(fpTrac << 
590           ->GetProcessID()));                  << 
591       fpParticleChange = fpCurrentProcess->AtR << 
592       fpCurrentProcess->ResetProcessState();   << 
593                                                << 
594       // Set the current process as a process  << 
595       fpStep->GetPostStepPoint()->SetProcessDe << 
596                                                << 
597       // Update Step                           << 
598       fpParticleChange->UpdateStepForAtRest(fp << 
599                                                << 
600       // Now Store the secondaries from Partic << 
601       DealWithSecondaries(fN2ndariesAtRestDoIt << 
602                                                << 
603       // Set the track status according to wha << 
604       // if kinetic energy >0, otherwise set   << 
605       fpTrack->SetTrackStatus(fpParticleChange << 
606                                                << 
607       // clear ParticleChange                  << 
608       fpParticleChange->Clear();               << 
609                                                << 
610     } //if(fSelectedAtRestDoItVector[np] != In << 
611   } //for(std::size_t np=0; np < MAXofAtRestLo << 
612   fpStep->UpdateTrack();                       << 
613                                                << 
614   // Modification par rapport au transport sta << 
615   // fStopAndKill doit etre propose par le mod << 
616   // sinon d autres processus AtRest seront ap << 
617   // au pas suivant                            << 
618   // fpTrack->SetTrackStatus(fStopAndKill);    << 
619 }                                                 398 }
620                                                   399 
621 //____________________________________________    400 //______________________________________________________________________________
622                                                   401 
623 // *******************************************    402 // ************************************************************************
624 //  AlongStepDoIt                              << 403 //  AlongStepDoIt
625 // *******************************************    404 // ************************************************************************
626                                                   405 
627 void G4ITStepProcessor::InvokeAlongStepDoItPro    406 void G4ITStepProcessor::InvokeAlongStepDoItProcs()
628 {                                                 407 {
629                                                   408 
630 #ifdef DEBUG_MEM                                  409 #ifdef DEBUG_MEM
631   MemStat mem_first, mem_second, mem_diff;     << 410     MemStat mem_first, mem_second, mem_diff;
632 #endif                                            411 #endif
633                                                   412 
634 #ifdef DEBUG_MEM                                  413 #ifdef DEBUG_MEM
635   mem_first = MemoryUsage();                   << 414     mem_first = MemoryUsage();
636 #endif                                            415 #endif
637                                                   416 
638   // If the current Step is defined by a 'Excl << 417     // If the current Step is defined by a 'ExclusivelyForced'
639   // PostStepDoIt, then don't invoke any Along << 418     // PostStepDoIt, then don't invoke any AlongStepDoIt
640   if(fpState->fStepStatus == fExclusivelyForce << 419     if(fpState->fStepStatus == fExclusivelyForcedProc)
641   {                                            << 420     {
642     return;               // Take note 'return << 421         return;               // Take note 'return' at here !!!
643   }                                            << 422     }
644                                                   423 
645   // Invoke the all active continuous processe << 424     // Invoke the all active continuous processes
646   for(std::size_t ci = 0; ci < fpProcessInfo-> << 425     for( size_t ci=0 ; ci<fpProcessInfo->MAXofAlongStepLoops ; ci++ )
647   {                                            << 426     {
648     fpCurrentProcess =                         << 427         fpCurrentProcess = (G4VITProcess*) (*fpProcessInfo->fpAlongStepDoItVector)[ci];
649         (G4VITProcess*) (*fpProcessInfo->fpAlo << 428         if (fpCurrentProcess== 0) continue;
650     if(fpCurrentProcess == nullptr) continue;  << 429         // NULL means the process is inactivated by a user on fly.
651     // NULL means the process is inactivated b << 
652                                                   430 
653     fpCurrentProcess->SetProcessState(fpTracki << 431         fpCurrentProcess->SetProcessState(fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID()));
654         ->GetProcessID()));                    << 432         fpParticleChange = fpCurrentProcess->AlongStepDoIt( *fpTrack, *fpStep );
655     fpParticleChange = fpCurrentProcess->Along << 
656                                                   433 
657 #ifdef DEBUG_MEM                                  434 #ifdef DEBUG_MEM
658     MemStat mem_intermediaire = MemoryUsage();    435     MemStat mem_intermediaire = MemoryUsage();
659     mem_diff = mem_intermediaire-mem_first;       436     mem_diff = mem_intermediaire-mem_first;
660     G4cout << "\t\t\t >> || MEM || After calli << 437     G4cout << "\t\t\t >> || MEM || After calling AlongStepDoIt for " <<  fpCurrentProcess->GetProcessName() << " and track "<< fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
661 #endif                                            438 #endif
662                                                   439 
663 //        fpCurrentProcess->SetProcessState(0)    440 //        fpCurrentProcess->SetProcessState(0);
664     fpCurrentProcess->ResetProcessState();     << 441       fpCurrentProcess->ResetProcessState();
665     // Update the PostStepPoint of Step accord << 442         // Update the PostStepPoint of Step according to ParticleChange
666                                                   443 
667     fpParticleChange->UpdateStepForAlongStep(f << 444         fpParticleChange->UpdateStepForAlongStep(fpStep);
668                                                   445 
669 #ifdef G4VERBOSE                               << 446         // Now Store the secondaries from ParticleChange to SecondaryList
670     // !!!!! Verbose                           << 447         DealWithSecondaries(fN2ndariesAlongStepDoIt) ;
671     if(fpVerbose != nullptr) fpVerbose->AlongS << 
672 #endif                                         << 
673                                                   448 
674     // Now Store the secondaries from Particle << 449         // Set the track status according to what the process defined
675     DealWithSecondaries(fN2ndariesAlongStepDoI << 450         // if kinetic energy >0, otherwise set  fStopButAlive
                                                   >> 451         fpTrack->SetTrackStatus( fpParticleChange->GetTrackStatus() );
676                                                   452 
677     // Set the track status according to what  << 453         // clear ParticleChange
678     // if kinetic energy >0, otherwise set  fS << 454         fpParticleChange->Clear();
679     fpTrack->SetTrackStatus(fpParticleChange-> << 455     }
680                                                << 
681     // clear ParticleChange                    << 
682     fpParticleChange->Clear();                 << 
683   }                                            << 
684                                                   456 
685 #ifdef DEBUG_MEM                                  457 #ifdef DEBUG_MEM
686   MemStat mem_intermediaire = MemoryUsage();   << 458     MemStat mem_intermediaire = MemoryUsage();
687   mem_diff = mem_intermediaire-mem_first;      << 459     mem_diff = mem_intermediaire-mem_first;
688   G4cout << "\t\t\t >> || MEM || After looping << 460     G4cout << "\t\t\t >> || MEM || After looping on processes with " << fpTrack->GetTrackID() << ", diff is : " << mem_diff << G4endl;
689 #endif                                            461 #endif
690                                                   462 
691   fpStep->UpdateTrack();                       << 463     fpStep->UpdateTrack();
692                                                   464 
693   G4TrackStatus fNewStatus = fpTrack->GetTrack << 465     G4TrackStatus fNewStatus = fpTrack->GetTrackStatus();
694                                                   466 
695   if(fNewStatus == fAlive && fpTrack->GetKinet << 467     if ( fNewStatus == fAlive && fpTrack->GetKineticEnergy() <= DBL_MIN )
696   {                                            << 468     {
697     //        G4cout << "G4ITStepProcessor::In << 469         //        G4cout << "G4ITStepProcessor::InvokeAlongStepDoItProcs : Track will be killed" << G4endl;
698     if(fpProcessInfo->MAXofAtRestLoops>0) fNew << 470         if(fpProcessInfo->MAXofAtRestLoops>0) fNewStatus = fStopButAlive;
699     else fNewStatus = fStopAndKill;            << 471         else                   fNewStatus = fStopAndKill;
700     fpTrack->SetTrackStatus( fNewStatus );     << 472         fpTrack->SetTrackStatus( fNewStatus );
701   }                                            << 473     }
702                                                   474 
703 }                                                 475 }
704                                                   476 
705 //____________________________________________    477 //______________________________________________________________________________
706                                                   478 
                                                   >> 479 
707 // *******************************************    480 // ************************************************************************
708 //  PostStepDoIt                               << 481 //  PostStepDoIt
709 // *******************************************    482 // ************************************************************************
710                                                   483 
                                                   >> 484 
711 void G4ITStepProcessor::InvokePostStepDoItProc    485 void G4ITStepProcessor::InvokePostStepDoItProcs()
712 {                                                 486 {
713   std::size_t _MAXofPostStepLoops = fpProcessI << 487 
714   G4SelectedPostStepDoItVector& selectedPostSt << 488     G4SelectedPostStepDoItVector& selectedPostStepDoItVector = fpState->fSelectedPostStepDoItVector;
715       ->fSelectedPostStepDoItVector;           << 489     G4StepStatus& stepStatus = fpState->fStepStatus;
716   G4StepStatus& stepStatus = fpState->fStepSta << 490 
717                                                << 491     // Invoke the specified discrete processes
718   // Invoke the specified discrete processes   << 492     for(size_t np=0; np < fpProcessInfo->MAXofPostStepLoops; np++)
719   for(std::size_t np = 0; np < _MAXofPostStepL << 493     {
720   {                                            << 494         //
721     //                                         << 495         // Note: DoItVector has inverse order against GetPhysIntVector
722     // Note: DoItVector has inverse order agai << 496         //       and SelectedPostStepDoItVector.
723     //       and SelectedPostStepDoItVector.   << 497         //
724     //                                         << 498         G4int Cond = selectedPostStepDoItVector[fpProcessInfo->MAXofPostStepLoops-np-1];
725     G4int Cond = selectedPostStepDoItVector[_M << 499         if(Cond != InActivated)
726                                             -  << 
727     if(Cond != InActivated)                    << 
728     {                                          << 
729       if(((Cond == NotForced) && (stepStatus = << 
730           ((Cond == Forced) && (stepStatus !=  << 
731          ||                                    << 
732          // ((Cond == Conditionally) && (stepS << 
733          ((Cond == ExclusivelyForced) && (step << 
734          || ((Cond == StronglyForced)))        << 
735       {                                        << 
736                                                << 
737         InvokePSDIP(np);                       << 
738       }                                        << 
739     } //if(*fSelectedPostStepDoItVector(np)... << 
740                                                << 
741     // Exit from PostStepLoop if the track has << 
742     // but extra treatment for processes with  << 
743     if(fpTrack->GetTrackStatus() == fStopAndKi << 
744     {                                          << 
745       for(std::size_t np1 = np + 1; np1 < _MAX << 
746       {                                        << 
747         G4int Cond2 = selectedPostStepDoItVect << 
748                                                << 
749         if(Cond2 == StronglyForced)            << 
750         {                                         500         {
751           InvokePSDIP(np1);                    << 501             if( ((Cond == NotForced) && (stepStatus == fPostStepDoItProc)) ||
                                                   >> 502                     ((Cond == Forced) && (stepStatus != fExclusivelyForcedProc)) ||
                                                   >> 503                     //                    ((Cond == Conditionally) && (stepStatus == fAlongStepDoItProc)) ||
                                                   >> 504                     ((Cond == ExclusivelyForced) && (stepStatus == fExclusivelyForcedProc)) ||
                                                   >> 505                     ((Cond == StronglyForced) )
                                                   >> 506                     )
                                                   >> 507             {
                                                   >> 508 
                                                   >> 509                 InvokePSDIP(np);
                                                   >> 510             }
                                                   >> 511         } //if(*fSelectedPostStepDoItVector(np)........
                                                   >> 512 
                                                   >> 513         // Exit from PostStepLoop if the track has been killed,
                                                   >> 514         // but extra treatment for processes with Strongly Forced flag
                                                   >> 515         if(fpTrack->GetTrackStatus() == fStopAndKill)
                                                   >> 516         {
                                                   >> 517             for(size_t np1=np+1; np1 < fpProcessInfo->MAXofPostStepLoops; np1++)
                                                   >> 518             {
                                                   >> 519                 G4int Cond2 = selectedPostStepDoItVector[fpProcessInfo->MAXofPostStepLoops-np1-1];
                                                   >> 520                 if (Cond2 == StronglyForced)
                                                   >> 521                 {
                                                   >> 522                     InvokePSDIP(np1);
                                                   >> 523                 }
                                                   >> 524             }
                                                   >> 525             break;
752         }                                         526         }
753       }                                        << 527     } //for(size_t np=0; np < MAXofPostStepLoops; np++){
754       break;                                   << 
755     }                                          << 
756   } //for(std::size_t np=0; np < MAXofPostStep << 
757 }                                                 528 }
758                                                   529 
759 //____________________________________________    530 //______________________________________________________________________________
760                                                   531 
761 void G4ITStepProcessor::InvokePSDIP(std::size_ << 532 void G4ITStepProcessor::InvokePSDIP(size_t np)
762 {                                                 533 {
763   fpCurrentProcess = (G4VITProcess*) (*fpProce << 534     fpCurrentProcess = (G4VITProcess*) (*fpProcessInfo->fpPostStepDoItVector)[np];
764                                                   535 
765   fpCurrentProcess->SetProcessState(fpTracking << 536     fpCurrentProcess->SetProcessState(fpTrackingInfo->GetProcessState(fpCurrentProcess->GetProcessID()));
766       ->GetProcessID()));                      << 537     fpParticleChange
767   fpParticleChange = fpCurrentProcess->PostSte << 538             = fpCurrentProcess->PostStepDoIt( *fpTrack, *fpStep);
768 //    fpCurrentProcess->SetProcessState(0);       539 //    fpCurrentProcess->SetProcessState(0);
769   fpCurrentProcess->ResetProcessState();       << 540     fpCurrentProcess->ResetProcessState();
770                                                << 
771   // Update PostStepPoint of Step according to << 
772   fpParticleChange->UpdateStepForPostStep(fpSt << 
773                                                   541 
774 #ifdef G4VERBOSE                               << 542     // Update PostStepPoint of Step according to ParticleChange
775   // !!!!! Verbose                             << 543     fpParticleChange->UpdateStepForPostStep(fpStep);
776   if(fpVerbose != nullptr) fpVerbose->PostStep << 
777 #endif                                         << 
778                                                   544 
779   // Update G4Track according to ParticleChang << 545     // Update G4Track according to ParticleChange after each PostStepDoIt
780   fpStep->UpdateTrack();                       << 546     fpStep->UpdateTrack();
781                                                   547 
782   // Update safety after each invocation of Po << 548     // Update safety after each invocation of PostStepDoIts
783   fpStep->GetPostStepPoint()->SetSafety(Calcul << 549     fpStep->GetPostStepPoint()->SetSafety( CalculateSafety() );
784                                                   550 
785   // Now Store the secondaries from ParticleCh << 551     // Now Store the secondaries from ParticleChange to SecondaryList
786   DealWithSecondaries(fN2ndariesPostStepDoIt); << 552     DealWithSecondaries(fN2ndariesPostStepDoIt) ;
787                                                   553 
788   // Set the track status according to what th << 554     // Set the track status according to what the process defined
789   fpTrack->SetTrackStatus(fpParticleChange->Ge << 555     fpTrack->SetTrackStatus( fpParticleChange->GetTrackStatus() );
790                                                   556 
791   // clear ParticleChange                      << 557     // clear ParticleChange
792   fpParticleChange->Clear();                   << 558     fpParticleChange->Clear();
793 }                                                 559 }
794                                                   560 
795 //____________________________________________    561 //______________________________________________________________________________
796                                                   562 
797 // *******************************************    563 // ************************************************************************
798 //  Transport on a given time                  << 564 //  Transport on a given time
799 // *******************************************    565 // ************************************************************************
800                                                   566 
801 void G4ITStepProcessor::FindTransportationStep    567 void G4ITStepProcessor::FindTransportationStep()
802 {                                                 568 {
803   double physicalStep(0.);                     << 569     double physicalStep(0.) ;
                                                   >> 570 
                                                   >> 571     fpTransportation =  fpProcessInfo->fpTransportation;
                                                   >> 572     // dynamic_cast<G4ITTransportation*>((fpProcessInfo->fpAlongStepGetPhysIntVector)[MAXofAlongStepLoops-1]);
804                                                   573 
805   fpTransportation = fpProcessInfo->fpTranspor << 574     if(!fpTrack)
806   // dynamic_cast<G4ITTransportation*>((fpProc << 575     {
                                                   >> 576         G4ExceptionDescription exceptionDescription ;
                                                   >> 577         exceptionDescription
                                                   >> 578                 << "No G4ITStepProcessor::fpTrack found";
                                                   >> 579         G4Exception("G4ITStepProcessor::FindTransportationStep","ITStepProcessor0013",
                                                   >> 580                     FatalErrorInArgument,exceptionDescription);
                                                   >> 581         return;
807                                                   582 
808   if(fpTrack == nullptr)                       << 583     }
809   {                                            << 584     if(!fpITrack)
810     G4ExceptionDescription exceptionDescriptio << 585     {
811     exceptionDescription << "No G4ITStepProces << 586         G4ExceptionDescription exceptionDescription ;
812     G4Exception("G4ITStepProcessor::FindTransp << 587         exceptionDescription
813                 "ITStepProcessor0013",         << 588                 << "No G4ITStepProcessor::fITrack" ;
814                 FatalErrorInArgument,          << 589         G4Exception("G4ITStepProcessor::FindTransportationStep","ITStepProcessor0014",
815                 exceptionDescription);         << 590                     FatalErrorInArgument,exceptionDescription);
816     return;                                    << 591         return;
817                                                << 592     }
818   }                                            << 593     if(!(fpITrack->GetTrack()))
819   if(fpITrack == nullptr)                      << 594     {
820   {                                            << 595         G4ExceptionDescription exceptionDescription ;
821     G4ExceptionDescription exceptionDescriptio << 596         exceptionDescription
822     exceptionDescription << "No G4ITStepProces << 597                 << "No G4ITStepProcessor::fITrack->GetTrack()" ;
823     G4Exception("G4ITStepProcessor::FindTransp << 598         G4Exception("G4ITStepProcessor::FindTransportationStep","ITStepProcessor0015",
824                 "ITStepProcessor0014",         << 599                     FatalErrorInArgument,exceptionDescription);
825                 FatalErrorInArgument,          << 600         return;
826                 exceptionDescription);         << 601     }
827     return;                                    << 
828   }                                            << 
829   if((fpITrack->GetTrack()) == nullptr)        << 
830   {                                            << 
831     G4ExceptionDescription exceptionDescriptio << 
832     exceptionDescription << "No G4ITStepProces << 
833     G4Exception("G4ITStepProcessor::FindTransp << 
834                 "ITStepProcessor0015",         << 
835                 FatalErrorInArgument,          << 
836                 exceptionDescription);         << 
837     return;                                    << 
838   }                                            << 
839                                                << 
840   if(fpTransportation != nullptr)              << 
841   {                                            << 
842     fpTransportation->SetProcessState(fpTracki << 
843         ->GetProcessID()));                    << 
844     fpTransportation->ComputeStep(*fpTrack, *f << 
845                                                   602 
                                                   >> 603     if(fpTransportation)
                                                   >> 604     {
                                                   >> 605         fpTransportation->SetProcessState(fpTrackingInfo->GetProcessState(fpTransportation->GetProcessID()));
                                                   >> 606         fpTransportation->ComputeStep(*fpTrack, *fpStep, fTimeStep, physicalStep) ;
846 //        fpTransportation->SetProcessState(0)    607 //        fpTransportation->SetProcessState(0);
847     fpTransportation->ResetProcessState();     << 608         fpTransportation->ResetProcessState();
848   }                                            << 609     }
849                                                   610 
850   if(physicalStep >= DBL_MAX)                  << 611     if(physicalStep >= DBL_MAX)
851   {                                            << 612     {
852 //    G4cout << "---- 2) Setting stop and kill << 613       G4cout << "---- 2) Setting stop and kill for " << GetIT(fpTrack)->GetName() << G4endl;
853     fpTrack -> SetTrackStatus(fStopAndKill);   << 614 
854     return;                                    << 615         fpTrack -> SetTrackStatus(fStopAndKill) ;
855   }                                            << 616         return ;
                                                   >> 617     }
856                                                   618 
857   fpState->fPhysicalStep = physicalStep;       << 619     fpState->fPhysicalStep = physicalStep ;
858 }                                                 620 }
859                                                   621 
860 //____________________________________________    622 //______________________________________________________________________________
861                                                   623 
862 void G4ITStepProcessor::InvokeTransportationPr    624 void G4ITStepProcessor::InvokeTransportationProc()
863 {                                                 625 {
864   std::size_t _MAXofPostStepLoops = fpProcessI << 626     size_t _MAXofPostStepLoops = fpProcessInfo->MAXofPostStepLoops;
865   G4SelectedPostStepDoItVector& selectedPostSt << 627     G4SelectedPostStepDoItVector& selectedPostStepDoItVector = fpState->fSelectedPostStepDoItVector;
866       ->fSelectedPostStepDoItVector;           << 628     G4StepStatus& stepStatus = fpState->fStepStatus;
867   G4StepStatus& stepStatus = fpState->fStepSta << 629 
868                                                << 630     // Invoke the specified discrete processes
869   // Invoke the specified discrete processes   << 631     for(size_t np=0; np < _MAXofPostStepLoops; np++)
870   for(std::size_t np = 0; np < _MAXofPostStepL << 632     {
871   {                                            << 633         //
872     //                                         << 634         // Note: DoItVector has inverse order against GetPhysIntVector
873     // Note: DoItVector has inverse order agai << 635         //       and SelectedPostStepDoItVector.
874     //       and SelectedPostStepDoItVector.   << 636         //
875     //                                         << 637         G4int Cond = selectedPostStepDoItVector[_MAXofPostStepLoops-np-1];
876     G4int Cond = selectedPostStepDoItVector[_M << 638         if(Cond != InActivated)
877     if(Cond != InActivated)                    << 
878     {                                          << 
879       if(((Cond == Forced) && (stepStatus != f << 
880       // ((Cond == Conditionally) && (stepStat << 
881       ((Cond == ExclusivelyForced) && (stepSta << 
882          || ((Cond == StronglyForced)))        << 
883       {                                        << 
884                                                << 
885         InvokePSDIP(np);                       << 
886       }                                        << 
887     } //if(Cond != InActivated)                << 
888                                                << 
889     // Exit from PostStepLoop if the track has << 
890     // but extra treatment for processes with  << 
891     if(fpTrack->GetTrackStatus() == fStopAndKi << 
892     {                                          << 
893       for(std::size_t np1 = np + 1; np1 < _MAX << 
894       {                                        << 
895         G4int Cond2 = selectedPostStepDoItVect << 
896         if(Cond2 == StronglyForced)            << 
897         {                                         639         {
898           InvokePSDIP(np1);                    << 640             if(
                                                   >> 641                     ((Cond == Forced) && (stepStatus != fExclusivelyForcedProc)) ||
                                                   >> 642                     //                ((Cond == Conditionally) && (stepStatus == fAlongStepDoItProc)) ||
                                                   >> 643                     ((Cond == ExclusivelyForced) && (stepStatus == fExclusivelyForcedProc)) ||
                                                   >> 644                     ((Cond == StronglyForced) )
                                                   >> 645                     )
                                                   >> 646             {
                                                   >> 647 
                                                   >> 648                 InvokePSDIP(np);
                                                   >> 649             }
                                                   >> 650         } //if(*fSelectedPostStepDoItVector(np)........
                                                   >> 651 
                                                   >> 652         // Exit from PostStepLoop if the track has been killed,
                                                   >> 653         // but extra treatment for processes with Strongly Forced flag
                                                   >> 654         if(fpTrack->GetTrackStatus() == fStopAndKill)
                                                   >> 655         {
                                                   >> 656             for(size_t np1=np+1; np1 < _MAXofPostStepLoops; np1++)
                                                   >> 657             {
                                                   >> 658                 G4int Cond2 = selectedPostStepDoItVector[_MAXofPostStepLoops-np1-1];
                                                   >> 659                 if (Cond2 == StronglyForced)
                                                   >> 660                 {
                                                   >> 661                     InvokePSDIP(np1);
                                                   >> 662                 }
                                                   >> 663             }
                                                   >> 664             break;
899         }                                         665         }
900       }                                        << 
901       break;                                   << 
902     }                                             666     }
903   }                                            << 
904 }                                                 667 }
905                                                   668 
906 //____________________________________________    669 //______________________________________________________________________________
907                                                   670 
908 // *******************************************    671 // ************************************************************************
909 //  Apply cuts                                 << 672 //  Apply cuts
910 // *******************************************    673 // ************************************************************************
911                                                   674 
                                                   >> 675 
912 void G4ITStepProcessor::ApplyProductionCut(G4T    676 void G4ITStepProcessor::ApplyProductionCut(G4Track* aSecondary)
913 {                                                 677 {
914   G4bool tBelowCutEnergyAndSafety = false;     << 678     G4bool tBelowCutEnergyAndSafety = false;
915   G4int tPtclIdx = G4ProductionCuts::GetIndex( << 679     G4int tPtclIdx
916   if(tPtclIdx < 0)                             << 680             = G4ProductionCuts::GetIndex(aSecondary->GetDefinition());
917   {                                            << 681     if (tPtclIdx<0)
918     return;                                    << 682     {
919   }                                            << 683         return;
920   G4ProductionCutsTable* tCutsTbl =            << 684     }
921       G4ProductionCutsTable::GetProductionCuts << 685     G4ProductionCutsTable* tCutsTbl
922   G4int tCoupleIdx = tCutsTbl->GetCoupleIndex( << 686             = G4ProductionCutsTable::GetProductionCutsTable();
923       ->GetMaterialCutsCouple());              << 687     G4int tCoupleIdx
924   G4double tProdThreshold =                    << 688             = tCutsTbl->GetCoupleIndex(fpPreStepPoint->GetMaterialCutsCouple());
925       (*(tCutsTbl->GetEnergyCutsVector(tPtclId << 689     G4double tProdThreshold
926   if(aSecondary->GetKineticEnergy() < tProdThr << 690             = (*(tCutsTbl->GetEnergyCutsVector(tPtclIdx)))[tCoupleIdx];
927   {                                            << 691     if( aSecondary->GetKineticEnergy()<tProdThreshold )
928     tBelowCutEnergyAndSafety = true;           << 692     {
929     if(std::abs(aSecondary->GetDynamicParticle << 693         tBelowCutEnergyAndSafety = true;
930     {                                          << 694         if(std::abs(aSecondary->GetDynamicParticle()->GetCharge()) > DBL_MIN)
931       G4double currentRange                    << 695         {
932       = G4LossTableManager::Instance()->GetRan << 696             G4double currentRange
933           aSecondary->GetKineticEnergy(),      << 697                     = G4LossTableManager::Instance()->GetRange(aSecondary->GetDefinition(),
934           fpPreStepPoint->GetMaterialCutsCoupl << 698                                                                aSecondary->GetKineticEnergy(),
935       tBelowCutEnergyAndSafety = (currentRange << 699                                                                fpPreStepPoint->GetMaterialCutsCouple());
936     }                                          << 700             tBelowCutEnergyAndSafety = (currentRange < CalculateSafety() );
937   }                                            << 701         }
938                                                << 702     }
939   if(tBelowCutEnergyAndSafety)                 << 703 
940   {                                            << 704     if( tBelowCutEnergyAndSafety )
941     if(!(aSecondary->IsGoodForTracking()))     << 705     {
942     {                                          << 706         if( !(aSecondary->IsGoodForTracking()) )
943       // Add kinetic energy to the total energ << 707         {
944       fpStep->AddTotalEnergyDeposit(aSecondary << 708             // Add kinetic energy to the total energy deposit
945       aSecondary->SetKineticEnergy(0.0);       << 709             fpStep->AddTotalEnergyDeposit(
                                                   >> 710                         aSecondary->GetKineticEnergy() );
                                                   >> 711             aSecondary->SetKineticEnergy(0.0);
                                                   >> 712         }
946     }                                             713     }
947   }                                            << 
948 }                                                 714 }
949                                                   715