Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:11:19

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 // G4ParameterisedNavigation
0027 //
0028 // Class description:
0029 //
0030 // Utility for navigation in volumes containing a single G4PVParameterised
0031 // volume for which voxels for the replicated volumes have been constructed.
0032 // [Voxels MUST be along one axis only: NOT refined]
0033 
0034 // Author: Paul Kent (CERN), August 1996
0035 // --------------------------------------------------------------------
0036 #ifndef G4PARAMETERISEDNAVIGATION_HH
0037 #define G4PARAMETERISEDNAVIGATION_HH 1
0038 
0039 #include "G4Types.hh"
0040 
0041 #include <vector>
0042 
0043 #include "G4VoxelNavigation.hh"
0044 #include "G4NavigationHistory.hh"
0045 #include "G4AffineTransform.hh"
0046 #include "G4VPhysicalVolume.hh"
0047 #include "G4VPVParameterisation.hh"
0048 #include "G4LogicalVolume.hh"
0049 #include "G4VSolid.hh"
0050 #include "G4ThreeVector.hh"
0051 #include "G4BlockingList.hh"
0052 
0053 /**
0054  * @brief G4ParameterisedNavigation is a concrete utility class for navigation
0055  * in volumes containing a single G4PVParameterised volume for which voxels for
0056  * the replicated volumes have been constructed.
0057  * @note Voxels MUST be along one axis only: NOT refined.
0058  */
0059 
0060 class G4ParameterisedNavigation : public G4VoxelNavigation
0061 {
0062   public:
0063 
0064     /**
0065      * Constructor and default Destructor.
0066      */
0067     G4ParameterisedNavigation();
0068     ~G4ParameterisedNavigation() override;
0069 
0070     /**
0071      * Locates voxel node based on given point. If no parameterisation axis
0072      * is specified, adopt default location strategy as for placements.
0073      *  @param[in] pHead Pointer to header of nodes to look through.
0074      *  @param[in] localPoint Local point
0075      *  @returns Pointer to the node where the given point is located.
0076      */
0077     inline G4SmartVoxelNode* ParamVoxelLocate( G4SmartVoxelHeader* pHead,
0078                                          const G4ThreeVector& localPoint );
0079 
0080     /**
0081      * Searches positioned volumes in mother at current top level of @p history
0082      * for volume containing @p globalPoint. Do not test against @p blockedVol.
0083      * If a containing volume is found, push it onto navigation history state.
0084      *  @param[in,out] history Navigation history.
0085      *  @param[in,out] blockedVol Blocked volume to be ignored in queries.
0086      *  @param[in,out] blockedNum Copy number for blocked replica volumes.
0087      *  @param[in,out] globalPoint Point in global coordinates system.
0088      *  @param[in,out] globalDirection Global direction vector.
0089      *  @param[in] pLocatedOnEdge Flag specifying if point is located on edge.
0090      *  @param[in,out] localPoint Point in local coordinates system.
0091      *  @returns Whether a containing volume has been found.
0092      */
0093     G4bool LevelLocate( G4NavigationHistory& history,
0094                   const G4VPhysicalVolume* blockedVol,
0095                   const G4int blockedNum,
0096                   const G4ThreeVector& globalPoint,
0097                   const G4ThreeVector* globalDirection,
0098                   const G4bool pLocatedOnEdge, 
0099                         G4ThreeVector& localPoint ) override;
0100 
0101     /**
0102      * Computes the length of a step to the next boundary.
0103      * Does not test against @p pBlockedPhysical. Identifies the next candidate
0104      * volume (if a daughter of the current volume), and returns it in:
0105      * pBlockedPhysical, blockedReplicaNo.
0106      *  @param[in] localPoint Local point.
0107      *  @param[in] localDirection Local direction vector.
0108      *  @param[in] currentProposedStepLength Current proposed step length.
0109      *  @param[in,out] newSafety New safety.
0110      *  @param[in,out] history Navigation history.
0111      *  @param[in,out] validExitNormal Flag to indicate whether exit normal is
0112      *                 valid or not.
0113      *  @param[in,out] exitNormal Exit normal.
0114      *  @param[in,out] exiting Flag to indicate whether exiting a volume.
0115      *  @param[in,out] entering Flag to indicate whether entering a volume.
0116      *  @param[in,out] pBlockedPhysical Blocked physical volume that should be
0117      *                 ignored in queries.
0118      *  @param[in,out] blockedReplicaNo Copy number for blocked replica volumes.
0119      *  @returns Length from current point to next boundary surface along
0120      *           @p localDirection.
0121      */
0122     G4double ComputeStep( const G4ThreeVector& localPoint,
0123                           const G4ThreeVector& localDirection,
0124                           const G4double currentProposedStepLength,
0125                                 G4double& newSafety,
0126                                 G4NavigationHistory& history,
0127                                 G4bool& validExitNormal,
0128                                 G4ThreeVector& exitNormal,
0129                                 G4bool& exiting,
0130                                 G4bool& entering,
0131                                 G4VPhysicalVolume *(*pBlockedPhysical),
0132                                 G4int& blockedReplicaNo ) override;
0133 
0134     /**
0135      * Calculates the isotropic distance to the nearest boundary from the
0136      * specified point in the local coordinate system. 
0137      * The localpoint utilised must be within the current volume.
0138      *  @param[in] localPoint Local point.
0139      *  @param[in] history Navigation history.
0140      *  @param[in] pMaxLength Maximum step length beyond which volumes
0141      *             need not be checked.
0142      *  @returns Length from current point to closest surface.
0143      */
0144     G4double ComputeSafety( const G4ThreeVector& localPoint,
0145                             const G4NavigationHistory& history,
0146                             const G4double pProposedMaxLength=DBL_MAX ) override;
0147 
0148     /**
0149      * Updates internal navigation state to take into account that location
0150      * has been moved, but remains within the @p motherPhysical volume.
0151      *  @param[in] motherPhysical Current physical volume.
0152      *  @param[in] localPoint Local point.
0153      */
0154     void RelocateWithinVolume( G4VPhysicalVolume* motherPhysical,
0155                                const G4ThreeVector& localPoint ) override;
0156 
0157   private:
0158 
0159     /**
0160      * Computes safety from specified point to voxel boundaries using already
0161      * located point.
0162      *  @param[in] localPoint Local point.
0163      *  @param[in] pAxis Axis of parameterisation.
0164      *  @returns Safety length from current point to voxel boundary.
0165      */
0166     G4double ComputeVoxelSafety( const G4ThreeVector& localPoint,
0167                                  const EAxis pAxis ) const;
0168 
0169     /**
0170      * Finds the next voxel from the current voxel and point in the specified
0171      * direction.
0172      *  @param[in] localPoint Local point.
0173      *  @param[in] localDirection Direction along which compute the distance.
0174      *  @param[in] currentStep Current step size.
0175      *  @param[in] pAxis Axis of parameterisation.
0176      *  @returns false if all voxels considered
0177      *           [current Step ends inside same voxel or leaves all voxels]
0178      *           true  otherwise
0179      *           [the information on the next voxel is saved].
0180      */
0181     G4bool LocateNextVoxel( const G4ThreeVector& localPoint,
0182                             const G4ThreeVector& localDirection,
0183                             const G4double currentStep,
0184                             const EAxis pAxis );
0185 
0186     /**
0187      * Calls virtual 'Compute' methods, and copies information if nested.
0188      * Method necessary to resolve cases with nested parameterisations.
0189      *  @param[in] num Copy number of parameterisation.
0190      *  @param[in] apparentPhys Potentially a PhysV or PhysT.
0191      *  @param[in] curParam Pointer to the parameterisation algorithm.
0192      *  @returns A pointer to the computed parameterised solid.
0193      */
0194     inline G4VSolid* IdentifyAndPlaceSolid( G4int num,
0195                                      G4VPhysicalVolume* apparentPhys, 
0196                                      G4VPVParameterisation* curParam );
0197 
0198   private:
0199 
0200     //  Voxel Stack information (for 1D optimisation only)
0201     //
0202     EAxis fVoxelAxis = kUndefined;
0203     G4int fVoxelNoSlices = 0;
0204     G4double fVoxelSliceWidth = 0.0; 
0205     std::size_t fVoxelNodeNo = 0;  
0206     G4SmartVoxelHeader* fVoxelHeader = nullptr;
0207 };
0208 
0209 #include "G4ParameterisedNavigation.icc"
0210 
0211 #endif