1#include "Tracking/Reco/TrackingGeometryUser.h"
3#include "Acts/MagneticField/ConstantBField.hpp"
5namespace tracking::reco {
7TrackingGeometryUser::TrackingGeometryUser(
const std::string& name,
11const Acts::GeometryContext& TrackingGeometryUser::geometryContext() {
12 return getNamedCondition<geo::GeometryContext>().get();
14const Acts::MagneticFieldContext& TrackingGeometryUser::magneticFieldContext() {
15 return getNamedCondition<geo::MagneticFieldContext>().get();
17const Acts::CalibrationContext& TrackingGeometryUser::calibrationContext() {
18 return getNamedCondition<geo::CalibrationContext>().get();
20const geo::TrackersTrackingGeometry& TrackingGeometryUser::geometry() {
21 return getNamedCondition<geo::TrackersTrackingGeometry>();
25 loadBField(geometry().fieldMapFile(), distortion);
28void TrackingGeometryUser::loadBField(
const std::string& path,
31 ldmx_log(warn) <<
"No B-field map path provided — using zero B-field";
33 std::make_shared<Acts::ConstantBField>(Acts::Vector3(0., 0., 0.));
38 b_field_ = std::make_shared<InterpolatedMagneticField3>(
39 loadDefaultBField(path, defaultTransformPos, defaultTransformBField));
44 const Acts::RotationMatrix3 rot_inv{rot.transpose()};
45 const Acts::Vector3 translation{distortion.
translation_};
46 const Acts::Vector3 pivot{distortion.
pivot_};
47 const double scale{distortion.
scale_};
50 auto transform_pos = [rot_inv, translation, pivot](
const Acts::Vector3& pos) {
51 return defaultTransformPos(rot_inv * (pos - translation - pivot) + pivot);
54 auto transform_b = [rot, scale](
const Acts::Vector3& field,
55 const Acts::Vector3& pos) {
56 return Acts::Vector3(scale * (rot * defaultTransformBField(field, pos)));
59 ldmx_log(info) <<
"B-field distortion active (LDMX frame): translation ("
60 << translation(1) <<
", " << translation(2) <<
", "
61 << translation(0) <<
") mm, rotation ("
63 <<
", " << distortion.
rotation_(0) <<
") rad about ("
64 << pivot(1) <<
", " << pivot(2) <<
", " << pivot(0)
65 <<
") mm, scale " << scale;
67 b_field_ = std::make_shared<InterpolatedMagneticField3>(
68 loadDefaultBField(path, transform_pos, transform_b));
73 const auto translation{
74 parameters.
get<std::vector<double>>(
"bfield_translation", {0., 0., 0.})};
76 parameters.
get<std::vector<double>>(
"bfield_rotation", {0., 0., 0.})};
77 const auto pivot{parameters.
get<std::vector<double>>(
78 "bfield_pivot", {0., 0., -DIPOLE_OFFSET})};
80 auto require_three = [](
const std::string& name,
81 const std::vector<double>& v) {
83 EXCEPTION_RAISE(
"BadConf", name +
" must have three entries");
85 require_three(
"bfield_translation", translation);
86 require_three(
"bfield_rotation", rotation);
87 require_three(
"bfield_pivot", pivot);
93 Acts::Vector3(translation[2], translation[0], translation[1]);
94 distortion.
rotation_ = Acts::Vector3(rotation[2], rotation[0], rotation[1]);
95 distortion.
pivot_ = Acts::Vector3(pivot[2], pivot[0], pivot[1]);
96 distortion.
scale_ = parameters.
get<
double>(
"bfield_scale", 1.);
Class which represents the process under execution.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
All classes in the ldmx-sw project use this namespace.
A deliberate mis-placement of the reconstruction magnetic field, used to quantify how well we need to...
double scale_
overall scaling of the field strength
Acts::Vector3 pivot_
centre of rotation [mm], default the field-map origin
Acts::Vector3 rotation_
rotation about x, y, z through pivot [rad]
Acts::RotationMatrix3 rotationMatrix() const
Rz(gamma) * Ry(beta) * Rx(alpha)
Acts::Vector3 translation_
displacement of the magnet [mm]
bool isNominal() const
Exact comparison on purpose: the nominal case reuses the default transforms unchanged,...