| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4MultiNavigator.hh,v 1.4 2007/05/21 15:36:25 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // class G4MultiNavigator
|
|---|
| 32 | //
|
|---|
| 33 | // Class description:
|
|---|
| 34 | //
|
|---|
| 35 | // Utility class for polling the navigators of several geometries to
|
|---|
| 36 | // identify the next boundary.
|
|---|
| 37 |
|
|---|
| 38 | // History:
|
|---|
| 39 | // - Created. John Apostolakis, November 2006
|
|---|
| 40 | // *********************************************************************
|
|---|
| 41 |
|
|---|
| 42 | #ifndef G4MULTINAVIGATOR_HH
|
|---|
| 43 | #define G4MULTINAVIGATOR_HH
|
|---|
| 44 |
|
|---|
| 45 | #include <iostream>
|
|---|
| 46 |
|
|---|
| 47 | #include "geomdefs.hh"
|
|---|
| 48 | #include "G4ThreeVector.hh"
|
|---|
| 49 | #include "G4Navigator.hh"
|
|---|
| 50 |
|
|---|
| 51 | #include "G4TouchableHistoryHandle.hh"
|
|---|
| 52 |
|
|---|
| 53 | #include "G4NavigationHistory.hh"
|
|---|
| 54 |
|
|---|
| 55 | enum ELimited { kDoNot,kUnique,kSharedTransport,kSharedOther,kUndefLimited };
|
|---|
| 56 |
|
|---|
| 57 | class G4TransportationManager;
|
|---|
| 58 | class G4VPhysicalVolume;
|
|---|
| 59 |
|
|---|
| 60 | class G4MultiNavigator : public G4Navigator
|
|---|
| 61 | {
|
|---|
| 62 | public: // with description
|
|---|
| 63 |
|
|---|
| 64 | friend std::ostream& operator << (std::ostream &os, const G4Navigator &n);
|
|---|
| 65 |
|
|---|
| 66 | G4MultiNavigator();
|
|---|
| 67 | // Constructor - initialisers and setup.
|
|---|
| 68 |
|
|---|
| 69 | ~G4MultiNavigator();
|
|---|
| 70 | // Destructor. No actions.
|
|---|
| 71 |
|
|---|
| 72 | G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
|
|---|
| 73 | const G4ThreeVector &pDirection,
|
|---|
| 74 | const G4double pCurrentProposedStepLength,
|
|---|
| 75 | G4double &pNewSafety);
|
|---|
| 76 | // Return the distance to the next boundary of any geometry
|
|---|
| 77 |
|
|---|
| 78 | G4double ObtainFinalStep( G4int navigatorId,
|
|---|
| 79 | G4double &pNewSafety, // for this geom
|
|---|
| 80 | G4double &minStepLast,
|
|---|
| 81 | ELimited &limitedStep);
|
|---|
| 82 | // Get values for a single geometry
|
|---|
| 83 |
|
|---|
| 84 | void PrepareNavigators();
|
|---|
| 85 | // Find which geometries are registered for this particles, and keep info
|
|---|
| 86 | void PrepareNewTrack( const G4ThreeVector position,
|
|---|
| 87 | const G4ThreeVector direction );
|
|---|
| 88 | // Prepare Navigators and locate
|
|---|
| 89 |
|
|---|
| 90 | G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point,
|
|---|
| 91 | const G4ThreeVector &direction,
|
|---|
| 92 | const G4TouchableHistory &h);
|
|---|
| 93 | // Reset the geometrical hierarchy for all geometries.
|
|---|
| 94 | // Use the touchable history for the first (mass) geometry.
|
|---|
| 95 | // Return the volume in the first (mass) geometry.
|
|---|
| 96 | //
|
|---|
| 97 | // Important Note: In order to call this the geometries MUST be closed.
|
|---|
| 98 |
|
|---|
| 99 | G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
|
|---|
| 100 | const G4ThreeVector* direction=0,
|
|---|
| 101 | const G4bool pRelativeSearch=true,
|
|---|
| 102 | const G4bool ignoreDirection=true);
|
|---|
| 103 | // Locate in all geometries.
|
|---|
| 104 | // Return the volume in the first (mass) geometry
|
|---|
| 105 | // Maintain vector of other volumes, to be returned separately
|
|---|
| 106 | //
|
|---|
| 107 | // Important Note: In order to call this the geometry MUST be closed.
|
|---|
| 108 |
|
|---|
| 109 | void LocateGlobalPointWithinVolume(const G4ThreeVector& position);
|
|---|
| 110 | // Relocate in all geometries for point that has not changed volume
|
|---|
| 111 | // (ie is within safety in all geometries or is distance less that
|
|---|
| 112 | // along the direction of a computed step.
|
|---|
| 113 |
|
|---|
| 114 | G4double ComputeSafety(const G4ThreeVector &globalpoint,
|
|---|
| 115 | const G4double pProposedMaxLength = DBL_MAX);
|
|---|
| 116 | // Calculate the isotropic distance to the nearest boundary
|
|---|
| 117 | // in any geometry from the specified point in the global coordinate
|
|---|
| 118 | // system. The geometry must be closed.
|
|---|
| 119 |
|
|---|
| 120 | G4TouchableHistoryHandle CreateTouchableHistoryHandle() const;
|
|---|
| 121 | // Returns a reference counted handle to a touchable history.
|
|---|
| 122 |
|
|---|
| 123 | public: // without description
|
|---|
| 124 |
|
|---|
| 125 | G4Navigator* GetNavigator(G4int n) const
|
|---|
| 126 | {
|
|---|
| 127 | if( (n>fNoActiveNavigators)||(n<0)){ n=0; }
|
|---|
| 128 | return fpNavigator[n];
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | protected: // with description
|
|---|
| 132 |
|
|---|
| 133 | void ResetState();
|
|---|
| 134 | // Utility method to reset the navigator state machine.
|
|---|
| 135 |
|
|---|
| 136 | void SetupHierarchy();
|
|---|
| 137 | // Renavigate & reset hierarchy described by current history
|
|---|
| 138 | // o Reset volumes
|
|---|
| 139 | // o Recompute transforms and/or solids of replicated/parameterised
|
|---|
| 140 | // volumes.
|
|---|
| 141 |
|
|---|
| 142 | void WhichLimited(); // Flag which processes limited the step
|
|---|
| 143 | void PrintLimited(); // Auxiliary, debugging printing
|
|---|
| 144 | void CheckMassWorld();
|
|---|
| 145 |
|
|---|
| 146 | private:
|
|---|
| 147 |
|
|---|
| 148 | // STATE Information
|
|---|
| 149 |
|
|---|
| 150 | G4int fNoActiveNavigators;
|
|---|
| 151 | static const G4int fMaxNav = 8; // rename to kMaxNoNav ??
|
|---|
| 152 | G4VPhysicalVolume* fLastMassWorld;
|
|---|
| 153 |
|
|---|
| 154 | // Global state (retained during stepping for one track
|
|---|
| 155 | G4Navigator* fpNavigator[fMaxNav]; // G4Navigator** fpNavigator;
|
|---|
| 156 |
|
|---|
| 157 | // State after a step computation
|
|---|
| 158 | ELimited fLimitedStep[fMaxNav];
|
|---|
| 159 | G4bool fLimitTruth[fMaxNav];
|
|---|
| 160 | G4double fCurrentStepSize[fMaxNav];
|
|---|
| 161 | G4double fNewSafety[ fMaxNav ]; // Safety for starting point
|
|---|
| 162 |
|
|---|
| 163 | // Lowest values - determine step length, and safety
|
|---|
| 164 | G4double fMinStep; // As reported by Navigators. Can be kInfinity
|
|---|
| 165 | G4double fMinSafety;
|
|---|
| 166 | G4double fTrueMinStep; // Corrected in case fMinStep >= proposed
|
|---|
| 167 |
|
|---|
| 168 | // State after calling 'locate'
|
|---|
| 169 | G4VPhysicalVolume* fLocatedVolume[fMaxNav];
|
|---|
| 170 | G4ThreeVector fLastLocatedPosition;
|
|---|
| 171 |
|
|---|
| 172 | // cache of safety information
|
|---|
| 173 | G4ThreeVector fSafetyLocation; // point where ComputeSafety is called
|
|---|
| 174 | G4double fMinSafety_atSafLocation; // /\ corresponding value of safety
|
|---|
| 175 | G4ThreeVector fPreStepLocation; // point where last ComputeStep called
|
|---|
| 176 | G4double fMinSafety_PreStepPt; // /\ corresponding value of safety
|
|---|
| 177 |
|
|---|
| 178 | G4TransportationManager* pTransportManager; // Cache for frequent use
|
|---|
| 179 | };
|
|---|
| 180 |
|
|---|
| 181 | #endif
|
|---|