CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
MucMagneticField Class Reference

#include <MucMagneticField.h>

Public Member Functions

 MucMagneticField ()
 
 ~MucMagneticField ()
 
void getMucField (int part, int layer, int mat, HepPoint3D &r, HepVector3D &b)
 
void readPar ()
 
std::string getPath ()
 

Detailed Description

Definition at line 15 of file MucMagneticField.h.

Constructor & Destructor Documentation

◆ MucMagneticField()

MucMagneticField::MucMagneticField ( )

Definition at line 10 of file MucMagneticField.cxx.

11{
12 path = std::string(getenv( "MAGNETICFIELDROOT" ));
13#else
14MucMagneticField::MucMagneticField(const std::string Path)
15{
16 path = Path;
17#endif
18 readPar();
19}

Referenced by MucMagneticField().

◆ ~MucMagneticField()

MucMagneticField::~MucMagneticField ( )

Definition at line 20 of file MucMagneticField.cxx.

21{
22}

Member Function Documentation

◆ getMucField()

void MucMagneticField::getMucField ( int part,
int layer,
int mat,
HepPoint3D & r,
HepVector3D & b )

Definition at line 23 of file MucMagneticField.cxx.

25{
26 double x,y,z,bmf,emf;
27 x = r.x()/m;
28 y = r.y()/m;
29 z = r.z()/m;
30 //barrel, layer is the number of iron layer, mat=0 iron, mat=1 air
31 if(part==1)
32 {
33 if(layer==0&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx0[i]; }
34 if(layer==0&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx0[i]; }
35 if(layer==1&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx1[i]; }
36 if(layer==1&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx1[i]; }
37 if(layer==2&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx2[i]; }
38 if(layer==2&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx2[i]; }
39 if(layer==3&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx3[i]; }
40 if(layer==3&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx3[i]; }
41 if(layer==4&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx4[i]; }
42 if(layer==4&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx4[i]; }
43 if(layer==5&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx5[i]; }
44 if(layer==5&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx5[i]; }
45 if(layer==6&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx6[i]; }
46 if(layer==6&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx6[i]; }
47 if(layer==7&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx7[i]; }
48 if(layer==7&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapx7[i]; }
49 if(layer==8&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipx8[i]; }
50 bmf = bp[0]+bp[1]*x+bp[2]*x*x+bp[3]*z+bp[4]*z*z+bp[5]*z*z*z+bp[6]*z*z*z*z
51 +bp[7]*z*z*z*z*z+bp[8]*z*z*z*z*z*z+bp[9]*z*z*z*z*z*z*z+bp[10]*y+bp[11]*y*y
52 +bp[12]*y*y*y+bp[13]*x*z+bp[14]*z*y+bp[15]*x*y+bp[16]*z*y*y+bp[17]*z*z*y;
53 b[0] = bmf*tesla;
54
55 if(layer==0&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy0[i]; }
56 if(layer==0&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy0[i]; }
57 if(layer==1&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy1[i]; }
58 if(layer==1&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy1[i]; }
59 if(layer==2&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy2[i]; }
60 if(layer==2&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy2[i]; }
61 if(layer==3&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy3[i]; }
62 if(layer==3&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy3[i]; }
63 if(layer==4&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy4[i]; }
64 if(layer==4&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy4[i]; }
65 if(layer==5&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy5[i]; }
66 if(layer==5&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy5[i]; }
67 if(layer==6&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy6[i]; }
68 if(layer==6&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy6[i]; }
69 if(layer==7&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy7[i]; }
70 if(layer==7&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapy7[i]; }
71 if(layer==8&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipy8[i]; }
72 bmf = bp[0]+bp[1]*x+bp[2]*x*x+bp[3]*z+bp[4]*z*z+bp[5]*z*z*z+bp[6]*z*z*z*z
73 +bp[7]*z*z*z*z*z+bp[8]*z*z*z*z*z*z+bp[9]*z*z*z*z*z*z*z+bp[10]*y+bp[11]*y*y
74 +bp[12]*y*y*y+bp[13]*x*z+bp[14]*z*y+bp[15]*x*y+bp[16]*z*y*y+bp[17]*z*z*y;
75 b[1] = bmf*tesla;
76
77 if(layer==0&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz0[i]; }
78 if(layer==0&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz0[i]; }
79 if(layer==1&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz1[i]; }
80 if(layer==1&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz1[i]; }
81 if(layer==2&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz2[i]; }
82 if(layer==2&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz2[i]; }
83 if(layer==3&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz3[i]; }
84 if(layer==3&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz3[i]; }
85 if(layer==4&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz4[i]; }
86 if(layer==4&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz4[i]; }
87 if(layer==5&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz5[i]; }
88 if(layer==5&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz5[i]; }
89 if(layer==6&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz6[i]; }
90 if(layer==6&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz6[i]; }
91 if(layer==7&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz7[i]; }
92 if(layer==7&&mat==1) { for(int i=0; i<18; i++) bp[i] = bapz7[i]; }
93 if(layer==8&&mat==0) { for(int i=0; i<18; i++) bp[i] = bipz8[i]; }
94 bmf = bp[0]+bp[1]*x+bp[2]*x*x+bp[3]*z+bp[4]*z*z+bp[5]*z*z*z+bp[6]*z*z*z*z
95 +bp[7]*z*z*z*z*z+bp[8]*z*z*z*z*z*z+bp[9]*z*z*z*z*z*z*z+bp[10]*y+bp[11]*y*y
96 +bp[12]*y*y*y+bp[13]*x*z+bp[14]*z*y+bp[15]*x*y+bp[16]*z*y*y+bp[17]*z*z*y;
97 b[2] = bmf*tesla;
98 }
99 //endcaps, layer is the number of iron layer, total 9. m=0 iron, m=1 air
100 if(part==0)
101 {
102 if(layer==0&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx0[i]; }
103 if(layer==0&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx0[i]; }
104 if(layer==1&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx1[i]; }
105 if(layer==1&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx1[i]; }
106 if(layer==2&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx2[i]; }
107 if(layer==2&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx2[i]; }
108 if(layer==3&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx3[i]; }
109 if(layer==3&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx3[i]; }
110 if(layer==4&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx4[i]; }
111 if(layer==4&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx4[i]; }
112 if(layer==5&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx5[i]; }
113 if(layer==5&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx5[i]; }
114 if(layer==6&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx6[i]; }
115 if(layer==6&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx6[i]; }
116 if(layer==7&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx7[i]; }
117 if(layer==7&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapx7[i]; }
118 if(layer==8&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipx8[i]; }
119 emf = ep[0]+ep[1]*x+ep[2]*x*x+ep[3]*x*x*x+ep[4]*x*x*x*x+ep[5]*x*x*x*x*x+ep[6]*x*x*x*x*x*x
120 +ep[7]*x*x*x*x*x*x*x+ep[8]*z+ep[9]*y+ep[10]*y*y+ep[11]*y*y*y+ep[12]*x*z+ep[13]*z*y
121 +ep[14]*y*x+ep[15]*y*x*x+ep[16]*y*y*x;
122 b[0] = emf*tesla;
123
124 if(layer==0&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy0[i]; }
125 if(layer==0&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy0[i]; }
126 if(layer==1&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy1[i]; }
127 if(layer==1&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy1[i]; }
128 if(layer==2&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy2[i]; }
129 if(layer==2&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy2[i]; }
130 if(layer==3&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy3[i]; }
131 if(layer==3&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy3[i]; }
132 if(layer==4&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy4[i]; }
133 if(layer==4&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy4[i]; }
134 if(layer==5&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy5[i]; }
135 if(layer==5&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy5[i]; }
136 if(layer==6&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy6[i]; }
137 if(layer==6&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy6[i]; }
138 if(layer==7&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy7[i]; }
139 if(layer==7&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapy7[i]; }
140 if(layer==8&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipy8[i]; }
141 emf = ep[0]+ep[1]*x+ep[2]*x*x+ep[3]*x*x*x+ep[4]*x*x*x*x+ep[5]*x*x*x*x*x+ep[6]*x*x*x*x*x*x
142 +ep[7]*x*x*x*x*x*x*x+ep[8]*z+ep[9]*y+ep[10]*y*y+ep[11]*y*y*y+ep[12]*x*z+ep[13]*z*y
143 +ep[14]*y*x+ep[15]*y*x*x+ep[16]*y*y*x;
144 b[1] = emf*tesla;
145
146 if(layer==0&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz0[i]; }
147 if(layer==0&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz0[i]; }
148 if(layer==1&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz1[i]; }
149 if(layer==1&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz1[i]; }
150 if(layer==2&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz2[i]; }
151 if(layer==2&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz2[i]; }
152 if(layer==3&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz3[i]; }
153 if(layer==3&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz3[i]; }
154 if(layer==4&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz4[i]; }
155 if(layer==4&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz4[i]; }
156 if(layer==5&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz5[i]; }
157 if(layer==5&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz5[i]; }
158 if(layer==6&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz6[i]; }
159 if(layer==6&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz6[i]; }
160 if(layer==7&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz7[i]; }
161 if(layer==7&&mat==1) { for(int i=0; i<17; i++) ep[i] = aapz7[i]; }
162 if(layer==8&&mat==0) { for(int i=0; i<17; i++) ep[i] = aipz8[i]; }
163 emf = ep[0]+ep[1]*x+ep[2]*x*x+ep[3]*x*x*x+ep[4]*x*x*x*x+ep[5]*x*x*x*x*x+ep[6]*x*x*x*x*x*x
164 +ep[7]*x*x*x*x*x*x*x+ep[8]*z+ep[9]*y+ep[10]*y*y+ep[11]*y*y*y+ep[12]*x*z+ep[13]*z*y
165 +ep[14]*y*x+ep[15]*y*x*x+ep[16]*y*y*x;
166 b[2] = emf*tesla;
167 }
168}
Double_t x[10]

Referenced by MagneticFieldSvc::fieldVector().

◆ getPath()

std::string MucMagneticField::getPath ( )
inline

Definition at line 28 of file MucMagneticField.h.

28{return path;}

◆ readPar()

void MucMagneticField::readPar ( )

Definition at line 169 of file MucMagneticField.cxx.

170{
171 filename = path +
172 std::string( "/dat/barIronpar.txt");
173 ifstream infile1(filename.c_str(),ios_base::in);
174 if(infile1) cout<<"*** Read field map: "<<filename<<endl;
175 for(int i=0; i<18; i++)
176 {
177 infile1>>bipx0[i]>>bipy0[i]>>bipz0[i]>>bipx1[i]>>bipy1[i]>>bipz1[i]
178 >>bipx2[i]>>bipy2[i]>>bipz2[i]>>bipx3[i]>>bipy3[i]>>bipz3[i]
179 >>bipx4[i]>>bipy4[i]>>bipz4[i]>>bipx5[i]>>bipy5[i]>>bipz5[i]
180 >>bipx6[i]>>bipy6[i]>>bipz6[i]>>bipx7[i]>>bipy7[i]>>bipz7[i]
181 >>bipx8[i]>>bipy8[i]>>bipz8[i];
182 }
183
184 filename = path +
185 std::string( "/dat/barAirpar.txt");
186
187 ifstream infile2(filename.c_str(),ios_base::in);
188 if(infile2) cout<<"*** Read field map: "<<filename<<endl;
189 for(int j=0; j<18; j++)
190 {
191 infile2>>bapx0[j]>>bapy0[j]>>bapz0[j]>>bapx1[j]>>bapy1[j]>>bapz1[j]
192 >>bapx2[j]>>bapy2[j]>>bapz2[j]>>bapx3[j]>>bapy3[j]>>bapz3[j]
193 >>bapx4[j]>>bapy4[j]>>bapz4[j]>>bapx5[j]>>bapy5[j]>>bapz5[j]
194 >>bapx6[j]>>bapy6[j]>>bapz6[j]>>bapx7[j]>>bapy7[j]>>bapz7[j];
195 }
196
197 filename = path +
198 std::string( "/dat/endIronpar.txt");
199
200 ifstream infile3(filename.c_str(),ios_base::in);
201 if(infile3) cout<<"*** Read field map: "<<filename<<endl;
202 for(int i=0; i<17; i++)
203 {
204 infile3>>aipx0[i]>>aipy0[i]>>aipz0[i]>>aipx1[i]>>aipy1[i]>>aipz1[i]
205 >>aipx2[i]>>aipy2[i]>>aipz2[i]>>aipx3[i]>>aipy3[i]>>aipz3[i]
206 >>aipx4[i]>>aipy4[i]>>aipz4[i]>>aipx5[i]>>aipy5[i]>>aipz5[i]
207 >>aipx6[i]>>aipy6[i]>>aipz6[i]>>aipx7[i]>>aipy7[i]>>aipz7[i]
208 >>aipx8[i]>>aipy8[i]>>aipz8[i];
209 }
210
211 filename = path +
212 std::string( "/dat/endAirpar.txt");
213
214 ifstream infile4(filename.c_str(),ios_base::in);
215 if(infile4) cout<<"*** Read field map: "<<filename<<endl;
216 for(int j=0; j<17; j++)
217 {
218 infile4>>aapx0[j]>>aapy0[j]>>aapz0[j]>>aapx1[j]>>aapy1[j]>>aapz1[j]
219 >>aapx2[j]>>aapy2[j]>>aapz2[j]>>aapx3[j]>>aapy3[j]>>aapz3[j]
220 >>aapx4[j]>>aapy4[j]>>aapz4[j]>>aapx5[j]>>aapy5[j]>>aapz5[j]
221 >>aapx6[j]>>aapy6[j]>>aapz6[j]>>aapx7[j]>>aapy7[j]>>aapz7[j];
222 }
223}

Referenced by MucMagneticField().


The documentation for this class was generated from the following files: