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] [ 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 /geometry/navigation/include/G4MultiNavigator.hh (Version 11.3.0) and /geometry/navigation/include/G4MultiNavigator.hh (Version 11.1.1)


  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 // class G4MultiNavigator                          26 // class G4MultiNavigator
 27 //                                                 27 //
 28 // Class description:                              28 // Class description:
 29 //                                                 29 //
 30 // Utility class for polling the navigators of     30 // Utility class for polling the navigators of several geometries to
 31 // identify the next boundary.                     31 // identify the next boundary. 
 32                                                    32 
 33 // History:                                        33 // History:
 34 // - Created. John Apostolakis, November 2006      34 // - Created. John Apostolakis, November 2006
 35 // -------------------------------------------     35 // --------------------------------------------------------------------
 36 #ifndef G4MULTINAVIGATOR_HH                        36 #ifndef G4MULTINAVIGATOR_HH
 37 #define G4MULTINAVIGATOR_HH                        37 #define G4MULTINAVIGATOR_HH
 38                                                    38 
 39 #include <iostream>                                39 #include <iostream>
 40                                                    40 
 41 #include "geomdefs.hh"                             41 #include "geomdefs.hh"
 42 #include "G4ThreeVector.hh"                        42 #include "G4ThreeVector.hh"
 43 #include "G4Navigator.hh"                          43 #include "G4Navigator.hh"
 44                                                    44 
 45 #include "G4TouchableHandle.hh"                <<  45 #include "G4TouchableHistoryHandle.hh"
 46                                                    46 
 47 #include "G4NavigationHistory.hh"                  47 #include "G4NavigationHistory.hh"
 48                                                    48 
 49 enum  ELimited { kDoNot,kUnique,kSharedTranspo     49 enum  ELimited { kDoNot,kUnique,kSharedTransport,kSharedOther,kUndefLimited };
 50                                                    50 
 51 class G4TransportationManager;                     51 class G4TransportationManager;
 52 class G4VPhysicalVolume;                           52 class G4VPhysicalVolume;
 53                                                    53 
 54 class G4MultiNavigator : public G4Navigator        54 class G4MultiNavigator : public G4Navigator
 55 {                                                  55 {
 56   public:  // with description                     56   public:  // with description
 57                                                    57 
 58   friend std::ostream& operator << (std::ostre     58   friend std::ostream& operator << (std::ostream& os, const G4Navigator& n);
 59                                                    59 
 60   G4MultiNavigator();                              60   G4MultiNavigator();
 61     // Constructor - initialisers and setup.       61     // Constructor - initialisers and setup.
 62                                                    62 
 63   ~G4MultiNavigator() override;                <<  63   ~G4MultiNavigator();
 64     // Destructor. No actions.                     64     // Destructor. No actions.
 65                                                    65 
 66   G4double ComputeStep( const G4ThreeVector& p     66   G4double ComputeStep( const G4ThreeVector& pGlobalPoint,
 67                         const G4ThreeVector& p     67                         const G4ThreeVector& pDirection,
 68                         const G4double       p     68                         const G4double       pCurrentProposedStepLength,
 69                               G4double&      p <<  69                               G4double&      pNewSafety );
 70     // Return the distance to the next boundar     70     // Return the distance to the next boundary of any geometry
 71                                                    71 
 72   G4double ObtainFinalStep( G4int        navig     72   G4double ObtainFinalStep( G4int        navigatorId, 
 73                             G4double&    pNewS     73                             G4double&    pNewSafety,     // for this geom 
 74                             G4double&    minSt     74                             G4double&    minStepLast,
 75                             ELimited&    limit     75                             ELimited&    limitedStep ); 
 76     // Get values for a single geometry            76     // Get values for a single geometry
 77                                                    77 
 78   void PrepareNavigators();                        78   void PrepareNavigators(); 
 79     // Find which geometries are registered fo     79     // Find which geometries are registered for this particles, and keep info
 80   void PrepareNewTrack( const G4ThreeVector& p <<  80   void PrepareNewTrack( const G4ThreeVector position, 
 81                         const G4ThreeVector di     81                         const G4ThreeVector direction ); 
 82     // Prepare Navigators and locate               82     // Prepare Navigators and locate 
 83                                                    83 
 84   G4VPhysicalVolume* ResetHierarchyAndLocate(      84   G4VPhysicalVolume* ResetHierarchyAndLocate( const G4ThreeVector& point,
 85                                    const G4Thr <<  85                                               const G4ThreeVector& direction,
 86                                    const G4Tou <<  86                                               const G4TouchableHistory& h );
 87     // Reset the geometrical hierarchy for all     87     // Reset the geometrical hierarchy for all geometries.
 88     // Use the touchable history for the first     88     // Use the touchable history for the first (mass) geometry.
 89     // Return the volume in the first (mass) g     89     // Return the volume in the first (mass) geometry.
 90     //                                             90     // 
 91     // Important Note: In order to call this t     91     // Important Note: In order to call this the geometries MUST be closed.
 92                                                    92 
 93   G4VPhysicalVolume* LocateGlobalPointAndSetup     93   G4VPhysicalVolume* LocateGlobalPointAndSetup( const G4ThreeVector& point,
 94                                    const G4Thr <<  94                                      const G4ThreeVector* direction = nullptr,
 95                                    const G4boo <<  95                                      const G4bool pRelativeSearch = true,
 96                                    const G4boo <<  96                                      const G4bool ignoreDirection = true);
 97     // Locate in all geometries.                   97     // Locate in all geometries.
 98     // Return the volume in the first (mass) g     98     // Return the volume in the first (mass) geometry
 99     //  Maintain vector of other volumes,  to      99     //  Maintain vector of other volumes,  to be returned separately
100     //                                            100     // 
101     // Important Note: In order to call this t    101     // Important Note: In order to call this the geometry MUST be closed.
102                                                   102 
103   void LocateGlobalPointWithinVolume( const G4 << 103   void LocateGlobalPointWithinVolume( const G4ThreeVector& position ); 
104     // Relocate in all geometries for point th    104     // Relocate in all geometries for point that has not changed volume
105     // (ie is within safety  in all geometries    105     // (ie is within safety  in all geometries or is distance less that 
106     // along the direction of a computed step.    106     // along the direction of a computed step.
107                                                   107 
108   G4double ComputeSafety( const G4ThreeVector&    108   G4double ComputeSafety( const G4ThreeVector& globalpoint,
109                           const G4double pProp    109                           const G4double pProposedMaxLength = DBL_MAX,
110                           const G4bool keepSta << 110                           const G4bool keepState = false );
111     // Calculate the isotropic distance to the    111     // Calculate the isotropic distance to the nearest boundary 
112     // in any geometry from the specified poin    112     // in any geometry from the specified point in the global coordinate
113     // system. The geometry must be closed.       113     // system. The geometry must be closed.
114                                                   114 
115   G4TouchableHandle CreateTouchableHistoryHand << 115   G4TouchableHistoryHandle CreateTouchableHistoryHandle() const;
116     // Returns a reference counted handle to a    116     // Returns a reference counted handle to a touchable history.
117                                                   117 
118   G4ThreeVector GetLocalExitNormal( G4bool* ob << 118   virtual G4ThreeVector GetLocalExitNormal( G4bool* obtained ); // const
119   G4ThreeVector GetLocalExitNormalAndCheck( co << 119   virtual G4ThreeVector GetLocalExitNormalAndCheck( const G4ThreeVector &E_Pt,
120                                             G4 << 120                                                     G4bool* obtained ); // const
121   G4ThreeVector GetGlobalExitNormal( const G4T << 121   virtual G4ThreeVector GetGlobalExitNormal( const G4ThreeVector &E_Pt,
122                                            G4b << 122                                                    G4bool* obtained ); // const
123     // Return Exit Surface Normal and validity    123     // Return Exit Surface Normal and validity too.
124     // Can only be called if the Navigator's l    124     // Can only be called if the Navigator's last Step either
125     //  - has just crossed a volume geometrica    125     //  - has just crossed a volume geometrical boundary and relocated, or
126     //  - has arrived at a boundary in a Compu    126     //  - has arrived at a boundary in a ComputeStep
127     // It returns the Normal to the surface po    127     // It returns the Normal to the surface pointing out of the volume that
128     //   was left behind and/or into the volum    128     //   was left behind and/or into the volume that was entered.
129     // Convention:x                               129     // Convention:x
130     //   The *local* normal is in the coordina    130     //   The *local* normal is in the coordinate system of the *final* volume.
131     // Restriction:                               131     // Restriction:
132     //   Normals are not available for replica    132     //   Normals are not available for replica volumes (returns obtained= false)
133                                                   133 
134  public:  // without description                  134  public:  // without description
135                                                   135 
136   inline G4Navigator* GetNavigator( G4int n )     136   inline G4Navigator* GetNavigator( G4int n ) const
137   {                                               137   { 
138     if( (n>fNoActiveNavigators) || (n<0) ) { n    138     if( (n>fNoActiveNavigators) || (n<0) ) { n=0; }
139     return fpNavigator[n];                        139     return fpNavigator[n]; 
140   }                                               140   }
141                                                   141 
142  protected:  // with description                  142  protected:  // with description
143                                                   143 
144   void ResetState() override;                  << 144   void ResetState();
145     // Utility method to reset the navigator s    145     // Utility method to reset the navigator state machine.
146                                                   146 
147   void SetupHierarchy() override;              << 147   void SetupHierarchy();
148     // Renavigate & reset hierarchy described     148     // Renavigate & reset hierarchy described by current history
149     // o Reset volumes                            149     // o Reset volumes
150     // o Recompute transforms and/or solids of    150     // o Recompute transforms and/or solids of replicated/parameterised
151     //   volumes.                                 151     //   volumes.
152                                                   152 
153   void WhichLimited(); // Flag which processes    153   void WhichLimited(); // Flag which processes limited the step
154   void PrintLimited(); // Auxiliary, debugging    154   void PrintLimited(); // Auxiliary, debugging printing 
155   void CheckMassWorld();                          155   void CheckMassWorld(); 
156                                                   156 
157  private:                                         157  private:
158                                                   158 
159    // STATE Information                           159    // STATE Information 
160                                                   160 
161    G4int fNoActiveNavigators = 0;                 161    G4int fNoActiveNavigators = 0; 
162    static const G4int fMaxNav = 16;               162    static const G4int fMaxNav = 16;
163    G4VPhysicalVolume* fLastMassWorld = nullptr    163    G4VPhysicalVolume* fLastMassWorld = nullptr; 
164                                                   164 
165    G4Navigator*  fpNavigator[fMaxNav];            165    G4Navigator*  fpNavigator[fMaxNav];
166      // Global state (retained during stepping    166      // Global state (retained during stepping for one track
167                                                   167 
168    // State after a step computation              168    // State after a step computation 
169    //                                             169    //
170    ELimited      fLimitedStep[fMaxNav];           170    ELimited      fLimitedStep[fMaxNav];
171    G4bool        fLimitTruth[fMaxNav];            171    G4bool        fLimitTruth[fMaxNav];
172    G4double      fCurrentStepSize[fMaxNav];       172    G4double      fCurrentStepSize[fMaxNav]; 
173    G4double      fNewSafety[ fMaxNav ]; // Saf    173    G4double      fNewSafety[ fMaxNav ]; // Safety for starting point
174    G4int         fNoLimitingStep = -1;  // How    174    G4int         fNoLimitingStep = -1;  // How many geometries limited the step
175    G4int         fIdNavLimiting = -1;   // Id     175    G4int         fIdNavLimiting = -1;   // Id of Navigator limiting step
176                                                   176 
177    // Lowest values - determine step length, a    177    // Lowest values - determine step length, and safety
178    //                                             178    //
179    G4double      fMinStep = -kInfinity; // As     179    G4double      fMinStep = -kInfinity; // As reported by Navigators
180    G4double      fMinSafety = -kInfinity;         180    G4double      fMinSafety = -kInfinity;
181    G4double      fTrueMinStep = -kInfinity; //    181    G4double      fTrueMinStep = -kInfinity; // Corrected if fMinStep>=proposed
182                                                   182 
183    // State after calling 'locate'                183    // State after calling 'locate'
184    //                                             184    //
185    G4VPhysicalVolume* fLocatedVolume[fMaxNav];    185    G4VPhysicalVolume* fLocatedVolume[fMaxNav];
186    G4ThreeVector      fLastLocatedPosition;       186    G4ThreeVector      fLastLocatedPosition; 
187                                                   187 
188    // Cache of safety information                 188    // Cache of safety information
189    //                                             189    //
190    G4ThreeVector fSafetyLocation;                 190    G4ThreeVector fSafetyLocation;
191      // point where ComputeSafety is called       191      // point where ComputeSafety is called
192    G4double      fMinSafety_atSafLocation = -1    192    G4double      fMinSafety_atSafLocation = -1.0;
193      // - corresponding value of safety           193      // - corresponding value of safety
194    G4ThreeVector fPreStepLocation;                194    G4ThreeVector fPreStepLocation;
195      // point where last ComputeStep called       195      // point where last ComputeStep called
196    G4double      fMinSafety_PreStepPt = -1.0;     196    G4double      fMinSafety_PreStepPt = -1.0;
197      // - corresponding value of safety           197      // - corresponding value of safety
198                                                   198 
199    G4TransportationManager* pTransportManager;    199    G4TransportationManager* pTransportManager; // Cache for frequent use
200 };                                                200 };
201                                                   201 
202 #endif                                            202 #endif
203                                                   203