Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // class G4TransportationManager
0027 //
0028 // Class description:
0029 //
0030 // A singleton class which stores the (volume) navigator used by 
0031 // the transportation process to do the geometrical tracking.
0032 // It also stores a pointer to the propagator used in a (magnetic) 
0033 // field and to the field manager.
0034 // The class instance is created before main() is called, and
0035 // in turn creates the navigator and the rest.
0036 
0037 // Created:  10 March 1997, J. Apostolakis
0038 // Reviewed: 26 April 2006, G. Cosmo
0039 // --------------------------------------------------------------------
0040 #ifndef  G4TransportationManager_hh
0041 #define  G4TransportationManager_hh
0042 
0043 #include "G4Navigator.hh"
0044 #include "G4SafetyHelper.hh"
0045 
0046 #include <vector>
0047 
0048 class G4PropagatorInField;
0049 class G4GeometryMessenger;
0050 class G4FieldManager;
0051 class G4VPhysicalVolume;
0052 
0053 class G4TransportationManager 
0054 {
0055   public:  // with description
0056 
0057      static G4TransportationManager* GetTransportationManager();
0058        // Retrieve the static instance
0059      static G4TransportationManager* GetInstanceIfExist();
0060        // Retrieve singleton instance pointer.
0061 
0062      inline G4PropagatorInField* GetPropagatorInField() const;
0063      inline void SetPropagatorInField(G4PropagatorInField* newFieldPropagator);
0064      inline G4FieldManager* GetFieldManager() const;
0065      void SetFieldManager( G4FieldManager* newFieldManager );
0066        // Accessors for field handling
0067 
0068      inline G4Navigator* GetNavigatorForTracking() const;
0069      void SetNavigatorForTracking( G4Navigator* newNavigator );
0070        // Accessors for the navigator for tracking
0071 
0072      inline void SetWorldForTracking(G4VPhysicalVolume* theWorld);
0073        // Set the world volume for tracking
0074        // This method is to be invoked by G4RunManagerKernel.
0075 
0076      inline std::size_t GetNoActiveNavigators() const;
0077      inline std::vector<G4Navigator*>::iterator GetActiveNavigatorsIterator();
0078        // Return an iterator to the list of active navigators
0079 
0080      inline std::size_t GetNoWorlds() const;
0081      inline std::vector<G4VPhysicalVolume*>::iterator GetWorldsIterator();
0082        // Return an iterator to the list of registered worlds
0083 
0084      inline G4SafetyHelper* GetSafetyHelper() const;
0085        // Return the pointer to the navigation safety helper instance
0086 
0087      G4VPhysicalVolume* GetParallelWorld ( const G4String& worldName );
0088        // Return an exact copy of the tracking world volume. If already
0089        // existing just return the pointer
0090 
0091      G4VPhysicalVolume* IsWorldExisting ( const G4String& worldName );
0092        // Verify existance or not of an istance of the world volume with
0093        // same name in the collection
0094 
0095      G4Navigator* GetNavigator ( const G4String& worldName );
0096      G4Navigator* GetNavigator ( G4VPhysicalVolume* aWorld );
0097        // Return a navigator associated to either the world volume name
0098        // or the pointer to world physical volume. If not existing already
0099        // create it and register it in the collection
0100 
0101      G4bool RegisterWorld( G4VPhysicalVolume* aWorld );
0102      void DeRegisterNavigator( G4Navigator* aNavigator );
0103      G4int  ActivateNavigator( G4Navigator* aNavigator );
0104      void DeActivateNavigator( G4Navigator* aNavigator );
0105      void InactivateAll();
0106        // Methods for handling navigators. Navigator for tracking is always the
0107        // first, i.e. position 0 in the collection and cannot be de-registered
0108 
0109      static G4Navigator* GetFirstTrackingNavigator();
0110      static void SetFirstTrackingNavigator(G4Navigator *nav);   
0111        // Retrieve/set first navigator pointer for 'mass' geometry
0112        //
0113        // It will be used as a template for cloning the tracking 
0114        //     navigator of additional threads.
0115 
0116   public:  // without description
0117 
0118      void ClearParallelWorlds();
0119        // Clear collection of navigators and delete allocated objects
0120        // associated with parallel worlds. Internal method called only
0121        // by the RunManager when the entire geometry is rebuilt from scratch.
0122 
0123      ~G4TransportationManager(); 
0124        // Destructor
0125 
0126   protected:
0127 
0128      G4TransportationManager();
0129        // Singleton. Protected constructor
0130 
0131   private:
0132 
0133      void ClearNavigators();
0134        // Clear collection of navigators and delete allocated objects
0135      void DeRegisterWorld( G4VPhysicalVolume* aWorld );
0136        // Register/de-register an already allocated world volume.
0137        // The pointed object is not deleted.
0138  
0139   private:
0140 
0141      std::vector<G4Navigator*> fNavigators;
0142        // The collection of all navigators registered
0143      std::vector<G4Navigator*> fActiveNavigators;
0144        // The collection of only active navigators
0145      std::vector<G4VPhysicalVolume*> fWorlds;
0146        // The collection of worlds associated to the registered navigators
0147 
0148      G4PropagatorInField* fPropagatorInField;
0149      G4FieldManager*      fFieldManager;
0150      G4GeometryMessenger* fGeomMessenger;
0151      G4SafetyHelper*      fSafetyHelper;
0152 
0153      static G4ThreadLocal G4TransportationManager* fTransportationManager;
0154 
0155      static G4Navigator* fFirstTrackingNavigator;
0156 
0157   public:
0158 
0159     static constexpr G4int kMassNavigatorId = 0;
0160 };
0161 
0162 #include "G4TransportationManager.icc"
0163 
0164 #endif