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