LDMX Software
tracking::reco::TrackingGeometryUser Class Reference

a helper base class providing some methods to shorten access to common conditions used within the tracking reconstruction More...

#include <TrackingGeometryUser.h>

Public Member Functions

 TrackingGeometryUser (const std::string &name, framework::Process &p)
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
virtual void produce (Event &event)=0
 Process the event and put new data products into it.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void configure (framework::config::Parameters &parameters)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Protected Member Functions

const Acts::GeometryContext & geometryContext ()
 
const Acts::MagneticFieldContext & magneticFieldContext ()
 
const Acts::CalibrationContext & calibrationContext ()
 
const geo::TrackersTrackingGeometrygeometry ()
 
void loadBField (const std::string &path, const BFieldDistortion &distortion={})
 Load the interpolated B-field map from path and cache it.
 
void loadBField (const BFieldDistortion &distortion={})
 Load B-field from the path recorded in the detector GDML.
 
std::shared_ptr< Acts::MagneticFieldProvider > bField () const
 Return the loaded B-field provider.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 

Static Protected Member Functions

static BFieldDistortion bFieldDistortion (const framework::config::Parameters &parameters)
 Build a BFieldDistortion from processor configuration.
 

Private Member Functions

template<typename ConditionType >
const ConditionType & getNamedCondition ()
 Templated condition access code for our conditions with static names.
 

Private Attributes

std::shared_ptr< Acts::MagneticFieldProvider > b_field_ {nullptr}
 

Additional Inherited Members

- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

a helper base class providing some methods to shorten access to common conditions used within the tracking reconstruction

Definition at line 22 of file TrackingGeometryUser.h.

Constructor & Destructor Documentation

◆ TrackingGeometryUser()

tracking::reco::TrackingGeometryUser::TrackingGeometryUser ( const std::string & name,
framework::Process & p )

Definition at line 7 of file TrackingGeometryUser.cxx.

9 : framework::Producer(name, p) {}
Base class for a module which produces a data product.

Member Function Documentation

◆ bField()

std::shared_ptr< Acts::MagneticFieldProvider > tracking::reco::TrackingGeometryUser::bField ( ) const
inlineprotected

Return the loaded B-field provider.

Null until loadBField() is called.

Definition at line 67 of file TrackingGeometryUser.h.

67 {
68 return b_field_;
69 }

Referenced by tracking::reco::CKFProcessor::onNewRun(), and tracking::reco::GSFProcessor::onNewRun().

◆ bFieldDistortion()

BFieldDistortion tracking::reco::TrackingGeometryUser::bFieldDistortion ( const framework::config::Parameters & parameters)
staticprotected

Build a BFieldDistortion from processor configuration.

Config is in the LDMX global frame (x bend, y vertical, z beam); this permutes it into the ACTS frame the lookup works in. Parameters:

  • bfield_translation {dx, dy, dz} [mm], default {0, 0, 0}
  • bfield_rotation {ax, ay, az} [rad], default {0, 0, 0}
  • bfield_pivot {x, y, z} [mm], default {0, 0, -400}, the map origin
  • bfield_scale field scaling, default 1

A positive translation moves the magnet, so the field at a fixed point becomes the nominal field from further upstream.

Definition at line 71 of file TrackingGeometryUser.cxx.

72 {
73 const auto translation{
74 parameters.get<std::vector<double>>("bfield_translation", {0., 0., 0.})};
75 const auto rotation{
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})};
79
80 auto require_three = [](const std::string& name,
81 const std::vector<double>& v) {
82 if (v.size() != 3)
83 EXCEPTION_RAISE("BadConf", name + " must have three entries");
84 };
85 require_three("bfield_translation", translation);
86 require_three("bfield_rotation", rotation);
87 require_three("bfield_pivot", pivot);
88
89 // LDMX (x, y, z) -> ACTS (z, x, y); a cyclic permutation, so the rotation
90 // angles reorder the same way as the positions
91 BFieldDistortion distortion;
92 distortion.translation_ =
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.);
97 return distortion;
98}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
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::Vector3 translation_
displacement of the magnet [mm]

References framework::config::Parameters::get(), BFieldDistortion::pivot_, BFieldDistortion::rotation_, BFieldDistortion::scale_, and BFieldDistortion::translation_.

Referenced by tracking::reco::CKFProcessor::configure(), and tracking::reco::GSFProcessor::configure().

◆ calibrationContext()

const Acts::CalibrationContext & tracking::reco::TrackingGeometryUser::calibrationContext ( )
protected

Definition at line 17 of file TrackingGeometryUser.cxx.

17 {
19}
const ConditionType & getNamedCondition()
Templated condition access code for our conditions with static names.

◆ geometry()

const geo::TrackersTrackingGeometry & tracking::reco::TrackingGeometryUser::geometry ( )
protected

