G4ReplicaNavigation.hh

Go to the documentation of this file.
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 // 
00030 // class G4ReplicaNavigation
00031 //
00032 // Class description:
00033 //
00034 // Utility for navigation in volumes containing a single G4PVParameterised
00035 // volume for which voxels for the replicated volumes have been constructed.
00036 // [Voxels MUST be along one axis only: NOT refined]
00037 
00038 // History:
00039 // - Created. Paul Kent, Aug 96
00040 // --------------------------------------------------------------------
00041 #ifndef G4REPLICANAVIGATION_HH
00042 #define G4REPLICANAVIGATION_HH
00043 
00044 #include <CLHEP/Units/SystemOfUnits.h>
00045 
00046 #include "G4Types.hh"
00047 #include "G4NavigationHistory.hh"
00048 #include "G4LogicalVolume.hh"
00049 #include "G4VPhysicalVolume.hh"
00050 #include "G4ThreeVector.hh"
00051 #include "G4BlockingList.hh"
00052 
00053 // Required for voxel handling
00054 //
00055 #include "G4SmartVoxelHeader.hh"
00056 
00057 class G4VSolid;
00058 
00059 struct G4ExitNormal
00060 {
00061    // Bucket to hold value of Normal (3-vector), 
00062    // bools for calculated and leave-behind or 'validConvex',
00063    // and exiting side.
00064    
00065    enum  ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPX,kMX,kPY,kMY,kPZ,kMZ,kMother};
00066      // Identity of 'Side' of Replicas. Used by DistanceToOut methods.
00067 
00068    G4ThreeVector exitNormal;
00069    G4bool        calculated;   // Normal
00070    G4bool        validConvex;  // Solid locally convex
00071    ESide         exitSide;
00072 
00073  public:
00074 
00075    G4ExitNormal(G4ThreeVector norm = G4ThreeVector(0.,0.,0.),
00076                 G4bool        calc = false,
00077                 G4bool        valid= false,
00078                 ESide         side = kNull )
00079    { exitNormal= norm; calculated= calc; validConvex=valid; exitSide=side;}
00080 };
00081 
00082 class G4ReplicaNavigation
00083 {
00084   public:  // with description
00085 
00086     G4ReplicaNavigation();
00087    ~G4ReplicaNavigation();
00088 
00089     inline G4bool LevelLocate( G4NavigationHistory& history,
00090                          const G4VPhysicalVolume *blockedVol,
00091                          const G4int blockedNum,
00092                          const G4ThreeVector &globalPoint,
00093                          const G4ThreeVector* globalDirection,
00094                          const G4bool pLocatedOnEdge, 
00095                                G4ThreeVector &localPoint );
00096 
00097     G4double ComputeStep( const G4ThreeVector &globalPoint,
00098                           const G4ThreeVector &globalDirection,
00099                           const G4ThreeVector &localPoint,
00100                           const G4ThreeVector &localDirection,
00101                           const G4double currentProposedStepLength,
00102                                 G4double &newSafety,
00103                                 G4NavigationHistory &history,
00104                                 G4bool &validExitNormal,
00105                                 G4bool &calculatedExitNormal,
00106                                 G4ThreeVector &exitNormal,
00107                                 G4bool &exiting,
00108                                 G4bool &entering,
00109                                 G4VPhysicalVolume *(*pBlockedPhysical),
00110                                 G4int &blockedReplicaNo );
00111 
00112     G4double ComputeSafety( const G4ThreeVector &globalPoint,
00113                             const G4ThreeVector &localPoint,
00114                                   G4NavigationHistory &history,
00115                             const G4double pProposedMaxLength=DBL_MAX );
00116 
00117     EInside BackLocate( G4NavigationHistory &history,
00118                   const G4ThreeVector &globalPoint,
00119                         G4ThreeVector &localPoint,
00120                   const G4bool &exiting,
00121                         G4bool &notKnownInside ) const;
00122 
00123     void ComputeTransformation( const G4int replicaNo,
00124                                       G4VPhysicalVolume *pVol,
00125                                       G4ThreeVector &point ) const; 
00126     void ComputeTransformation( const G4int replicaNo,
00127                                       G4VPhysicalVolume *pVol ) const; 
00128 
00129     EInside Inside( const G4VPhysicalVolume *pVol,
00130                     const G4int replicaNo,
00131                     const G4ThreeVector &localPoint ) const;
00132     G4double DistanceToOut( const G4VPhysicalVolume *pVol,
00133                             const G4int replicaNo,
00134                             const G4ThreeVector &localPoint ) const;
00135     G4double DistanceToOut( const G4VPhysicalVolume *pVol,
00136                             const G4int replicaNo,
00137                             const G4ThreeVector &localPoint,
00138                             const G4ThreeVector &localDirection,
00139                                   G4ExitNormal& candidateNormal ) const;
00140 
00141     inline G4int GetVerboseLevel() const;
00142     inline void  SetVerboseLevel(G4int level);
00143       // Get/Set Verbose(ness) level.
00144       // [if level>0 && G4VERBOSE, printout can occur]
00145 
00146     inline void  CheckMode(G4bool mode);
00147       // Run navigation in "check-mode", therefore using additional
00148       // verifications and more strict correctness conditions.
00149       // Is effective only with G4VERBOSE set.
00150 
00151   private:
00152 
00153     inline G4int VoxelLocate( const G4SmartVoxelHeader *pHead,
00154                               const G4ThreeVector &localPoint,
00155                               const G4int blocked=-1 ) const;
00156 
00157     G4double DistanceToOutPhi( const G4ThreeVector &localPoint,
00158                                const G4ThreeVector &localDirection,
00159                                const G4double width,
00160                                G4ExitNormal& foundNormal ) const;
00161 
00162     G4double DistanceToOutRad( const G4ThreeVector &localPoint,
00163                                const G4ThreeVector &localDirection,
00164                                const G4double width,
00165                                const G4double offset,
00166                                const G4int replicaNo,
00167                                      G4ExitNormal& foundNormal ) const;
00168     inline void SetPhiTransformation( const G4double ang,
00169                                             G4VPhysicalVolume *pVol=0 ) const;
00170   private:
00171 
00172     // Invariants - unaltered during navigation
00173     // **********
00174 
00175     G4bool fCheck; 
00176     G4int  fVerbose;
00177       // Configuration parameters
00178 
00179     G4double kCarTolerance, kRadTolerance, kAngTolerance;
00180       // Local copy of constants
00181 };
00182 
00183 #include "G4ReplicaNavigation.icc"
00184 
00185 #endif

Generated on Mon May 27 17:49:43 2013 for Geant4 by  doxygen 1.4.7