Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-29 09:08:19

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4NavigationHistory
0027 //
0028 // Class description:
0029 //
0030 // Responsible for maintenance of the history of the path taken through
0031 // the geometrical hierarchy. Principally a utility class for use by the
0032 // G4Navigator.
0033 
0034 // Author: Paul Kent (CERN), 25.07.1996 - Initial version.
0035 //                   Services derived from requirements of G4Navigator.
0036 // ----------------------------------------------------------------------
0037 #ifndef G4NAVIGATIONHISTORY_HH
0038 #define G4NAVIGATIONHISTORY_HH
0039 
0040 #include <assert.h>
0041 #include <vector>
0042 #include <iostream>
0043 
0044 #include "geomdefs.hh"
0045 #include "geomwdefs.hh"
0046 #include "G4AffineTransform.hh"
0047 #include "G4VPhysicalVolume.hh"
0048 #include "G4NavigationLevel.hh"
0049 #include "G4NavigationHistoryPool.hh"
0050 #include "G4Allocator.hh"
0051 
0052 /**
0053  * @brief G4NavigationHistory is a class responsible for the maintenance
0054  * of the history of the path taken through the geometrical hierarchy.
0055  */
0056 
0057 class G4NavigationHistory
0058 {
0059   public:
0060 
0061     /**
0062      * Streaming operator.
0063      */
0064     friend std::ostream&
0065     operator << (std::ostream& os, const G4NavigationHistory& h);
0066 
0067     /**
0068      * Constructor. Sizes history lists & resets histories.
0069      */
0070     G4NavigationHistory();
0071 
0072     /**
0073      * Default Destructor.
0074      */
0075     ~G4NavigationHistory();
0076 
0077     /**
0078      * Copy contructor and assigment operator.
0079      */
0080     G4NavigationHistory(const G4NavigationHistory& h);
0081     inline G4NavigationHistory& operator=(const G4NavigationHistory& h);
0082 
0083     /**
0084      * Resets history. It does clear most entries. Level 0 is preserved.
0085      */
0086     inline void Reset();
0087 
0088     /**
0089      * Clears entries, zeroing transforms, matrices & negating replica history.
0090      */
0091     inline void Clear();
0092 
0093     /**
0094      * Setups the initial entry in stack: copies through volume transform 
0095      * and rotarion matrix. The volume 'pVol' is assumed to be unrotated.
0096      */
0097     inline void SetFirstEntry(G4VPhysicalVolume* pVol);
0098 
0099     /**
0100      * Returns the topmost transformation.
0101      */
0102     inline const G4AffineTransform& GetTopTransform() const; 
0103 
0104     /**
0105      * Returns a pointer to the topmost transformation.
0106      */
0107     inline const G4AffineTransform* GetPtrTopTransform() const;
0108 
0109     /**
0110      * Returns the topmost replica number record.
0111      */
0112     inline G4int GetTopReplicaNo() const;
0113 
0114     /**
0115      * Returns the topmost volume type.
0116      */
0117     inline EVolume GetTopVolumeType() const;
0118 
0119     /**
0120      * Returns the topmost physical volume pointer.
0121      */
0122     inline G4VPhysicalVolume* GetTopVolume() const;
0123 
0124     /**
0125      * Returns the current history depth.
0126      */
0127     inline std::size_t GetDepth() const;
0128 
0129     /**
0130      * Returns the current maximum size of the history. The maximum depth
0131      * is set to 16, meaning history entries [0..15] inclusive.
0132      */
0133     inline std::size_t GetMaxDepth() const;
0134 
0135     /**
0136      * Returns the specified transformation.
0137      *  @param[in] n The history level.
0138      */
0139     inline const G4AffineTransform& GetTransform(G4int n) const;
0140 
0141     /**
0142      * Returns the specified replica number record.
0143      *  @param[in] n The history level.
0144      */
0145     inline G4int GetReplicaNo(G4int n) const;
0146 
0147     /**
0148      * Returns the specified volume type.
0149      *  @param[in] n The history level.
0150      */
0151     inline EVolume GetVolumeType(G4int n) const;
0152 
0153     /**
0154      * Returns the specified physical volume pointer.
0155      *  @param[in] n The history level.
0156      */
0157     inline G4VPhysicalVolume* GetVolume(G4int n) const;
0158 
0159     /**
0160      * Changes the navigation level to that of the new mother.
0161      *  @param[in] pNewMother Pointer to the mother physical volume
0162      *  @param[in] vType The volume type.
0163      *  @param[in] nReplica The replica number.
0164      */
0165     inline void NewLevel(G4VPhysicalVolume* pNewMother,
0166                          EVolume vType = kNormal,
0167                          G4int nReplica = -1);
0168 
0169     /**
0170      * Backs up one level in history: from mother to grandmother.
0171      * It does not erase the history record of the current mother.
0172      */
0173     inline void BackLevel();
0174 
0175     /**
0176      * Backs up the specified number of levels in history.
0177      *  @param[in] n The history level.
0178      */
0179     inline void BackLevel(G4int n);
0180 
0181     /**
0182      * New/delete override for "G4Allocator".
0183      */
0184     inline void *operator new(std::size_t);
0185     inline void operator delete(void *aHistory);
0186 
0187   private:
0188 
0189     /**
0190      * Enlarges the history if required: increases the size by kHistoryStride.
0191      * Note that additional history entries are 'dirty' (non zero) apart
0192      * from the volume history.
0193      */
0194     inline void EnlargeHistory();
0195 
0196   private:
0197 
0198     /** Pointer to the vector of navigation levels. */
0199     std::vector<G4NavigationLevel>* fNavHistory;
0200 
0201     /** Depth of the stack: effectively depth in the geometrical tree. */
0202     std::size_t fStackDepth{0};
0203 };
0204 
0205 #include "G4NavigationHistory.icc"
0206 
0207 #endif