Geant4  10.00.p03
G4FieldTrack.icc
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 //
27 // $Id: G4FieldTrack.icc 81686 2014-06-04 14:44:57Z gcosmo $
28 //
29 // -------------------------------------------------------------------
30 
31 inline
32 G4FieldTrack::G4FieldTrack( const G4FieldTrack& rStVec )
33  : fDistanceAlongCurve( rStVec.fDistanceAlongCurve),
34  fKineticEnergy( rStVec.fKineticEnergy ),
35  fRestMass_c2( rStVec.fRestMass_c2),
36  fLabTimeOfFlight( rStVec.fLabTimeOfFlight ),
37  fProperTimeOfFlight( rStVec.fProperTimeOfFlight ),
38  // fMomentumModulus( rStVec.fMomentumModulus ),
39  fPolarization( rStVec.fPolarization ),
40  fMomentumDir( rStVec.fMomentumDir ),
41  fChargeState( rStVec.fChargeState )
42 {
43  SixVector[0]= rStVec.SixVector[0];
44  SixVector[1]= rStVec.SixVector[1];
45  SixVector[2]= rStVec.SixVector[2];
46  SixVector[3]= rStVec.SixVector[3];
47  SixVector[4]= rStVec.SixVector[4];
48  SixVector[5]= rStVec.SixVector[5];
49 
50  // fpChargeState= new G4ChargeState( *rStVec.fpChargeState );
51  // Can share charge state only when using handles etc
52  // fpChargeState = rStVec.fpChargeState;
53 }
54 
55 inline
56 G4FieldTrack::~G4FieldTrack()
57 {
58  // delete fpChargeState;
59 }
60 
61 inline G4FieldTrack&
62 G4FieldTrack::SetCurvePnt(const G4ThreeVector& pPosition,
63  const G4ThreeVector& pMomentum,
64  G4double s_curve )
65 {
66  SixVector[0] = pPosition.x();
67  SixVector[1] = pPosition.y();
68  SixVector[2] = pPosition.z();
69 
70  SixVector[3] = pMomentum.x();
71  SixVector[4] = pMomentum.y();
72  SixVector[5] = pMomentum.z();
73 
74  fMomentumDir = pMomentum.unit();
75 
76  fDistanceAlongCurve= s_curve;
77 
78  return *this;
79 }
80 
81 inline
82 G4ThreeVector G4FieldTrack::GetPosition() const
83 {
84  G4ThreeVector myPosition( SixVector[0], SixVector[1], SixVector[2] );
85  return myPosition;
86 }
87 
88 inline
89 void G4FieldTrack::SetPosition( G4ThreeVector pPosition)
90 {
91  SixVector[0] = pPosition.x();
92  SixVector[1] = pPosition.y();
93  SixVector[2] = pPosition.z();
94 }
95 
96 inline
97 const G4ThreeVector& G4FieldTrack::GetMomentumDir() const
98 {
99  // G4ThreeVector myMomentum( SixVector[3], SixVector[4], SixVector[5] );
100  // return myVelocity;
101  return fMomentumDir;
102 }
103 
104 inline
105 G4ThreeVector G4FieldTrack::GetMomentumDirection() const
106 {
107  return fMomentumDir;
108 }
109 
110 inline
111 G4double G4FieldTrack::GetCurveLength() const
112 {
113  return fDistanceAlongCurve;
114 }
115 
116 inline
117 void G4FieldTrack::SetCurveLength(G4double nCurve_s)
118 {
119  fDistanceAlongCurve= nCurve_s;
120 }
121 
122 inline
123 G4double G4FieldTrack::GetKineticEnergy() const
124 {
125  return fKineticEnergy;
126 }
127 
128 inline
129 void G4FieldTrack::SetKineticEnergy(G4double newKinEnergy)
130 {
131  fKineticEnergy=newKinEnergy;
132 }
133 
134 inline
135 G4ThreeVector G4FieldTrack::GetPolarization() const
136 {
137  return fPolarization;
138 }
139 
140 inline
141 void G4FieldTrack::SetPolarization(const G4ThreeVector& vecPlz)
142 {
143  fPolarization= vecPlz;
144 }
145 
146 inline
147 G4double G4FieldTrack::GetLabTimeOfFlight() const
148 {
149  return fLabTimeOfFlight;
150 }
151 
152 inline
153 void G4FieldTrack::SetLabTimeOfFlight(G4double nTOF)
154 {
155  fLabTimeOfFlight=nTOF;
156 }
157 
158 inline
159 G4double G4FieldTrack::GetProperTimeOfFlight() const
160 {
161  return fProperTimeOfFlight;
162 }
163 
164 inline
165 void G4FieldTrack::SetProperTimeOfFlight(G4double nTOF)
166 {
167  fProperTimeOfFlight=nTOF;
168 }
169 
170 inline
171 void G4FieldTrack::SetMomentumDir(G4ThreeVector newMomDir)
172 {
173  fMomentumDir= newMomDir;
174 }
175 
176 inline
177 G4ThreeVector G4FieldTrack::GetMomentum() const
178 {
179  return G4ThreeVector( SixVector[3], SixVector[4], SixVector[5] );
180 }
181 
182 inline
183 void G4FieldTrack::SetMomentum(G4ThreeVector pMomentum)
184 {
185  SixVector[3] = pMomentum.x();
186  SixVector[4] = pMomentum.y();
187  SixVector[5] = pMomentum.z();
188 
189  fMomentumDir = pMomentum.unit();
190 }
191 
192 inline
193 G4double G4FieldTrack::GetCharge() const
194 {
195  return fChargeState.GetCharge();
196 }
197 
198 // Dump values to array
199 //
200 // note that momentum direction is not saved
201 
202 inline
203 void G4FieldTrack::DumpToArray(G4double valArr[ncompSVEC] ) const
204 {
205  valArr[0]=SixVector[0];
206  valArr[1]=SixVector[1];
207  valArr[2]=SixVector[2];
208  valArr[3]=SixVector[3];
209  valArr[4]=SixVector[4];
210  valArr[5]=SixVector[5];
211 
212  G4ThreeVector Momentum(valArr[3],valArr[4],valArr[5]);
213 
214  // G4double mass_in_Kg;
215  // mass_in_Kg = fEnergy / velocity_mag_sq * (1-velocity_mag_sq/c_squared);
216  // valArr[6]= mass_in_Kg;
217 
218  // The following components may or may not be integrated.
219  valArr[6]= fKineticEnergy;
220 
221  // valArr[6]=fEnergy; // When it is integrated over, do this ...
222  valArr[7]=fLabTimeOfFlight;
223  valArr[8]=fProperTimeOfFlight;
224  valArr[9]=fPolarization.x();
225  valArr[10]=fPolarization.y();
226  valArr[11]=fPolarization.z();
227  // valArr[13]=fMomentumDir.x();
228  // valArr[14]=fMomentumDir.y();
229  // valArr[15]=fMomentumDir.z();
230  // valArr[]=fDistanceAlongCurve;
231 }
232 
233 inline
234 G4FieldTrack & G4FieldTrack::operator = ( const G4FieldTrack& rStVec )
235 {
236  if (&rStVec == this) return *this;
237 
238  SixVector[0]= rStVec.SixVector[0];
239  SixVector[1]= rStVec.SixVector[1];
240  SixVector[2]= rStVec.SixVector[2];
241  SixVector[3]= rStVec.SixVector[3];
242  SixVector[4]= rStVec.SixVector[4];
243  SixVector[5]= rStVec.SixVector[5];
244  SetCurveLength( rStVec.GetCurveLength() );
245 
246  fKineticEnergy= rStVec.fKineticEnergy;
247  fRestMass_c2= rStVec.fRestMass_c2;
248  SetLabTimeOfFlight( rStVec.GetLabTimeOfFlight() );
249  SetProperTimeOfFlight( rStVec.GetProperTimeOfFlight() );
250  SetPolarization( rStVec.GetPolarization() );
251  fMomentumDir= rStVec.fMomentumDir;
252 
253  fChargeState= rStVec.fChargeState;
254  // (*fpChargeState)= *(rStVec.fpChargeState);
255  // fpChargeState= rStVec.fpChargeState; // Handles!!
256  return *this;
257 }
258 
259 inline void
260 G4FieldTrack::UpdateFourMomentum( G4double kineticEnergy,
261  const G4ThreeVector& momentumDirection )
262 {
263  G4double momentum_mag = std::sqrt(kineticEnergy*kineticEnergy
264  +2.0*fRestMass_c2*kineticEnergy);
265  G4ThreeVector momentumVector= momentum_mag * momentumDirection;
266 
267  // SetMomentum( momentumVector ); // Set direction (from unit): used sqrt, div
268  SixVector[3] = momentumVector.x();
269  SixVector[4] = momentumVector.y();
270  SixVector[5] = momentumVector.z();
271 
272  fMomentumDir= momentumDirection; // Set directly to avoid inaccuracy.
273  fKineticEnergy= kineticEnergy;
274 }
275 
276 inline void G4FieldTrack::UpdateState( const G4ThreeVector& position,
277  G4double laboratoryTimeOfFlight,
278  const G4ThreeVector& momentumDirection,
279  G4double kineticEnergy
280  )
281 {
282  // SetCurvePnt( position, momentumVector, s_curve=0.0);
283  SetPosition( position);
284  fLabTimeOfFlight= laboratoryTimeOfFlight;
285  fDistanceAlongCurve= 0.0;
286 
287  UpdateFourMomentum( kineticEnergy, momentumDirection);
288 }