LDMX Software
GeometryContext.cxx
1#include "Tracking/geo/GeometryContext.h"
2
3#include <stdexcept> // Include for std::logic_error
4
6#include "Framework/Configure/Parameters.h"
7#include "Framework/Exception/Exception.h"
8
9namespace tracking::geo {
10
11const std::string GeometryContext::NAME = "TrackingGeometryContext";
12
13GeometryContext::GeometryContext() : framework::ConditionsObject(NAME) {
14 acts_gc_ = this;
15}
16
17const Acts::GeometryContext& GeometryContext::get() const { return acts_gc_; }
18
19void GeometryContext::loadTransformations(const tgSurfMap& surf_map) {
20 // Always clear the map before reloading the transformations.
21 alignment_map.clear();
22
23 for (auto entry : surf_map) {
24 alignment_map[entry.first] =
25 static_cast<const DetectorElement*>(
26 (entry.second)->associatedDetectorElement())
27 ->uncorrectedTransform();
28 }
29}
30/*
31 Some testing functionality
32 deltaT = (tu, tv, tw)
33 deltaR = (ru, rv, rw)
34
35 / 1 -rw rv \
36deltaR = | rw 1 -ru |
37 \ -rv ru 1 /
38
39 "active" means "rotate, then translate"
40 "passive" means "translate, then rotate"
41*/
42
43void GeometryContext::addAlignCorrection(unsigned int sensorId,
44 const Acts::Vector3 deltaT,
45 const Acts::Vector3 deltaR,
46 bool active) {
47 Acts::Translation3 deltaTranslation{deltaT};
48 Acts::RotationMatrix3 rot = deltaRot(deltaR);
49 Acts::Transform3 correction(deltaTranslation * rot);
50
51 // Add the correction to the alignment map
52
53 if (alignment_map.count(sensorId) < 1) {
54 throw std::logic_error("GeometryContext:: could not addAlignCorrection");
55 }
56
57 if (active) {
58 // qaligned = dR*R(t0 + dt0).
59 // ==> rotate, then translate.
60 alignment_map[sensorId].rotate(correction.rotation());
61 alignment_map[sensorId].translate(correction.translation());
62 } else {
63 alignment_map[sensorId].translate(correction.translation());
64 alignment_map[sensorId].rotate(correction.rotation());
65 }
66}
67
69 public:
78 GeometryContextProvider(const std::string& name, const std::string& tagname,
79 const framework::config::Parameters& parameters,
82 parameters, process) {}
83
93 std::pair<const framework::ConditionsObject*, framework::ConditionsIOV>
94 getCondition(const ldmx::EventHeader& context) final override {
95 return std::make_pair<const framework::ConditionsObject*,
97 new GeometryContext(), framework::ConditionsIOV(true, true));
98 }
99};
100
101} // namespace tracking::geo
102
103DECLARE_CONDITIONS_PROVIDER_NS(tracking::geo, GeometryContextProvider)
Base class for provider of conditions information like pedestals, gains, electronics maps,...
#define DECLARE_CONDITIONS_PROVIDER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
be configured to load conditions objects from CSV files.
Class which defines the run/event/type range for which a given condition is valid,...
Base class for all providers of conditions objects.
const Process & process() const
Get the process handle.
Base class for all conditions objects, very simple.
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
Provides header information an event such as event number and timestamp.
Definition EventHeader.h:44
std::pair< const framework::ConditionsObject *, framework::ConditionsIOV > getCondition(const ldmx::EventHeader &context) final override
Get the context as a conditions object.
GeometryContextProvider(const std::string &name, const std::string &tagname, const framework::config::Parameters &parameters, framework::Process &process)
Create the context conditions object.
The context for a specific geometry.
static const std::string NAME
Conditions object name.
const Acts::GeometryContext & get() const
get an Acts::GeometryContext wrapping the pointer to the instance of this GeometryContext
Acts::GeometryContext acts_gc_
Wrap this instance in an Acts::GeometryContext any object for passing it down to the various acts too...
GeometryContext()
TODO it should be private == KEEPING IT PUBLIC FOR TESTING PURPOSE.
void addAlignCorrection(unsigned int sensorId, const Acts::Vector3 deltaT, const Acts::Vector3 deltaR, const bool active=true)
Fill an internal map holding the alignment transformations sensorId : id of the alignable element in ...
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45
Visualization.