LDMX Software
GeometryContext.cxx
1#include "Tracking/geo/GeometryContext.h"
2
4#include "Framework/Configure/Parameters.h"
5#include "Framework/Exception/Exception.h"
6
7namespace tracking::geo {
8
9const std::string GeometryContext::NAME = "TrackingGeometryContext";
10
11GeometryContext::GeometryContext() : framework::ConditionsObject(NAME) {
12 acts_gc_ = this;
13}
14
15const Acts::GeometryContext& GeometryContext::get() const { return acts_gc_; }
16
17void GeometryContext::loadTransformations(const tgSurfMap& surf_map) {
18 // Always clear the map before reloading the transformations.
19 alignment_map_.clear();
20
21 for (auto entry : surf_map) {
22 alignment_map_[entry.first] =
23 static_cast<const DetectorElement*>(
24 (entry.second)->associatedDetectorElement())
25 ->uncorrectedTransform();
26 }
27}
28/*
29 Some testing functionality
30 deltaT = (tu, tv, tw)
31 deltaR = (ru, rv, rw)
32
33 / 1 -rw rv \
34deltaR = | rw 1 -ru |
35 \ -rv ru 1 /
36
37 "active" means "rotate, then translate"
38 "passive" means "translate, then rotate"
39*/
40
41void GeometryContext::addAlignCorrection(unsigned int sensorId,
42 const Acts::Vector3 deltaT,
43 const Acts::Vector3 deltaR,
44 bool active) {
45 Acts::Translation3 delta_translation{deltaT};
46 Acts::RotationMatrix3 rot = deltaRot(deltaR);
47 Acts::Transform3 correction(delta_translation * rot);
48
49 // Add the correction to the alignment map
50
51 if (alignment_map_.count(sensorId) < 1) {
52 EXCEPTION_RAISE("BadGeometry",
53 "GeometryContext:: could not addAlignCorrection");
54 }
55
56 if (active) {
57 // qaligned = dR*R(t0 + dt0).
58 // ==> rotate, then translate.
59 alignment_map_[sensorId].rotate(correction.rotation());
60 alignment_map_[sensorId].translate(correction.translation());
61 } else {
62 alignment_map_[sensorId].translate(correction.translation());
63 alignment_map_[sensorId].rotate(correction.rotation());
64 }
65}
66
68 public:
77 GeometryContextProvider(const std::string& name, const std::string& tagname,
78 const framework::config::Parameters& parameters,
81 parameters, process) {}
82
92 std::pair<const framework::ConditionsObject*, framework::ConditionsIOV>
93 getCondition(const ldmx::EventHeader& context) final override {
94 return std::make_pair<const framework::ConditionsObject*,
96 new GeometryContext(), framework::ConditionsIOV(true, true));
97 }
98};
99
100} // namespace tracking::geo
101
Base class for provider of conditions information like pedestals, gains, electronics maps,...
#define DECLARE_CONDITIONS_PROVIDER(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:37
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
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.
Visualization.