Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/navigation/src/G4TransportationManager.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 /geometry/navigation/src/G4TransportationManager.cc (Version 11.3.0) and /geometry/navigation/src/G4TransportationManager.cc (Version 10.5)


  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 // Class G4TransportationManager implementatio <<  26 //
                                                   >>  27 //
                                                   >>  28 //
                                                   >>  29 // G4TransportationManager 
 27 //                                                 30 //
 28 // Created : J.Apostolakis, 1997                   31 // Created : J.Apostolakis, 1997
 29 // Reviewed: G.Cosmo, 2006                         32 // Reviewed: G.Cosmo, 2006
                                                   >>  33 //  10.04.07 V.Ivanchenko  Use unique G4SafetyHelper
                                                   >>  34 //
 30 // -------------------------------------------     35 // --------------------------------------------------------------------
 31                                                    36 
 32 #include "G4TransportationManager.hh"              37 #include "G4TransportationManager.hh"
 33                                                    38 
 34 #include <algorithm>                               39 #include <algorithm>
 35                                                    40 
 36 #include "G4GeometryMessenger.hh"                  41 #include "G4GeometryMessenger.hh"
 37 #include "G4PropagatorInField.hh"                  42 #include "G4PropagatorInField.hh"
 38 #include "G4FieldManager.hh"                       43 #include "G4FieldManager.hh"
 39 #include "G4LogicalVolume.hh"                      44 #include "G4LogicalVolume.hh"
 40 #include "G4PVPlacement.hh"                        45 #include "G4PVPlacement.hh"
 41                                                    46 
 42 // Initialise the static instance of the singl     47 // Initialise the static instance of the singleton
 43 //                                                 48 //
 44 G4ThreadLocal G4TransportationManager*             49 G4ThreadLocal G4TransportationManager*
 45 G4TransportationManager::fTransportationManage <<  50 G4TransportationManager::fTransportationManager=0;
 46                                                << 
 47 // The first registered navigator -- expect th << 
 48 //  If it has an external sub-navigator, it wi << 
 49 G4Navigator* G4TransportationManager::fFirstTr << 
 50                                                    51 
 51 // -------------------------------------------     52 // ----------------------------------------------------------------------------
 52 // Constructor                                     53 // Constructor
 53 //                                                 54 //
 54 G4TransportationManager::G4TransportationManag     55 G4TransportationManager::G4TransportationManager() 
 55 {                                                  56 { 
 56   if (fTransportationManager != nullptr)       <<  57   if (fTransportationManager)
 57   {                                                58   {
 58     G4Exception("G4TransportationManager::G4Tr     59     G4Exception("G4TransportationManager::G4TransportationManager()",
 59                 "GeomNav0002", FatalException,     60                 "GeomNav0002", FatalException,
 60                 "Only ONE instance of G4Transp     61                 "Only ONE instance of G4TransportationManager is allowed!");
 61   }                                                62   }
 62                                                    63 
 63   // Create the navigator for tracking and act     64   // Create the navigator for tracking and activate it; add to collections
 64   //                                               65   //
 65   G4Navigator* trackingNavigator= nullptr;     <<  66   G4Navigator* trackingNavigator = new G4Navigator();
 66   if( (fFirstTrackingNavigator != nullptr) &&  << 
 67   {                                            << 
 68      trackingNavigator = fFirstTrackingNavigat << 
 69   }                                            << 
 70   else                                         << 
 71   {                                            << 
 72      trackingNavigator = new G4Navigator();    << 
 73      if( fFirstTrackingNavigator == nullptr )  << 
 74      {                                         << 
 75         fFirstTrackingNavigator = trackingNavi << 
 76      }                                         << 
 77   }                                            << 
 78   trackingNavigator->Activate(true);               67   trackingNavigator->Activate(true);
 79   fNavigators.push_back(trackingNavigator);        68   fNavigators.push_back(trackingNavigator);
 80   fActiveNavigators.push_back(trackingNavigato     69   fActiveNavigators.push_back(trackingNavigator);
 81   fWorlds.push_back(trackingNavigator->GetWorl     70   fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
 82                                                    71 
 83   fGeomMessenger    = new G4GeometryMessenger(     72   fGeomMessenger    = new G4GeometryMessenger(this);
 84   fFieldManager     = new G4FieldManager(); //     73   fFieldManager     = new G4FieldManager(); // deleted by G4FieldManagerStore
 85   fPropagatorInField= new G4PropagatorInField(     74   fPropagatorInField= new G4PropagatorInField(trackingNavigator,fFieldManager);
 86   fSafetyHelper     = new G4SafetyHelper();        75   fSafetyHelper     = new G4SafetyHelper();
 87                                                << 
 88   G4FieldManager::SetGlobalFieldManager(fField << 
 89 }                                                  76 } 
 90                                                    77 
 91 // -------------------------------------------     78 // ----------------------------------------------------------------------------
 92 // Destructor                                      79 // Destructor
 93 //                                                 80 //
 94 G4TransportationManager::~G4TransportationMana     81 G4TransportationManager::~G4TransportationManager()
 95 {                                                  82 {
 96   delete fSafetyHelper;                            83   delete fSafetyHelper;
 97   delete fPropagatorInField;                       84   delete fPropagatorInField;
 98   delete fGeomMessenger;                           85   delete fGeomMessenger;
 99   ClearNavigators();                               86   ClearNavigators();
100   fTransportationManager = nullptr;            <<  87   fTransportationManager = 0; 
101 }                                                  88 }
102                                                    89 
103 // -------------------------------------------     90 // ----------------------------------------------------------------------------
104 // GetTransportationManager()                      91 // GetTransportationManager()
105 //                                                 92 //
106 // Retrieve the static instance of the singlet     93 // Retrieve the static instance of the singleton and create it if not existing
107 //                                                 94 //
108 G4TransportationManager* G4TransportationManag <<  95 G4TransportationManager* G4TransportationManager::GetTransportationManager()
109 {                                                  96 {
110    if (fTransportationManager == nullptr)      <<  97    if (!fTransportationManager)
111    {                                               98    {
112      fTransportationManager = new G4Transporta     99      fTransportationManager = new G4TransportationManager;
113    }                                              100    }   
114    return fTransportationManager;                 101    return fTransportationManager;
115 }                                                 102 }
116                                                   103 
117 // -------------------------------------------    104 // ----------------------------------------------------------------------------
118 // GetInstanceIfExist()                           105 // GetInstanceIfExist()
119 //                                                106 //
120 // Retrieve the static instance pointer of the    107 // Retrieve the static instance pointer of the singleton
121 //                                                108 //
122 G4TransportationManager* G4TransportationManag    109 G4TransportationManager* G4TransportationManager::GetInstanceIfExist()
123 {                                                 110 {
124    return fTransportationManager;                 111    return fTransportationManager;
125 }                                                 112 }
126                                                   113 
127 // -------------------------------------------    114 // ----------------------------------------------------------------------------
128 // SetFieldManager()                              115 // SetFieldManager()
129 //                                                116 //
130 // Set the associated field manager.              117 // Set the associated field manager.
131 //                                                118 //
132 void G4TransportationManager::SetFieldManager(    119 void G4TransportationManager::SetFieldManager(G4FieldManager* newFieldManager)
133 {                                                 120 {
134    fFieldManager = newFieldManager;               121    fFieldManager = newFieldManager; 
135    G4FieldManager::SetGlobalFieldManager(fFiel << 
136                                                   122 
137    // Message the PropagatorInField,              123    // Message the PropagatorInField, 
138    // which also maintains this information (t    124    // which also maintains this information (to be reviewed)
139    //                                             125    //
140    if( fPropagatorInField != nullptr )         << 126    if( fPropagatorInField )
141    {                                              127    {
142       fPropagatorInField -> SetDetectorFieldMa    128       fPropagatorInField -> SetDetectorFieldManager( newFieldManager );
143    }                                              129    }
144 }                                                 130 }
145                                                   131 
146 // -------------------------------------------    132 // ----------------------------------------------------------------------------
147 // SetNavigatorForTracking()                      133 // SetNavigatorForTracking()
148 //                                                134 //
149 // Set the active navigator for tracking, alwa    135 // Set the active navigator for tracking, always
150 // the first in the collection of registered n    136 // the first in the collection of registered navigators.
151 //                                                137 //
152 void G4TransportationManager::SetNavigatorForT    138 void G4TransportationManager::SetNavigatorForTracking(G4Navigator* newNavigator)
153 {                                                 139 {
154    fNavigators[0] = newNavigator;                 140    fNavigators[0] = newNavigator;
155    fActiveNavigators[0] = newNavigator;           141    fActiveNavigators[0] = newNavigator;
156    fPropagatorInField->SetNavigatorForPropagat    142    fPropagatorInField->SetNavigatorForPropagating(newNavigator);
157 }                                                 143 }
158                                                   144 
159 // -------------------------------------------    145 // ----------------------------------------------------------------------------
160 // ClearNavigators()                              146 // ClearNavigators()
161 //                                                147 //
162 // Clear collection of navigators and delete a    148 // Clear collection of navigators and delete allocated objects.
163 // Called only by the class destructor.           149 // Called only by the class destructor.
164 //                                                150 //
165 void G4TransportationManager::ClearNavigators(    151 void G4TransportationManager::ClearNavigators()
166 {                                                 152 {
167    for (const auto & fNavigator : fNavigators) << 153    std::vector<G4Navigator*>::iterator pNav;
                                                   >> 154    for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
168    {                                              155    {
169      delete fNavigator;                        << 156      delete *pNav;
170    }                                              157    }
171    fNavigators.clear();                           158    fNavigators.clear();
172    fActiveNavigators.clear();                     159    fActiveNavigators.clear();
173    fWorlds.clear();                               160    fWorlds.clear();
174 }                                                 161 }
175                                                   162 
176 // -------------------------------------------    163 // ----------------------------------------------------------------------------
177 // GetParallelWorld()                             164 // GetParallelWorld()
178 //                                                165 //
179 // Provided the name of a world volume, return    166 // Provided the name of a world volume, returns the associated world pointer.
180 // If not existing, create (allocate) and regi    167 // If not existing, create (allocate) and register it in the collection.
181 //                                                168 //
182 G4VPhysicalVolume*                                169 G4VPhysicalVolume*
183 G4TransportationManager::GetParallelWorld( con    170 G4TransportationManager::GetParallelWorld( const G4String& worldName )
184 {                                                 171 {
185    G4VPhysicalVolume* wPV = IsWorldExisting(wo    172    G4VPhysicalVolume* wPV = IsWorldExisting(worldName);
186    if (wPV == nullptr)                         << 173    if (!wPV)
187    {                                              174    {
188      wPV = GetNavigatorForTracking()->GetWorld    175      wPV = GetNavigatorForTracking()->GetWorldVolume();
189      G4LogicalVolume* wLV = wPV->GetLogicalVol    176      G4LogicalVolume* wLV = wPV->GetLogicalVolume();
190      wLV = new G4LogicalVolume(wLV->GetSolid() << 177      wLV = new G4LogicalVolume(wLV->GetSolid(), 0,
191                                worldName);        178                                worldName);
192      wPV = new G4PVPlacement (wPV->GetRotation    179      wPV = new G4PVPlacement (wPV->GetRotation(),
193                               wPV->GetTranslat    180                               wPV->GetTranslation(),
194                               wLV, worldName,  << 181                               wLV, worldName, 0, false, 0);
195      RegisterWorld(wPV);                          182      RegisterWorld(wPV);
196    }                                              183    }
197    return wPV;                                    184    return wPV;
198 }                                                 185 }
199                                                   186 
200 // -------------------------------------------    187 // ----------------------------------------------------------------------------
201 // GetNavigator()                                 188 // GetNavigator()
202 //                                                189 //
203 // Provided the name of a world volume, return    190 // Provided the name of a world volume, returns the associated navigator.
204 // If not existing, create it and register it     191 // If not existing, create it and register it in the collection, throw an
205 // exception if the associated parallel world     192 // exception if the associated parallel world does not exist.
206 //                                                193 //
207 G4Navigator* G4TransportationManager::GetNavig    194 G4Navigator* G4TransportationManager::GetNavigator( const G4String& worldName )
208 {                                                 195 {
209    // If already existing, return the stored p    196    // If already existing, return the stored pointer to the navigator
210    //                                             197    //
211    for (const auto & fNavigator : fNavigators) << 198    std::vector<G4Navigator*>::iterator pNav;
                                                   >> 199    for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
212    {                                              200    {
213       if (fNavigator->GetWorldVolume()->GetNam << 201       if ((*pNav)->GetWorldVolume()->GetName() == worldName) { return *pNav; }
214       {                                        << 
215         return fNavigator;                     << 
216       }                                        << 
217    }                                              202    }
218                                                   203 
219    // Check if world of that name already exis    204    // Check if world of that name already exists,
220    // create a navigator and register it          205    // create a navigator and register it
221    //                                             206    //
222    G4Navigator* aNavigator = nullptr;          << 207    G4Navigator* aNavigator = 0;
223    G4VPhysicalVolume* aWorld = IsWorldExisting    208    G4VPhysicalVolume* aWorld = IsWorldExisting(worldName);
224    if(aWorld != nullptr)                       << 209    if(aWorld)
225    {                                              210    {
226       aNavigator = new G4Navigator();             211       aNavigator = new G4Navigator();
227       aNavigator->SetWorldVolume(aWorld);         212       aNavigator->SetWorldVolume(aWorld);
228       fNavigators.push_back(aNavigator);          213       fNavigators.push_back(aNavigator);
229    }                                              214    }
230    else                                           215    else
231    {                                              216    {
232       G4String message                            217       G4String message
233          = "World volume with name -" + worldN    218          = "World volume with name -" + worldName
234          + "- does not exist. Create it first     219          + "- does not exist. Create it first by GetParallelWorld() method!";      
235       G4Exception("G4TransportationManager::Ge    220       G4Exception("G4TransportationManager::GetNavigator(name)",
236                   "GeomNav0002", FatalExceptio    221                   "GeomNav0002", FatalException, message);
237    }                                              222    }
238                                                   223 
239    return aNavigator;                             224    return aNavigator;
240 }                                                 225 }
241                                                   226 
242 // -------------------------------------------    227 // ----------------------------------------------------------------------------
243 // GetNavigator()                                 228 // GetNavigator()
244 //                                                229 //
245 // Provided a pointer to a world volume, retur    230 // Provided a pointer to a world volume, returns the associated navigator.
246 // Create it in case not existing and add it t    231 // Create it in case not existing and add it to the collection.
247 // If world volume not existing, issue an exce    232 // If world volume not existing, issue an exception.
248 //                                                233 //
249 G4Navigator* G4TransportationManager::GetNavig    234 G4Navigator* G4TransportationManager::GetNavigator( G4VPhysicalVolume* aWorld )
250 {                                                 235 {
251    for (const auto & fNavigator : fNavigators) << 236    std::vector<G4Navigator*>::iterator pNav;
                                                   >> 237    for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
252    {                                              238    {
253      if (fNavigator->GetWorldVolume() == aWorl << 239      if ((*pNav)->GetWorldVolume() == aWorld) { return *pNav; }
254    }                                              240    }
255    G4Navigator* aNavigator = nullptr;          << 241    G4Navigator* aNavigator = 0;
256    auto pWorld = std::find(fWorlds.cbegin(), f << 242    std::vector<G4VPhysicalVolume*>::iterator pWorld =
257    if (pWorld != fWorlds.cend())               << 243      std::find(fWorlds.begin(), fWorlds.end(), aWorld);
                                                   >> 244    if (pWorld != fWorlds.end())
258    {                                              245    {
259       aNavigator = new G4Navigator();             246       aNavigator = new G4Navigator();
260       aNavigator->SetWorldVolume(aWorld);         247       aNavigator->SetWorldVolume(aWorld);
261       fNavigators.push_back(aNavigator);          248       fNavigators.push_back(aNavigator);
262    }                                              249    }
263    else                                           250    else
264    {                                              251    {
265       G4String message                            252       G4String message
266          = "World volume with name -" + aWorld    253          = "World volume with name -" + aWorld->GetName()
267          + "- does not exist. Create it first     254          + "- does not exist. Create it first by GetParallelWorld() method!";
268       G4Exception("G4TransportationManager::Ge    255       G4Exception("G4TransportationManager::GetNavigator(pointer)",
269                   "GeomNav0002", FatalExceptio    256                   "GeomNav0002", FatalException, message);
270    }                                              257    }
271                                                   258 
272    return aNavigator;                             259    return aNavigator;
273 }                                                 260 }
274                                                   261 
275 // -------------------------------------------    262 // ----------------------------------------------------------------------------
276 // DeRegisterNavigator()                          263 // DeRegisterNavigator()
277 //                                                264 //
278 // Provided a pointer to an already allocated     265 // Provided a pointer to an already allocated navigator object, removes the
279 // associated entry in the navigators collecti    266 // associated entry in the navigators collection (remove pair) but does not
280 // delete the actual pointed object, which is     267 // delete the actual pointed object, which is still owned by the caller.
281 // The navigator for tracking -cannot- be dere    268 // The navigator for tracking -cannot- be deregistered.
282 //                                                269 //
283 void G4TransportationManager::DeRegisterNaviga    270 void G4TransportationManager::DeRegisterNavigator( G4Navigator* aNavigator )
284 {                                                 271 {
285    if (aNavigator == fNavigators[0])              272    if (aNavigator == fNavigators[0])
286    {                                              273    {
287       G4Exception("G4TransportationManager::De    274       G4Exception("G4TransportationManager::DeRegisterNavigator()",
288                   "GeomNav0003", FatalExceptio    275                   "GeomNav0003", FatalException,
289                   "The navigator for tracking     276                   "The navigator for tracking CANNOT be deregistered!");
290    }                                              277    }
291    auto pNav = std::find(fNavigators.cbegin(), << 278    std::vector<G4Navigator*>::iterator pNav =
292    if (pNav != fNavigators.cend())             << 279      std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
                                                   >> 280    if (pNav != fNavigators.end())
293    {                                              281    {
294       // Deregister associated world volume       282       // Deregister associated world volume
295       //                                          283       //
296       DeRegisterWorld((*pNav)->GetWorldVolume(    284       DeRegisterWorld((*pNav)->GetWorldVolume());
297                                                   285 
298       // Deregister the navigator                 286       // Deregister the navigator
299       //                                          287       //
300       fNavigators.erase(pNav);                    288       fNavigators.erase(pNav);
301    }                                              289    }
302    else                                           290    else
303    {                                              291    {
304       G4String message                            292       G4String message
305          = "Navigator for volume -" + aNavigat    293          = "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
306          + "- not found in memory!";              294          + "- not found in memory!";      
307       G4Exception("G4TransportationManager::De    295       G4Exception("G4TransportationManager::DeRegisterNavigator()",
308                   "GeomNav1002", JustWarning,     296                   "GeomNav1002", JustWarning, message);
309    }                                              297    }
310 }                                                 298 }
311                                                   299 
312 // -------------------------------------------    300 // ----------------------------------------------------------------------------
313 // ActivateNavigator()                            301 // ActivateNavigator()
314 //                                                302 //
315 // Provided a pointer to an already allocated     303 // Provided a pointer to an already allocated navigator object, set to 'true'
316 // the associated activation flag for the navi    304 // the associated activation flag for the navigator in the collection.
317 // If the provided navigator is not already re    305 // If the provided navigator is not already registered, issue a warning
318 // Return the index of the activated navigator    306 // Return the index of the activated navigator. This index should be used for
319 // ComputeStep() method of G4PathFinder.          307 // ComputeStep() method of G4PathFinder.
320 //                                                308 //
321 G4int G4TransportationManager::ActivateNavigat    309 G4int G4TransportationManager::ActivateNavigator( G4Navigator* aNavigator )
322 {                                                 310 {
323    auto pNav = std::find(fNavigators.cbegin(), << 311    std::vector<G4Navigator*>::iterator pNav =
324    if (pNav == fNavigators.cend())             << 312      std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
                                                   >> 313    if (pNav == fNavigators.end())
325    {                                              314    {
326       G4String message                            315       G4String message
327          = "Navigator for volume -" + aNavigat    316          = "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
328          + "- not found in memory!";              317          + "- not found in memory!";      
329       G4Exception("G4TransportationManager::Ac    318       G4Exception("G4TransportationManager::ActivateNavigator()",
330                   "GeomNav1002", FatalExceptio    319                   "GeomNav1002", FatalException, message);
331       return -1;                                  320       return -1;
332    }                                              321    }
333                                                   322 
334    aNavigator->Activate(true);                    323    aNavigator->Activate(true);
335    G4int id = 0;                                  324    G4int id = 0;
336    for(const auto & fActiveNavigator : fActive << 325    std::vector<G4Navigator*>::iterator pActiveNav;
                                                   >> 326    for(pActiveNav=fActiveNavigators.begin();
                                                   >> 327        pActiveNav!=fActiveNavigators.end(); pActiveNav++)
337    {                                              328    {
338       if (fActiveNavigator == aNavigator)  { r << 329       if (*pActiveNav == aNavigator)  { return id; }
339       ++id;                                    << 330       id++;
340    }                                              331    }
341                                                   332    
342    fActiveNavigators.push_back(aNavigator);       333    fActiveNavigators.push_back(aNavigator);
343    return id;                                     334    return id;
344 }                                                 335 }
345                                                   336 
346 // -------------------------------------------    337 // ----------------------------------------------------------------------------
347 // DeActivateNavigator()                          338 // DeActivateNavigator()
348 //                                                339 //
349 // Provided a pointer to an already allocated     340 // Provided a pointer to an already allocated navigator object, set to 'false'
350 // the associated activation flag in the navig    341 // the associated activation flag in the navigators collection.
351 // If the provided navigator is not already re    342 // If the provided navigator is not already registered, issue a warning.
352 //                                                343 //
353 void G4TransportationManager::DeActivateNaviga    344 void G4TransportationManager::DeActivateNavigator( G4Navigator* aNavigator )
354 {                                                 345 {
355    auto pNav = std::find(fNavigators.cbegin(), << 346    std::vector<G4Navigator*>::iterator pNav =
356    if (pNav != fNavigators.cend())             << 347      std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
                                                   >> 348    if (pNav != fNavigators.end())
357    {                                              349    {
358       (*pNav)->Activate(false);                   350       (*pNav)->Activate(false);
359    }                                              351    }
360    else                                           352    else
361    {                                              353    {
362       G4String message                            354       G4String message
363          = "Navigator for volume -" + aNavigat    355          = "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
364          + "- not found in memory!";              356          + "- not found in memory!";
365       G4Exception("G4TransportationManager::De    357       G4Exception("G4TransportationManager::DeActivateNavigator()",
366                   "GeomNav1002", JustWarning,     358                   "GeomNav1002", JustWarning, message);
367    }                                              359    }
368                                                   360 
369    auto pActiveNav = std::find(fActiveNavigato << 361    std::vector<G4Navigator*>::iterator pActiveNav =
370                                fActiveNavigato << 362      std::find(fActiveNavigators.begin(), fActiveNavigators.end(), aNavigator);
371    if (pActiveNav != fActiveNavigators.cend()) << 363    if (pActiveNav != fActiveNavigators.end())
372    {                                              364    {
373       fActiveNavigators.erase(pActiveNav);        365       fActiveNavigators.erase(pActiveNav);
374    }                                              366    }
375 }                                                 367 }
376                                                   368 
377 // -------------------------------------------    369 // ----------------------------------------------------------------------------
378 // InactivateAll()                                370 // InactivateAll()
379 //                                                371 //
380 // Inactivate all the navigators except for th    372 // Inactivate all the navigators except for the tracking one, and clear the
381 // store of active navigators.                    373 // store of active navigators.
382 //                                                374 //
383 void G4TransportationManager::InactivateAll( )    375 void G4TransportationManager::InactivateAll( )
384 {                                                 376 {
385    for (const auto & fActiveNavigator : fActiv << 377    std::vector<G4Navigator*>::iterator pNav;
                                                   >> 378    for (pNav=fActiveNavigators.begin(); pNav!=fActiveNavigators.end(); pNav++)
386    {                                              379    {
387       fActiveNavigator->Activate(false);       << 380       (*pNav)->Activate(false);
388    }                                              381    }
389    fActiveNavigators.clear();                     382    fActiveNavigators.clear();
390                                                   383 
391    // Restore status for the navigator for tra    384    // Restore status for the navigator for tracking
392    //                                             385    //
393    fNavigators[0]->Activate(true);                386    fNavigators[0]->Activate(true);
394    fActiveNavigators.push_back(fNavigators[0])    387    fActiveNavigators.push_back(fNavigators[0]);
395 }                                                 388 }
396                                                   389 
397 // -------------------------------------------    390 // ----------------------------------------------------------------------------
398 // IsWorldExisting()                              391 // IsWorldExisting()
399 //                                                392 //
400 // Verify existance or not of an istance of th    393 // Verify existance or not of an istance of the world volume with
401 // same name in the collection. Return the wor    394 // same name in the collection. Return the world pointer if existing.
402 //                                                395 //
403 G4VPhysicalVolume*                                396 G4VPhysicalVolume*
404 G4TransportationManager::IsWorldExisting ( con    397 G4TransportationManager::IsWorldExisting ( const G4String& name )
405 {                                                 398 {
406    auto pWorld = fWorlds.begin();              << 399    std::vector<G4VPhysicalVolume*>::iterator pWorld = fWorlds.begin();
407    if ( *pWorld==nullptr )  { *pWorld=fNavigat << 400    if (*pWorld==0)  { *pWorld=fNavigators[0]->GetWorldVolume(); }
408                                                   401 
409    for (const auto & fWorld : fWorlds)         << 402    for (pWorld=fWorlds.begin(); pWorld!=fWorlds.end(); pWorld++)
410    {                                              403    {
411       if (fWorld->GetName() == name ) { return << 404       if ((*pWorld)->GetName() == name ) { return *pWorld; }
412    }                                              405    }
413    return nullptr;                             << 406    return 0;
414 }                                                 407 }
415                                                   408 
416 // -------------------------------------------    409 // ----------------------------------------------------------------------------
417 // RegisterWorld()                                410 // RegisterWorld()
418 //                                                411 //
419 // Provided a pointer to an already allocated     412 // Provided a pointer to an already allocated world object, check and add the
420 // associated entry in the worlds collection.     413 // associated entry in the worlds collection. Return 'true' if registration
421 // succeeds and the new entry is created.         414 // succeeds and the new entry is created.
422 //                                                415 //
423 G4bool G4TransportationManager::RegisterWorld(    416 G4bool G4TransportationManager::RegisterWorld( G4VPhysicalVolume* aWorld )
424 {                                                 417 {
425    G4bool done = false;                           418    G4bool done = false;
426                                                   419 
427    auto pWorld = std::find(fWorlds.cbegin(), f << 420    std::vector<G4VPhysicalVolume*>::iterator pWorld =
428    if (pWorld == fWorlds.cend())               << 421      std::find(fWorlds.begin(), fWorlds.end(), aWorld);
                                                   >> 422    if (pWorld == fWorlds.end())
429    {                                              423    {
430      fWorlds.push_back(aWorld);                   424      fWorlds.push_back(aWorld);
431      done = true;                                 425      done = true;
432    }                                              426    }
433    return done;                                   427    return done;
434 }                                                 428 }
435                                                   429 
436 // -------------------------------------------    430 // ----------------------------------------------------------------------------
437 // DeRegisterWorld()                              431 // DeRegisterWorld()
438 //                                                432 //
439 // Provided a pointer to an already allocated     433 // Provided a pointer to an already allocated world object, removes the
440 // associated entry in the worlds collection b    434 // associated entry in the worlds collection but does not delete the actual
441 // pointed object, which is still owned by the    435 // pointed object, which is still owned by the caller.
442 //                                                436 //
443 void G4TransportationManager::DeRegisterWorld(    437 void G4TransportationManager::DeRegisterWorld( G4VPhysicalVolume* aWorld )
444 {                                                 438 {
445    auto pWorld = std::find(fWorlds.cbegin(), f << 439    std::vector<G4VPhysicalVolume*>::iterator pWorld =
446    if (pWorld != fWorlds.cend())               << 440      std::find(fWorlds.begin(), fWorlds.end(), aWorld);
                                                   >> 441    if (pWorld != fWorlds.end())
447    {                                              442    {
448       fWorlds.erase(pWorld);                      443       fWorlds.erase(pWorld);
449    }                                              444    }
450    else                                           445    else
451    {                                              446    {
452      G4String message                             447      G4String message
453        = "World volume -" + aWorld->GetName()     448        = "World volume -" + aWorld->GetName() + "- not found in memory!";      
454      G4Exception("G4TransportationManager::DeR    449      G4Exception("G4TransportationManager::DeRegisterWorld()",
455                  "GeomNav1002", JustWarning, m    450                  "GeomNav1002", JustWarning, message);
456    }                                              451    }
457 }                                                 452 }
458                                                   453 
459 // -------------------------------------------    454 // ----------------------------------------------------------------------------
460 // ClearParallelWorlds()                          455 // ClearParallelWorlds()
461 //                                                456 //
462 // Clear collection of navigators and delete a    457 // Clear collection of navigators and delete allocated objects associated with
463 // parallel worlds.                               458 // parallel worlds.
464 // Called only by the RunManager when the enti    459 // Called only by the RunManager when the entire geometry is rebuilt from
465 // scratch.                                       460 // scratch.
466 //                                                461 //
467 void G4TransportationManager::ClearParallelWor    462 void G4TransportationManager::ClearParallelWorlds()
468 {                                                 463 {
469    auto pNav = fNavigators.cbegin();           << 464    std::vector<G4Navigator*>::iterator pNav = fNavigators.begin();
470    G4Navigator* trackingNavigator = *pNav;        465    G4Navigator* trackingNavigator = *pNav;
471    for (pNav=fNavigators.cbegin(); pNav!=fNavi << 466    for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
472    {                                              467    {
473      if (*pNav != trackingNavigator)  { delete    468      if (*pNav != trackingNavigator)  { delete *pNav; }
474    }                                              469    }
475    fNavigators.clear();                           470    fNavigators.clear();
476    fActiveNavigators.clear();                     471    fActiveNavigators.clear();
477    fWorlds.clear();                               472    fWorlds.clear();
478                                                   473 
                                                   >> 474    // trackingNavigator->SetWorldVolume(0);
479    fNavigators.push_back(trackingNavigator);      475    fNavigators.push_back(trackingNavigator);
480    fActiveNavigators.push_back(trackingNavigat    476    fActiveNavigators.push_back(trackingNavigator);
481    fWorlds.push_back(nullptr); // NULL registe << 477    // fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
                                                   >> 478    fWorlds.push_back(0); // NULL registered
482 }                                                 479 }
483                                                   480 
484 // ------------------------------------------- << 
485 // GetFirstTrackingNavigator()                 << 
486 //                                             << 
487 // Get pointer to the first tracking Navigator << 
488 //                                             << 
489 G4Navigator* G4TransportationManager::GetFirst << 
490 {                                              << 
491   return fFirstTrackingNavigator;              << 
492 }                                              << 
493                                                << 
494 // ------------------------------------------- << 
495 // GetFirstTrackingNavigator()                 << 
496 //                                             << 
497 // Get pointer to the first tracking Navigator << 
498                                                << 
499 void G4TransportationManager::SetFirstTracking << 
500 {                                              << 
501   fFirstTrackingNavigator= nav;                << 
502 }                                              << 
503                                                   481