LDMX Software
DetectorElement.cxx
1#include "Tracking/geo/DetectorElement.h"
2
3#include "Tracking/geo/GeometryContext.h"
4
5namespace tracking::geo {
6
7DetectorElement::~DetectorElement(){};
8
9const Acts::Transform3& DetectorElement::transform(
10 const Acts::GeometryContext& gctx) const {
11 if (!m_surface_)
12 throw std::logic_error("DetectorElement:: Sensor/Element ID not set");
13
14 // The elementId will be valid only after tracking geometry is built
15 // I will use this fact to return the default transform in order to build
16 // always the same default tracking geometry and modify later the sensor
17 // transformations.
18
19 unsigned int element_id = unpackGeometryIdentifier(m_surface_->geometryId());
20
21 // Check if the elementId is valid
22 if (element_id > 9999) {
23 // elementId not valid: return default transformation
24 return m_transform_;
25 }
26
27 auto ctx = gctx.get<GeometryContext*>();
28
29 // Found the aligned transform for this sensor
30 if ((ctx->alignment_map_).count(element_id) > 0) {
31 const Acts::Transform3& c_transform = ctx->alignment_map_[element_id];
32
33 if (false) {
34 // TODO : Have this in the logging system
35 std::cout << "Aligned transform" << std::endl;
36 std::cout << c_transform.translation() << std::endl;
37 std::cout << c_transform.rotation() << std::endl;
38 std::cout << "Original transform" << std::endl;
39 std::cout << m_transform_.translation() << std::endl;
40 std::cout << m_transform_.rotation() << std::endl;
41 }
42
43 return c_transform;
44 }
45
46 else
47 return m_transform_;
48}
49
50const Acts::Surface& DetectorElement::surface() const {
51 if (!m_surface_)
52 throw std::logic_error(
53 "DetectorElement::Attempted to return reference of null ptr");
54 return *m_surface_;
55}
56Acts::Surface& DetectorElement::surface() {
57 if (!m_surface_)
58 throw std::logic_error(
59 "DetectorElement::Attempted to return reference of null ptr");
60 return *m_surface_;
61}
62
63// The thickness of the detector element is taken from the center of the
64// associated surface
65double DetectorElement::thickness() const {
66 // return m_thickness;
67 auto material = static_cast<const Acts::HomogeneousSurfaceMaterial*>(
68 m_surface_->surfaceMaterial());
69 return material->materialSlab(Acts::Vector2{0., 0.}).thickness();
70}
71} // namespace tracking::geo
Visualization.
unsigned int unpackGeometryIdentifier(const Acts::GeometryIdentifier &geoId)
The geometry identifier will return vol=0 and lay=0 when it is not valid.
Definition GeoUtils.cxx:5