Geant4 Cross Reference |
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 // >> 27 // $Id$ >> 28 // 26 // class G4TransportationManager 29 // class G4TransportationManager 27 // 30 // 28 // Class description: 31 // Class description: 29 // 32 // 30 // A singleton class which stores the (volume) 33 // A singleton class which stores the (volume) navigator used by 31 // the transportation process to do the geomet 34 // the transportation process to do the geometrical tracking. 32 // It also stores a pointer to the propagator 35 // It also stores a pointer to the propagator used in a (magnetic) 33 // field and to the field manager. 36 // field and to the field manager. 34 // The class instance is created before main() 37 // The class instance is created before main() is called, and 35 // in turn creates the navigator and the rest. 38 // in turn creates the navigator and the rest. 36 39 37 // Created: 10 March 1997, J. Apostolakis 40 // Created: 10 March 1997, J. Apostolakis 38 // Reviewed: 26 April 2006, G. Cosmo 41 // Reviewed: 26 April 2006, G. Cosmo 39 // ------------------------------------------- 42 // -------------------------------------------------------------------- >> 43 40 #ifndef G4TransportationManager_hh 44 #ifndef G4TransportationManager_hh 41 #define G4TransportationManager_hh 45 #define G4TransportationManager_hh 42 46 43 #include "G4Navigator.hh" 47 #include "G4Navigator.hh" 44 #include "G4SafetyHelper.hh" 48 #include "G4SafetyHelper.hh" 45 49 46 #include <vector> 50 #include <vector> 47 51 48 class G4PropagatorInField; 52 class G4PropagatorInField; 49 class G4GeometryMessenger; 53 class G4GeometryMessenger; 50 class G4FieldManager; 54 class G4FieldManager; 51 class G4VPhysicalVolume; 55 class G4VPhysicalVolume; 52 56 53 class G4TransportationManager 57 class G4TransportationManager 54 { 58 { 55 public: // with description 59 public: // with description 56 60 57 static G4TransportationManager* GetTransp 61 static G4TransportationManager* GetTransportationManager(); 58 // Retrieve the static instance 62 // Retrieve the static instance 59 static G4TransportationManager* GetInstan 63 static G4TransportationManager* GetInstanceIfExist(); 60 // Retrieve singleton instance pointer. 64 // Retrieve singleton instance pointer. 61 65 62 inline G4PropagatorInField* GetPropagator 66 inline G4PropagatorInField* GetPropagatorInField() const; 63 inline void SetPropagatorInField(G4Propag << 67 inline void SetPropagatorInField( G4PropagatorInField* newFieldPropagator ); 64 inline G4FieldManager* GetFieldManager() 68 inline G4FieldManager* GetFieldManager() const; 65 void SetFieldManager( G4FieldManager* new 69 void SetFieldManager( G4FieldManager* newFieldManager ); 66 // Accessors for field handling 70 // Accessors for field handling 67 71 68 inline G4Navigator* GetNavigatorForTracki 72 inline G4Navigator* GetNavigatorForTracking() const; 69 void SetNavigatorForTracking( G4Navigator 73 void SetNavigatorForTracking( G4Navigator* newNavigator ); 70 // Accessors for the navigator for trac 74 // Accessors for the navigator for tracking 71 75 72 inline void SetWorldForTracking(G4VPhysic 76 inline void SetWorldForTracking(G4VPhysicalVolume* theWorld); 73 // Set the world volume for tracking 77 // Set the world volume for tracking 74 // This method is to be invoked by G4Ru 78 // This method is to be invoked by G4RunManagerKernel. 75 79 76 inline std::size_t GetNoActiveNavigators( << 80 inline size_t GetNoActiveNavigators() const; 77 inline std::vector<G4Navigator*>::iterato 81 inline std::vector<G4Navigator*>::iterator GetActiveNavigatorsIterator(); 78 // Return an iterator to the list of ac 82 // Return an iterator to the list of active navigators 79 83 80 inline std::size_t GetNoWorlds() const; << 84 inline size_t GetNoWorlds() const; 81 inline std::vector<G4VPhysicalVolume*>::i 85 inline std::vector<G4VPhysicalVolume*>::iterator GetWorldsIterator(); 82 // Return an iterator to the list of re 86 // Return an iterator to the list of registered worlds 83 87 84 inline G4SafetyHelper* GetSafetyHelper() 88 inline G4SafetyHelper* GetSafetyHelper() const; 85 // Return the pointer to the navigation 89 // Return the pointer to the navigation safety helper instance 86 90 87 G4VPhysicalVolume* GetParallelWorld ( con 91 G4VPhysicalVolume* GetParallelWorld ( const G4String& worldName ); 88 // Return an exact copy of the tracking 92 // Return an exact copy of the tracking world volume. If already 89 // existing just return the pointer 93 // existing just return the pointer 90 94 91 G4VPhysicalVolume* IsWorldExisting ( cons 95 G4VPhysicalVolume* IsWorldExisting ( const G4String& worldName ); 92 // Verify existance or not of an istanc 96 // Verify existance or not of an istance of the world volume with 93 // same name in the collection 97 // same name in the collection 94 98 95 G4Navigator* GetNavigator ( const G4Strin 99 G4Navigator* GetNavigator ( const G4String& worldName ); 96 G4Navigator* GetNavigator ( G4VPhysicalVo 100 G4Navigator* GetNavigator ( G4VPhysicalVolume* aWorld ); 97 // Return a navigator associated to eit 101 // Return a navigator associated to either the world volume name 98 // or the pointer to world physical vol 102 // or the pointer to world physical volume. If not existing already 99 // create it and register it in the col 103 // create it and register it in the collection 100 104 101 G4bool RegisterWorld( G4VPhysicalVolume* 105 G4bool RegisterWorld( G4VPhysicalVolume* aWorld ); 102 void DeRegisterNavigator( G4Navigator* aN 106 void DeRegisterNavigator( G4Navigator* aNavigator ); 103 G4int ActivateNavigator( G4Navigator* aN 107 G4int ActivateNavigator( G4Navigator* aNavigator ); 104 void DeActivateNavigator( G4Navigator* aN 108 void DeActivateNavigator( G4Navigator* aNavigator ); 105 void InactivateAll(); 109 void InactivateAll(); 106 // Methods for handling navigators. Nav 110 // Methods for handling navigators. Navigator for tracking is always the 107 // first, i.e. position 0 in the collec 111 // first, i.e. position 0 in the collection and cannot be de-registered 108 112 109 static G4Navigator* GetFirstTrackingNavig << 110 static void SetFirstTrackingNavigator(G4N << 111 // Retrieve/set first navigator pointer << 112 // << 113 // It will be used as a template for cl << 114 // navigator of additional threads. << 115 << 116 public: // without description 113 public: // without description 117 114 118 void ClearParallelWorlds(); 115 void ClearParallelWorlds(); 119 // Clear collection of navigators and d 116 // Clear collection of navigators and delete allocated objects 120 // associated with parallel worlds. Int 117 // associated with parallel worlds. Internal method called only 121 // by the RunManager when the entire ge 118 // by the RunManager when the entire geometry is rebuilt from scratch. 122 119 123 ~G4TransportationManager(); 120 ~G4TransportationManager(); 124 // Destructor 121 // Destructor 125 122 126 protected: 123 protected: 127 124 128 G4TransportationManager(); 125 G4TransportationManager(); 129 // Singleton. Protected constructor 126 // Singleton. Protected constructor 130 127 131 private: 128 private: 132 129 133 void ClearNavigators(); 130 void ClearNavigators(); 134 // Clear collection of navigators and d 131 // Clear collection of navigators and delete allocated objects 135 void DeRegisterWorld( G4VPhysicalVolume* 132 void DeRegisterWorld( G4VPhysicalVolume* aWorld ); 136 // Register/de-register an already allo 133 // Register/de-register an already allocated world volume. 137 // The pointed object is not deleted. 134 // The pointed object is not deleted. 138 135 139 private: 136 private: 140 137 141 std::vector<G4Navigator*> fNavigators; 138 std::vector<G4Navigator*> fNavigators; 142 // The collection of all navigators reg 139 // The collection of all navigators registered 143 std::vector<G4Navigator*> fActiveNavigato 140 std::vector<G4Navigator*> fActiveNavigators; 144 // The collection of only active naviga 141 // The collection of only active navigators 145 std::vector<G4VPhysicalVolume*> fWorlds; 142 std::vector<G4VPhysicalVolume*> fWorlds; 146 // The collection of worlds associated 143 // The collection of worlds associated to the registered navigators 147 144 148 G4PropagatorInField* fPropagatorInField; << 145 G4PropagatorInField* fPropagatorInField; 149 G4FieldManager* fFieldManager; << 146 G4FieldManager* fFieldManager; 150 G4GeometryMessenger* fGeomMessenger; << 147 G4GeometryMessenger* fGeomMessenger; 151 G4SafetyHelper* fSafetyHelper; << 148 G4SafetyHelper* fSafetyHelper; 152 << 153 static G4ThreadLocal G4TransportationMana << 154 << 155 static G4Navigator* fFirstTrackingNavigat << 156 << 157 public: << 158 149 159 static constexpr G4int kMassNavigatorId = << 150 static G4ThreadLocal G4TransportationManager* fTransportationManager; 160 }; 151 }; 161 152 162 #include "G4TransportationManager.icc" 153 #include "G4TransportationManager.icc" 163 154 164 #endif 155 #endif 165 156