G4SafetyHelper.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 G4SafetyHelper
00031 //
00032 // Class description:
00033 //
00034 // This class is a helper for physics processes which require 
00035 // knowledge of the safety, and the step size for the 'mass' geometry
00036 
00037 // First version:  J. Apostolakis,  July 5th, 2006
00038 // Modified:
00039 //  10.04.07 V.Ivanchenko  Use unique G4SafetyHelper
00040 // --------------------------------------------------------------------
00041 
00042 #ifndef G4SAFETYHELPER_HH
00043 #define G4SAFETYHELPER_HH 1
00044 
00045 #include <vector>
00046 
00047 #include "G4Types.hh"
00048 #include "G4ThreeVector.hh"
00049 #include "G4Navigator.hh"
00050 
00051 class G4PathFinder;
00052 
00053 class G4SafetyHelper
00054 {
00055 public: // with description
00056 
00057   G4SafetyHelper(); 
00058   ~G4SafetyHelper();
00059      //
00060      // Constructor and destructor
00061 
00062   G4double CheckNextStep( const G4ThreeVector& position, 
00063                           const G4ThreeVector& direction,
00064                           const G4double currentMaxStep,
00065                                 G4double& newSafety );
00066      //
00067      // Return linear step for mass geometry
00068 
00069   G4double ComputeSafety( const G4ThreeVector& pGlobalPoint,
00070                          G4double maxRadius=DBL_MAX );   // Radius of interest
00071      //
00072      // Return safety for all geometries.
00073      //
00074      //  The 2nd argument is the radius of your interest (e.g. maximum displacement )
00075      //    Giving this you can reduce the average computational cost.
00076      //  If the second argument is not given, this is the real isotropic safety
00077 
00078   void Locate(const G4ThreeVector& pGlobalPoint,
00079               const G4ThreeVector& direction);
00080      //
00081      // Locate the point for all geometries
00082 
00083   void ReLocateWithinVolume(const G4ThreeVector& pGlobalPoint );
00084      //
00085      // Relocate the point in the volume of interest
00086 
00087   inline void EnableParallelNavigation(G4bool parallel);
00088      // 
00089      //  To have parallel worlds considered, must be true.
00090      //  Alternative is to use single (mass) Navigator directly
00091 
00092   void InitialiseNavigator();
00093      //
00094      // Check for new navigator for tracking, and reinitialise pointer
00095 
00096   G4int SetVerboseLevel( G4int lev ) { G4int oldlv= fVerbose; fVerbose= lev; return oldlv; } 
00097 
00098   inline G4VPhysicalVolume* GetWorldVolume();
00099   inline void SetCurrentSafety(G4double val, const G4ThreeVector& pos);
00100 
00101 public: // without description
00102 
00103   void InitialiseHelper();
00104 
00105 private:
00106 
00107   G4PathFinder* fpPathFinder;
00108   G4Navigator*  fpMassNavigator;
00109   G4int         fMassNavigatorId;
00110 
00111   G4bool        fUseParallelGeometries; 
00112     // Flag whether to use PathFinder or single (mass) Navigator directly
00113   G4bool fFirstCall;
00114     // Flag of first call
00115   G4int         fVerbose; 
00116     // Whether to print warning in case of move outside safety
00117 
00118   // State used during tracking -- for optimisation
00119   G4ThreeVector fLastSafetyPosition;
00120   G4double      fLastSafety;
00121   const G4double  fRecomputeFactor;   
00122        // parameter for further optimisation: 
00123        // if ( move < fact*safety )  do fast recomputation of safety
00124   // End State (tracking)
00125 };
00126 
00127 // Inline definitions
00128 
00129 inline
00130 void G4SafetyHelper::EnableParallelNavigation(G4bool parallel) 
00131 {
00132   fUseParallelGeometries = parallel;
00133 } 
00134 
00135 inline
00136 G4VPhysicalVolume* G4SafetyHelper::GetWorldVolume()
00137 {
00138   return fpMassNavigator->GetWorldVolume();
00139 }
00140 
00141 inline
00142 void G4SafetyHelper::SetCurrentSafety(G4double val, const G4ThreeVector& pos)
00143 {
00144   fLastSafety = val;
00145   fLastSafetyPosition = pos;
00146 }
00147 
00148 #endif

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