1 #ifndef MACRO_G4BEAMLINE_C
2 #define MACRO_G4BEAMLINE_C
19 R__LOAD_LIBRARY(libg4detectors.so)
89 magFile =
string(getenv(
"CALIBRATIONROOT")) +
"/Beam/D0DXMagnets.dat";
96 std::ifstream
infile(magFile);
99 double biggest_z = 0.;
102 while (std::getline(infile, line))
104 if (!line.compare(0, 1,
"B") ||
105 !line.compare(0, 1,
"Q") ||
106 !line.compare(0, 1,
"S"))
108 std::istringstream iss(line);
113 double inner_radius_zin;
114 double inner_radius_zout;
115 double outer_magnet_diameter;
118 double dipole_field_x;
119 double fieldgradient;
120 if (!(iss >> magname >> x >> y >> z >> inner_radius_zin >> inner_radius_zout >> outer_magnet_diameter >> length >> angle >> dipole_field_x >> fieldgradient))
122 cout <<
"could not decode " << line << endl;
130 if (inner_radius_zin != inner_radius_zout)
132 cout <<
"inner radius at front of magnet " << inner_radius_zin
133 <<
" not equal radius at back of magnet " << inner_radius_zout
134 <<
" needs change in code (replace tube by cone for beamline)" << endl;
141 <<
"\tID number " << imagnet << endl;
142 cout <<
"magname: " << magname << endl;
143 cout <<
"x: " << x << endl;
144 cout <<
"y: " << y << endl;
145 cout <<
"z: " << z << endl;
146 cout <<
"inner_radius_zin: " << inner_radius_zin << endl;
147 cout <<
"inner_radius_zout: " << inner_radius_zout << endl;
148 cout <<
"outer_magnet_diameter: " << outer_magnet_diameter << endl;
149 cout <<
"length: " << length << endl;
150 cout <<
"angle: " << angle << endl;
151 cout <<
"dipole_field_x: " << dipole_field_x << endl;
152 cout <<
"fieldgradient: " << fieldgradient << endl;
154 if (!magname.compare(0, 1,
"B"))
158 else if (!magname.compare(0, 1,
"Q"))
160 magtype =
"QUADRUPOLE";
162 else if (!magname.compare(0, 1,
"S"))
164 magtype =
"SEXTUPOLE";
168 cout <<
"cannot decode magnet name " << magname << endl;
176 inner_radius_zin *= 100.;
177 outer_magnet_diameter *= 100.;
178 angle = (angle / M_PI * 180.) / 1000.;
182 if (magnetlist.empty() || magnetlist.find(imagnet) != magnetlist.end())
224 if (fabs(z) + length > biggest_z)
226 biggest_z = fabs(z) +
length;
241 const int ntube = 10;
242 const string nm[ntube] = {
"B00",
"B01",
"B10",
"B11",
"B20",
"B21",
"B30",
"B31",
"B32",
"B33"};
243 const double qlen[ntube] = {233.8, 233.8, 118.7, 118.7, 217.16, 217.16, 182.5, 182.5, 182.5, 182.5};
244 const double qir[ntube] = {6.08, 6.08, 14.60, 14.60, 20.0, 20.0, 6.07, 6.07, 6.07, 6.07};
245 const double qor[ntube] = {6.35, 6.35, 15.24, 15.24, 20.96, 20.96, 6.35, 6.35, 6.35, 6.35};
246 const double qrot[ntube] = {0, 0, 0, 0, 0, 0, 1.074, -1.074, -1.074, 1.074};
247 const double qxC[ntube] = {0, 0, 0, 0, 0, 0, 12.820, -12.820, 12.820, -12.820};
248 const double qyC[ntube] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
249 const double qzC[ntube] = {863.1, -863.1, 1474.470, -1474.470, 1642.4, -1642.4, 1843.2, 1843.2, -1843.2, -1843.2};
250 for (
int i = 0;
i < ntube;
i++)
252 string name =
"beamPipe" + nm[
i];
288 const double len[nSec] = {20.87, 20.87};
289 const double ir1[nSec] = {7.14, 14.60};
290 const double or1[nSec] = {7.77, 15.24};
291 const double ir2[nSec] = {14.60, 7.14};
292 const double or2[nSec] = {15.24, 7.77};
293 const double xC[nSec] = {0, 0};
294 const double yC[nSec] = {0, 0};
295 const double zC[nSec] = {1394.25, -1394.25};
296 for (
int i = 0;
i < nSec;
i++)