Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:43

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 // 25.07.96 - P.Kent Initial version. Services derived from
0035 //                   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 class G4NavigationHistory
0053 {
0054 
0055  public:  // with description
0056 
0057   friend std::ostream&
0058   operator << (std::ostream& os, const G4NavigationHistory& h);
0059 
0060   G4NavigationHistory();
0061     // Constructor: sizes history lists & resets histories.
0062 
0063   ~G4NavigationHistory();
0064     // Destructor.
0065 
0066   G4NavigationHistory(const G4NavigationHistory& h);
0067     // Copy constructor.
0068 
0069   inline G4NavigationHistory& operator=(const G4NavigationHistory& h);
0070     // Assignment operator.
0071 
0072   inline void Reset();
0073     // Resets history. It now does clear most entries.
0074     // Level 0 is preserved.
0075 
0076   inline void Clear();
0077     // Clears entries, zeroing transforms, matrices & negating
0078     // replica history.
0079 
0080   inline void SetFirstEntry(G4VPhysicalVolume* pVol);
0081     // Setup initial entry in stack: copies through volume transform & matrix.
0082     // The volume is assumed to be unrotated.
0083 
0084   inline const G4AffineTransform& GetTopTransform() const; 
0085     // Returns topmost transform.
0086 
0087   inline const G4AffineTransform* GetPtrTopTransform() const;
0088     // Returns pointer to topmost transform.
0089 
0090   inline G4int GetTopReplicaNo() const;
0091     // Returns topmost replica no record.
0092 
0093   inline EVolume GetTopVolumeType() const;
0094     // Returns topmost volume type.
0095 
0096   inline G4VPhysicalVolume* GetTopVolume() const;
0097     // Returns topmost physical volume pointer.
0098 
0099   inline std::size_t GetDepth() const;
0100     // Returns current history depth.
0101 
0102   inline std::size_t GetMaxDepth() const;
0103     // Returns current maximum size of history.
0104     // Note: MaxDepth of 16 mean history entries [0..15] inclusive.
0105 
0106   inline const G4AffineTransform& GetTransform(G4int n) const;
0107     // Returns specified transformation.
0108 
0109   inline G4int GetReplicaNo(G4int n) const;
0110     // Returns specified replica no record.
0111 
0112   inline EVolume GetVolumeType(G4int n) const;
0113     // Returns specified volume type.
0114 
0115   inline G4VPhysicalVolume* GetVolume(G4int n) const;
0116     // Returns specified physical volume pointer.
0117 
0118   inline void NewLevel(G4VPhysicalVolume* pNewMother,
0119                        EVolume vType = kNormal,
0120                        G4int nReplica = -1);
0121     // Changes navigation level to that of the new mother.
0122 
0123   inline void BackLevel();
0124     // Back up one level in history: from mother to grandmother.
0125     // It does not erase history record of current mother.
0126 
0127   inline void BackLevel(G4int n);
0128     // Back up specified number of levels in history.
0129 
0130   inline void *operator new(std::size_t);
0131     // Override "new" for "G4Allocator".
0132   inline void operator delete(void *aHistory);
0133     // Override "delete" for "G4Allocator".
0134 
0135  private:
0136 
0137   inline void EnlargeHistory();
0138     // Enlarge history if required: increase size by kHistoryStride.
0139     // Note that additional history entries are `dirty' (non zero) apart
0140     // from the volume history.
0141 
0142  private:
0143 
0144   std::vector<G4NavigationLevel>* fNavHistory;
0145     // Pointer to the vector of navigation levels.
0146 
0147   std::size_t fStackDepth{0};
0148     // Depth of stack: effectively depth in geometrical tree.
0149 };
0150 
0151 #include "G4NavigationHistory.icc"
0152 
0153 #endif