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: G4FastTrack.hh,v 1.8 2007/05/11 13:50:20 mverderi Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
29 | // |
---|
30 | // $Id: |
---|
31 | //--------------------------------------------------------------- |
---|
32 | // |
---|
33 | // G4FastTrack.hh |
---|
34 | // |
---|
35 | // Description: |
---|
36 | // Keeps the current track information and special features |
---|
37 | // for Parameterised Simulation Models. |
---|
38 | // |
---|
39 | // History: |
---|
40 | // Oct 97: Verderi && MoraDeFreitas - First Implementation. |
---|
41 | // |
---|
42 | //--------------------------------------------------------------- |
---|
43 | |
---|
44 | |
---|
45 | #ifndef G4FastTrack_h |
---|
46 | #define G4FastTrack_h |
---|
47 | |
---|
48 | #include "G4VSolid.hh" |
---|
49 | #include "G4LogicalVolume.hh" |
---|
50 | #include "G4Region.hh" |
---|
51 | #include "G4AffineTransform.hh" |
---|
52 | #include "G4Track.hh" |
---|
53 | #include "G4Navigator.hh" |
---|
54 | |
---|
55 | //--------------------------- |
---|
56 | // For possible future needs: |
---|
57 | //--------------------------- |
---|
58 | typedef G4Region G4Envelope; |
---|
59 | |
---|
60 | |
---|
61 | //------------------------------------------- |
---|
62 | // |
---|
63 | // G4FastTrack class |
---|
64 | // |
---|
65 | //------------------------------------------- |
---|
66 | |
---|
67 | // Class Description: |
---|
68 | // The G4FastTrack provides you access to the current G4Track, |
---|
69 | // gives simple access to envelope related features (G4Region, |
---|
70 | // G4LogicalVolume, G4VSolid, G4AffineTransform references between |
---|
71 | // the global and the envelope local coordinates systems) and |
---|
72 | // simple access to the position, momentum expressed in the |
---|
73 | // envelope coordinate system. Using those quantities and the |
---|
74 | // G4VSolid methods, you can for example easily check how far you |
---|
75 | // are from the envelope boundary. |
---|
76 | // |
---|
77 | |
---|
78 | |
---|
79 | class G4FastTrack |
---|
80 | { |
---|
81 | public: // without description |
---|
82 | //------------------------ |
---|
83 | // Constructor/Destructor |
---|
84 | //------------------------ |
---|
85 | // Only one Constructor. By default the envelope can |
---|
86 | // be placed n-Times. If the user is sure that it'll be |
---|
87 | // placed just one time, the IsUnique flag should be set |
---|
88 | // TRUE to avoid the G4AffineTransform re-calculations each |
---|
89 | // time we reach the envelope. |
---|
90 | G4FastTrack(G4Envelope *anEnvelope, |
---|
91 | G4bool IsUnique); |
---|
92 | ~G4FastTrack(); |
---|
93 | |
---|
94 | //------------------------------------------------------------ |
---|
95 | // The fast simulation manager uses the SetCurrentTrack |
---|
96 | // method to setup the current G4FastTrack object |
---|
97 | //------------------------------------------------------------ |
---|
98 | void SetCurrentTrack(const G4Track&, const G4Navigator* a = 0); |
---|
99 | |
---|
100 | //------------------------------------------------------------ |
---|
101 | // The fast simulation manager uses the OnTheBoundaryButExiting |
---|
102 | // method to test if the particle is leaving the envelope. |
---|
103 | //------------------------------------------------------------ |
---|
104 | G4bool OnTheBoundaryButExiting() const; |
---|
105 | |
---|
106 | //---------------------------------- |
---|
107 | // Informations useful to the user : |
---|
108 | // General public get functions. |
---|
109 | //---------------------------------- |
---|
110 | |
---|
111 | public: // with Description |
---|
112 | |
---|
113 | const G4Track* GetPrimaryTrack() const; |
---|
114 | // Returns the current G4Track. |
---|
115 | |
---|
116 | G4Envelope* GetEnvelope() const; |
---|
117 | // Returns the Envelope G4Region pointer. |
---|
118 | |
---|
119 | G4LogicalVolume* GetEnvelopeLogicalVolume() const; |
---|
120 | // Returns the Envelope G4LogicalVolume pointer. |
---|
121 | |
---|
122 | G4VPhysicalVolume* GetEnvelopePhysicalVolume() const; |
---|
123 | // Returns the Envelope G4VPhysicalVolume pointer. |
---|
124 | |
---|
125 | G4VSolid* GetEnvelopeSolid() const; |
---|
126 | // Returns the Envelope G4VSolid pointer. |
---|
127 | |
---|
128 | //----------------------------------- |
---|
129 | // Primary track informations in the |
---|
130 | // Envelope coordinate system. |
---|
131 | //----------------------------------- |
---|
132 | |
---|
133 | G4ThreeVector GetPrimaryTrackLocalPosition() const; |
---|
134 | // Returns the particle position in envelope coordinates. |
---|
135 | |
---|
136 | G4ThreeVector GetPrimaryTrackLocalMomentum() const; |
---|
137 | // Returns the particle momentum in envelope coordinates. |
---|
138 | |
---|
139 | G4ThreeVector GetPrimaryTrackLocalDirection() const; |
---|
140 | // Returns the particle direction in envelope coordinates. |
---|
141 | |
---|
142 | G4ThreeVector GetPrimaryTrackLocalPolarization() const; |
---|
143 | // Returns the particle polarization in envelope coordinates. |
---|
144 | |
---|
145 | //------------------------------------ |
---|
146 | // 3D transformation of the envelope: |
---|
147 | //------------------------------------ |
---|
148 | // Global -> Local |
---|
149 | |
---|
150 | const G4AffineTransform* GetAffineTransformation() const; |
---|
151 | // Returns the envelope Global -> Local G4AffineTransform |
---|
152 | |
---|
153 | // Local -> Global |
---|
154 | const G4AffineTransform* GetInverseAffineTransformation() const; |
---|
155 | // Returns the envelope Local -> Global G4AffineTransform |
---|
156 | |
---|
157 | //----------------- |
---|
158 | // Private members |
---|
159 | //----------------- |
---|
160 | private: |
---|
161 | |
---|
162 | // Current G4Track pointer |
---|
163 | const G4Track* fTrack; |
---|
164 | |
---|
165 | //------------------------------------------------ |
---|
166 | // Records the Affine/InverseAffine transformation |
---|
167 | // of the envelope. |
---|
168 | //------------------------------------------------ |
---|
169 | void FRecordsAffineTransformation(const G4Navigator*); |
---|
170 | G4bool fAffineTransformationDefined; |
---|
171 | G4Envelope* fEnvelope; |
---|
172 | G4bool fIsUnique; |
---|
173 | G4LogicalVolume* fEnvelopeLogicalVolume; |
---|
174 | G4VPhysicalVolume* fEnvelopePhysicalVolume; |
---|
175 | G4VSolid* fEnvelopeSolid; |
---|
176 | G4ThreeVector fLocalTrackPosition, |
---|
177 | fLocalTrackMomentum, |
---|
178 | fLocalTrackDirection, |
---|
179 | fLocalTrackPolarization; |
---|
180 | G4AffineTransform fAffineTransformation, |
---|
181 | fInverseAffineTransformation; |
---|
182 | }; |
---|
183 | |
---|
184 | |
---|
185 | // ----------------- |
---|
186 | // -- Inline methods |
---|
187 | // ----------------- |
---|
188 | |
---|
189 | inline G4Envelope* G4FastTrack::GetEnvelope() const |
---|
190 | { |
---|
191 | return fEnvelope; |
---|
192 | } |
---|
193 | |
---|
194 | inline G4LogicalVolume* G4FastTrack::GetEnvelopeLogicalVolume() const |
---|
195 | { |
---|
196 | return fEnvelopeLogicalVolume; |
---|
197 | } |
---|
198 | |
---|
199 | inline G4VPhysicalVolume* G4FastTrack::GetEnvelopePhysicalVolume() const |
---|
200 | { |
---|
201 | return fEnvelopePhysicalVolume; |
---|
202 | } |
---|
203 | |
---|
204 | inline G4VSolid* G4FastTrack::GetEnvelopeSolid() const |
---|
205 | { |
---|
206 | return fEnvelopeSolid; |
---|
207 | } |
---|
208 | |
---|
209 | inline const G4Track* G4FastTrack::GetPrimaryTrack() const |
---|
210 | { |
---|
211 | return fTrack; |
---|
212 | } |
---|
213 | |
---|
214 | inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPosition() const |
---|
215 | { |
---|
216 | return fLocalTrackPosition; |
---|
217 | } |
---|
218 | |
---|
219 | inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalMomentum() const |
---|
220 | { |
---|
221 | return fLocalTrackMomentum; |
---|
222 | } |
---|
223 | |
---|
224 | inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalDirection() const |
---|
225 | { |
---|
226 | return fLocalTrackDirection; |
---|
227 | } |
---|
228 | |
---|
229 | inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPolarization() const |
---|
230 | { |
---|
231 | return fLocalTrackPolarization; |
---|
232 | } |
---|
233 | |
---|
234 | inline const G4AffineTransform* G4FastTrack::GetAffineTransformation() const |
---|
235 | { |
---|
236 | return &fAffineTransformation; |
---|
237 | } |
---|
238 | |
---|
239 | inline const G4AffineTransform* G4FastTrack::GetInverseAffineTransformation() const |
---|
240 | { |
---|
241 | return &fInverseAffineTransformation; |
---|
242 | } |
---|
243 | |
---|
244 | inline G4bool G4FastTrack::OnTheBoundaryButExiting() const |
---|
245 | { |
---|
246 | // tests if particle are on the boundary and leaving. |
---|
247 | return GetEnvelopeSolid()-> |
---|
248 | DistanceToOut(GetPrimaryTrackLocalPosition(), |
---|
249 | GetPrimaryTrackLocalDirection())==0.; |
---|
250 | } |
---|
251 | |
---|
252 | #endif |
---|