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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 ]

Diff markup

Differences between /processes/electromagnetic/dna/management/include/G4ITMultiNavigator.hh (Version 11.3.0) and /processes/electromagnetic/dna/management/include/G4ITMultiNavigator.hh (Version 11.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 //                                                 27 //
 28 //                                                 28 //
 29 // class G4ITMultiNavigator                        29 // class G4ITMultiNavigator
 30 //                                                 30 //
 31 // Class description:                              31 // Class description:
 32 //                                                 32 //
 33 // Utility class for polling the navigators of     33 // Utility class for polling the navigators of several geometries to
 34 // identify the next  boundary.                    34 // identify the next  boundary. 
 35                                                    35 
 36 /// \brief { Class description:                    36 /// \brief { Class description:
 37 ///                                                37 ///
 38 /// G4ITMultiNavigator is a duplicate version      38 /// G4ITMultiNavigator is a duplicate version of G4MultiNavigator 
 39 ///                                                39 ///
 40 /// Utility class for polling the navigators o     40 /// Utility class for polling the navigators of several geometries to
 41 /// identify the next  boundary.                   41 /// identify the next  boundary.
 42 ///                                                42 ///
 43 /// }                                              43 /// }
 44                                                    44 
 45 // History:                                        45 // History:
 46 // - Created. John Apostolakis, November 2006      46 // - Created. John Apostolakis, November 2006
 47 // *******************************************     47 // *********************************************************************
 48                                                    48 
 49 #ifndef G4ITMULTINAVIGATOR_HH                      49 #ifndef G4ITMULTINAVIGATOR_HH
 50 #define G4ITMULTINAVIGATOR_HH                      50 #define G4ITMULTINAVIGATOR_HH
 51                                                    51 
 52 #include <iostream>                                52 #include <iostream>
 53                                                    53 
 54 #include "geomdefs.hh"                             54 #include "geomdefs.hh"
 55 #include "G4ThreeVector.hh"                        55 #include "G4ThreeVector.hh"
 56 #include "G4ITNavigator.hh"                        56 #include "G4ITNavigator.hh"
 57                                                    57 
 58 #include "G4TouchableHandle.hh"                <<  58 #include "G4TouchableHistoryHandle.hh"
 59                                                    59 
 60 #include "G4NavigationHistory.hh"                  60 #include "G4NavigationHistory.hh"
 61 #include "G4TrackState.hh"                         61 #include "G4TrackState.hh"
 62 #include "G4MultiNavigator.hh"                     62 #include "G4MultiNavigator.hh"
 63                                                    63 
 64 namespace G4ITMN                                   64 namespace G4ITMN
 65 {                                                  65 {
 66 enum ELimited                                      66 enum ELimited
 67 {                                                  67 {
 68   kDoNot,                                          68   kDoNot,
 69   kUnique,                                         69   kUnique,
 70   kSharedTransport,                                70   kSharedTransport,
 71   kSharedOther,                                    71   kSharedOther,
 72   kUndefLimited                                    72   kUndefLimited
 73 };                                                 73 };
 74 }                                                  74 }
 75 class G4ITTransportationManager;                   75 class G4ITTransportationManager;
 76 class G4VPhysicalVolume;                           76 class G4VPhysicalVolume;
 77                                                    77 
 78 class G4ITMultiNavigator;                          78 class G4ITMultiNavigator;
 79                                                    79 
 80 // Global state (retained during stepping for      80 // Global state (retained during stepping for one track
 81 template<>                                         81 template<>
 82   class G4TrackState<G4ITMultiNavigator> : pub     82   class G4TrackState<G4ITMultiNavigator> : public G4TrackState<G4ITNavigator>
 83   {                                                83   {
 84   public:                                          84   public:
 85     ~G4TrackState() override                   <<  85     ~G4TrackState()
 86     = default;                                 <<  86     {
                                                   >>  87     }
 87                                                    88 
 88     G4TrackState()                                 89     G4TrackState()
 89     {                                              90     {
 90       G4ThreeVector Big3Vector(kInfinity, kInf     91       G4ThreeVector Big3Vector(kInfinity, kInfinity, kInfinity);
 91       fLastLocatedPosition = Big3Vector;           92       fLastLocatedPosition = Big3Vector;
 92       fSafetyLocation = Big3Vector;                93       fSafetyLocation = Big3Vector;
 93       fPreStepLocation = Big3Vector;               94       fPreStepLocation = Big3Vector;
 94                                                    95 
 95       fMinSafety_PreStepPt = -1.0;                 96       fMinSafety_PreStepPt = -1.0;
 96       fMinSafety_atSafLocation = -1.0;             97       fMinSafety_atSafLocation = -1.0;
 97       fMinSafety = -kInfinity;                     98       fMinSafety = -kInfinity;
 98       fTrueMinStep = fMinStep = -kInfinity;        99       fTrueMinStep = fMinStep = -kInfinity;
 99                                                   100 
100       for (G4int num = 0; num < G4ITNavigator:    101       for (G4int num = 0; num < G4ITNavigator::fMaxNav; ++num)
101       {                                           102       {
102         fLimitTruth[num] = false;                 103         fLimitTruth[num] = false;
103         fLimitedStep[num] = kUndefLimited;        104         fLimitedStep[num] = kUndefLimited;
104         fCurrentStepSize[num] = fNewSafety[num    105         fCurrentStepSize[num] = fNewSafety[num] = -1.0;
105         fLocatedVolume[num] = nullptr;         << 106         fLocatedVolume[num] = 0;
106       }                                           107       }
107                                                   108 
108       fNoLimitingStep = -1; // How many geomet    109       fNoLimitingStep = -1; // How many geometries limited the step
109       fIdNavLimiting = -1; // Id of Navigator     110       fIdNavLimiting = -1; // Id of Navigator limiting step (if only one limits)
110       fWasLimitedByGeometry = false;              111       fWasLimitedByGeometry = false;
111     }                                             112     }
112     ;                                             113     ;
113                                                   114 
114   protected:                                      115   protected:
115     friend class G4ITMultiNavigator;              116     friend class G4ITMultiNavigator;
116     // State after a step computation             117     // State after a step computation
117     ELimited fLimitedStep[G4ITNavigator::fMaxN    118     ELimited fLimitedStep[G4ITNavigator::fMaxNav];
118     G4bool fLimitTruth[G4ITNavigator::fMaxNav]    119     G4bool fLimitTruth[G4ITNavigator::fMaxNav];
119     G4double fCurrentStepSize[G4ITNavigator::f    120     G4double fCurrentStepSize[G4ITNavigator::fMaxNav];
120     G4double fNewSafety[G4ITNavigator::fMaxNav    121     G4double fNewSafety[G4ITNavigator::fMaxNav]; // Safety for starting point
121     G4int fNoLimitingStep; // How many geometr    122     G4int fNoLimitingStep; // How many geometries limited the step
122     G4int fIdNavLimiting; // Id of Navigator l    123     G4int fIdNavLimiting; // Id of Navigator limiting step (if only one limits)
123                                                   124 
124     G4bool fWasLimitedByGeometry;                 125     G4bool fWasLimitedByGeometry;
125                                                   126 
126     // Lowest values - determine step length,     127     // Lowest values - determine step length, and safety
127     G4double fMinStep; // As reported by Navig    128     G4double fMinStep; // As reported by Navigators. Can be kInfinity
128     G4double fMinSafety;                          129     G4double fMinSafety;
129     G4double fTrueMinStep; // Corrected in cas    130     G4double fTrueMinStep; // Corrected in case fMinStep >= proposed
130                                                   131 
131     // State after calling 'locate'               132     // State after calling 'locate'
132     G4VPhysicalVolume* fLocatedVolume[G4ITNavi    133     G4VPhysicalVolume* fLocatedVolume[G4ITNavigator::fMaxNav];
133     G4ThreeVector fLastLocatedPosition;           134     G4ThreeVector fLastLocatedPosition;
134                                                   135 
135     // cache of safety information                136     // cache of safety information
136     G4ThreeVector fSafetyLocation; //  point w    137     G4ThreeVector fSafetyLocation; //  point where ComputeSafety is called
137     G4double fMinSafety_atSafLocation; // /\ c    138     G4double fMinSafety_atSafLocation; // /\ corresponding value of safety
138     G4ThreeVector fPreStepLocation; //  point     139     G4ThreeVector fPreStepLocation; //  point where last ComputeStep called
139     G4double fMinSafety_PreStepPt; //   /\ cor    140     G4double fMinSafety_PreStepPt; //   /\ corresponding value of safety
140   };                                              141   };
141                                                   142 
142 class G4ITMultiNavigator : public G4ITNavigato    143 class G4ITMultiNavigator : public G4ITNavigator,
143                            public G4TrackState    144                            public G4TrackStateDependent<G4ITMultiNavigator>
144 {                                                 145 {
145 public:                                           146 public:
146   // with description                             147   // with description
147                                                   148 
148   friend std::ostream& operator <<(std::ostrea    149   friend std::ostream& operator <<(std::ostream &os, const G4ITNavigator &n);
149                                                   150 
150   G4ITMultiNavigator();                           151   G4ITMultiNavigator();
151   // Constructor - initialisers and setup.        152   // Constructor - initialisers and setup.
152                                                   153 
153   ~G4ITMultiNavigator() override;              << 154   ~G4ITMultiNavigator();
154   // Destructor. No actions.                      155   // Destructor. No actions.
155                                                   156 
156   G4double ComputeStep(const G4ThreeVector &pG    157   G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
157                        const G4ThreeVector &pD    158                        const G4ThreeVector &pDirection,
158                        const G4double pCurrent    159                        const G4double pCurrentProposedStepLength,
159                        G4double &pNewSafety) o << 160                        G4double &pNewSafety);
160   // Return the distance to the next boundary     161   // Return the distance to the next boundary of any geometry
161                                                   162 
162   G4double ObtainFinalStep(G4int navigatorId,     163   G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, // for this geom
163                            G4double &minStepLa    164                            G4double &minStepLast,
164                            ELimited &limitedSt    165                            ELimited &limitedStep);
165   // Get values for a single geometry             166   // Get values for a single geometry
166                                                   167 
167   void PrepareNavigators();                       168   void PrepareNavigators();
168   // Find which geometries are registered for     169   // Find which geometries are registered for this particles, and keep info
169   void PrepareNewTrack(const G4ThreeVector pos    170   void PrepareNewTrack(const G4ThreeVector position,
170                        const G4ThreeVector dir    171                        const G4ThreeVector direction);
171   // Prepare Navigators and locate                172   // Prepare Navigators and locate
172                                                   173 
173   G4VPhysicalVolume* ResetHierarchyAndLocate(c    174   G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point,
174                                              c    175                                              const G4ThreeVector &direction,
175                                              c << 176                                              const G4TouchableHistory &h);
176   // Reset the geometrical hierarchy for all g    177   // Reset the geometrical hierarchy for all geometries.
177   // Use the touchable history for the first (    178   // Use the touchable history for the first (mass) geometry.
178   // Return the volume in the first (mass) geo    179   // Return the volume in the first (mass) geometry.
179   //                                              180   //
180   // Important Note: In order to call this the    181   // Important Note: In order to call this the geometries MUST be closed.
181                                                   182 
182   G4VPhysicalVolume* LocateGlobalPointAndSetup    183   G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
183                                                   184                                                const G4ThreeVector* direction =
184                                                << 185                                                    0,
185                                                   186                                                const G4bool pRelativeSearch =
186                                                   187                                                    true,
187                                                   188                                                const G4bool ignoreDirection =
188                                                << 189                                                    true);
189   // Locate in all geometries.                    190   // Locate in all geometries.
190   // Return the volume in the first (mass) geo    191   // Return the volume in the first (mass) geometry
191   //  Maintain vector of other volumes,  to be    192   //  Maintain vector of other volumes,  to be returned separately
192   //                                              193   //
193   // Important Note: In order to call this the    194   // Important Note: In order to call this the geometry MUST be closed.
194                                                   195 
195   void LocateGlobalPointWithinVolume(const G4T << 196   void LocateGlobalPointWithinVolume(const G4ThreeVector& position);
196   // Relocate in all geometries for point that    197   // Relocate in all geometries for point that has not changed volume
197   // (ie is within safety  in all geometries o    198   // (ie is within safety  in all geometries or is distance less that
198   // along the direction of a computed step.      199   // along the direction of a computed step.
199                                                   200 
200   G4double ComputeSafety(const G4ThreeVector &    201   G4double ComputeSafety(const G4ThreeVector &globalpoint,
201                          const G4double pPropo    202                          const G4double pProposedMaxLength = DBL_MAX,
202                          const G4bool keepStat << 203                          const G4bool keepState = false);
203                          // Calculate the isot    204                          // Calculate the isotropic distance to the nearest boundary
204                          // in any geometry fr    205                          // in any geometry from the specified point in the global coordinate
205                          // system. The geomet    206                          // system. The geometry must be closed.
206                                                   207 
207   G4TouchableHandle CreateTouchableHistoryHand << 208   G4TouchableHistoryHandle CreateTouchableHistoryHandle() const;
208   // Returns a reference counted handle to a t    209   // Returns a reference counted handle to a touchable history.
209                                                   210 
210   G4ThreeVector GetLocalExitNormal(G4bool* obt << 211   virtual G4ThreeVector GetLocalExitNormal(G4bool* obtained);// const
211   G4ThreeVector GetLocalExitNormalAndCheck(con << 212   virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point,
212   G4bool* obtained) override;// const          << 213   G4bool* obtained);// const
213   G4ThreeVector GetGlobalExitNormal(const G4Th << 214   virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point,
214   G4bool* obtained) override;// const          << 215   G4bool* obtained);// const
215   // Return Exit Surface Normal and validity t    216   // Return Exit Surface Normal and validity too.
216   // Can only be called if the Navigator's las    217   // Can only be called if the Navigator's last Step either
217   //  - has just crossed a volume geometrical     218   //  - has just crossed a volume geometrical boundary and relocated, or
218   //  - has arrived at a boundary in a Compute    219   //  - has arrived at a boundary in a ComputeStep
219   // It returns the Normal to the surface poin    220   // It returns the Normal to the surface pointing out of the volume that
220   //   was left behind and/or into the volume     221   //   was left behind and/or into the volume that was entered.
221   // Convention:x                                 222   // Convention:x
222   //   The *local* normal is in the coordinate    223   //   The *local* normal is in the coordinate system of the *final* volume.
223   // Restriction:                                 224   // Restriction:
224   //   Normals are not available for replica v    225   //   Normals are not available for replica volumes (returns obtained= false)
225                                                   226 
226 public:// without description                     227 public:// without description
227                                                   228 
228  G4ITNavigator* GetNavigator(G4int n) const       229  G4ITNavigator* GetNavigator(G4int n) const
229  {                                                230  {
230    if( (n>fNoActiveNavigators)||(n<0))            231    if( (n>fNoActiveNavigators)||(n<0))
231    { n=0;}                                        232    { n=0;}
232    return fpNavigator[n];                         233    return fpNavigator[n];
233  }                                                234  }
234                                                   235 
235 protected: // with description                    236 protected: // with description
236                                                   237 
237   void ResetState() override;                  << 238   void ResetState();
238   // Utility method to reset the navigator sta    239   // Utility method to reset the navigator state machine.
239                                                   240 
240   void SetupHierarchy() override;              << 241   void SetupHierarchy();
241   // Renavigate & reset hierarchy described by    242   // Renavigate & reset hierarchy described by current history
242   // o Reset volumes                              243   // o Reset volumes
243   // o Recompute transforms and/or solids of r    244   // o Recompute transforms and/or solids of replicated/parameterised
244   //   volumes.                                   245   //   volumes.
245                                                   246 
246   void WhichLimited();// Flag which processes     247   void WhichLimited();// Flag which processes limited the step
247   void PrintLimited();// Auxiliary, debugging     248   void PrintLimited();// Auxiliary, debugging printing
248   void CheckMassWorld();                          249   void CheckMassWorld();
249                                                   250 
250 private:                                          251 private:
251                                                   252 
252   G4int fNoActiveNavigators;                      253   G4int fNoActiveNavigators;
253   G4VPhysicalVolume* fLastMassWorld{nullptr};  << 254   G4VPhysicalVolume* fLastMassWorld;
254                                                   255 
255   G4ITNavigator* fpNavigator[fMaxNav];// G4ITN    256   G4ITNavigator* fpNavigator[fMaxNav];// G4ITNavigator** fpNavigator;
256                                                   257 
257   G4ITTransportationManager* pTransportManager    258   G4ITTransportationManager* pTransportManager;// Cache for frequent use
258 };                                                259 };
259                                                   260 
260 #endif                                            261 #endif
261                                                   262