14#include "GaudiKernel/SystemOfUnits.h"
16#include "GaudiKernel/MsgStream.h"
24 explicit RestoreIOSFlags (std::ostream &os)
26 m_precision(m_os->precision())
29 m_os->precision(m_precision);
33 std::streamsize m_precision;
61 const double cotTheta)
79 const double cotTheta)
113 double smallOffset = 0.0000000000001;
118 constexpr int n = 200;
122 double cotTheta = smallOffset;
123 for (
int binTheta = 0; binTheta <
s_maxBinTheta - 1; ++binTheta) {
132 derivative.setZero();
133 for (
int k = 0; k < n; ++k){
136 double w = (n - k)*(n - k);
137 double zLocal =
z - zAtAxis;
140 derivative(k,4) = w*zLocal*zLocal;
141 derivative(k,5) = w*zLocal*zLocal*zLocal;
144 derivative(k,1) = w*zLocal*zLocal;
145 derivative(k,2) = w*zLocal*zLocal*zLocal;
150 Amg::VectorX solution = derivative.colPivHouseholderQr().solve(difference);
210 msg << __func__<<
"\n"
211 << std::setiosflags(std::ios::fixed)
212 <<
" eta rEnd mean(Bz) max(dBz/dR) mean(Bt) max(dBt/dR) "
213 <<
"min(Bt) max(Bt) reverse-bend(z) integrals: Bt.dR Bl.dR"
221 double maxR = 1000.*Gaudi::Units::mm;
222 double maxZ = 2650.*Gaudi::Units::mm;
230 for (
int i = 0; i != 31; ++i)
233 double cotTheta = std::sinh(
eta);
236 if (std::abs(cotTheta) > maxZ/maxR) rEnd = maxZ/
direction.z();
237 double step = rEnd/
static_cast<double>(numSteps);
243 double minBT = 9999.;
244 double maxGradBT = 0.;
245 double maxGradBZ = 0.;
248 double reverseZ = 0.;
251 for (
int j = 0; j != numSteps; ++j)
258 double BZ = field.z();
260 double BL = std::sqrt(vCrossB.mag2() - BT*BT);
264 if (BT > maxBT) maxBT = BT;
265 if (BT < minBT) minBT = BT;
269 double grad = std::abs(BT - prevBT);
270 if (grad > maxGradBT) maxGradBT = grad;
271 grad = std::abs(BZ - prevBZ);
272 if (grad > maxGradBZ) maxGradBZ = grad;
279 maxGradBT *=
static_cast<double>(numSteps)/step;
280 maxGradBZ *=
static_cast<double>(numSteps)/step;
281 meanBL /=
static_cast<double>(numSteps);
282 meanBT /=
static_cast<double>(numSteps);
283 meanBZ /=
static_cast<double>(numSteps);
284 double integralBL = meanBL*rEnd;
285 double integralBT = meanBT*rEnd;
287 msg << std::setw(6) << std::setprecision(2) <<
eta
288 << std::setw(8) << std::setprecision(3) << rEnd /Gaudi::Units::meter
289 << std::setw(11) << std::setprecision(4) << meanBZ /Gaudi::Units::tesla
290 << std::setw(12) << std::setprecision(3) << maxGradBZ /Gaudi::Units::tesla
291 << std::setw(13) << std::setprecision(4) << meanBT /Gaudi::Units::tesla
292 << std::setw(12) << std::setprecision(3) << maxGradBT /Gaudi::Units::tesla
293 << std::setw(13) << std::setprecision(4) << minBT /Gaudi::Units::tesla
294 << std::setw(8) << std::setprecision(4) << maxBT /Gaudi::Units::tesla;
297 msg << std::setw(17) << std::setprecision(2) << reverseZ /Gaudi::Units::meter
298 << std::setw(18) << std::setprecision(4) << integralBT /(Gaudi::Units::tesla*Gaudi::Units::meter)
299 << std::setw(8) << std::setprecision(4) << integralBL /(Gaudi::Units::tesla*Gaudi::Units::meter)
304 msg << std::setw(35) << std::setprecision(4) << integralBT /(Gaudi::Units::tesla*Gaudi::Units::meter)
305 << std::setw(8) << std::setprecision(4) << integralBL /(Gaudi::Units::tesla*Gaudi::Units::meter)
310 for (
int k = 0; k != 3; ++k)
318 for (
int j = 0; j != numSteps; ++j)
328 asymm = asymm/
static_cast<double>(numSteps) - meanBT;
329 msg << std::setw(9) << std::setprecision(4) << asymm /Gaudi::Units::tesla;
339 double cotTheta = 1./std::tan(2.*std::atan(1./std::exp(
eta)));
352 << std::setiosflags(std::ios::fixed)
353 <<
"SolenoidParametrization: line with eta " << std::setw(6) << std::setprecision(2) <<
eta
354 <<
" from (r,z) 0.0," << std::setw(6) << std::setprecision(1) << z_origin
355 <<
" inner terms: z0 "<< std::setw(6) << std::setprecision(2)
357 <<
" z^2 "<< std::setw(6) << std::setprecision(3)
359 <<
" z^3 " << std::setw(6) << std::setprecision(3)
361 <<
" outer terms: z0 "<< std::setw(6) << std::setprecision(3)
363 <<
" z^2 "<< std::setw(6) << std::setprecision(3)
365 <<
" z^3 " << std::setw(6) << std::setprecision(3)
367 << std::resetiosflags(std::ios::fixed) <<
"\n";
373 double cotTheta = 1./std::tan(2.*std::atan(1./std::exp(std::abs(
eta))));
386 double chiSquareIn = 0.;
387 double chiSquareOut = 0.;
390 double worstBCalc = 0.;
391 double worstBTrue = 0.;
392 double worstDiff = -1.;
397 for (
int k = 0; k < n; ++k)
414 if (std::abs(
diff) > worstDiff)
416 worstDiff = std::abs(
diff);
425 if ((nIn == 0) or (nOut == 0)){
426 msg <<__func__<<
"nIn = "<<nIn<<
"; nOut = "<<nOut<<
".\n";
431 << std::setiosflags(std::ios::fixed)
432 <<
"SolenoidParametrization: line with eta " << std::setw(6) << std::setprecision(2) <<
eta
433 <<
" from (r,z) 0.0, " << std::setw(6) << std::setprecision(1) << zOrigin
434 <<
" rms diff inner/outer " << std::setw(6) << std::setprecision(3)
435 << std::sqrt(chiSquareIn/nIn) /Gaudi::Units::tesla <<
" " << std::setw(6) << std::setprecision(3)
436 << std::sqrt(chiSquareOut/nOut) /Gaudi::Units::tesla << std::endl
437 <<
" worst residual at: (r,z) "
438 << std::setw(6) << std::setprecision(1) << worstR
439 <<
", " << std::setw(6) << std::setprecision(1) << worstZ
440 <<
" with B true/calc " << std::setw(6) << std::setprecision(3)
442 <<
" " << std::setw(6) << std::setprecision(3) << worstBCalc/
s_lightSpeed /Gaudi::Units::tesla
443 << std::resetiosflags(std::ios::fixed) <<
"\n";
Scalar eta() const
pseudorapidity method
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h).
void getField(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given,...
BinParameters(const double zAtAxis, const double cotTheta)
Parameters(const SolenoidParametrization &spar, const double r, const double z, const double cotTheta)
static const double s_binInvSizeZ
double m_parameters[14688]
static const double s_binZeroZ
static int fieldKey(BinParameters &parms)
static const int s_maxBinZ
void parametrizeSolenoid()
static const double s_zOuter
void printParametersForEtaLine(double eta, double z_origin, MsgStream &msg) const
static const double s_lightSpeed
static const double s_rOuter
static const double s_rInner
static const double s_zInner
static const int s_maxBinTheta
static const double s_binZeroTheta
static const int s_numberParameters
static const double s_maximumImpactAtOrigin
static const double s_maximumZatOrigin
void setTerms(int, Parameters &parms) const
SolenoidParametrization(const AtlasFieldCacheCondObj &field_cond_obj)
const AtlasFieldCacheCondObj * m_fieldCondObj
void printFieldIntegrals(MsgStream &m) const
static const double s_binInvSizeTheta
double fieldComponent(double z, const Parameters &parms) const
void printResidualForEtaLine(double eta, double zOrigin, MsgStream &msg) const
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Ensure that the ATLAS eigen extensions are properly loaded.
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.
@ z
global position (cartesian)
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.