source: trunk/source/processes/parameterisation/src/G4FastTrack.cc@ 1066

Last change on this file since 1066 was 1007, checked in by garnier, 17 years ago

update to geant4.9.2

File size: 6.7 KB
RevLine 
[819]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.cc,v 1.10 2006/06/29 21:09:34 gunter Exp $
[1007]28// GEANT4 tag $Name: geant4-09-02 $
[819]29//
30//---------------------------------------------------------------
31//
32// G4FastTrack.cc
33//
34// Description:
35// Keeps the current track information and special features
36// for Parameterised Simulation Models.
37//
38// History:
39// Oct 97: Verderi && MoraDeFreitas - First Implementation.
40//
41//---------------------------------------------------------------
42
43#include "G4ios.hh"
44#include "G4FastTrack.hh"
45#include "G4TransportationManager.hh"
46#include "G4TouchableHistoryHandle.hh"
47
48// -----------
49// Constructor
50// -----------
51//
52G4FastTrack::G4FastTrack(G4Envelope *anEnvelope,
53 G4bool IsUnique) :
54 fAffineTransformationDefined(false), fEnvelope(anEnvelope),
55 fIsUnique(IsUnique), fEnvelopeLogicalVolume(0), fEnvelopePhysicalVolume(0),
56 fEnvelopeSolid(0)
57{}
58
59// -----------
60// Destructor:
61// -----------
62G4FastTrack::~G4FastTrack()
63{}
64
65//------------------------------------------------------------
66// The parameterised simulation manager uses the SetCurrentTrack
67// method to setup the current G4FastTrack object
68//------------------------------------------------------------
69void G4FastTrack::SetCurrentTrack(const G4Track& track,
70 const G4Navigator* theNavigator)
71{
72
73 // -- Register track pointer (used everywhere):
74 fTrack = &track;
75
76 //-----------------------------------------------------
77 // First time the track enters the volume or if the
78 // Logical Volume was placed n-Times in the geometry :
79 //
80 // Records the Rotation+Translation for the Envelope !
81 // When the particle is inside or on the boundary, the
82 // NavigationHistory IS UP TO DATE.
83 //------------------------------------------------------
84 if (!fAffineTransformationDefined || !fIsUnique)
85 FRecordsAffineTransformation(theNavigator);
86
87 //-------------------------------------------
88 // Records local position/momentum/direction
89 // of the Track.
90 // They are accessible to the user through a
91 // set of Get functions and should be useful
92 // to decide to trigger or not.
93 //-------------------------------------------
94 // -- local position:
95 fLocalTrackPosition = fAffineTransformation.
96 TransformPoint(fTrack->GetPosition());
97 // -- local momentum:
98 fLocalTrackMomentum = fAffineTransformation.
99 TransformAxis(fTrack->GetMomentum());
100 // -- local direction:
101 fLocalTrackDirection = fLocalTrackMomentum.unit();
102 // -- local polarization:
103 fLocalTrackPolarization = fAffineTransformation.
104 TransformAxis(fTrack->GetPolarization());
105}
106
107//------------------------------------
108//
109// 3D transformation of the envelope
110// This is Done only one time.
111//
112//------------------------------------
113void
114G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
115{
116
117 //--------------------------------------------------------
118 // Get the touchable history which represents the current
119 // volume hierachy the particle is in.
120 // Note that TouchableHistory allocated by the Navigator
121 // must be deleted by G4FastTrack.
122 //--------------------------------------------------------
123 const G4Navigator* NavigatorToUse;
124 if(theNavigator != 0 ) NavigatorToUse=theNavigator;
125 else
126 NavigatorToUse=
127 G4TransportationManager::GetTransportationManager()->
128 GetNavigatorForTracking();
129
130 G4TouchableHistoryHandle history =
131 NavigatorToUse->CreateTouchableHistoryHandle();
132
133 //-----------------------------------------------------
134 // Run accross the hierarchy to find the physical volume
135 // associated with the envelope
136 //-----------------------------------------------------
137 G4int depth = history->GetHistory()->GetDepth();
138 G4int idepth, Done = 0;
139 for (idepth = 0; idepth <= depth; idepth++)
140 {
141 G4VPhysicalVolume* currPV = history->GetHistory()->GetVolume(idepth);
142 G4LogicalVolume* currLV = currPV->GetLogicalVolume();
143 if ( (currLV->GetRegion() == fEnvelope) && (currLV->IsRootRegion()) )
144 {
145 fEnvelopePhysicalVolume = currPV;
146 fEnvelopeLogicalVolume = currLV;
147 fEnvelopeSolid = currLV->GetSolid();
148 Done = 1;
149 break;
150 }
151 }
152 //---------------------------------------------
153 //-- Verification: should be removed in future:
154 //---------------------------------------------
155 if ( !Done )
156 {
157 G4cout << "WARNING - G4FastTrack::FRecordsAffineTransformation()"
158 << G4endl
159 << " Can't find transformation for "
160 << fEnvelopePhysicalVolume->GetName() << G4endl;
161 G4Exception("G4FastTrack::FRecordsAffineTransformation()",
162 "InvalidSetup", JustWarning,
163 "Transformation for envelope volume not found!");
164 }
165 else
166 {
167 //-------------------------------------------------------
168 // Records the transformation and inverse transformation:
169 //-------------------------------------------------------
170 fAffineTransformation = history->GetHistory()->GetTransform(idepth);
171 fInverseAffineTransformation = fAffineTransformation.Inverse();
172
173 fAffineTransformationDefined = true;
174 }
175}
Note: See TracBrowser for help on using the repository browser.