00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "G4QuadrupoleMagField.hh"
00032 #include "G4RotationMatrix.hh"
00033
00034 static G4RotationMatrix IdentityMatrix;
00035
00036 G4QuadrupoleMagField::G4QuadrupoleMagField(G4double pGradient)
00037 {
00038
00039 fGradient = pGradient ;
00040 fOrigin = G4ThreeVector( 0.0, 0.0, 0.0) ;
00041 fpMatrix = &IdentityMatrix;
00042 }
00043
00045
00046 G4QuadrupoleMagField::G4QuadrupoleMagField(G4double pGradient, G4ThreeVector
00047 pOrigin, G4RotationMatrix* pMatrix)
00048 {
00049 fGradient = pGradient ;
00050 fOrigin = pOrigin ;
00051 fpMatrix = pMatrix ;
00052 }
00053
00055
00056 G4QuadrupoleMagField::~G4QuadrupoleMagField()
00057 {
00058 }
00059
00061
00062
00063
00064 void G4QuadrupoleMagField::GetFieldValue( const G4double y[7],
00065 G4double B[3] ) const
00066 {
00067
00068 G4ThreeVector r_global = G4ThreeVector(
00069 y[0] - fOrigin.x(),
00070 y[1] - fOrigin.y(),
00071 y[2] - fOrigin.z());
00072
00073 G4ThreeVector r_local = G4ThreeVector(
00074 fpMatrix->colX() * r_global,
00075 fpMatrix->colY() * r_global,
00076 fpMatrix->colZ() * r_global);
00077
00078 G4ThreeVector B_local = G4ThreeVector(
00079 fGradient * r_local.y(),
00080 fGradient * r_local.x(),
00081 0);
00082
00083 G4ThreeVector B_global = G4ThreeVector(
00084 fpMatrix->inverse().rowX() * B_local,
00085 fpMatrix->inverse().rowY() * B_local,
00086 fpMatrix->inverse().rowZ() * B_local);
00087
00088 B[0] = B_global.x() ;
00089 B[1] = B_global.y() ;
00090 B[2] = B_global.z() ;
00091 }