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