1 #ifndef MACRO_G4HFARFWDBEAMLINE_EIC_C
2 #define MACRO_G4HFARFWDBEAMLINE_EIC_C
4 #include <GlobalVariables.C>
11 #include <eicg4zdc/EICG4ZDCHitTree.h>
12 #include <eicg4zdc/EICG4ZDCNtuple.h>
13 #include <eicg4zdc/EICG4ZDCSubsystem.h>
45 namespace hFarFwdBeamLine
67 cout <<
"You cannot have magnets for both IP6 and IP8 ON at the same time" << endl;
110 magFile = string(getenv(
"CALIBRATIONROOT")) +
"/Beam/ip6_h_farFwdBeamLineMagnets.dat";
112 magFile = string(getenv(
"CALIBRATIONROOT")) +
"/Beam/ip8_35mrad_h_farFwdBeamLineMagnets.dat";
115 cout <<
" You have to enable either the IP6 or IP8 Magnet configuration to define magnets! " << endl;
120 bool magnet_active =
false;
121 int absorberactive = 0;
128 std::ifstream infile(magFile);
129 if (infile.is_open())
131 double biggest_z = 0.;
136 if (!line.compare(0, 1,
"B") ||
137 !line.compare(0, 1,
"Q") ||
138 !line.compare(0, 1,
"S"))
140 std::istringstream iss(line);
145 double inner_radius_zin;
146 double inner_radius_zout;
147 double outer_magnet_diameter;
150 double dipole_field_x;
151 double fieldgradient;
152 if (!(iss >> magname >> x >> y >> z >> inner_radius_zin >> inner_radius_zout >> outer_magnet_diameter >> length >> angle >> dipole_field_x >> fieldgradient))
154 cout <<
"coud not decode " << line << endl;
160 if (inner_radius_zin != inner_radius_zout)
162 cout <<
"inner radius at front of magnet " << inner_radius_zin
163 <<
" not equal radius at back of magnet " << inner_radius_zout
164 <<
" needs change in code (replace tube by cone for beamline)" << endl;
171 <<
"\tID number " << imagnet << endl;
172 cout <<
"magname: " << magname << endl;
173 cout <<
"x: " << x << endl;
174 cout <<
"y: " << y << endl;
175 cout <<
"z: " << z << endl;
176 cout <<
"inner_radius_zin: " << inner_radius_zin << endl;
177 cout <<
"inner_radius_zout: " << inner_radius_zout << endl;
178 cout <<
"outer_magnet_diameter: " << outer_magnet_diameter << endl;
179 cout <<
"length: " << length << endl;
180 cout <<
"angle: " << angle << endl;
181 cout <<
"dipole_field_x: " << dipole_field_x << endl;
182 cout <<
"fieldgradient: " << fieldgradient << endl;
184 if (!magname.compare(0, 1,
"B"))
188 else if (!magname.compare(0, 1,
"Q"))
190 magtype =
"QUADRUPOLE";
192 else if (!magname.compare(0, 1,
"S"))
194 magtype =
"SEXTUPOLE";
198 cout <<
"cannot decode magnet name " << magname << endl;
206 inner_radius_zin *= 100.;
207 outer_magnet_diameter *= 100.;
208 angle = (angle / TMath::Pi() * 180.) / 1000.;
210 if (magnetlist.empty() || magnetlist.find(imagnet) != magnetlist.end())
245 if (fabs(z) + length > biggest_z)
247 biggest_z = fabs(z) +
length;
261 cout <<
"You cannot have detectors enabled for both IP6 and IP8 ON at the same time" << endl;
268 const double detZDCsurrogate_size_z = 0.1;
269 detZDCsurrogate->SuperDetector(
"ZDCsurrogate");
270 detZDCsurrogate->set_double_param(
"place_x", 96.24);
271 detZDCsurrogate->set_double_param(
"place_y", 0);
273 detZDCsurrogate->set_double_param(
"rot_y", -0.025 * TMath::RadToDeg());
274 detZDCsurrogate->set_double_param(
"size_x", 60);
275 detZDCsurrogate->set_double_param(
"size_y", 60);
276 detZDCsurrogate->set_double_param(
"size_z", detZDCsurrogate_size_z);
277 detZDCsurrogate->set_string_param(
"material",
"G4_Si");
278 detZDCsurrogate->SetActive();
279 detZDCsurrogate->set_color(1, 0, 0, 0.5);
280 detZDCsurrogate->OverlapCheck(overlapCheck);
283 detZDCsurrogate->Verbosity(verbosity);
299 const int offMomDetNr = 2;
300 const double om_zCent[offMomDetNr] = {3450, 3650};
301 const double om_xCent[offMomDetNr] = {162, 171};
302 for (
int i = 0; i < offMomDetNr; i++)
305 detOM->SuperDetector(
"offMomTruth");
306 detOM->set_double_param(
"place_x", om_xCent[i]);
307 detOM->set_double_param(
"place_y", 0);
309 detOM->set_double_param(
"rot_y", -0.045 * TMath::RadToDeg());
310 detOM->set_double_param(
"size_x", 50);
311 detOM->set_double_param(
"size_y", 35);
312 detOM->set_double_param(
"size_z", 0.03);
313 detOM->set_string_param(
"material",
"G4_Si");
316 detOM->Verbosity(verbosity);
317 detOM->OverlapCheck(overlapCheck);
322 const int rpDetNr = 2;
323 const double rp_zCent[rpDetNr] = {2600, 2800};
324 const double rp_xCent[rpDetNr] = {84.49, 93.59};
325 for (
int i = 0; i < rpDetNr; i++)
348 detRP->SuperDetector(
"rpTruth");
349 detRP->set_double_param(
"place_x", rp_xCent[i]);
350 detRP->set_double_param(
"place_y", 0);
352 detRP->set_double_param(
"rot_y", -0.025 * TMath::RadToDeg());
353 detRP->set_double_param(
"radius", 0);
354 detRP->set_double_param(
"thickness", 25);
355 detRP->set_double_param(
"length", 0.03);
356 detRP->set_string_param(
"material",
"G4_Si");
357 detRP->OverlapCheck(overlapCheck);
362 detRP->Verbosity(verbosity);
366 const int b0DetNr = 4;
367 const double b0Mag_zCent = 590;
368 const double b0Mag_zLen = 120;
369 for (
int i = 0; i < b0DetNr; i++)
372 detB0->SuperDetector(
"b0Truth");
373 detB0->set_double_param(
"radius", 0);
374 detB0->set_double_param(
"thickness", 20);
375 detB0->set_double_param(
"length", 0.1);
376 detB0->set_string_param(
"material",
"G4_Si");
377 detB0->set_double_param(
"place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2));
378 detB0->SetActive(
true);
380 detB0->Verbosity(verbosity);
381 detB0->OverlapCheck(overlapCheck);
389 cout << __PRETTY_FUNCTION__ <<
" : IP8 setup is not yet validated!" << endl;
395 cout <<
"You cannot have detectors enabled for both IP6 and IP8 ON at the same time" << endl;
401 const int offMomDetNr = 3;
402 const double om_zCent[offMomDetNr] = {4250, 4400, 4550};
403 const double om_xCent[offMomDetNr] = {100, 100, 100};
404 for (
int i = 0; i < offMomDetNr; i++)
407 detOM->set_double_param(
"place_x", om_xCent[i]);
408 detOM->set_double_param(
"place_y", 0);
409 detOM->set_double_param(
"place_z", om_zCent[i]);
410 detOM->set_double_param(
"rot_y", -0.029 * TMath::RadToDeg());
411 detOM->set_double_param(
"size_x", 100);
412 detOM->set_double_param(
"size_y", 100);
413 detOM->set_double_param(
"size_z", 0.03);
414 detOM->set_string_param(
"material",
"G4_Si");
417 detOM->Verbosity(verbosity);
422 const double detZDCsurrogate_size_z = 0.1;
423 detZDCsurrogate->SuperDetector(
"ZDCsurrogate");
424 detZDCsurrogate->set_double_param(
"place_x", 127.8);
425 detZDCsurrogate->set_double_param(
"place_y", 0);
426 detZDCsurrogate->set_double_param(
"place_z", 3650);
427 detZDCsurrogate->set_double_param(
"rot_y", -0.035 * TMath::RadToDeg());
428 detZDCsurrogate->set_double_param(
"size_x", 60);
429 detZDCsurrogate->set_double_param(
"size_y", 60);
430 detZDCsurrogate->set_double_param(
"size_z", detZDCsurrogate_size_z);
431 detZDCsurrogate->set_string_param(
"material",
"G4_Si");
432 detZDCsurrogate->SetActive();
433 detZDCsurrogate->OverlapCheck(overlapCheck);
434 detZDCsurrogate->set_color(1, 0, 0, 0.5);
437 detZDCsurrogate->Verbosity(verbosity);
448 const int rpDetNr = 4;
449 const double rp_zCent[rpDetNr] = {2200, 2500, 2800, 3100};
450 const double rp_xCent[rpDetNr] = {75, 75, 75, 75};
451 for (
int i = 0; i < rpDetNr; i++)
455 detRP->SuperDetector(Form(
"RomanPots_%d", i));
456 detRP->set_double_param(
"place_x", rp_xCent[i]);
457 detRP->set_double_param(
"place_y", 0);
458 detRP->set_double_param(
"place_z", rp_zCent[i]);
459 detRP->set_double_param(
"rot_y", -0.0215 * TMath::RadToDeg());
460 detRP->set_double_param(
"size_x", 100);
461 detRP->set_double_param(
"size_y", 100);
462 detRP->set_double_param(
"size_z", 0.03);
463 detRP->set_string_param(
"material",
"G4_Si");
466 detRP->Verbosity(verbosity);
470 const int b0DetNr = 4;
471 const double b0Mag_zCent = 610;
472 const double b0Mag_zLen = 120;
473 for (
int i = 0; i < b0DetNr; i++)
477 detB0->set_double_param(
"radius", 0);
478 detB0->set_double_param(
"thickness", 20);
479 detB0->set_double_param(
"length", 0.1);
480 detB0->set_string_param(
"material",
"G4_Si");
481 detB0->set_double_param(
"place_x", 21.2);
482 detB0->set_double_param(
"place_y", 0);
483 detB0->set_double_param(
"place_z", (b0Mag_zCent - b0Mag_zLen / 2) + b0Mag_zLen / (b0DetNr - 1) * i);
484 detB0->SetActive(
true);
486 detB0->Verbosity(verbosity);
522 const string nm[nSecQ] = {
"B0apf",
"Q1apf",
"Q1bpf",
"Q2pf",
"B1pf"};
523 const double qlen[nSecQ] = {160, 150, 220, 440, 330};
524 const double qir[nSecQ] = {4, 5.1, 7, 12, 12.2};
525 const double qor[nSecQ] = {4.1, 5.2, 7.2, 12.2, 12.4};
526 const double qrot[nSecQ] = {25, 19.5, 15, 15, 34};
527 const double qxC[nSecQ] = {19.8, 24.47, 30.05, 39.5, 48};
528 const double qyC[nSecQ] = {0, 0, 0, 0, 0};
529 const double qzC[nSecQ] = {770, 922.8, 1106.3, 1416.7, 1806.7};
530 for (
int i = 0; i < nSecQ; i++)
575 const double len[nSec] = {850, 1150};
576 const double ir1[nSec] = {17, 17};
577 const double or1[nSec] = {17.1, 17.1};
578 const double ir2[nSec] = {17, 7};
579 const double or2[nSec] = {17.1, 7.1};
580 const double xC[nSec] = {83, 130};
581 const double yC[nSec] = {0, 0};
582 const double zC[nSec] = {2550, 3550};
583 for (
int i = 0; i < nSec; i++)