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 | // |
---|
27 | // $Id: G4TouchableHistory.icc,v 1.10 2006/12/07 14:26:28 japost Exp $ |
---|
28 | // GEANT4 tag $Name: HEAD $ |
---|
29 | // |
---|
30 | // |
---|
31 | // class G4TouchableHistory inline implementation |
---|
32 | // ---------------------------------------------------------------------- |
---|
33 | |
---|
34 | inline |
---|
35 | G4TouchableHistory::G4TouchableHistory() |
---|
36 | : frot(G4RotationMatrix()), |
---|
37 | ftlate(G4ThreeVector(0.,0.,0.)), |
---|
38 | fhistory() |
---|
39 | { |
---|
40 | G4VPhysicalVolume* pPhysVol=0; |
---|
41 | fhistory.SetFirstEntry(pPhysVol); |
---|
42 | } |
---|
43 | |
---|
44 | inline |
---|
45 | G4TouchableHistory::G4TouchableHistory( const G4NavigationHistory &history ) |
---|
46 | : fhistory(history) |
---|
47 | { |
---|
48 | G4AffineTransform tf(fhistory.GetTopTransform().Inverse()); |
---|
49 | ftlate = tf.NetTranslation(); |
---|
50 | frot = tf.NetRotation(); |
---|
51 | } |
---|
52 | |
---|
53 | inline |
---|
54 | void G4TouchableHistory::UpdateYourself( G4VPhysicalVolume* pPhysVol, |
---|
55 | const G4NavigationHistory* pHistory ) |
---|
56 | { |
---|
57 | fhistory = *pHistory; |
---|
58 | G4AffineTransform tf(fhistory.GetTopTransform().Inverse()); |
---|
59 | if( pPhysVol == 0 ) |
---|
60 | { |
---|
61 | // This means that the track has left the World Volume. |
---|
62 | // Since the Navigation History does not already reflect this, |
---|
63 | // we must correct this problem here. |
---|
64 | // |
---|
65 | fhistory.SetFirstEntry(pPhysVol); |
---|
66 | } |
---|
67 | ftlate = tf.NetTranslation(); |
---|
68 | frot = tf.NetRotation(); |
---|
69 | } |
---|
70 | |
---|
71 | inline |
---|
72 | G4int G4TouchableHistory::CalculateHistoryIndex( G4int stackDepth ) const |
---|
73 | { |
---|
74 | return (fhistory.GetDepth()-stackDepth); // was -1 |
---|
75 | } |
---|
76 | |
---|
77 | inline |
---|
78 | G4VPhysicalVolume* G4TouchableHistory::GetVolume( G4int depth ) const |
---|
79 | { |
---|
80 | return fhistory.GetVolume(CalculateHistoryIndex(depth)); |
---|
81 | } |
---|
82 | |
---|
83 | inline |
---|
84 | G4VSolid* G4TouchableHistory::GetSolid( G4int depth ) const |
---|
85 | { |
---|
86 | return fhistory.GetVolume(CalculateHistoryIndex(depth)) |
---|
87 | ->GetLogicalVolume()->GetSolid(); |
---|
88 | } |
---|
89 | |
---|
90 | inline |
---|
91 | G4int G4TouchableHistory::GetReplicaNumber( G4int depth ) const |
---|
92 | { |
---|
93 | return fhistory.GetReplicaNo(CalculateHistoryIndex(depth)); |
---|
94 | } |
---|
95 | |
---|
96 | inline |
---|
97 | G4int G4TouchableHistory::GetHistoryDepth() const |
---|
98 | { |
---|
99 | return fhistory.GetDepth(); |
---|
100 | } |
---|
101 | |
---|
102 | inline |
---|
103 | G4int G4TouchableHistory::MoveUpHistory( G4int num_levels ) |
---|
104 | { |
---|
105 | G4NavigationHistory* nHistory= &fhistory; |
---|
106 | G4int maxLevelsMove = nHistory->GetDepth(); |
---|
107 | G4int minLevelsMove = 0; // Cannot redescend today! |
---|
108 | // Soon it will be possible |
---|
109 | // by adding a data member here |
---|
110 | // fCurrentDepth; |
---|
111 | if( num_levels > maxLevelsMove ) |
---|
112 | { |
---|
113 | num_levels = maxLevelsMove; |
---|
114 | } |
---|
115 | else if( num_levels < minLevelsMove ) |
---|
116 | { |
---|
117 | num_levels = minLevelsMove; |
---|
118 | } |
---|
119 | nHistory->BackLevel( num_levels ); |
---|
120 | |
---|
121 | return num_levels; |
---|
122 | } |
---|
123 | |
---|
124 | inline |
---|
125 | const G4NavigationHistory* G4TouchableHistory::GetHistory() const |
---|
126 | { |
---|
127 | return &fhistory; |
---|
128 | } |
---|