94 Double_t fmax,
const std::string
path)
96 mMeasuredMap(nullptr),
102 mDefaultIntegration(integ),
104 mMultipicativeFactorSolenoid(factorSol),
105 mMultipicativeFactorDipole(factorDip),
107 mDipoleOnOffFlag(factorDip == 0.),
108 mQuadrupoleGradient(0),
110 mCompensatorField2C(0),
111 mCompensatorField1A(0),
112 mCompensatorField2A(0),
113 mParameterNames(
"",
"")
365 const Double_t kBComp1CZ = 1075., kBComp1hDZ = 260. / 2., kBComp1SqR = 4.0 * 4.0;
366 const Double_t kBComp2CZ = 2049., kBComp2hDZ = 153. / 2., kBComp2SqR = 4.5 * 4.5;
368 const Double_t kTripQ1CZ = 2615., kTripQ1hDZ = 637. / 2., kTripQ1SqR = 3.5 * 3.5;
369 const Double_t kTripQ2CZ = 3480., kTripQ2hDZ = 550. / 2., kTripQ2SqR = 3.5 * 3.5;
370 const Double_t kTripQ3CZ = 4130., kTripQ3hDZ = 550. / 2., kTripQ3SqR = 3.5 * 3.5;
371 const Double_t kTripQ4CZ = 5015., kTripQ4hDZ = 637. / 2., kTripQ4SqR = 3.5 * 3.5;
373 const Double_t kDip1CZ = 6310.8, kDip1hDZ = 945. / 2., kDip1SqRC = 4.5 * 4.5, kDip1SqRA = 3.375 * 3.375;
374 const Double_t kDip2CZ = 12640.3, kDip2hDZ = 945. / 2., kDip2SqRC = 4.5 * 4.5, kDip2SqRA = 3.75 * 3.75;
375 const Double_t kDip2DXC = 9.7, kDip2DXA = 9.4;
377 double rad2 =
x[0] *
x[0] +
x[1] *
x[1];
379 b[0] =
b[1] =
b[2] = 0;
383 if (TMath::Abs(
x[2] + kBComp2CZ) < kBComp2hDZ && rad2 < kBComp2SqR) {
384 b[0] = mCompensatorField2C * mMultipicativeFactorDipole;
385 }
else if (TMath::Abs(
x[2] + kTripQ1CZ) < kTripQ1hDZ && rad2 < kTripQ1SqR) {
386 b[0] = mQuadrupoleGradient *
x[1];
387 b[1] = mQuadrupoleGradient *
x[0];
388 }
else if (TMath::Abs(
x[2] + kTripQ2CZ) < kTripQ2hDZ && rad2 < kTripQ2SqR) {
389 b[0] = -mQuadrupoleGradient *
x[1];
390 b[1] = -mQuadrupoleGradient *
x[0];
391 }
else if (TMath::Abs(
x[2] + kTripQ3CZ) < kTripQ3hDZ && rad2 < kTripQ3SqR) {
392 b[0] = -mQuadrupoleGradient *
x[1];
393 b[1] = -mQuadrupoleGradient *
x[0];
394 }
else if (TMath::Abs(
x[2] + kTripQ4CZ) < kTripQ4hDZ && rad2 < kTripQ4SqR) {
395 b[0] = mQuadrupoleGradient *
x[1];
396 b[1] = mQuadrupoleGradient *
x[0];
397 }
else if (TMath::Abs(
x[2] + kDip1CZ) < kDip1hDZ && rad2 < kDip1SqRC) {
399 }
else if (TMath::Abs(
x[2] + kDip2CZ) < kDip2hDZ && rad2 < kDip2SqRC) {
400 double dxabs = TMath::Abs(
x[0]) - kDip2DXC;
401 if ((dxabs * dxabs +
x[1] *
x[1]) < kDip2SqRC) {
402 b[1] = -mDipoleField;
409 if (TMath::Abs(
x[2] - kBComp1CZ) < kBComp1hDZ && rad2 < kBComp1SqR) {
411 b[0] = mCompensatorField1A * mMultipicativeFactorDipole;
414 if (TMath::Abs(
x[2] - kBComp2CZ) < kBComp2hDZ && rad2 < kBComp2SqR) {
415 b[0] = mCompensatorField2A * mMultipicativeFactorDipole;
416 }
else if (TMath::Abs(
x[2] - kTripQ1CZ) < kTripQ1hDZ && rad2 < kTripQ1SqR) {
417 b[0] = -mQuadrupoleGradient *
x[1];
418 b[1] = -mQuadrupoleGradient *
x[0];
419 }
else if (TMath::Abs(
x[2] - kTripQ2CZ) < kTripQ2hDZ && rad2 < kTripQ2SqR) {
420 b[0] = mQuadrupoleGradient *
x[1];
421 b[1] = mQuadrupoleGradient *
x[0];
422 }
else if (TMath::Abs(
x[2] - kTripQ3CZ) < kTripQ3hDZ && rad2 < kTripQ3SqR) {
423 b[0] = mQuadrupoleGradient *
x[1];
424 b[1] = mQuadrupoleGradient *
x[0];
425 }
else if (TMath::Abs(
x[2] - kTripQ4CZ) < kTripQ4hDZ && rad2 < kTripQ4SqR) {
426 b[0] = -mQuadrupoleGradient *
x[1];
427 b[1] = -mQuadrupoleGradient *
x[0];
428 }
else if (TMath::Abs(
x[2] - kDip1CZ) < kDip1hDZ && rad2 < kDip1SqRA) {
429 b[1] = -mDipoleField;
430 }
else if (TMath::Abs(
x[2] - kDip2CZ) < kDip2hDZ && rad2 < kDip2SqRA) {
431 double dxabs = TMath::Abs(
x[0]) - kDip2DXA;
432 if ((dxabs * dxabs +
x[1] *
x[1]) < kDip2SqRA) {
552 const float l3NominalCurrent1 = 30000.f;
553 const float l3NominalCurrent2 = 12000.f;
554 const float diNominalCurrent = 6000.f;
556 const float tolerance = 0.03;
557 const float zero = 77.f;
561 float l3sav = l3, dipsav = dip;
563 float l3Pol = l3 > 0 ? 1 : -1;
564 float diPol = dip > 0 ? 1 : -1;
567 dip = TMath::Abs(dip);
568 static bool overrideL3 = std::getenv(
"O2_OVERRIDE_L3_CURRENT") !=
nullptr;
569 static bool overrideDIP = std::getenv(
"O2_OVERRIDE_DIPOLE_CURRENT") !=
nullptr;
570 static bool warnL3Done =
false, warnDipDone =
false, warnPolarityDone =
false;
572 if (TMath::Abs((sclDip = dip / diNominalCurrent) - 1.) > tolerance && !uniform) {
577 LOG(fatal) <<
"MagneticField::createFieldMap: Wrong dipole current (" << dipsav <<
" A)!";
580 LOGP(error,
"Dipole current was overridden to unsupported value {}", dipsav);
590 sclL3 = l3 / l3NominalCurrent1;
592 if (TMath::Abs((sclL3 = l3 / l3NominalCurrent1) - 1.) < tolerance) {
594 }
else if (TMath::Abs((sclL3 = l3 / l3NominalCurrent2) - 1.) < tolerance) {
596 }
else if (l3 <= zero && dip <= zero) {
602 LOG(fatal) <<
"MagneticField::createFieldMap: Wrong L3 current (" << l3sav <<
" A)!";
605 LOGP(error,
"L3 current was overridden to unsupported value {}", l3sav);
609 sclL3 = l3 / l3NominalCurrent1;
615 ((convention ==
kConvLHC && l3Pol != diPol) || (convention ==
kConvDCS2008 && l3Pol == diPol))) {
616 if (overrideL3 || overrideDIP) {
617 if (!warnPolarityDone) {
618 LOG(error) <<
"Overriden currents have wrong combination for L3/Dipole polarities ("
619 << (l3Pol > 0 ?
'+' :
'-') <<
"/" << (diPol > 0 ?
'+' :
'-') <<
") for convention "
621 warnPolarityDone =
true;
624 LOG(fatal) <<
"MagneticField::createFieldMap: Wrong combination for L3/Dipole polarities ("
625 << (l3Pol > 0 ?
'+' :
'-') <<
"/" << (diPol > 0 ?
'+' :
'-') <<
") for convention "
630 l3 = (l3Pol < 0) ? -sclL3 : sclL3;
631 dip = (diPol < 0) ? -sclDip : sclDip;
636 float beamenergy,
const Char_t* beamtype,
const std::string
path)
638 float sclL3 = l3Cur, sclDip = diCur;
641 TString btypestr = beamtype;
643 TPRegexp protonBeam(R
"((proton|p)\s*-?\s*\1)");
644 TPRegexp ionBeam(R"((lead|pb|ion|a|A)\s*-?\s*\1)");
645 TPRegexp protonionBeam(R"((proton|p)\s*-?\s*(lead|pb|ion|a|A))");
646 TPRegexp ionprotonBeam(R"((lead|pb|ion|a|A)\s*-?\s*(proton|p))");
647 if (btypestr.Contains(ionBeam)) {
649 }
else if (btypestr.Contains(protonBeam)) {
651 }
else if (btypestr.Contains(protonionBeam)) {
653 }
else if (btypestr.Contains(ionprotonBeam)) {
656 LOG(info) <<
"Assume no LHC magnet field for the beam type " << beamtype;
659 snprintf(ttl, 79,
"L3: %+5d Dip: %+4d kA; %s | Polarities in %s convention", (
int)TMath::Sign(l3Cur,
float(sclL3)),
660 (
int)TMath::Sign(diCur,
float(sclDip)), uniform ?
" Constant" :
"",
661 convention ==
kConvLHC ?
"LHC" :
"DCS2008");
667 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"))