Definition at line 20 of file TrackingGeometryUser.cxx.

◆ geometryContext()

const Acts::GeometryContext & tracking::reco::TrackingGeometryUser::geometryContext ( )
protected

Definition at line 11 of file TrackingGeometryUser.cxx.

11 {
13}

◆ getNamedCondition()

template<typename ConditionType >
const ConditionType & tracking::reco::TrackingGeometryUser::getNamedCondition ( )
inlineprivate

Templated condition access code for our conditions with static names.

We assume that the condition has a constant name stored in ConditionType::NAME

Template Parameters
ConditionTypetype of condition we are retrieving
Returns
condition object

Definition at line 84 of file TrackingGeometryUser.h.

84 {
85 return getCondition<ConditionType>(ConditionType::NAME);
86 }
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.

References framework::EventProcessor::getCondition().

◆ loadBField() [1/2]

void tracking::reco::TrackingGeometryUser::loadBField ( const BFieldDistortion & distortion = {})
protected

Load B-field from the path recorded in the detector GDML.

Definition at line 24 of file TrackingGeometryUser.cxx.

24 {
25 loadBField(geometry().fieldMapFile(), distortion);
26}
void loadBField(const std::string &path, const BFieldDistortion &distortion={})
Load the interpolated B-field map from path and cache it.

◆ loadBField() [2/2]

void tracking::reco::TrackingGeometryUser::loadBField ( const std::string & path,
const BFieldDistortion & distortion = {} )
protected

Load the interpolated B-field map from path and cache it.

Uses the standard LDMX→ACTS coordinate transform plus DIPOLE_OFFSET. An optional distortion can be supplied to deliberately mis-place the reconstruction field for systematic studies; the default leaves the field bit-for-bit nominal.

Parameters
pathPath to the field map text file.
distortionOptional mis-placement of the reconstruction field.

Definition at line 28 of file TrackingGeometryUser.cxx.

29 {
30 if (path.empty()) {
31 ldmx_log(warn) << "No B-field map path provided — using zero B-field";
32 b_field_ =
33 std::make_shared<Acts::ConstantBField>(Acts::Vector3(0., 0., 0.));
34 return;
35 }
36
37 if (distortion.isNominal()) {
38 b_field_ = std::make_shared<InterpolatedMagneticField3>(
39 loadDefaultBField(path, defaultTransformPos, defaultTransformBField));
40 return;
41 }
42
43 const Acts::RotationMatrix3 rot{distortion.rotationMatrix()};
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_};
48
49 // undo the distortion, then the nominal ACTS -> map transform
50 auto transform_pos = [rot_inv, translation, pivot](const Acts::Vector3& pos) {
51 return defaultTransformPos(rot_inv * (pos - translation - pivot) + pivot);
52 };
53 // nominal map -> ACTS transform, then redo the distortion
54 auto transform_b = [rot, scale](const Acts::Vector3& field,
55 const Acts::Vector3& pos) {
56 return Acts::Vector3(scale * (rot * defaultTransformBField(field, pos)));
57 };
58
59 ldmx_log(info) << "B-field distortion active (LDMX frame): translation ("
60 << translation(1) << ", " << translation(2) << ", "
61 << translation(0) << ") mm, rotation ("
62 << distortion.rotation_(1) << ", " << distortion.rotation_(2)
63 << ", " << distortion.rotation_(0) << ") rad about ("
64 << pivot(1) << ", " << pivot(2) << ", " << pivot(0)
65 << ") mm, scale " << scale;
66
67 b_field_ = std::make_shared<InterpolatedMagneticField3>(
68 loadDefaultBField(path, transform_pos, transform_b));
69}
Acts::RotationMatrix3 rotationMatrix() const
Rz(gamma) * Ry(beta) * Rx(alpha)
bool isNominal() const
Exact comparison on purpose: the nominal case reuses the default transforms unchanged,...

References BFieldDistortion::isNominal(), BFieldDistortion::pivot_, BFieldDistortion::rotation_, BFieldDistortion::rotationMatrix(), BFieldDistortion::scale_, and BFieldDistortion::translation_.

Referenced by tracking::reco::CKFProcessor::onNewRun(), and tracking::reco::GSFProcessor::onNewRun().

◆ magneticFieldContext()

const Acts::MagneticFieldContext & tracking::reco::TrackingGeometryUser::magneticFieldContext ( )
protected

Definition at line 14 of file TrackingGeometryUser.cxx.

14 {
16}

Member Data Documentation

◆ b_field_

std::shared_ptr<Acts::MagneticFieldProvider> tracking::reco::TrackingGeometryUser::b_field_ {nullptr}
private

Definition at line 72 of file TrackingGeometryUser.h.

72{nullptr};

The documentation for this class was generated from the following files: