source: trunk/source/geometry/magneticfield/src/G4FieldTrack.cc@ 1043

Last change on this file since 1043 was 921, checked in by garnier, 17 years ago

en test de gl2ps. Problemes de libraries

File size: 6.0 KB
Line 
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,v 1.14 2007/10/03 15:34:42 japost Exp $
28// GEANT4 tag $Name: geant4-09-02-cand-01 $
29//
30// -------------------------------------------------------------------
31
32#include "G4FieldTrack.hh"
33
34std::ostream& operator<<( std::ostream& os, const G4FieldTrack& SixVec)
35{
36 const G4double *SixV = SixVec.SixVector;
37 os << " ( ";
38 os << " X= " << SixV[0] << " " << SixV[1] << " " << SixV[2] << " "; // Position
39 os << " V= " << SixV[3] << " " << SixV[4] << " " << SixV[5] << " "; // Momentum
40 os << " v2= " << G4ThreeVector(SixV[3], SixV[4], SixV[5]).mag(); // mom magnitude
41 os << " mdm= " << SixVec.fMomentumDir.mag();
42 os << " l= " << SixVec.GetCurveLength();
43 os << " ) ";
44 return os;
45}
46
47G4FieldTrack::G4FieldTrack( const G4ThreeVector& pPosition,
48 G4double LaboratoryTimeOfFlight,
49 const G4ThreeVector& pMomentumDirection,
50 G4double kineticEnergy,
51 G4double restMass_c2,
52 G4double charge,
53 const G4ThreeVector& Spin,
54 G4double magnetic_dipole_moment,
55 G4double curve_length )
56 : fKineticEnergy(kineticEnergy),
57 fRestMass_c2(restMass_c2),
58 fLabTimeOfFlight(LaboratoryTimeOfFlight),
59 // fProperTimeOfFlight(0.0),
60 // fMomentumDir(pMomentumDirection),
61 fChargeState( charge, magnetic_dipole_moment )
62{
63 G4double momentum = std::sqrt(kineticEnergy*kineticEnergy
64 +2.0*restMass_c2*kineticEnergy);
65
66 G4ThreeVector pMomentum= momentum * pMomentumDirection;
67 SetCurvePnt( pPosition, pMomentum, curve_length );
68 // Sets momentum direction as well.
69
70 // Set the momentum direction again - keeping value from argument exactly
71 fMomentumDir=pMomentumDirection;
72
73 InitialiseSpin( Spin );
74
75 // fpChargeState = new G4ChargeState( charge, magnetic_dipole_moment );
76}
77
78G4FieldTrack::G4FieldTrack( const G4ThreeVector& pPosition,
79 const G4ThreeVector& pMomentumDirection,
80 G4double curve_length,
81 G4double kineticEnergy,
82 const G4double restMass_c2,
83 G4double, // velocity
84 G4double pLaboratoryTimeOfFlight,
85 G4double pProperTimeOfFlight,
86 const G4ThreeVector* pSpin)
87 : fKineticEnergy(kineticEnergy),
88 fRestMass_c2(restMass_c2),
89 fLabTimeOfFlight(pLaboratoryTimeOfFlight),
90 fProperTimeOfFlight(pProperTimeOfFlight),
91 // fMomentumDir(pMomentumDirection),
92 fChargeState( DBL_MAX ) // charge not set
93{
94 G4double momentum = std::sqrt(kineticEnergy*kineticEnergy
95 +2.0*restMass_c2*kineticEnergy);
96 G4ThreeVector pMomentum= momentum * pMomentumDirection;
97
98 SetCurvePnt( pPosition, pMomentum, curve_length );
99 // Sets momentum direction as well.
100
101 // Set the momentum direction again
102 // -- to avoid numerical issues from multiplying by momentum and dividing again
103 fMomentumDir=pMomentumDirection;
104
105 G4ThreeVector Spin(0.0, 0.0, 0.0);
106 if( !pSpin ) Spin= G4ThreeVector(0.,0.,0.);
107 else Spin= *pSpin;
108 InitialiseSpin( Spin );
109
110 // fpChargeState = new G4ChargeState( DBL_MAX ); // charge not yet set !!
111}
112
113G4FieldTrack::G4FieldTrack( char ) // Nothing is set !!
114 : fRestMass_c2(0.0), fLabTimeOfFlight(0.0),
115 fChargeState( DBL_MAX ) // charge not set
116{
117 G4ThreeVector Zero(0.0, 0.0, 0.0);
118 SetCurvePnt( Zero, Zero, 0.0 );
119 InitialiseSpin( Zero );
120 // fpChargeState = new G4ChargeState( DBL_MAX );
121}
122
123void G4FieldTrack::
124 SetChargeAndMoments(G4double charge,
125 G4double magnetic_dipole_moment, // default= DBL_MAX - do not change
126 G4double electric_dipole_moment, // ditto
127 G4double magnetic_charge ) // ditto
128{
129 fChargeState.SetChargeAndMoments( charge, magnetic_dipole_moment,
130 electric_dipole_moment, magnetic_charge );
131
132 // fpChargeState->SetChargeAndMoments( charge, magnetic_dipole_moment,
133 // electric_dipole_moment, magnetic_charge );
134
135 // TO-DO: Improve the implementation using handles
136 // -- and handle to the old one (which can be shared by other copies) and
137 // must not be left to hang loose
138 //
139 // fpChargeState= new G4ChargeState( charge, magnetic_dipole_moment,
140 // electric_dipole_moment, magnetic_charge );
141}
Note: See TracBrowser for help on using the repository browser.