Geant4 Cross Reference |
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 // G4TouchableHistory 27 // 28 // Class description: 29 // 30 // Object representing a touchable detector element, and its history in the 31 // geometrical hierarchy, including its net resultant local->global transform. 32 // 33 // Touchables are objects capable of maintaining an 34 // association between parts of the geometrical hierarchy (volumes 35 // &/or solids) and their resultant transformation. 36 // 37 // Utilisation: 38 // ----------- 39 // A touchable is a geometrical volume (solid) which has a unique 40 // placement in a detector description. It is an abstract base class which 41 // can be implemented in a variety of ways. Each way must provide the 42 // capabilities of obtaining the transformation and solid that is described 43 // by the touchable. 44 // 45 // All touchable implementations must respond to the two following "requests": 46 // 47 // 1) GetTranslation and GetRotation that return the components of the 48 // volume's transformation. 49 // 50 // 2) GetSolid that gives the solid of this touchable. 51 // 52 // 53 // Additional capabilities are available from implementations with more 54 // information. These have a default implementation that causes an exception. 55 // 56 // Several capabilities are available from touchables with physical volumes: 57 // 58 // 3) GetVolume gives the physical volume. 59 // 60 // 4) GetReplicaNumber or GetCopyNumber gives the copy number of the 61 // physical volume, either if it is replicated or not. 62 // 63 // Touchables that store volume hierarchy (history) have the whole stack of 64 // parent volumes available. Thus it is possible to add a little more state 65 // in order to extend its functionality. We add a "pointer" to a level and a 66 // member function to move the level in this stack. Then calling the above 67 // member functions for another level, the information for that level can be 68 // retrieved. 69 // 70 // The top of the history tree is, by convention, the world volume. 71 // 72 // 5) GetHistoryDepth gives the depth of the history tree. 73 // 74 // 6) GetReplicaNumber/GetCopyNumber, GetVolume, GetTranslation and 75 // GetRotation each can be called with a depth argument. 76 // They return the value of the respective level of the touchable. 77 // 78 // 7) MoveUpHistory(num) moves the current pointer inside the touchable 79 // to point "num" levels up the history tree. Thus, eg, calling 80 // it with num=1 will cause the internal pointer to move to the mother 81 // of the current volume. 82 // NOTE: this method MODIFIES the touchable. 83 // 84 // An update method, with different arguments is available, so that the 85 // information in a touchable can be updated: 86 // 87 // 8) UpdateYourself takes a physical volume pointer and can additionally 88 // take a NavigationHistory. 89 90 // Created: Paul Kent, August 1996 91 // ---------------------------------------------------------------------- 92 #ifndef G4TOUCHABLEHISTORY_HH 93 #define G4TOUCHABLEHISTORY_HH 94 95 #include "G4NavigationHistory.hh" 96 #include "G4Allocator.hh" 97 #include "G4LogicalVolume.hh" 98 #include "G4ThreeVector.hh" 99 #include "G4RotationMatrix.hh" 100 101 #include "geomwdefs.hh" 102 103 class G4TouchableHistory 104 { 105 public: 106 107 G4TouchableHistory(); 108 // The default constructor produces a touchable-history of 109 // 'zero-depth', ie an "unphysical" and not very unusable one. 110 // It is for initialisation only. 111 112 G4TouchableHistory( const G4NavigationHistory& history ); 113 // Copy constructor 114 115 virtual ~G4TouchableHistory(); 116 // Destructor 117 118 inline virtual G4VPhysicalVolume* GetVolume( G4int depth = 0 ) const; 119 inline virtual G4VSolid* GetSolid( G4int depth = 0 ) const; 120 virtual const G4ThreeVector& GetTranslation( G4int depth = 0 ) const; 121 virtual const G4RotationMatrix* GetRotation( G4int depth = 0 ) const; 122 123 inline virtual G4int GetReplicaNumber( G4int depth = 0 ) const; 124 inline G4int GetCopyNumber( G4int depth = 0 ) const; 125 inline virtual G4int GetHistoryDepth() const; 126 virtual G4int MoveUpHistory( G4int num_levels = 1 ); 127 // Access methods for touchables with history 128 129 virtual void UpdateYourself( G4VPhysicalVolume* pPhysVol, 130 const G4NavigationHistory* history = nullptr ); 131 // Update methods for touchables with history 132 133 inline virtual const G4NavigationHistory* GetHistory() const; 134 // Internal: used in G4Navigator::LocateGlobalPointAndSetup(). 135 136 inline void* operator new(std::size_t); 137 inline void operator delete(void* aTH); 138 // Override "new" and "delete" to use "G4Allocator". 139 140 private: 141 142 inline G4int CalculateHistoryIndex( G4int stackDepth ) const; 143 144 G4RotationMatrix frot; 145 G4ThreeVector ftlate; 146 G4NavigationHistory fhistory; 147 }; 148 149 #include "G4TouchableHistory.icc" 150 151 #endif 152