00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // class G4TransportationManager 00030 // 00031 // Class description: 00032 // 00033 // A singleton class which stores the (volume) navigator used by 00034 // the transportation process to do the geometrical tracking. 00035 // It also stores a pointer to the propagator used in a (magnetic) 00036 // field and to the field manager. 00037 // The class instance is created before main() is called, and 00038 // in turn creates the navigator and the rest. 00039 00040 // Created: 10 March 1997, J. Apostolakis 00041 // Reviewed: 26 April 2006, G. Cosmo 00042 // -------------------------------------------------------------------- 00043 00044 #ifndef G4TransportationManager_hh 00045 #define G4TransportationManager_hh 00046 00047 #include "G4Navigator.hh" 00048 #include "G4SafetyHelper.hh" 00049 00050 #include <vector> 00051 00052 class G4PropagatorInField; 00053 class G4GeometryMessenger; 00054 class G4FieldManager; 00055 class G4VPhysicalVolume; 00056 00057 class G4TransportationManager 00058 { 00059 public: // with description 00060 00061 static G4TransportationManager* GetTransportationManager(); 00062 // Retrieve the static instance 00063 00064 inline G4PropagatorInField* GetPropagatorInField() const; 00065 inline void SetPropagatorInField( G4PropagatorInField* newFieldPropagator ); 00066 inline G4FieldManager* GetFieldManager() const; 00067 void SetFieldManager( G4FieldManager* newFieldManager ); 00068 // Accessors for field handling 00069 00070 inline G4Navigator* GetNavigatorForTracking() const; 00071 inline void SetNavigatorForTracking( G4Navigator* newNavigator ); 00072 // Accessors for the navigator for tracking 00073 00074 inline void SetWorldForTracking(G4VPhysicalVolume* theWorld); 00075 // Set the world volume for tracking 00076 // This method is to be invoked by G4RunManagerKernel. 00077 00078 inline size_t GetNoActiveNavigators() const; 00079 inline std::vector<G4Navigator*>::iterator GetActiveNavigatorsIterator(); 00080 // Return an iterator to the list of active navigators 00081 00082 inline size_t GetNoWorlds() const; 00083 inline std::vector<G4VPhysicalVolume*>::iterator GetWorldsIterator(); 00084 // Return an iterator to the list of registered worlds 00085 00086 inline G4SafetyHelper* GetSafetyHelper() const; 00087 // Return the pointer to the navigation safety helper instance 00088 00089 G4VPhysicalVolume* GetParallelWorld ( const G4String& worldName ); 00090 // Return an exact copy of the tracking world volume. If already 00091 // existing just return the pointer 00092 00093 G4VPhysicalVolume* IsWorldExisting ( const G4String& worldName ); 00094 // Verify existance or not of an istance of the world volume with 00095 // same name in the collection 00096 00097 G4Navigator* GetNavigator ( const G4String& worldName ); 00098 G4Navigator* GetNavigator ( G4VPhysicalVolume* aWorld ); 00099 // Return a navigator associated to either the world volume name 00100 // or the pointer to world physical volume. If not existing already 00101 // create it and register it in the collection 00102 00103 void DeRegisterNavigator( G4Navigator* aNavigator ); 00104 G4int ActivateNavigator( G4Navigator* aNavigator ); 00105 void DeActivateNavigator( G4Navigator* aNavigator ); 00106 void InactivateAll(); 00107 // Methods for handling navigators. Navigator for tracking is always the 00108 // first, i.e. position 0 in the collection and cannot be de-registered 00109 00110 protected: 00111 00112 G4TransportationManager(); 00113 ~G4TransportationManager(); 00114 // Singleton. Protected constructor and destructor 00115 00116 private: 00117 00118 void ClearNavigators(); 00119 // Clear collection of navigators and delete allocated objects 00120 G4bool RegisterWorld( G4VPhysicalVolume* aWorld ); 00121 void DeRegisterWorld( G4VPhysicalVolume* aWorld ); 00122 // Register/de-register an already allocated world volume. 00123 // The pointed object is not deleted. 00124 00125 private: 00126 00127 std::vector<G4Navigator*> fNavigators; 00128 // The collection of all navigators registered 00129 std::vector<G4Navigator*> fActiveNavigators; 00130 // The collection of only active navigators 00131 std::vector<G4VPhysicalVolume*> fWorlds; 00132 // The collection of worlds associated to the registered navigators 00133 00134 G4PropagatorInField* fPropagatorInField; 00135 G4FieldManager* fFieldManager; 00136 G4GeometryMessenger* fGeomMessenger; 00137 G4SafetyHelper* fSafetyHelper; 00138 00139 static G4TransportationManager* fTransportationManager; 00140 }; 00141 00142 #include "G4TransportationManager.icc" 00143 00144 #endif