5 #include "CLHEP/Units/PhysicalConstants.h" 9 G4double y, G4double z, G4double rot,
string ROTaxis)
19 if (rotaxis !=
"X" && rotaxis !=
"Y" && rotaxis !=
"Z")
21 cout <<
"!!! Error: multipole field has rot axis along X or Y or Z, while you have axis " 22 << rotaxis << endl; exit(-1);
34 G4ThreeVector x0(pos[0], pos[1], pos[2]);
35 G4ThreeVector x1(origin[0], origin[1], origin[2]);
37 G4ThreeVector x0_local;
40 x2 = G4ThreeVector(0*cm,0*cm,1*cm).rotateX(rotation)+x1;
41 x0_local = (x0 - x1).rotateX(-rotation);
43 else if (rotaxis==
"Y")
45 x2 = G4ThreeVector(0*cm,0*cm,1*cm).rotateY(rotation)+x1;
46 x0_local = (x0 - x1).rotateY(-rotation);
48 else if (rotaxis==
"Z")
50 x2 = G4ThreeVector(0*cm,0*cm,1*cm).rotateZ(rotation)+x1;
51 x0_local = (x0 - x1).rotateZ(-rotation);
55 cout <<
"!!! Error: multipole field has rot axis along X or Y or Z, while you have axis: " 60 G4double r = (x2 - x1).cross(x1 - x0).mag() / (x2 - x1).mag();
61 G4double phi = atan2(x0_local.y(), x0_local.x());
63 G4ThreeVector B_local;
67 B_local.setY(strength);
72 int a = polenumber / 2 - 1;
73 B_local.setX(strength * pow(r/m, a) * sin(a * phi));
74 B_local.setY(strength * pow(r/m, a) * cos(a * phi));
78 G4ThreeVector B_lab=B_local;
79 if (rotaxis==
"X") {B_lab.rotateX(rotation);}
80 else if (rotaxis==
"Y") {B_lab.rotateY(rotation);}
81 else if (rotaxis==
"Z") {B_lab.rotateZ(rotation);}
82 else {cout <<
"!!! Error: multipole field has rot axis along X or Y or Z, while you have axis " 83 << rotaxis << endl; exit(-1);
virtual ~multipoleField()
multipoleField(int Npole, G4double scale, G4double x, G4double y, G4double z, G4double rot, string ROTaxis)
virtual void GetFieldValue(const G4double pos[4], G4double *MagField) const