LDMX Software
DetectorElement.h
1#pragma once
2
3#include <iostream>
4#include <stdexcept> // Include for std::logic_error
5
6#include "Acts/Definitions/Algebra.hpp"
7#include "Acts/Geometry/DetectorElementBase.hpp"
8#include "Acts/Geometry/GeometryContext.hpp"
9#include "Acts/Geometry/GeometryIdentifier.hpp"
10#include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
11#include "Acts/Surfaces/Surface.hpp"
12#include "Tracking/geo/GeoUtils.h"
13
14// This class is necessary in order to apply any transformation change passed
15// via the geometry context to the final sensitive element.
16
17namespace tracking::geo {
18
19class DetectorElement : public Acts::DetectorElementBase {
20 public:
21 // The detector element is initialized with the surface initial transformation
22 // created from the TrackingGeometry constructor/parser
23 // The DetectorElement ACTS mechanism is such that subsequent calls to the
24 // transform(GeometryContext) method will return the full transformation valid
25 // for a certain IoV via the ConditionsProvider mechanism
26
27 DetectorElement(const std::shared_ptr<Acts::Surface>& surface,
28 const Acts::Transform3& default_transform, double thickness) {
29 m_surface = surface;
30 m_thickness = thickness;
31
32 // This is the local to global transformation
33 m_transform = default_transform;
34 }
35
36 ~DetectorElement() override;
37
38 // This method will always return a copy to the uncorrected transformation
39
40 Acts::Transform3 uncorrectedTransform() const { return m_transform; }
41
42 // This method will load the transformation from the geometry context if found
43 // otherwise will return the default transform
44 // This is very *hot* code, do not place computations in this function in
45 // order to keep performance under control.
46
47 // CAUTION:: The tracking geometry + geometry context machinery
48 // assumes large enough envelopes / gaps between sensors
49 // to allow for not breaking the layers overlaps.
50 // In case the corrections to the stored transformations will be too large
51 // this assumption will be broken.
52
53 // TODO Current implementation implies always checking the stored map of
54 // corrections Could be interesting to cache the transformations and re-update
55 // all of them when IoV changes
56
57 const Acts::Transform3& transform(
58 const Acts::GeometryContext& gctx) const override;
59
60 const Acts::Surface& surface() const override;
61
62 Acts::Surface& surface() override;
63
64 // The thickness of the detector element is taken from the center of the
65 // associated surface
66 double thickness() const override;
67
68 Acts::GeometryIdentifier geometryId() const {
69 if (!m_surface)
70 throw std::logic_error("DetectorElement:: surface not assigned");
71
72 return (m_surface->geometryId());
73 }
74
75 private:
76 // cache
77 Acts::Transform3 m_transform = Acts::Transform3::Identity();
78
79 std::shared_ptr<Acts::Surface> m_surface;
80 double m_thickness;
81 bool m_debug{false};
82};
83
84} // namespace tracking::geo
Visualization.