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 elementId = unpackGeometryIdentifier(m_surface->geometryId());
20
21 // Check if the elementId is valid
22 if (elementId > 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(elementId) > 0) {
31 const Acts::Transform3& c_transform = ctx->alignment_map[elementId];
32
33 if (m_debug) {
34 std::cout << "Aligned transform" << std::endl;
35 std::cout << c_transform.translation() << std::endl;
36 std::cout << c_transform.rotation() << std::endl;
37 std::cout << "Original transform" << std::endl;
38 std::cout << m_transform.translation() << std::endl;
39 std::cout << m_transform.rotation() << std::endl;
40 }
41
42 return c_transform;
43 }
44
45 else
46 return m_transform;
47}
48
49const Acts::Surface& DetectorElement::surface() const {
50 if (!m_surface)
51 throw std::logic_error(
52 "DetectorElement::Attempted to return reference of null ptr");
53 return *m_surface;
54}
55Acts::Surface& DetectorElement::surface() {
56 if (!m_surface)
57 throw std::logic_error(
58 "DetectorElement::Attempted to return reference of null ptr");
59 return *m_surface;
60}
61
62// The thickness of the detector element is taken from the center of the
63// associated surface
64double DetectorElement::thickness() const {
65 // return m_thickness;
66 auto material = static_cast<const Acts::HomogeneousSurfaceMaterial*>(
67 m_surface->surfaceMaterial());
68 return material->materialSlab(Acts::Vector2{0., 0.}).thickness();
69}
70} // 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