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

Last change on this file since 1348 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 5.9 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.15 2010/07/14 10:00:36 gcosmo Exp $
28// GEANT4 tag $Name: field-V09-03-03 $
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] << " "
39                  << SixV[2] << " ";  // Position
40     os << " V= " << SixV[3] << " " << SixV[4] << " "
41                  << SixV[5] << " ";  // Momentum
42     os << " v2= "
43        << G4ThreeVector(SixV[3], SixV[4], SixV[5]).mag(); // mom magnitude
44     os << " mdm= " << SixVec.fMomentumDir.mag(); 
45     os << " l= " << SixVec.GetCurveLength();
46     os << " ) ";
47     return os;
48}
49
50G4FieldTrack::G4FieldTrack( const G4ThreeVector& pPosition, 
51                                  G4double       LaboratoryTimeOfFlight,
52                            const G4ThreeVector& pMomentumDirection,
53                                  G4double       kineticEnergy,
54                                  G4double       restMass_c2,
55                                  G4double       charge, 
56                            const G4ThreeVector& Spin,
57                                  G4double       magnetic_dipole_moment,
58                                  G4double       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  G4double momentum  = std::sqrt(kineticEnergy*kineticEnergy
67                            +2.0*restMass_c2*kineticEnergy);
68  G4ThreeVector pMomentum= momentum * pMomentumDirection; 
69  SetCurvePnt( pPosition, pMomentum, curve_length );
70    // Sets momentum direction as well.
71
72  fMomentumDir=pMomentumDirection; 
73    // Set the momentum direction again - keeping value from argument exactly
74
75  InitialiseSpin( Spin ); 
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
111G4FieldTrack::G4FieldTrack( char )                  //  Nothing is set !!
112  : fKineticEnergy(0.), fRestMass_c2(0.), fLabTimeOfFlight(0.),
113    fProperTimeOfFlight(0.), fChargeState( DBL_MAX )
114{
115  G4ThreeVector Zero(0.0, 0.0, 0.0);
116  SetCurvePnt( Zero, Zero, 0.0 );
117  InitialiseSpin( Zero ); 
118}
119
120void G4FieldTrack::
121     SetChargeAndMoments(G4double charge, 
122                         G4double magnetic_dipole_moment, // default= DBL_MAX - do not change
123                         G4double electric_dipole_moment, //   ditto
124                         G4double magnetic_charge )       //   ditto
125{
126  fChargeState.SetChargeAndMoments( charge,  magnetic_dipole_moment, 
127                      electric_dipole_moment,  magnetic_charge ); 
128
129  // fpChargeState->SetChargeAndMoments( charge,  magnetic_dipole_moment,
130  //          electric_dipole_moment,  magnetic_charge );
131
132  // TO-DO: Improve the implementation using handles
133  //   -- and handle to the old one (which can be shared by other copies) and
134  //      must not be left to hang loose
135  //
136  // fpChargeState= new G4ChargeState(  charge, magnetic_dipole_moment,
137  //                         electric_dipole_moment, magnetic_charge  );
138}
Note: See TracBrowser for help on using the repository browser.