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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 //
 28 //
 29 // class G4ITMultiNavigator
 30 //
 31 // Class description:
 32 //
 33 // Utility class for polling the navigators of several geometries to
 34 // identify the next  boundary. 
 35 
 36 /// \brief { Class description:
 37 ///
 38 /// G4ITMultiNavigator is a duplicate version of G4MultiNavigator 
 39 ///
 40 /// Utility class for polling the navigators of several geometries to
 41 /// identify the next  boundary.
 42 ///
 43 /// }
 44 
 45 // History:
 46 // - Created. John Apostolakis, November 2006
 47 // *********************************************************************
 48 
 49 #ifndef G4ITMULTINAVIGATOR_HH
 50 #define G4ITMULTINAVIGATOR_HH
 51 
 52 #include <iostream>
 53 
 54 #include "geomdefs.hh"
 55 #include "G4ThreeVector.hh"
 56 #include "G4ITNavigator.hh"
 57 
 58 #include "G4TouchableHandle.hh"
 59 
 60 #include "G4NavigationHistory.hh"
 61 #include "G4TrackState.hh"
 62 #include "G4MultiNavigator.hh"
 63 
 64 namespace G4ITMN
 65 {
 66 enum ELimited
 67 {
 68   kDoNot,
 69   kUnique,
 70   kSharedTransport,
 71   kSharedOther,
 72   kUndefLimited
 73 };
 74 }
 75 class G4ITTransportationManager;
 76 class G4VPhysicalVolume;
 77 
 78 class G4ITMultiNavigator;
 79 
 80 // Global state (retained during stepping for one track
 81 template<>
 82   class G4TrackState<G4ITMultiNavigator> : public G4TrackState<G4ITNavigator>
 83   {
 84   public:
 85     ~G4TrackState() override
 86     = default;
 87 
 88     G4TrackState()
 89     {
 90       G4ThreeVector Big3Vector(kInfinity, kInfinity, kInfinity);
 91       fLastLocatedPosition = Big3Vector;
 92       fSafetyLocation = Big3Vector;
 93       fPreStepLocation = Big3Vector;
 94 
 95       fMinSafety_PreStepPt = -1.0;
 96       fMinSafety_atSafLocation = -1.0;
 97       fMinSafety = -kInfinity;
 98       fTrueMinStep = fMinStep = -kInfinity;
 99 
100       for (G4int num = 0; num < G4ITNavigator::fMaxNav; ++num)
101       {
102         fLimitTruth[num] = false;
103         fLimitedStep[num] = kUndefLimited;
104         fCurrentStepSize[num] = fNewSafety[num] = -1.0;
105         fLocatedVolume[num] = nullptr;
106       }
107 
108       fNoLimitingStep = -1; // How many geometries limited the step
109       fIdNavLimiting = -1; // Id of Navigator limiting step (if only one limits)
110       fWasLimitedByGeometry = false;
111     }
112     ;
113 
114   protected:
115     friend class G4ITMultiNavigator;
116     // State after a step computation
117     ELimited fLimitedStep[G4ITNavigator::fMaxNav];
118     G4bool fLimitTruth[G4ITNavigator::fMaxNav];
119     G4double fCurrentStepSize[G4ITNavigator::fMaxNav];
120     G4double fNewSafety[G4ITNavigator::fMaxNav]; // Safety for starting point
121     G4int fNoLimitingStep; // How many geometries limited the step
122     G4int fIdNavLimiting; // Id of Navigator limiting step (if only one limits)
123 
124     G4bool fWasLimitedByGeometry;
125 
126     // Lowest values - determine step length, and safety
127     G4double fMinStep; // As reported by Navigators. Can be kInfinity
128     G4double fMinSafety;
129     G4double fTrueMinStep; // Corrected in case fMinStep >= proposed
130 
131     // State after calling 'locate'
132     G4VPhysicalVolume* fLocatedVolume[G4ITNavigator::fMaxNav];
133     G4ThreeVector fLastLocatedPosition;
134 
135     // cache of safety information
136     G4ThreeVector fSafetyLocation; //  point where ComputeSafety is called
137     G4double fMinSafety_atSafLocation; // /\ corresponding value of safety
138     G4ThreeVector fPreStepLocation; //  point where last ComputeStep called
139     G4double fMinSafety_PreStepPt; //   /\ corresponding value of safety
140   };
141 
142 class G4ITMultiNavigator : public G4ITNavigator,
143                            public G4TrackStateDependent<G4ITMultiNavigator>
144 {
145 public:
146   // with description
147 
148   friend std::ostream& operator <<(std::ostream &os, const G4ITNavigator &n);
149 
150   G4ITMultiNavigator();
151   // Constructor - initialisers and setup.
152 
153   ~G4ITMultiNavigator() override;
154   // Destructor. No actions.
155 
156   G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
157                        const G4ThreeVector &pDirection,
158                        const G4double pCurrentProposedStepLength,
159                        G4double &pNewSafety) override;
160   // Return the distance to the next boundary of any geometry
161 
162   G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, // for this geom
163                            G4double &minStepLast,
164                            ELimited &limitedStep);
165   // Get values for a single geometry
166 
167   void PrepareNavigators();
168   // Find which geometries are registered for this particles, and keep info
169   void PrepareNewTrack(const G4ThreeVector position,
170                        const G4ThreeVector direction);
171   // Prepare Navigators and locate
172 
173   G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point,
174                                              const G4ThreeVector &direction,
175                                              const G4TouchableHistory &h) override;
176   // Reset the geometrical hierarchy for all geometries.
177   // Use the touchable history for the first (mass) geometry.
178   // Return the volume in the first (mass) geometry.
179   //
180   // Important Note: In order to call this the geometries MUST be closed.
181 
182   G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
183                                                const G4ThreeVector* direction =
184                                                    nullptr,
185                                                const G4bool pRelativeSearch =
186                                                    true,
187                                                const G4bool ignoreDirection =
188                                                    true) override;
189   // Locate in all geometries.
190   // Return the volume in the first (mass) geometry
191   //  Maintain vector of other volumes,  to be returned separately
192   //
193   // Important Note: In order to call this the geometry MUST be closed.
194 
195   void LocateGlobalPointWithinVolume(const G4ThreeVector& position) override;
196   // Relocate in all geometries for point that has not changed volume
197   // (ie is within safety  in all geometries or is distance less that
198   // along the direction of a computed step.
199 
200   G4double ComputeSafety(const G4ThreeVector &globalpoint,
201                          const G4double pProposedMaxLength = DBL_MAX,
202                          const G4bool keepState = false) override;
203                          // Calculate the isotropic distance to the nearest boundary
204                          // in any geometry from the specified point in the global coordinate
205                          // system. The geometry must be closed.
206 
207   G4TouchableHandle CreateTouchableHistoryHandle() const override;
208   // Returns a reference counted handle to a touchable history.
209 
210   G4ThreeVector GetLocalExitNormal(G4bool* obtained) override;// const
211   G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point,
212   G4bool* obtained) override;// const
213   G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point,
214   G4bool* obtained) override;// const
215   // Return Exit Surface Normal and validity too.
216   // Can only be called if the Navigator's last Step either
217   //  - has just crossed a volume geometrical boundary and relocated, or
218   //  - has arrived at a boundary in a ComputeStep
219   // It returns the Normal to the surface pointing out of the volume that
220   //   was left behind and/or into the volume that was entered.
221   // Convention:x
222   //   The *local* normal is in the coordinate system of the *final* volume.
223   // Restriction:
224   //   Normals are not available for replica volumes (returns obtained= false)
225 
226 public:// without description
227 
228  G4ITNavigator* GetNavigator(G4int n) const
229  {
230    if( (n>fNoActiveNavigators)||(n<0))
231    { n=0;}
232    return fpNavigator[n];
233  }
234 
235 protected: // with description
236 
237   void ResetState() override;
238   // Utility method to reset the navigator state machine.
239 
240   void SetupHierarchy() override;
241   // Renavigate & reset hierarchy described by current history
242   // o Reset volumes
243   // o Recompute transforms and/or solids of replicated/parameterised
244   //   volumes.
245 
246   void WhichLimited();// Flag which processes limited the step
247   void PrintLimited();// Auxiliary, debugging printing
248   void CheckMassWorld();
249 
250 private:
251 
252   G4int fNoActiveNavigators;
253   G4VPhysicalVolume* fLastMassWorld{nullptr};
254 
255   G4ITNavigator* fpNavigator[fMaxNav];// G4ITNavigator** fpNavigator;
256 
257   G4ITTransportationManager* pTransportManager;// Cache for frequent use
258 };
259 
260 #endif
261