Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TouchableHistory.hh
Go to the documentation of this file.
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.
41// It must respond to the two following "requests":
42//
43// 1) GetTranslation and GetRotation that return the components of the
44// volume's transformation.
45//
46// 2) GetSolid that gives the solid of this touchable.
47//
48// Additional capabilities are available from implementations with more
49// information. These have a default implementation that causes an exception.
50//
51// Several capabilities are available from touchables with physical volumes:
52//
53// 3) GetVolume gives the physical volume.
54//
55// 4) GetReplicaNumber or GetCopyNumber gives the copy number of the
56// physical volume, either if it is replicated or not.
57//
58// Touchables that store volume hierarchy (history) have the whole stack of
59// parent volumes available. Thus it is possible to add a little more state
60// in order to extend its functionality. We add a "pointer" to a level and a
61// member function to move the level in this stack. Then calling the above
62// member functions for another level, the information for that level can be
63// retrieved.
64//
65// The top of the history tree is, by convention, the world volume.
66//
67// 5) GetHistoryDepth gives the depth of the history tree.
68//
69// 6) GetReplicaNumber/GetCopyNumber, GetVolume, GetTranslation and
70// GetRotation each can be called with a depth argument.
71// They return the value of the respective level of the touchable.
72//
73// 7) MoveUpHistory(num) moves the current pointer inside the touchable
74// to point "num" levels up the history tree. Thus, eg, calling
75// it with num=1 will cause the internal pointer to move to the mother
76// of the current volume.
77// NOTE: this method MODIFIES the touchable.
78//
79// An update method, with different arguments is available, so that the
80// information in a touchable can be updated:
81//
82// 8) UpdateYourself takes a physical volume pointer and can additionally
83// take a NavigationHistory.
84
85// Author: Paul Kent (CERN), August 1996
86// ----------------------------------------------------------------------
87#ifndef G4TOUCHABLEHISTORY_HH
88#define G4TOUCHABLEHISTORY_HH
89
91#include "G4Allocator.hh"
92#include "G4LogicalVolume.hh"
93#include "G4ThreeVector.hh"
94#include "G4RotationMatrix.hh"
95
96#include "geomwdefs.hh"
97
98/**
99 * @brief G4TouchableHistory is an object representing a touchable detector
100 * element, and its history in the geometrical hierarchy, including its net
101 * resultant local->global transform.
102 * A touchable is a geometrical volume (solid) which has a unique placement
103 * in a detector description.
104 */
105
107{
108 public:
109
110 /**
111 * Default Constructor. It produces a touchable-history of 'zero-depth',
112 * i.e. an "unphysical" and not very usable one; for initialisation only.
113 */
115
116 /**
117 * Default Destructor. Virtual, as it is a reference-counted object,
118 * but there is no provision for this class to be subclassed; if subclassed,
119 * it may fail and not give explicit errors!
120 */
121 virtual ~G4TouchableHistory() = default;
122
123 /**
124 * Copy constructor.
125 */
126 G4TouchableHistory( const G4NavigationHistory& history );
127
128 /**
129 * Accessors.
130 */
131 inline G4VPhysicalVolume* GetVolume( G4int depth = 0 ) const;
132 inline G4VSolid* GetSolid( G4int depth = 0 ) const;
133 const G4ThreeVector& GetTranslation( G4int depth = 0 ) const;
134 const G4RotationMatrix* GetRotation( G4int depth = 0 ) const;
135
136 /**
137 * Accessors for touchables with history.
138 */
139 inline G4int GetReplicaNumber( G4int depth = 0 ) const;
140 inline G4int GetCopyNumber( G4int depth = 0 ) const;
141 inline G4int GetHistoryDepth() const;
142 G4int MoveUpHistory( G4int num_levels = 1 );
143
144 /**
145 * Update method for touchables with history.
146 */
148 const G4NavigationHistory* history = nullptr );
149
150 /**
151 * Returns a pointer to the navigation history; used in
152 * G4Navigator::LocateGlobalPointAndSetup().
153 */
154 inline const G4NavigationHistory* GetHistory() const;
155
156 /**
157 * Operators overriding new/delete for use by G4Allocator.
158 */
159 inline void* operator new(std::size_t);
160 inline void operator delete(void* aTH);
161
162 private:
163
164 /**
165 * Calculates and returns the history index, given a depth 'stackDepth'.
166 */
167 inline G4int CalculateHistoryIndex( G4int stackDepth ) const;
168
169 private:
170
171 G4RotationMatrix frot;
172 G4ThreeVector ftlate;
173 G4NavigationHistory fhistory;
174};
175
176#include "G4TouchableHistory.icc"
177
178#endif
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
int G4int
Definition G4Types.hh:85
G4NavigationHistory is a class responsible for the maintenance of the history of the path taken throu...
G4VSolid * GetSolid(G4int depth=0) const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
G4int GetCopyNumber(G4int depth=0) const
const G4RotationMatrix * GetRotation(G4int depth=0) const
G4VPhysicalVolume * GetVolume(G4int depth=0) const
G4int GetHistoryDepth() const
const G4NavigationHistory * GetHistory() const
const G4ThreeVector & GetTranslation(G4int depth=0) const
G4int GetReplicaNumber(G4int depth=0) const
virtual ~G4TouchableHistory()=default
G4int MoveUpHistory(G4int num_levels=1)
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
Definition G4VSolid.hh:80