Geant4-11
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// G4FieldTrack inline methods implementation
27//
28// Author: John Apostolakis, CERN - First version, 14.10.1996
29// -------------------------------------------------------------------
30
31inline
32G4FieldTrack::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
55inline
56G4FieldTrack& G4FieldTrack::operator= ( const G4FieldTrack& rStVec )
57{
58 if (&rStVec == this) return *this;
59
60 SixVector[0]= rStVec.SixVector[0];
61 SixVector[1]= rStVec.SixVector[1];
62 SixVector[2]= rStVec.SixVector[2];
63 SixVector[3]= rStVec.SixVector[3];
64 SixVector[4]= rStVec.SixVector[4];
65 SixVector[5]= rStVec.SixVector[5];
66 SetCurveLength( rStVec.GetCurveLength() );
67
68 fKineticEnergy= rStVec.fKineticEnergy;
69 fRestMass_c2= rStVec.fRestMass_c2;
70 SetLabTimeOfFlight( rStVec.GetLabTimeOfFlight() );
71 SetProperTimeOfFlight( rStVec.GetProperTimeOfFlight() );
72 SetPolarization( rStVec.GetPolarization() );
73 fMomentumDir= rStVec.fMomentumDir;
74
75 fChargeState= rStVec.fChargeState;
76 // (*fpChargeState)= *(rStVec.fpChargeState);
77 // fpChargeState= rStVec.fpChargeState; // Handles!!
78 return *this;
79}
80
81inline
82G4FieldTrack::G4FieldTrack(G4FieldTrack&& from)
83 : fDistanceAlongCurve( from.fDistanceAlongCurve),
84 fKineticEnergy( from.fKineticEnergy ),
85 fRestMass_c2( from.fRestMass_c2),
86 fLabTimeOfFlight( from.fLabTimeOfFlight ),
87 fProperTimeOfFlight( from.fProperTimeOfFlight ),
88 fChargeState( from.fChargeState )
89{
90 SixVector[0]= from.SixVector[0];
91 SixVector[1]= from.SixVector[1];
92 SixVector[2]= from.SixVector[2];
93 SixVector[3]= from.SixVector[3];
94 SixVector[4]= from.SixVector[4];
95 SixVector[5]= from.SixVector[5];
96
97 fPolarization = std::move( from.fPolarization );
98 fMomentumDir = std::move( from.fMomentumDir );
99}
100
101inline
102G4FieldTrack& G4FieldTrack::operator=(G4FieldTrack&& from)
103{
104 if (&from == this) return *this;
105
106 SixVector[0]= from.SixVector[0];
107 SixVector[1]= from.SixVector[1];
108 SixVector[2]= from.SixVector[2];
109 SixVector[3]= from.SixVector[3];
110 SixVector[4]= from.SixVector[4];
111 SixVector[5]= from.SixVector[5];
112
113 fDistanceAlongCurve = from.fDistanceAlongCurve;
114 fKineticEnergy = from.fKineticEnergy;
115 fRestMass_c2 = from.fRestMass_c2;
116 fLabTimeOfFlight = from.fLabTimeOfFlight;
117 fProperTimeOfFlight = from.fProperTimeOfFlight;
118 fChargeState = from.fChargeState;
119
120 fPolarization = std::move( from.fPolarization );
121 fMomentumDir = std::move( from.fMomentumDir );
122
123 return *this;
124}
125
126inline
127G4FieldTrack::~G4FieldTrack()
128{
129 // delete fpChargeState;
130}
131
132inline G4FieldTrack&
133G4FieldTrack::SetCurvePnt(const G4ThreeVector& pPosition,
134 const G4ThreeVector& pMomentum,
135 G4double s_curve )
136{
137 SixVector[0] = pPosition.x();
138 SixVector[1] = pPosition.y();
139 SixVector[2] = pPosition.z();
140
141 SixVector[3] = pMomentum.x();
142 SixVector[4] = pMomentum.y();
143 SixVector[5] = pMomentum.z();
144
145 fMomentumDir = (pMomentum.mag2() > 0.0)
146 ? pMomentum.unit() : G4ThreeVector( 0.0, 0.0, 0.0 );
147
148 fDistanceAlongCurve = s_curve;
149
150 return *this;
151}
152
153inline
154void G4FieldTrack::SetPDGSpin(G4double pdgSpin)
155{
156 fChargeState.SetPDGSpin(pdgSpin);
157}
158
159inline
160G4double G4FieldTrack::GetPDGSpin()
161{
162 return fChargeState.GetPDGSpin();
163}
164
165inline
166G4ThreeVector G4FieldTrack::GetPosition() const
167{
168 G4ThreeVector myPosition( SixVector[0], SixVector[1], SixVector[2] );
169 return myPosition;
170}
171
172inline
173void G4FieldTrack::SetPosition( G4ThreeVector pPosition)
174{
175 SixVector[0] = pPosition.x();
176 SixVector[1] = pPosition.y();
177 SixVector[2] = pPosition.z();
178}
179
180inline
181const G4ThreeVector& G4FieldTrack::GetMomentumDir() const
182{
183 // G4ThreeVector myMomentum( SixVector[3], SixVector[4], SixVector[5] );
184 // return myVelocity;
185 return fMomentumDir;
186}
187
188inline
189G4ThreeVector G4FieldTrack::GetMomentumDirection() const
190{
191 return fMomentumDir;
192}
193
194inline
195G4double G4FieldTrack::GetCurveLength() const
196{
197 return fDistanceAlongCurve;
198}
199
200inline
201void G4FieldTrack::SetCurveLength(G4double nCurve_s)
202{
203 fDistanceAlongCurve = nCurve_s;
204}
205
206inline
207G4double G4FieldTrack::GetKineticEnergy() const
208{
209 return fKineticEnergy;
210}
211
212inline
213void G4FieldTrack::SetKineticEnergy(G4double newKinEnergy)
214{
215 fKineticEnergy = newKinEnergy;
216}
217
218inline
219G4ThreeVector G4FieldTrack::GetPolarization() const
220{
221 return fPolarization;
222}
223
224inline
225void G4FieldTrack::SetPolarization(const G4ThreeVector& vecPlz)
226{
227 fPolarization = vecPlz;
228}
229
230inline
231const G4ChargeState* G4FieldTrack::GetChargeState() const
232{
233 return &fChargeState;
234}
235
236inline
237G4double G4FieldTrack::GetLabTimeOfFlight() const
238{
239 return fLabTimeOfFlight;
240}
241
242inline
243void G4FieldTrack::SetLabTimeOfFlight(G4double nTOF)
244{
245 fLabTimeOfFlight = nTOF;
246}
247
248inline
249G4double G4FieldTrack::GetProperTimeOfFlight() const
250{
251 return fProperTimeOfFlight;
252}
253
254inline
255void G4FieldTrack::SetProperTimeOfFlight(G4double nTOF)
256{
257 fProperTimeOfFlight = nTOF;
258}
259
260inline
261void G4FieldTrack::SetMomentumDir(G4ThreeVector newMomDir)
262{
263 fMomentumDir = newMomDir;
264}
265
266inline
267G4ThreeVector G4FieldTrack::GetMomentum() const
268{
269 return G4ThreeVector( SixVector[3], SixVector[4], SixVector[5] );
270}
271
272inline
273void G4FieldTrack::SetMomentum(G4ThreeVector pMomentum)
274{
275 SixVector[3] = pMomentum.x();
276 SixVector[4] = pMomentum.y();
277 SixVector[5] = pMomentum.z();
278
279 if( pMomentum.mag2() > 0.0 )
280 fMomentumDir = pMomentum.unit();
281 else
282 fMomentumDir = G4ThreeVector( 0.0, 0.0, 0.0 );
283}
284
285inline
286G4double G4FieldTrack::GetCharge() const
287{
288 return fChargeState.GetCharge();
289}
290
291inline
292G4double G4FieldTrack::GetRestMass() const
293{
294 return fRestMass_c2;
295}
296
297inline
298void G4FieldTrack::SetRestMass(G4double Mass_c2)
299{
300 fRestMass_c2 = Mass_c2;
301}
302
303// Dump values to array
304//
305// Note that momentum direction is not saved
306//
307inline
308void G4FieldTrack::DumpToArray(G4double valArr[ncompSVEC] ) const
309{
310 valArr[0]=SixVector[0];
311 valArr[1]=SixVector[1];
312 valArr[2]=SixVector[2];
313 valArr[3]=SixVector[3];
314 valArr[4]=SixVector[4];
315 valArr[5]=SixVector[5];
316
317 G4ThreeVector Momentum(valArr[3],valArr[4],valArr[5]);
318
319 // G4double mass_in_Kg;
320 // mass_in_Kg = fEnergy / velocity_mag_sq * (1-velocity_mag_sq/c_squared);
321 // valArr[6]= mass_in_Kg;
322
323 // The following components may or may not be integrated.
324 //
325 valArr[6]= fKineticEnergy;
326
327 // valArr[6]=fEnergy; // When it is integrated over, do this ...
328 valArr[7]=fLabTimeOfFlight;
329 valArr[8]=fProperTimeOfFlight;
330 valArr[9]=fPolarization.x();
331 valArr[10]=fPolarization.y();
332 valArr[11]=fPolarization.z();
333 // valArr[13]=fMomentumDir.x();
334 // valArr[14]=fMomentumDir.y();
335 // valArr[15]=fMomentumDir.z();
336 // valArr[]=fDistanceAlongCurve;
337}
338
339inline
340void G4FieldTrack::UpdateFourMomentum( G4double kineticEnergy,
341 const G4ThreeVector& momentumDirection )
342{
343 G4double momentum_mag = std::sqrt(kineticEnergy*kineticEnergy
344 +2.0*fRestMass_c2*kineticEnergy);
345 G4ThreeVector momentumVector = momentum_mag * momentumDirection;
346
347 // SetMomentum( momentumVector );
348 // Set direction (from unit): used sqrt, div
349 SixVector[3] = momentumVector.x();
350 SixVector[4] = momentumVector.y();
351 SixVector[5] = momentumVector.z();
352
353 fMomentumDir= momentumDirection; // Set directly to avoid inaccuracy.
354 fKineticEnergy= kineticEnergy;
355}
356
357inline
358void G4FieldTrack::UpdateState( const G4ThreeVector& position,
359 G4double laboratoryTimeOfFlight,
360 const G4ThreeVector& momentumDirection,
361 G4double kineticEnergy )
362{
363 // SetCurvePnt( position, momentumVector, s_curve=0.0);
364 SetPosition( position);
365 fLabTimeOfFlight = laboratoryTimeOfFlight;
366 fDistanceAlongCurve = 0.0;
367
368 UpdateFourMomentum( kineticEnergy, momentumDirection);
369}
370
371inline
372void G4FieldTrack::InitialiseSpin( const G4ThreeVector& vecPolarization )
373{
374 SetPolarization( vecPolarization );
375}
376
377inline G4ThreeVector G4FieldTrack::GetSpin() const
378{
379 return GetPolarization();
380}
381
382inline
383void G4FieldTrack::SetSpin(G4ThreeVector vSpin)
384{
385 SetPolarization(vSpin);
386}