95 Double_t fmax,
const std::string
path)
97 mMeasuredMap(nullptr),
103 mDefaultIntegration(integ),
105 mMultipicativeFactorSolenoid(factorSol),
106 mMultipicativeFactorDipole(factorDip),
108 mDipoleOnOffFlag(factorDip == 0.),
109 mQuadrupoleGradient(0),
111 mCompensatorField2C(0),
112 mCompensatorField1A(0),
113 mCompensatorField2A(0),
114 mParameterNames(
"",
"")
367 const Double_t kBComp1CZ = 1075., kBComp1hDZ = 260. / 2., kBComp1SqR = 4.0 * 4.0;
368 const Double_t kBComp2CZ = 2049., kBComp2hDZ = 153. / 2., kBComp2SqR = 4.5 * 4.5;
370 const Double_t kTripQ1CZ = 2615., kTripQ1hDZ = 637. / 2., kTripQ1SqR = 3.5 * 3.5;
371 const Double_t kTripQ2CZ = 3480., kTripQ2hDZ = 550. / 2., kTripQ2SqR = 3.5 * 3.5;
372 const Double_t kTripQ3CZ = 4130., kTripQ3hDZ = 550. / 2., kTripQ3SqR = 3.5 * 3.5;
373 const Double_t kTripQ4CZ = 5015., kTripQ4hDZ = 637. / 2., kTripQ4SqR = 3.5 * 3.5;
375 const Double_t kDip1CZ = 6310.8, kDip1hDZ = 945. / 2., kDip1SqRC = 4.5 * 4.5, kDip1SqRA = 3.375 * 3.375;
376 const Double_t kDip2CZ = 12640.3, kDip2hDZ = 945. / 2., kDip2SqRC = 4.5 * 4.5, kDip2SqRA = 3.75 * 3.75;
377 const Double_t kDip2DXC = 9.7, kDip2DXA = 9.4;
379 double rad2 =
x[0] *
x[0] +
x[1] *
x[1];
381 b[0] =
b[1] =
b[2] = 0;
385 if (TMath::Abs(
x[2] + kBComp2CZ) < kBComp2hDZ && rad2 < kBComp2SqR) {
386 b[0] = mCompensatorField2C * mMultipicativeFactorDipole;
387 }
else if (TMath::Abs(
x[2] + kTripQ1CZ) < kTripQ1hDZ && rad2 < kTripQ1SqR) {
388 b[0] = mQuadrupoleGradient *
x[1];
389 b[1] = mQuadrupoleGradient *
x[0];
390 }
else if (TMath::Abs(
x[2] + kTripQ2CZ) < kTripQ2hDZ && rad2 < kTripQ2SqR) {
391 b[0] = -mQuadrupoleGradient *
x[1];
392 b[1] = -mQuadrupoleGradient *
x[0];
393 }
else if (TMath::Abs(
x[2] + kTripQ3CZ) < kTripQ3hDZ && rad2 < kTripQ3SqR) {
394 b[0] = -mQuadrupoleGradient *
x[1];
395 b[1] = -mQuadrupoleGradient *
x[0];
396 }
else if (TMath::Abs(
x[2] + kTripQ4CZ) < kTripQ4hDZ && rad2 < kTripQ4SqR) {
397 b[0] = mQuadrupoleGradient *
x[1];
398 b[1] = mQuadrupoleGradient *
x[0];
399 }
else if (TMath::Abs(
x[2] + kDip1CZ) < kDip1hDZ && rad2 < kDip1SqRC) {
401 }
else if (TMath::Abs(
x[2] + kDip2CZ) < kDip2hDZ && rad2 < kDip2SqRC) {
402 double dxabs = TMath::Abs(
x[0]) - kDip2DXC;
403 if ((dxabs * dxabs +
x[1] *
x[1]) < kDip2SqRC) {
404 b[1] = -mDipoleField;
411 if (TMath::Abs(
x[2] - kBComp1CZ) < kBComp1hDZ && rad2 < kBComp1SqR) {
413 b[0] = mCompensatorField1A * mMultipicativeFactorDipole;
416 if (TMath::Abs(
x[2] - kBComp2CZ) < kBComp2hDZ && rad2 < kBComp2SqR) {
417 b[0] = mCompensatorField2A * mMultipicativeFactorDipole;
418 }
else if (TMath::Abs(
x[2] - kTripQ1CZ) < kTripQ1hDZ && rad2 < kTripQ1SqR) {
419 b[0] = -mQuadrupoleGradient *
x[1];
420 b[1] = -mQuadrupoleGradient *
x[0];
421 }
else if (TMath::Abs(
x[2] - kTripQ2CZ) < kTripQ2hDZ && rad2 < kTripQ2SqR) {
422 b[0] = mQuadrupoleGradient *
x[1];
423 b[1] = mQuadrupoleGradient *
x[0];
424 }
else if (TMath::Abs(
x[2] - kTripQ3CZ) < kTripQ3hDZ && rad2 < kTripQ3SqR) {
425 b[0] = mQuadrupoleGradient *
x[1];
426 b[1] = mQuadrupoleGradient *
x[0];
427 }
else if (TMath::Abs(
x[2] - kTripQ4CZ) < kTripQ4hDZ && rad2 < kTripQ4SqR) {
428 b[0] = -mQuadrupoleGradient *
x[1];
429 b[1] = -mQuadrupoleGradient *
x[0];
430 }
else if (TMath::Abs(
x[2] - kDip1CZ) < kDip1hDZ && rad2 < kDip1SqRA) {
431 b[1] = -mDipoleField;
432 }
else if (TMath::Abs(
x[2] - kDip2CZ) < kDip2hDZ && rad2 < kDip2SqRA) {
433 double dxabs = TMath::Abs(
x[0]) - kDip2DXA;
434 if ((dxabs * dxabs +
x[1] *
x[1]) < kDip2SqRA) {
554 const float l3NominalCurrent1 = 30000.f;
555 const float l3NominalCurrent2 = 12000.f;
556 const float diNominalCurrent = 6000.f;
558 const float tolerance = 0.03;
559 const float zero = 77.f;
563 float l3sav = l3, dipsav = dip;
565 float l3Pol = l3 > 0 ? 1 : -1;
566 float diPol = dip > 0 ? 1 : -1;
569 dip = TMath::Abs(dip);
570 static bool overrideL3 = std::getenv(
"O2_OVERRIDE_L3_CURRENT") !=
nullptr;
571 static bool overrideDIP = std::getenv(
"O2_OVERRIDE_DIPOLE_CURRENT") !=
nullptr;
572 static bool warnL3Done =
false, warnDipDone =
false, warnPolarityDone =
false;
574 if (TMath::Abs((sclDip = dip / diNominalCurrent) - 1.) > tolerance && !uniform) {
579 LOG(fatal) <<
"MagneticField::createFieldMap: Wrong dipole current (" << dipsav <<
" A)!";
582 LOGP(error,
"Dipole current was overridden to unsupported value {}", dipsav);
592 sclL3 = l3 / l3NominalCurrent1;
594 if (TMath::Abs((sclL3 = l3 / l3NominalCurrent1) - 1.) < tolerance) {
596 }
else if (TMath::Abs((sclL3 = l3 / l3NominalCurrent2) - 1.) < tolerance) {
598 }
else if (l3 <= zero && dip <= zero) {
604 LOG(fatal) <<
"MagneticField::createFieldMap: Wrong L3 current (" << l3sav <<
" A)!";
607 LOGP(error,
"L3 current was overridden to unsupported value {}", l3sav);
611 sclL3 = l3 / l3NominalCurrent1;
617 ((convention ==
kConvLHC && l3Pol != diPol) || (convention ==
kConvDCS2008 && l3Pol == diPol))) {
618 if (overrideL3 || overrideDIP) {
619 if (!warnPolarityDone) {
620 LOG(error) <<
"Overriden currents have wrong combination for L3/Dipole polarities ("
621 << (l3Pol > 0 ?
'+' :
'-') <<
"/" << (diPol > 0 ?
'+' :
'-') <<
") for convention "
623 warnPolarityDone =
true;
626 LOG(fatal) <<
"MagneticField::createFieldMap: Wrong combination for L3/Dipole polarities ("
627 << (l3Pol > 0 ?
'+' :
'-') <<
"/" << (diPol > 0 ?
'+' :
'-') <<
") for convention "
632 l3 = (l3Pol < 0) ? -sclL3 : sclL3;
633 dip = (diPol < 0) ? -sclDip : sclDip;
638 float beamenergy,
const Char_t* beamtype,
const std::string
path)
640 float sclL3 = l3Cur, sclDip = diCur;
643 TString btypestr = beamtype;
645 TPRegexp protonBeam(R
"((proton|p)\s*-?\s*\1)");
646 TPRegexp ionBeam(R"((lead|pb|ion|a|A)\s*-?\s*\1)");
647 TPRegexp protonionBeam(R"((proton|p)\s*-?\s*(lead|pb|ion|a|A))");
648 TPRegexp ionprotonBeam(R"((lead|pb|ion|a|A)\s*-?\s*(proton|p))");
649 if (btypestr.Contains(ionBeam)) {
651 }
else if (btypestr.Contains(protonBeam)) {
653 }
else if (btypestr.Contains(protonionBeam)) {
655 }
else if (btypestr.Contains(ionprotonBeam)) {
658 LOG(info) <<
"Assume no LHC magnet field for the beam type " << beamtype;
661 snprintf(ttl, 79,
"L3: %+5d Dip: %+4d kA; %s | Polarities in %s convention", (
int)TMath::Sign(l3Cur,
float(sclL3)),
662 (
int)TMath::Sign(diCur,
float(sclDip)), uniform ?
" Constant" :
"",
663 convention ==
kConvLHC ?
"LHC" :
"DCS2008");
669 return new MagneticField(
"MagneticFieldMap", ttl, sclL3, sclDip, map, btype, beamenergy, 2, 10.,
path);
static MagneticField * createFieldMap(float l3Current=-30000., float diCurrent=-6000., Int_t convention=0, Bool_t uniform=kFALSE, float beamenergy=7000, const Char_t *btype="pp", const std::string path=std::string(gSystem->Getenv("VMCWORKDIR"))+std::string("/Common/maps/mfchebKGI_sym.root"))