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