Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:42

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 G4MultiNavigator
0027 //
0028 // Class description:
0029 //
0030 // Utility class for polling the navigators of several geometries to
0031 // identify the next boundary. 
0032 
0033 // History:
0034 // - Created. John Apostolakis, November 2006
0035 // --------------------------------------------------------------------
0036 #ifndef G4MULTINAVIGATOR_HH
0037 #define G4MULTINAVIGATOR_HH
0038 
0039 #include <iostream>
0040 
0041 #include "geomdefs.hh"
0042 #include "G4ThreeVector.hh"
0043 #include "G4Navigator.hh"
0044 
0045 #include "G4TouchableHandle.hh"
0046 
0047 #include "G4NavigationHistory.hh"
0048 
0049 enum  ELimited { kDoNot,kUnique,kSharedTransport,kSharedOther,kUndefLimited };
0050 
0051 class G4TransportationManager;
0052 class G4VPhysicalVolume;
0053 
0054 class G4MultiNavigator : public G4Navigator
0055 {
0056   public:  // with description
0057 
0058   friend std::ostream& operator << (std::ostream& os, const G4Navigator& n);
0059 
0060   G4MultiNavigator();
0061     // Constructor - initialisers and setup.
0062 
0063   ~G4MultiNavigator() override;
0064     // Destructor. No actions.
0065 
0066   G4double ComputeStep( const G4ThreeVector& pGlobalPoint,
0067                         const G4ThreeVector& pDirection,
0068                         const G4double       pCurrentProposedStepLength,
0069                               G4double&      pNewSafety ) override;
0070     // Return the distance to the next boundary of any geometry
0071 
0072   G4double ObtainFinalStep( G4int        navigatorId, 
0073                             G4double&    pNewSafety,     // for this geom 
0074                             G4double&    minStepLast,
0075                             ELimited&    limitedStep ); 
0076     // Get values for a single geometry
0077 
0078   void PrepareNavigators(); 
0079     // Find which geometries are registered for this particles, and keep info
0080   void PrepareNewTrack( const G4ThreeVector& position, 
0081                         const G4ThreeVector direction ); 
0082     // Prepare Navigators and locate 
0083 
0084   G4VPhysicalVolume* ResetHierarchyAndLocate( const G4ThreeVector& point,
0085                                    const G4ThreeVector& direction,
0086                                    const G4TouchableHistory& h ) override;
0087     // Reset the geometrical hierarchy for all geometries.
0088     // Use the touchable history for the first (mass) geometry.
0089     // Return the volume in the first (mass) geometry.
0090     // 
0091     // Important Note: In order to call this the geometries MUST be closed.
0092 
0093   G4VPhysicalVolume* LocateGlobalPointAndSetup( const G4ThreeVector& point,
0094                                    const G4ThreeVector* direction = nullptr,
0095                                    const G4bool pRelativeSearch = true,
0096                                    const G4bool ignoreDirection = true) override;
0097     // Locate in all geometries.
0098     // Return the volume in the first (mass) geometry
0099     //  Maintain vector of other volumes,  to be returned separately
0100     // 
0101     // Important Note: In order to call this the geometry MUST be closed.
0102 
0103   void LocateGlobalPointWithinVolume( const G4ThreeVector& position ) override; 
0104     // Relocate in all geometries for point that has not changed volume
0105     // (ie is within safety  in all geometries or is distance less that 
0106     // along the direction of a computed step.
0107 
0108   G4double ComputeSafety( const G4ThreeVector& globalpoint,
0109                           const G4double pProposedMaxLength = DBL_MAX,
0110                           const G4bool keepState = false ) override;
0111     // Calculate the isotropic distance to the nearest boundary 
0112     // in any geometry from the specified point in the global coordinate
0113     // system. The geometry must be closed.
0114 
0115   G4TouchableHandle CreateTouchableHistoryHandle() const override;
0116     // Returns a reference counted handle to a touchable history.
0117 
0118   G4ThreeVector GetLocalExitNormal( G4bool* obtained ) override; // const
0119   G4ThreeVector GetLocalExitNormalAndCheck( const G4ThreeVector &E_Pt,
0120                                             G4bool* obtained ) override; // const
0121   G4ThreeVector GetGlobalExitNormal( const G4ThreeVector &E_Pt,
0122                                            G4bool* obtained ) override; // const
0123     // Return Exit Surface Normal and validity too.
0124     // Can only be called if the Navigator's last Step either
0125     //  - has just crossed a volume geometrical boundary and relocated, or
0126     //  - has arrived at a boundary in a ComputeStep
0127     // It returns the Normal to the surface pointing out of the volume that
0128     //   was left behind and/or into the volume that was entered.
0129     // Convention:x
0130     //   The *local* normal is in the coordinate system of the *final* volume.
0131     // Restriction:
0132     //   Normals are not available for replica volumes (returns obtained= false)
0133 
0134  public:  // without description
0135 
0136   inline G4Navigator* GetNavigator( G4int n ) const
0137   { 
0138     if( (n>fNoActiveNavigators) || (n<0) ) { n=0; }
0139     return fpNavigator[n]; 
0140   }
0141 
0142  protected:  // with description
0143 
0144   void ResetState() override;
0145     // Utility method to reset the navigator state machine.
0146 
0147   void SetupHierarchy() override;
0148     // Renavigate & reset hierarchy described by current history
0149     // o Reset volumes
0150     // o Recompute transforms and/or solids of replicated/parameterised
0151     //   volumes.
0152 
0153   void WhichLimited(); // Flag which processes limited the step
0154   void PrintLimited(); // Auxiliary, debugging printing 
0155   void CheckMassWorld(); 
0156 
0157  private:
0158 
0159    // STATE Information 
0160 
0161    G4int fNoActiveNavigators = 0; 
0162    static const G4int fMaxNav = 16;
0163    G4VPhysicalVolume* fLastMassWorld = nullptr; 
0164 
0165    G4Navigator*  fpNavigator[fMaxNav];
0166      // Global state (retained during stepping for one track
0167 
0168    // State after a step computation 
0169    //
0170    ELimited      fLimitedStep[fMaxNav];
0171    G4bool        fLimitTruth[fMaxNav];
0172    G4double      fCurrentStepSize[fMaxNav]; 
0173    G4double      fNewSafety[ fMaxNav ]; // Safety for starting point
0174    G4int         fNoLimitingStep = -1;  // How many geometries limited the step
0175    G4int         fIdNavLimiting = -1;   // Id of Navigator limiting step
0176 
0177    // Lowest values - determine step length, and safety
0178    //
0179    G4double      fMinStep = -kInfinity; // As reported by Navigators
0180    G4double      fMinSafety = -kInfinity;
0181    G4double      fTrueMinStep = -kInfinity; // Corrected if fMinStep>=proposed
0182 
0183    // State after calling 'locate'
0184    //
0185    G4VPhysicalVolume* fLocatedVolume[fMaxNav];
0186    G4ThreeVector      fLastLocatedPosition; 
0187 
0188    // Cache of safety information
0189    //
0190    G4ThreeVector fSafetyLocation;
0191      // point where ComputeSafety is called
0192    G4double      fMinSafety_atSafLocation = -1.0;
0193      // - corresponding value of safety
0194    G4ThreeVector fPreStepLocation;
0195      // point where last ComputeStep called
0196    G4double      fMinSafety_PreStepPt = -1.0;
0197      // - corresponding value of safety
0198 
0199    G4TransportationManager* pTransportManager; // Cache for frequent use
0200 };
0201 
0202 #endif