Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4FieldTrack.cc
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.cc 69786 2013-05-15 09:38:51Z gcosmo $
28 //
29 // -------------------------------------------------------------------
30 
31 #include "G4FieldTrack.hh"
32 
33 std::ostream& operator<<( std::ostream& os, const G4FieldTrack& SixVec)
34 {
35  const G4double *SixV = SixVec.SixVector;
36  os << " ( ";
37  os << " X= " << SixV[0] << " " << SixV[1] << " "
38  << SixV[2] << " "; // Position
39  os << " V= " << SixV[3] << " " << SixV[4] << " "
40  << SixV[5] << " "; // Momentum
41  os << " v2= "
42  << G4ThreeVector(SixV[3], SixV[4], SixV[5]).mag(); // mom magnitude
43  os << " mdm= " << SixVec.fMomentumDir.mag();
44  os << " l= " << SixVec.GetCurveLength();
45  os << " ) ";
46  return os;
47 }
48 
50  G4double LaboratoryTimeOfFlight,
51  const G4ThreeVector& pMomentumDirection,
52  G4double kineticEnergy,
53  G4double restMass_c2,
54  G4double charge,
55  const G4ThreeVector& Spin,
56  G4double magnetic_dipole_moment,
57  G4double curve_length )
58 : fDistanceAlongCurve(curve_length),
59  fKineticEnergy(kineticEnergy),
60  fRestMass_c2(restMass_c2),
61  fLabTimeOfFlight(LaboratoryTimeOfFlight),
62  fProperTimeOfFlight(0.),
63  // fMomentumDir(pMomentumDirection),
64  fChargeState( charge, magnetic_dipole_moment )
65 {
66  UpdateFourMomentum( kineticEnergy, pMomentumDirection );
67  // Sets momentum direction as well.
68 
69  SetPosition( pPosition );
70 
71  InitialiseSpin( Spin );
72 }
73 
75  const G4ThreeVector& pMomentumDirection,
76  G4double curve_length,
77  G4double kineticEnergy,
78  const G4double restMass_c2,
79  G4double, // velocity
80  G4double pLaboratoryTimeOfFlight,
81  G4double pProperTimeOfFlight,
82  const G4ThreeVector* pSpin)
83  : fDistanceAlongCurve(curve_length),
84  fKineticEnergy(kineticEnergy),
85  fRestMass_c2(restMass_c2),
86  fLabTimeOfFlight(pLaboratoryTimeOfFlight),
87  fProperTimeOfFlight(pProperTimeOfFlight),
88  // fMomentumDir(pMomentumDirection),
89  fChargeState( DBL_MAX ) // charge not set
90 {
91  UpdateFourMomentum( kineticEnergy, pMomentumDirection );
92  // Sets momentum direction as well.
93 
94  SetPosition( pPosition );
95 
96  G4ThreeVector Spin(0.0, 0.0, 0.0);
97  if( pSpin ) Spin= *pSpin;
98  InitialiseSpin( Spin );
99 }
100 
101 G4FieldTrack::G4FieldTrack( char ) // Nothing is set !!
102  : fKineticEnergy(0.), fRestMass_c2(0.), fLabTimeOfFlight(0.),
103  fProperTimeOfFlight(0.), fChargeState( DBL_MAX )
104 {
105  G4ThreeVector Zero(0.0, 0.0, 0.0);
106  SetCurvePnt( Zero, Zero, 0.0 );
107  InitialiseSpin( Zero );
108  // fInitialMomentumMag= 0.00; // Invalid
109  // fLastMomentumMag= 0.0;
110 }
111 
112 void G4FieldTrack::
114  G4double magnetic_dipole_moment, // default= DBL_MAX - do not change
115  G4double electric_dipole_moment, // ditto
116  G4double magnetic_charge ) // ditto
117 {
118  fChargeState.SetChargeAndMoments( charge, magnetic_dipole_moment,
119  electric_dipole_moment, magnetic_charge );
120 
121  // fpChargeState->SetChargeAndMoments( charge, magnetic_dipole_moment,
122  // electric_dipole_moment, magnetic_charge );
123 
124  // TO-DO: Improve the implementation using handles
125  // -- and handle to the old one (which can be shared by other copies) and
126  // must not be left to hang loose
127  //
128  // fpChargeState= new G4ChargeState( charge, magnetic_dipole_moment,
129  // electric_dipole_moment, magnetic_charge );
130 }