Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ErrorSurfaceTrajState.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// $Id$
27//
28// ------------------------------------------------------------
29// GEANT 4 class implementation file
30// ------------------------------------------------------------
31//
32
35
37#include "G4SystemOfUnits.hh"
38#include "G4Field.hh"
39#include "G4FieldManager.hh"
41
42#include "G4ErrorMatrix.hh"
43
44#include <iomanip>
45
46
47//------------------------------------------------------------------------
49G4ErrorSurfaceTrajState( const G4String& partType, const G4Point3D& pos,
50 const G4Vector3D& mom, const G4Vector3D& vecU,
51 const G4Vector3D& vecV, const G4ErrorTrajErr& errmat)
52 : G4ErrorTrajState( partType, pos, mom, errmat )
53{
54 Init();
55 fTrajParam = G4ErrorSurfaceTrajParam( pos, mom, vecU, vecV );
56}
57
58
59//------------------------------------------------------------------------
61G4ErrorSurfaceTrajState( const G4String& partType, const G4Point3D& pos,
62 const G4Vector3D& mom, const G4Plane3D& plane,
63 const G4ErrorTrajErr& errmat )
64 : G4ErrorTrajState( partType, pos, mom, errmat )
65{
66 Init();
67 fTrajParam = G4ErrorSurfaceTrajParam( pos, mom, plane );
68
69}
70
71
72//------------------------------------------------------------------------
75 : G4ErrorTrajState( tpSC.GetParticleType(), tpSC.GetPosition(),
76 tpSC.GetMomentum() )
77{
78 // fParticleType = tpSC.GetParticleType();
79 // fPosition = tpSC.GetPosition();
80 // fMomentum = tpSC.GetMomentum();
81 fTrajParam = G4ErrorSurfaceTrajParam( fPosition, fMomentum, plane );
82 Init();
83
84 //----- Get the error matrix in SC coordinates
86}
87
88
89//------------------------------------------------------------------------
92 const G4Vector3D& vecV )
93 : G4ErrorTrajState( tpSC.GetParticleType(), tpSC.GetPosition(),
94 tpSC.GetMomentum() )
95{
96 fTrajParam = G4ErrorSurfaceTrajParam( fPosition, fMomentum, vecU, vecV );
98 //----- Get the error matrix in SC coordinates
99 BuildErrorMatrix( tpSC, vecU, vecV );
100}
101
102
103//------------------------------------------------------------------------
106 const G4Vector3D& )
107{
108 G4double sclambda = tpSC.GetParameters().GetLambda();
109 G4double scphi = tpSC.GetParameters().GetPhi();
111 sclambda *= -1;
112 scphi += CLHEP::pi;
113 }
114 G4double cosLambda = std::cos( sclambda );
115 G4double sinLambda = std::sin( sclambda );
116 G4double sinPhi = std::sin( scphi );
117 G4double cosPhi = std::cos( scphi );
118
119#ifdef G4EVERBOSE
120 if( iverbose >= 4) G4cout << " PM " << fMomentum.mag() << " pLambda " << sclambda << " pPhi " << scphi << G4endl;
121#endif
122
123 G4ThreeVector vTN( cosLambda*cosPhi, cosLambda*sinPhi,sinLambda );
124 G4ThreeVector vUN( -sinPhi, cosPhi, 0. );
125 G4ThreeVector vVN( -vTN.z()*vUN.y(),vTN.z()*vUN.x(), cosLambda );
126
127#ifdef G4EVERBOSE
128 if( iverbose >= 4) G4cout << " SC2SD: vTN " << vTN << " vUN " << vUN << " vVN " << vVN << G4endl;
129#endif
130 G4double UJ = vUN*GetVectorV();
131 G4double UK = vUN*GetVectorW();
132 G4double VJ = vVN*GetVectorV();
133 G4double VK = vVN*GetVectorW();
134
135
136 //--- Get transformation first
137 G4ErrorMatrix transfM(5, 5, 0 );
138 //--- Get magnetic field
140
141 G4Vector3D vectorU = GetVectorV().cross( GetVectorW() );
142
143#ifdef G4EVERBOSE
144 if( iverbose >= 4) G4cout << "vectors " << vectorU << " " << GetVectorV() << " " << GetVectorW() << G4endl;
145#endif
146 G4double T1R = 1. / ( vTN * vectorU );
147
148 if( fCharge != 0 && field ) {
149 G4double pos[3]; pos[0] = fPosition.x()*cm; pos[1] = fPosition.y()*cm; pos[2] = fPosition.z()*cm;
150 G4double Hd[3];
151 field->GetFieldValue( pos, Hd );
152 G4ThreeVector H = G4ThreeVector( Hd[0], Hd[1], Hd[2] ) / tesla *10.; //in kilogauus
153 G4double magH = H.mag();
154 G4double invP = 1./(fMomentum.mag()/GeV);
155 G4double magHM = magH * invP;
156 if( magH != 0. ) {
157 G4double magHM2 = fCharge / magH;
158 G4double Q = -magHM * c_light/ (km/ns);
159#ifdef G4EVERBOSE
160 if( iverbose >= 4) G4cout << GeV << " Q " << Q << " magHM " << magHM << " c_light/(km/ns) " << c_light/(km/ns) << G4endl;
161#endif
162
163 G4double sinz = -H*vUN * magHM2;
164 G4double cosz = H*vVN * magHM2;
165 G4double T3R = Q * std::pow(T1R,3);
166 G4double UI = vUN * vectorU;
167 G4double VI = vVN * vectorU;
168#ifdef G4EVERBOSE
169 if( iverbose >= 4) {
170 G4cout << " T1R " << T1R << " T3R " << T3R << G4endl;
171 G4cout << " UI " << UI << " VI " << VI << " vectorU " << vectorU << G4endl;
172 G4cout << " UJ " << UJ << " VJ " << VJ << G4endl;
173 G4cout << " UK " << UK << " VK " << VK << G4endl;
174 }
175#endif
176
177 transfM[1][3] = -UI*( VK*cosz-UK*sinz)*T3R;
178 transfM[1][4] = -VI*( VK*cosz-UK*sinz)*T3R;
179 transfM[2][3] = UI*( VJ*cosz-UJ*sinz)*T3R;
180 transfM[2][4] = VI*( VJ*cosz-UJ*sinz)*T3R;
181 }
182 }
183
184 G4double T2R = T1R * T1R;
185 transfM[0][0] = 1.;
186 transfM[1][1] = -UK*T2R;
187 transfM[1][2] = VK*cosLambda*T2R;
188 transfM[2][1] = UJ*T2R;
189 transfM[2][2] = -VJ*cosLambda*T2R;
190 transfM[3][3] = VK*T1R;
191 transfM[3][4] = -UK*T1R;
192 transfM[4][3] = -VJ*T1R;
193 transfM[4][4] = UJ*T1R;
194
195#ifdef G4EVERBOSE
196 if( iverbose >= 4) G4cout << " SC2SD transf matrix A= " << transfM << G4endl;
197#endif
198 fError = G4ErrorTrajErr( tpSC.GetError().similarity( transfM ) );
199
200#ifdef G4EVERBOSE
201 if( iverbose >= 1) G4cout << "G4EP: error matrix SC2SD " << fError << G4endl;
202 if( iverbose >= 4) G4cout << "G4ErrorSurfaceTrajState from SC " << *this << G4endl;
203#endif
204
205}
206
207
208//------------------------------------------------------------------------
209void G4ErrorSurfaceTrajState::Init()
210{
212 BuildCharge();
213}
214
215
216//------------------------------------------------------------------------
217void G4ErrorSurfaceTrajState::Dump( std::ostream& out ) const
218{
219 out << *this;
220}
221
222
223//------------------------------------------------------------------------
224std::ostream& operator<<(std::ostream& out, const G4ErrorSurfaceTrajState& ts)
225{
226 std::ios::fmtflags oldFlags = out.flags();
227 out.setf(std::ios::fixed,std::ios::floatfield);
228
229 ts.DumpPosMomError( out );
230
231 out << " G4ErrorSurfaceTrajState: Params: " << ts.fTrajParam << G4endl;
232 out.flags(oldFlags);
233 return out;
234}
@ G4ErrorMode_PropBackwards
std::ostream & operator<<(std::ostream &out, const G4ErrorSurfaceTrajState &ts)
G4ErrorSymMatrix G4ErrorTrajErr
@ G4eTS_OS
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
double z() const
double x() const
double y() const
double mag() const
G4double GetLambda() const
G4ErrorFreeTrajParam GetParameters() const
static G4ErrorPropagatorData * GetErrorPropagatorData()
virtual void Dump(std::ostream &out=G4cout) const
G4ErrorSurfaceTrajState(const G4String &partType, const G4Point3D &pos, const G4Vector3D &mom, const G4Plane3D &plane, const G4ErrorTrajErr &errmat=G4ErrorTrajErr(5, 0))
void BuildErrorMatrix(G4ErrorFreeTrajState &tpSC, const G4Vector3D &vecV, const G4Vector3D &vecW)
G4ErrorSymMatrix similarity(const G4ErrorMatrix &m1) const
void DumpPosMomError(std::ostream &out=G4cout) const
G4ErrorTrajErr fError
G4ErrorTrajErr GetError() const
const G4Field * GetDetectorField() const
virtual void GetFieldValue(const double Point[4], double *fieldArr) const =0
static G4TransportationManager * GetTransportationManager()
G4FieldManager * GetFieldManager() const
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
#define ns
Definition: xmlparse.cc:597