Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/parameterisation/src/G4FastSimulationManagerProcess.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/parameterisation/src/G4FastSimulationManagerProcess.cc (Version 11.3.0) and /processes/parameterisation/src/G4FastSimulationManagerProcess.cc (Version 11.0.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 //                                                 26 //
 27 //                                                 27 //
 28 //                                                 28 //
 29 //--------------------------------------------     29 //---------------------------------------------------------------
 30 //                                                 30 //
 31 //  G4FastSimulationProcess.cc                     31 //  G4FastSimulationProcess.cc
 32 //                                                 32 //
 33 //  Description:                                   33 //  Description:
 34 //    The process that triggers the parameteri     34 //    The process that triggers the parameterised simulations,
 35 //    if any.                                      35 //    if any.
 36 //                                                 36 //
 37 //  History:                                       37 //  History:
 38 //    August 97: First implementation. Verderi     38 //    August 97: First implementation. Verderi && MoraDeFreitas.
 39 //    October 06: move to parallel geometry sc     39 //    October 06: move to parallel geometry scheme, M. Verderi
 40 //--------------------------------------------     40 //---------------------------------------------------------------
 41                                                    41 
                                                   >>  42 #include "G4ios.hh"
 42 #include "G4FastSimulationManagerProcess.hh"       43 #include "G4FastSimulationManagerProcess.hh"
 43                                                << 
 44 #include "G4FieldTrackUpdator.hh"              << 
 45 #include "G4GlobalFastSimulationManager.hh"        44 #include "G4GlobalFastSimulationManager.hh"
 46 #include "G4ParticleChange.hh"                 << 
 47 #include "G4PathFinder.hh"                     << 
 48 #include "G4TransportationManager.hh"              45 #include "G4TransportationManager.hh"
 49 #include "G4ios.hh"                            <<  46 #include "G4PathFinder.hh"
                                                   >>  47 #include "G4ParticleChange.hh"
                                                   >>  48 #include "G4FieldTrackUpdator.hh"
 50                                                    49 
 51 G4FastSimulationManagerProcess::G4FastSimulati <<  50 #define  PARANOIA
 52                                                <<  51 
 53   : G4VProcess(processName, theType),          <<  52 G4FastSimulationManagerProcess::
 54     fWorldVolume(nullptr),                     <<  53 G4FastSimulationManagerProcess(const G4String& processName,
 55     fIsTrackingTime(false),                    <<  54              G4ProcessType       theType) : 
 56     fIsFirstStep(false),                       <<  55   G4VProcess(processName,theType),
 57     fGhostNavigator(nullptr),                  <<  56   fWorldVolume          ( nullptr ),
 58     fGhostNavigatorIndex(-1),                  <<  57   fIsTrackingTime       ( false   ),
 59     fIsGhostGeometry(false),                   <<  58   fIsFirstStep          ( false   ),
 60     fGhostSafety(-1.0),                        <<  59   fGhostNavigator       ( nullptr ),
 61     fFieldTrack('0'),                          <<  60   fGhostNavigatorIndex  ( -1      ),
 62     fFastSimulationManager(nullptr),           <<  61   fIsGhostGeometry      ( false   ),
 63     fFastSimulationTrigger(false)              <<  62   fGhostSafety          ( -1.0    ),
                                                   >>  63   fFieldTrack           ( '0'     ),
                                                   >>  64   fFastSimulationManager( nullptr ),
                                                   >>  65   fFastSimulationTrigger( false   )
 64 {                                                  66 {
 65   // -- set Process Sub Type                       67   // -- set Process Sub Type
 66   SetProcessSubType(static_cast<int>(FASTSIM_M     68   SetProcessSubType(static_cast<int>(FASTSIM_ManagerProcess));
 67                                                    69 
 68   fPathFinder = G4PathFinder::GetInstance();   << 
 69   fTransportationManager = G4TransportationMan << 
 70                                                    70 
                                                   >>  71   fPathFinder            = G4PathFinder::GetInstance();
                                                   >>  72   fTransportationManager = G4TransportationManager::GetTransportationManager();
                                                   >>  73   
 71   SetWorldVolume(fTransportationManager->GetNa     74   SetWorldVolume(fTransportationManager->GetNavigatorForTracking()->GetWorldVolume()->GetName());
 72   if (verboseLevel > 0)                        <<  75   if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName() 
 73     G4cout << "G4FastSimulationManagerProcess  <<  76            << "' is created, and will message geometry with world volume `" 
 74            << "' is created, and will message  <<  77            << fWorldVolume->GetName() << "'." << G4endl;
 75            << fWorldVolume->GetName() << "'."  << 
 76   G4GlobalFastSimulationManager::GetGlobalFast     78   G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
 77 }                                                  79 }
 78                                                    80 
 79 G4FastSimulationManagerProcess::G4FastSimulati <<  81 
 80                                                <<  82 G4FastSimulationManagerProcess::
 81                                                <<  83 G4FastSimulationManagerProcess(const G4String&     processName,
 82   : G4VProcess(processName, theType),          <<  84              const G4String& worldVolumeName,
 83     fWorldVolume(nullptr),                     <<  85              G4ProcessType           theType) :
 84     fIsTrackingTime(false),                    <<  86   G4VProcess(processName,theType),
 85     fIsFirstStep(false),                       <<  87   fWorldVolume          ( nullptr ),
 86     fGhostNavigator(nullptr),                  <<  88   fIsTrackingTime       ( false   ),
 87     fGhostNavigatorIndex(-1),                  <<  89   fIsFirstStep          ( false   ),
 88     fIsGhostGeometry(false),                   <<  90   fGhostNavigator       ( nullptr ),
 89     fGhostSafety(-1.0),                        <<  91   fGhostNavigatorIndex  ( -1      ),
 90     fFieldTrack('0'),                          <<  92   fIsGhostGeometry      ( false   ),
 91     fFastSimulationManager(nullptr),           <<  93   fGhostSafety          ( -1.0    ),
 92     fFastSimulationTrigger(false)              <<  94   fFieldTrack           ( '0'     ),
                                                   >>  95   fFastSimulationManager( nullptr ),
                                                   >>  96   fFastSimulationTrigger( false   )
 93 {                                                  97 {
 94   // -- set Process Sub Type                       98   // -- set Process Sub Type
 95   SetProcessSubType(static_cast<int>(FASTSIM_M     99   SetProcessSubType(static_cast<int>(FASTSIM_ManagerProcess));
 96                                                   100 
 97   fPathFinder = G4PathFinder::GetInstance();   << 101 
                                                   >> 102   fPathFinder            = G4PathFinder::GetInstance();
 98   fTransportationManager = G4TransportationMan    103   fTransportationManager = G4TransportationManager::GetTransportationManager();
 99                                                   104 
100   SetWorldVolume(worldVolumeName);                105   SetWorldVolume(worldVolumeName);
101   if (verboseLevel > 0)                        << 106   if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName() 
102     G4cout << "G4FastSimulationManagerProcess  << 107            << "' is created, and will message geometry with world volume `" 
103            << "' is created, and will message  << 108            << fWorldVolume->GetName() << "'." << G4endl;
104            << fWorldVolume->GetName() << "'."  << 
105   G4GlobalFastSimulationManager::GetGlobalFast    109   G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
106 }                                                 110 }
107                                                   111 
108 G4FastSimulationManagerProcess::G4FastSimulati << 112 
109                                                << 113 G4FastSimulationManagerProcess::
110                                                << 114 G4FastSimulationManagerProcess(const G4String&    processName,
111   : G4VProcess(processName, theType),          << 115              G4VPhysicalVolume* worldVolume,
112     fWorldVolume(nullptr),                     << 116              G4ProcessType      theType) :
113     fIsTrackingTime(false),                    << 117   G4VProcess(processName,theType),
114     fIsFirstStep(false),                       << 118   fWorldVolume          ( nullptr ),
115     fGhostNavigator(nullptr),                  << 119   fIsTrackingTime       ( false   ),
116     fGhostNavigatorIndex(-1),                  << 120   fIsFirstStep          ( false   ),
117     fIsGhostGeometry(false),                   << 121   fGhostNavigator       ( nullptr ),
118     fGhostSafety(-1.0),                        << 122   fGhostNavigatorIndex  ( -1      ),
119     fFieldTrack('0'),                          << 123   fIsGhostGeometry      ( false   ),
120     fFastSimulationManager(nullptr),           << 124   fGhostSafety          ( -1.0    ),
121     fFastSimulationTrigger(false)              << 125   fFieldTrack           ( '0'     ),
                                                   >> 126   fFastSimulationManager( nullptr ),
                                                   >> 127   fFastSimulationTrigger( false   )
122 {                                                 128 {
123   // -- set Process Sub Type                      129   // -- set Process Sub Type
124   SetProcessSubType(static_cast<int>(FASTSIM_M    130   SetProcessSubType(static_cast<int>(FASTSIM_ManagerProcess));
                                                   >> 131   
125                                                   132 
126   fPathFinder = G4PathFinder::GetInstance();   << 133   fPathFinder            = G4PathFinder::GetInstance();
127   fTransportationManager = G4TransportationMan    134   fTransportationManager = G4TransportationManager::GetTransportationManager();
128                                                   135 
129   SetWorldVolume(worldVolume);                    136   SetWorldVolume(worldVolume);
130   if (verboseLevel > 0)                        << 137   if (verboseLevel>0) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName() 
131     G4cout << "G4FastSimulationManagerProcess  << 138            << "' is created, and will message geometry with world volume `" 
132            << "' is created, and will message  << 139            << fWorldVolume->GetName() << "'." << G4endl;
133            << fWorldVolume->GetName() << "'."  << 
134   G4GlobalFastSimulationManager::GetGlobalFast    140   G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->AddFSMP(this);
135 }                                                 141 }
136                                                   142 
                                                   >> 143 
137 G4FastSimulationManagerProcess::~G4FastSimulat    144 G4FastSimulationManagerProcess::~G4FastSimulationManagerProcess()
138 {                                                 145 {
139   G4GlobalFastSimulationManager::GetGlobalFast    146   G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->RemoveFSMP(this);
140 }                                                 147 }
141                                                   148 
                                                   >> 149 
142 // -----------------------                        150 // -----------------------
143 //   User access methods:                         151 //   User access methods:
144 // -----------------------                        152 // -----------------------
145 void G4FastSimulationManagerProcess::SetWorldV    153 void G4FastSimulationManagerProcess::SetWorldVolume(G4String newWorldName)
146 {                                                 154 {
147   if (fIsTrackingTime) {                       << 155   if (fIsTrackingTime)
148     G4ExceptionDescription ed;                 << 156     {
149     ed << "G4FastSimulationManagerProcess `" < << 157       G4ExceptionDescription ed;
150        << "': changing of world volume at trac << 158       ed << "G4FastSimulationManagerProcess `" << GetProcessName()
151     G4Exception("G4FastSimulationManagerProces << 159    << "': changing of world volume at tracking time is not allowed." << G4endl;
152                 JustWarning, ed, "Call ignored << 160       G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4String)",
153   }                                            << 161       "FastSim002",
154   else {                                       << 162       JustWarning, ed,
155     G4VPhysicalVolume* newWorld = fTransportat << 163       "Call ignored.");
156     if (newWorld == nullptr) {                 << 
157       G4ExceptionDescription tellWhatIsWrong;  << 
158       tellWhatIsWrong << "Volume newWorldName  << 
159                       << "' is not a parallel  << 
160       G4Exception("G4FastSimulationManagerProc << 
161                   FatalException, tellWhatIsWr << 
162     }                                             164     }
163     if (verboseLevel > 0) {                    << 165   else
164       if (fWorldVolume != nullptr)             << 166     {
165         G4cout << "G4FastSimulationManagerProc << 167       G4VPhysicalVolume* newWorld = fTransportationManager->IsWorldExisting(newWorldName);
166                << "': changing world volume fr << 168       if (newWorld == 0)
167                << newWorld << "'." << G4endl;  << 169   {
168       else                                     << 170     G4ExceptionDescription  tellWhatIsWrong;
169         G4cout << "G4FastSimulationManagerProc << 171     tellWhatIsWrong << "Volume newWorldName = `" <<  newWorldName
170                << "': setting world volume fro << 172         << "' is not a parallel world nor the mass world volume."
                                                   >> 173         << G4endl;
                                                   >> 174     G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4String)",
                                                   >> 175           "FastSim003",
                                                   >> 176           FatalException,
                                                   >> 177           tellWhatIsWrong);
                                                   >> 178   }
                                                   >> 179       if (verboseLevel>0)
                                                   >> 180       {
                                                   >> 181   if (fWorldVolume) G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
                                                   >> 182          << "': changing world volume from '"  << fWorldVolume->GetName() 
                                                   >> 183          << "' to `" << newWorld << "'." << G4endl;
                                                   >> 184   else              G4cout << "G4FastSimulationManagerProcess `" << GetProcessName()
                                                   >> 185          << "': setting world volume from to `"<< newWorld->GetName() << "'." << G4endl;
                                                   >> 186       }
                                                   >> 187       fWorldVolume = newWorld;
171     }                                             188     }
172     fWorldVolume = newWorld;                   << 
173   }                                            << 
174 }                                                 189 }
175                                                   190 
                                                   >> 191 
176 void G4FastSimulationManagerProcess::SetWorldV    192 void G4FastSimulationManagerProcess::SetWorldVolume(G4VPhysicalVolume* newWorld)
177 {                                                 193 {
178   if (newWorld != nullptr)                     << 194   if (newWorld) SetWorldVolume(newWorld->GetName());
179     SetWorldVolume(newWorld->GetName());       << 195   else
180   else {                                       << 196     {
181     G4ExceptionDescription tellWhatIsWrong;    << 197       G4ExceptionDescription  tellWhatIsWrong;
182     tellWhatIsWrong << "Null pointer passed fo << 198       tellWhatIsWrong << "Null pointer passed for world volume." << G4endl;
183     G4Exception("G4FastSimulationManagerProces << 199       G4Exception("G4FastSimulationManagerProcess::SetWorldVolume(const G4VPhysicalVolume* newWorld)",
184                 "FastSim004", FatalException,  << 200       "FastSim004",
185   }                                            << 201       FatalException,
                                                   >> 202       tellWhatIsWrong); 
                                                   >> 203     }
186 }                                                 204 }
187                                                   205 
                                                   >> 206 
188 // --------------------                           207 // --------------------
189 //  Start/End tracking:                           208 //  Start/End tracking:
190 // --------------------                           209 // --------------------
191 void G4FastSimulationManagerProcess::StartTrac    210 void G4FastSimulationManagerProcess::StartTracking(G4Track* track)
192 {                                                 211 {
193   fIsTrackingTime = true;                         212   fIsTrackingTime = true;
194   fIsFirstStep = true;                         << 213   fIsFirstStep    = true;
195                                                << 214   
196   // -- fetch the navigator (and its index) an    215   // -- fetch the navigator (and its index) and activate it:
197   G4TransportationManager* transportationManag << 216   G4TransportationManager* transportationManager = G4TransportationManager::GetTransportationManager();
198     G4TransportationManager::GetTransportation << 217   fGhostNavigator                            = transportationManager->GetNavigator(fWorldVolume);
199   fGhostNavigator = transportationManager->Get << 218   fIsGhostGeometry                           = (fGhostNavigator != transportationManager->GetNavigatorForTracking());
200   fIsGhostGeometry = (fGhostNavigator != trans << 219   if (fIsGhostGeometry) fGhostNavigatorIndex = transportationManager->ActivateNavigator(fGhostNavigator);
201   if (fIsGhostGeometry)                        << 220   else                  fGhostNavigatorIndex = -1;
202     fGhostNavigatorIndex = transportationManag << 
203   else                                         << 
204     fGhostNavigatorIndex = -1;                 << 
205                                                   221 
206   fPathFinder->PrepareNewTrack(track->GetPosit    222   fPathFinder->PrepareNewTrack(track->GetPosition(), track->GetMomentumDirection());
207 }                                                 223 }
208                                                   224 
209 void G4FastSimulationManagerProcess::EndTracki << 225 
                                                   >> 226 void
                                                   >> 227 G4FastSimulationManagerProcess::
                                                   >> 228 EndTracking()
210 {                                                 229 {
211   fIsTrackingTime = false;                        230   fIsTrackingTime = false;
212   if (fIsGhostGeometry) fTransportationManager << 231   if ( fIsGhostGeometry ) fTransportationManager->DeActivateNavigator(fGhostNavigator); 
213 }                                                 232 }
214                                                   233 
                                                   >> 234 
215 // ------------------------------------------     235 // ------------------------------------------
216 //   PostStepGetPhysicalInteractionLength():      236 //   PostStepGetPhysicalInteractionLength():
217 // ------------------------------------------     237 // ------------------------------------------
218 G4double                                       << 238 G4double 
219 G4FastSimulationManagerProcess::PostStepGetPhy << 239 G4FastSimulationManagerProcess::
220                                                << 240 PostStepGetPhysicalInteractionLength(const G4Track&               track, 
                                                   >> 241              G4double,
                                                   >> 242              G4ForceCondition*        condition)
221 {                                                 243 {
222   // -- Get current volume, and check for pres    244   // -- Get current volume, and check for presence of fast simulation manager.
223   // -- For the case of the navigator for trac    245   // -- For the case of the navigator for tracking (fGhostNavigatorIndex == 0)
224   // -- we use the track volume. This allows t    246   // -- we use the track volume. This allows the code to be valid for both
225   // -- cases where the PathFinder is used (G4    247   // -- cases where the PathFinder is used (G4CoupledTranportation) or not
226   // -- (G4Transportation).                       248   // -- (G4Transportation).
227   const G4VPhysicalVolume* currentVolume(nullp << 249   const G4VPhysicalVolume* currentVolume(0);
228   if (fIsGhostGeometry)                        << 250   if ( fIsGhostGeometry )  currentVolume = fPathFinder->GetLocatedVolume(fGhostNavigatorIndex);
229     currentVolume = fPathFinder->GetLocatedVol << 251   else                     currentVolume = track.GetVolume();
230   else                                         << 252 
231     currentVolume = track.GetVolume();         << 253   if ( currentVolume )
232                                                << 254     {
233   if (currentVolume != nullptr) {              << 255       fFastSimulationManager = currentVolume->GetLogicalVolume()->GetFastSimulationManager();
234     fFastSimulationManager = currentVolume->Ge << 256       if( fFastSimulationManager )
235     if (fFastSimulationManager != nullptr) {   << 257   {
236       // Ask for trigger:                      << 258     // Ask for trigger:
237       fFastSimulationTrigger =                 << 259     fFastSimulationTrigger = fFastSimulationManager->PostStepGetFastSimulationManagerTrigger(track, fGhostNavigator);
238         fFastSimulationManager->PostStepGetFas << 260     if( fFastSimulationTrigger )
239       if (fFastSimulationTrigger) {            << 261       {
240         // Take control over stepping:         << 262         // Take control over stepping:
241         *condition = ExclusivelyForced;        << 263         *condition = ExclusivelyForced;
242         return 0.0;                            << 264         return 0.0;
243       }                                        << 265       }
                                                   >> 266   }     
244     }                                             267     }
245   }                                            << 268   
246                                                << 
247   // -- no fast simulation occuring there:        269   // -- no fast simulation occuring there:
248   *condition = NotForced;                         270   *condition = NotForced;
249   return DBL_MAX;                                 271   return DBL_MAX;
250 }                                                 272 }
251                                                   273 
252 //------------------------------------            274 //------------------------------------
253 //             PostStepDoIt()                     275 //             PostStepDoIt()
254 //------------------------------------            276 //------------------------------------
255 G4VParticleChange* G4FastSimulationManagerProc << 277 G4VParticleChange*
                                                   >> 278 G4FastSimulationManagerProcess::
                                                   >> 279 PostStepDoIt(const G4Track&,
                                                   >> 280        const G4Step&)
256 {                                                 281 {
257   G4VParticleChange* finalState = fFastSimulat    282   G4VParticleChange* finalState = fFastSimulationManager->InvokePostStepDoIt();
258                                                << 283   
259   // If the particle is still alive, suspend i    284   // If the particle is still alive, suspend it to force physics re-initialisation:
260   if (finalState->GetTrackStatus() != fStopAnd    285   if (finalState->GetTrackStatus() != fStopAndKill) finalState->ProposeTrackStatus(fSuspend);
261                                                << 286   
262   return finalState;                              287   return finalState;
263 }                                                 288 }
264                                                   289 
265 G4double G4FastSimulationManagerProcess::Along << 290 
266   const G4Track& track, G4double previousStepS << 291 G4double 
267   G4double& proposedSafety, G4GPILSelection* s << 292 G4FastSimulationManagerProcess::
                                                   >> 293 AlongStepGetPhysicalInteractionLength(const G4Track&                track,
                                                   >> 294               G4double           previousStepSize,
                                                   >> 295               G4double         currentMinimumStep, 
                                                   >> 296               G4double&            proposedSafety, 
                                                   >> 297               G4GPILSelection*          selection)
268 {                                                 298 {
269   *selection = NotCandidateForSelection;       << 299   
                                                   >> 300   *selection            = NotCandidateForSelection;
270   G4double returnedStep = DBL_MAX;                301   G4double returnedStep = DBL_MAX;
271                                                   302 
272   // -----------------------------------------    303   // ---------------------------------------------------
273   // -- Below code valid for ghost geometry, o    304   // -- Below code valid for ghost geometry, otherwise
274   // -- useless for fast simulation attached t    305   // -- useless for fast simulation attached to mass
275   // -- geometry. Warn user in case along used << 306   // -- geometry. Warn user in case along used for 
276   // -- mass geometry ?                           307   // -- mass geometry ?
277   // -----------------------------------------    308   // --------------------------------------------------
278   if (fIsGhostGeometry) {                      << 309   if ( fIsGhostGeometry )
279     static G4ThreadLocal G4FieldTrack* endTrac << 310     {
280     if (endTrack_G4MT_TLS_ == nullptr) endTrac << 311       static G4ThreadLocal G4FieldTrack *endTrack_G4MT_TLS_ = 0 ;
281     G4FieldTrack& endTrack = *endTrack_G4MT_TL << 312       if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ = new  G4FieldTrack ('0') ;
282                                                << 313       G4FieldTrack &endTrack = *endTrack_G4MT_TLS_;
283     static G4ThreadLocal ELimited* eLimited_G4 << 314       
284     if (eLimited_G4MT_TLS_ == nullptr) eLimite << 315       static G4ThreadLocal ELimited *eLimited_G4MT_TLS_ = 0 ;
285     ELimited& eLimited = *eLimited_G4MT_TLS_;  << 316       if (!eLimited_G4MT_TLS_) eLimited_G4MT_TLS_ = new  ELimited  ;
286                                                << 317       ELimited &eLimited = *eLimited_G4MT_TLS_;
287     if (previousStepSize > 0.) fGhostSafety -= << 318       
288     if (fGhostSafety < 0.) fGhostSafety = 0.0; << 319       if (previousStepSize > 0.) fGhostSafety -= previousStepSize;
289                                                << 320       if (fGhostSafety < 0.)     fGhostSafety = 0.0;
290     // --------------------------------------- << 321       
291     // Determination of the proposed step leng << 322       // ------------------------------------------
292     // --------------------------------------- << 323       // Determination of the proposed step length:
293     if (currentMinimumStep <= fGhostSafety &&  << 324       // ------------------------------------------
294       // -- No chance to limit the step, as pr << 325       if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
295       returnedStep = currentMinimumStep;       << 326   {
296       proposedSafety = fGhostSafety - currentM << 327     // -- No chance to limit the step, as proposed move inside safety
297     }                                          << 328     returnedStep   = currentMinimumStep;
298     else {                                     << 329     proposedSafety = fGhostSafety - currentMinimumStep;
299       // -- Proposed move exceeds safety, need << 330   }
300       G4FieldTrackUpdator::Update(&fFieldTrack << 331       else
301       returnedStep = fPathFinder->ComputeStep( << 332   {
302                                                << 333     // -- Proposed move exceeds safety, need to state
303                                                << 334     G4FieldTrackUpdator::Update(&fFieldTrack, &track);
304                                                << 335     returnedStep = fPathFinder->ComputeStep(fFieldTrack,
305       if (eLimited == kDoNot)                  << 336               currentMinimumStep,
306         fGhostSafety =                         << 337               fGhostNavigatorIndex,
307           fGhostNavigator->ComputeSafety(endTr << 338               track.GetCurrentStepNumber(),
308       proposedSafety = fGhostSafety;           << 339               fGhostSafety,
309       if (eLimited == kUnique || eLimited == k << 340               eLimited,
310         *selection = CandidateForSelection;    << 341               endTrack,
311       else if (eLimited == kSharedTransport)   << 342               track.GetVolume());
312         returnedStep *=                        << 343     
313           (1.0 + 1.0e-9);  // -- Expand to dis << 344     if(eLimited == kDoNot) fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition()); // -- step no limited by ghost
                                                   >> 345     proposedSafety = fGhostSafety;
                                                   >> 346     if      (eLimited == kUnique || eLimited == kSharedOther) *selection     = CandidateForSelection;
                                                   >> 347     else if (eLimited == kSharedTransport)                     returnedStep *= (1.0 + 1.0e-9);   // -- Expand to disable its selection in Step Manager comparison
                                                   >> 348   }
314     }                                             349     }
315   }                                            << 350   
316                                                   351 
317   // -----------------------------------------    352   // ----------------------------------------------
318   // Returns the fGhostSafety as the proposedS    353   // Returns the fGhostSafety as the proposedSafety
319   // The SteppingManager will take care of kee    354   // The SteppingManager will take care of keeping
320   // the smallest one.                            355   // the smallest one.
321   // -----------------------------------------    356   // ----------------------------------------------
322   return returnedStep;                            357   return returnedStep;
323 }                                                 358 }
324                                                   359 
325 G4VParticleChange* G4FastSimulationManagerProc << 360 G4VParticleChange*
326                                                << 361 G4FastSimulationManagerProcess::
                                                   >> 362 AlongStepDoIt(const G4Track& track,
                                                   >> 363         const G4Step&)
327 {                                                 364 {
328   fDummyParticleChange.Initialize(track);         365   fDummyParticleChange.Initialize(track);
329   return &fDummyParticleChange;                   366   return &fDummyParticleChange;
330 }                                                 367 }
331                                                   368 
                                                   >> 369 
332 //--------------------------------------------    370 //--------------------------------------------
333 //         At Rest parameterisation:              371 //         At Rest parameterisation:
334 //--------------------------------------------    372 //--------------------------------------------
335 //   AtRestGetPhysiscalInteractionLength:         373 //   AtRestGetPhysiscalInteractionLength:
336 //--------------------------------------------    374 //--------------------------------------------
337 G4double                                       << 375 G4double 
338 G4FastSimulationManagerProcess::AtRestGetPhysi << 376 G4FastSimulationManagerProcess::
339                                                << 377 AtRestGetPhysicalInteractionLength(const G4Track&        track, 
340 {                                              << 378            G4ForceCondition* condition)
341   const G4VPhysicalVolume* currentVolume(nullp << 379 {
342   if (fIsGhostGeometry)                        << 380   const G4VPhysicalVolume* currentVolume(0);
343     currentVolume = fPathFinder->GetLocatedVol << 381   if ( fIsGhostGeometry )  currentVolume = fPathFinder->GetLocatedVolume(fGhostNavigatorIndex);
344   else                                         << 382   else                     currentVolume = track.GetVolume();
345     currentVolume = track.GetVolume();         << 
346   fFastSimulationManager = currentVolume->GetL    383   fFastSimulationManager = currentVolume->GetLogicalVolume()->GetFastSimulationManager();
347   if (fFastSimulationManager != nullptr) {     << 384   if( fFastSimulationManager )
348     // Ask for trigger:                        << 385     {
349     fFastSimulationTrigger =                   << 386       // Ask for trigger:
350       fFastSimulationManager->AtRestGetFastSim << 387       fFastSimulationTrigger = fFastSimulationManager->AtRestGetFastSimulationManagerTrigger(track, fGhostNavigator);
351     if (fFastSimulationTrigger) {              << 388       if( fFastSimulationTrigger )
352       // Dirty trick to take control over step << 389   {
353       *condition = NotForced;                  << 390     // Dirty trick to take control over stepping. Does anyone will ever use that ?
354       return -1.0;                             << 391     *condition = NotForced;
                                                   >> 392     return -1.0;
                                                   >> 393   }
355     }                                             394     }
356   }                                            << 395   
357                                                << 
358   // -- no fast simulation occuring there:        396   // -- no fast simulation occuring there:
359   *condition = NotForced;                         397   *condition = NotForced;
360   return DBL_MAX;                                 398   return DBL_MAX;
361 }                                                 399 }
362                                                   400 
363 //--------------------------------------------    401 //-----------------------------------------------
364 //                  AtRestDoIt:                   402 //                  AtRestDoIt:
365 //--------------------------------------------    403 //-----------------------------------------------
366 G4VParticleChange* G4FastSimulationManagerProc    404 G4VParticleChange* G4FastSimulationManagerProcess::AtRestDoIt(const G4Track&, const G4Step&)
367 {                                                 405 {
368   return fFastSimulationManager->InvokeAtRestD    406   return fFastSimulationManager->InvokeAtRestDoIt();
369 }                                                 407 }
                                                   >> 408 
                                                   >> 409 
                                                   >> 410 void G4FastSimulationManagerProcess::Verbose() const
                                                   >> 411 {
                                                   >> 412   /*  G4cout << "     >>>>> Trigger Status : ";
                                                   >> 413   switch(fFastSimulationManager->GetTriggerStatus())
                                                   >> 414     {
                                                   >> 415     case NoModel:
                                                   >> 416       G4cout << "NoModel" << G4endl;
                                                   >> 417       break;
                                                   >> 418     case OnBoundaryButLeaving:
                                                   >> 419       G4cout << "OnBoundaryButLeaving" << G4endl;
                                                   >> 420       break;
                                                   >> 421     case OneModelTrigger:
                                                   >> 422       G4cout << "OneModelTrigger" << G4endl;
                                                   >> 423       break;
                                                   >> 424     case NoModelTrigger:
                                                   >> 425       G4cout << "NoModelTrigger" << G4endl;
                                                   >> 426       break;
                                                   >> 427     case Undefined:
                                                   >> 428       G4cout << "Undefined" << G4endl;
                                                   >> 429       break;
                                                   >> 430     default:
                                                   >> 431       G4cout << " Bizarre..." << G4endl;
                                                   >> 432       break;
                                                   >> 433     }*/
                                                   >> 434 }
                                                   >> 435 
                                                   >> 436 
370                                                   437