LDMX Software
GeometryContext.cxx
1#include "Tracking/geo/GeometryContext.h"
2
4#include "Framework/Configure/Parameters.h"
5#include "Framework/Exception/Exception.h"
6#include "Tracking/geo/DetectorElement.h"
7#include "Tracking/geo/GeoUtils.h"
8
9namespace tracking::geo {
10
11const std::string GeometryContext::NAME = "TrackingGeometryContext";
12
14 : framework::ConditionsObject(NAME),
15 acts_gc_(Acts::GeometryContext(this)) {}
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*>((entry.second)->surfacePlacement())
26 ->uncorrectedTransform();
27 }
28}
29/*
30 Some testing functionality
31 deltaT = (tu, tv, tw)
32 deltaR = (ru, rv, rw)
33
34 / 1 -rw rv \
35deltaR = | rw 1 -ru |
36 \ -rv ru 1 /
37
38 "active" means "rotate, then translate"
39 "passive" means "translate, then rotate"
40*/
41
42void GeometryContext::addAlignCorrection(unsigned int sensorId,
43 const Acts::Vector3 deltaT,
44 const Acts::Vector3 deltaR,
45 bool active) {
46 Acts::Translation3 delta_translation{deltaT};
47 Acts::RotationMatrix3 rot = deltaRot(deltaR);
48 Acts::Transform3 correction(delta_translation * rot);
49
50 // Add the correction to the alignment map
51
52 if (alignment_map_.count(sensorId) < 1) {
53 EXCEPTION_RAISE("BadGeometry",
54 "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
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:34
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
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.