Skip to content

Commit 7a5112a

Browse files
goblirscparadajzblond
authored andcommitted
chore: Remove AlignedTelescopeDetector and default-align TelescopeDetector (acts-project#5369)
Remove AlignedTelescopeDetector, align TelescopeDetector
1 parent 227e905 commit 7a5112a

10 files changed

Lines changed: 34 additions & 178 deletions

File tree

Examples/Detectors/TelescopeDetector/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ acts_add_library(
33
src/TelescopeDetector.cpp
44
src/TelescopeDetectorElement.cpp
55
src/BuildTelescopeDetector.cpp
6-
src/AlignedTelescopeDetector.cpp
76
)
87

98
target_include_directories(

Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/AlignedTelescopeDetector.hpp

Lines changed: 0 additions & 25 deletions
This file was deleted.

Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "Acts/Geometry/TrackingGeometry.hpp"
1212
#include "Acts/Utilities/AxisDefinitions.hpp"
13-
#include "ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp"
1413

1514
#include <array>
1615
#include <memory>
@@ -43,7 +42,6 @@ enum class TelescopeSurfaceType {
4342
/// parallel to
4443
std::unique_ptr<const Acts::TrackingGeometry> buildTelescopeDetector(
4544
const Acts::GeometryContext& gctx,
46-
const TelescopeDetectorElement::DetectorElementFactory& factory,
4745
std::vector<std::shared_ptr<const Acts::SurfacePlacementBase>>&
4846
detectorStore,
4947
const std::vector<double>& positions,

Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetector.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#pragma once
1010

1111
#include "Acts/Definitions/Units.hpp"
12-
#include "Acts/Utilities/AxisDefinitions.hpp"
1312
#include "Acts/Utilities/Logger.hpp"
1413
#include "ActsExamples/DetectorCommons/Detector.hpp"
1514

Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
#include "Acts/Geometry/GeometryContext.hpp"
1313
#include "Acts/Surfaces/Surface.hpp"
1414
#include "Acts/Surfaces/SurfacePlacementBase.hpp"
15+
#include "ActsExamples/DetectorCommons/AlignmentContext.hpp"
1516

1617
#include <memory>
17-
#include <utility>
18-
#include <vector>
1918

2019
namespace Acts {
2120
class Surface;
@@ -42,14 +41,6 @@ class TelescopeDetectorElement : public Acts::SurfacePlacementBase {
4241
using identifier_diff = long long;
4342
using Identifier = identifier_type;
4443

45-
using DetectorElementFactory =
46-
std::function<std::shared_ptr<TelescopeDetectorElement>(
47-
const Acts::Transform3&,
48-
std::variant<std::shared_ptr<const Acts::PlanarBounds>,
49-
std::shared_ptr<const Acts::DiscBounds>>,
50-
double, std::shared_ptr<const Acts::ISurfaceMaterial>,
51-
std::vector<std::shared_ptr<const Acts::SurfacePlacementBase>>&)>;
52-
5344
/// Constructor for single sided detector element
5445
/// - bound to a Plane Surface
5546
///
@@ -105,18 +96,6 @@ class TelescopeDetectorElement : public Acts::SurfacePlacementBase {
10596
return nominalTransform();
10697
}
10798

108-
/// Return local to global transform associated with this identifier
109-
///
110-
/// @param alignedTransform is a new transform
111-
/// @param iov is the batch for which it is meant
112-
void addAlignedTransform(std::unique_ptr<Acts::Transform3> alignedTransform,
113-
unsigned int iov);
114-
115-
/// Return the set of alignment transforms in flight
116-
const std::vector<std::unique_ptr<Acts::Transform3>>& alignedTransforms()
117-
const {
118-
return m_alignedTransforms;
119-
};
12099
/// Is the detector element a sensitive element
121100
bool isSensitive() const final { return true; }
122101

@@ -128,8 +107,6 @@ class TelescopeDetectorElement : public Acts::SurfacePlacementBase {
128107
Identifier m_elementIdentifier;
129108
/// the transform for positioning in 3D space
130109
std::shared_ptr<const Acts::Transform3> m_elementTransform = nullptr;
131-
// the aligned transforms
132-
std::vector<std::unique_ptr<Acts::Transform3>> m_alignedTransforms = {};
133110
/// the surface represented by it
134111
std::shared_ptr<Acts::Surface> m_elementSurface = nullptr;
135112
/// the element thickness
@@ -155,28 +132,24 @@ inline double TelescopeDetectorElement::thickness() const {
155132
inline const Acts::Transform3& TelescopeDetectorElement::localToGlobalTransform(
156133
const Acts::GeometryContext& gctx) const {
157134
// Check if a different transform than the nominal exists
158-
if (!m_alignedTransforms.empty()) {
159-
// cast into the right context object
160-
auto alignContext = gctx.get<ContextType>();
161-
return (*m_alignedTransforms[alignContext.iov].get());
135+
if (gctx.hasValue()) {
136+
const auto* alignmentContext = gctx.maybeGet<AlignmentContext>();
137+
if (alignmentContext != nullptr && alignmentContext->store != nullptr) {
138+
const auto* transform =
139+
alignmentContext->store->contextualTransform(this->surface());
140+
// The store may only have a subset of surfaces registered
141+
if (transform != nullptr) {
142+
return *transform;
143+
}
144+
}
162145
}
163-
// Return the standard transform if not found
164-
return nominalTransform(gctx);
146+
// If no alignment context is available, return the nominal transform
147+
return nominalTransform();
165148
}
166149

167150
inline const Acts::Transform3& TelescopeDetectorElement::nominalTransform()
168151
const {
169152
return *m_elementTransform;
170153
}
171154

172-
inline void TelescopeDetectorElement::addAlignedTransform(
173-
std::unique_ptr<Acts::Transform3> alignedTransform, unsigned int iov) {
174-
// most standard case, it's just a new one:
175-
auto cios = m_alignedTransforms.size();
176-
for (unsigned int ic = cios; ic <= iov; ++ic) {
177-
m_alignedTransforms.push_back(nullptr);
178-
}
179-
m_alignedTransforms[iov] = std::move(alignedTransform);
180-
}
181-
182155
} // namespace ActsExamples

Examples/Detectors/TelescopeDetector/src/AlignedTelescopeDetector.cpp

Lines changed: 0 additions & 55 deletions
This file was deleted.

Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "Acts/Surfaces/SurfaceArray.hpp"
3030
#include "Acts/Surfaces/SurfacePlacementBase.hpp"
3131
#include "Acts/Utilities/Logger.hpp"
32+
#include "ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp"
3233

3334
#include <algorithm>
3435
#include <cstddef>
@@ -37,7 +38,6 @@
3738
std::unique_ptr<const Acts::TrackingGeometry>
3839
ActsExamples::buildTelescopeDetector(
3940
const Acts::GeometryContext& gctx,
40-
const TelescopeDetectorElement::DetectorElementFactory& factory,
4141
std::vector<std::shared_ptr<const Acts::SurfacePlacementBase>>&
4242
detectorStore,
4343
const std::vector<double>& positions,
@@ -91,13 +91,21 @@ ActsExamples::buildTelescopeDetector(
9191

9292
// Create the detector element
9393
std::shared_ptr<TelescopeDetectorElement> detElement = nullptr;
94+
95+
const auto id =
96+
static_cast<TelescopeDetectorElement::Identifier>(detectorStore.size());
97+
9498
if (surfaceType == TelescopeSurfaceType::Plane) {
95-
detElement =
96-
factory(trafo, pBounds, 1._um, surfaceMaterial, detectorStore);
99+
detElement = std::make_shared<TelescopeDetectorElement>(
100+
id, std::make_shared<Acts::Transform3>(trafo), pBounds, 1._um,
101+
surfaceMaterial);
97102
} else {
98-
detElement =
99-
factory(trafo, rBounds, 1._um, surfaceMaterial, detectorStore);
103+
detElement = std::make_shared<TelescopeDetectorElement>(
104+
id, std::make_shared<Acts::Transform3>(trafo), rBounds, 1._um,
105+
surfaceMaterial);
100106
}
107+
detectorStore.push_back(detElement);
108+
101109
// Get the surface
102110
auto surface = detElement->surface().getSharedPtr();
103111
// Add the detector element to the detector store

Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "Acts/Geometry/GeometryContext.hpp"
1212
#include "ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp"
13-
#include "ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp"
1413

1514
#include <stdexcept>
1615

@@ -41,37 +40,10 @@ TelescopeDetector::TelescopeDetector(const Config& cfg)
4140

4241
m_nominalGeometryContext =
4342
Acts::GeometryContext::dangerouslyDefaultConstruct();
44-
auto detectorElementFactory =
45-
[](const Acts::Transform3& transform,
46-
std::variant<std::shared_ptr<const Acts::PlanarBounds>,
47-
std::shared_ptr<const Acts::DiscBounds>>
48-
bounds,
49-
double thickness,
50-
std::shared_ptr<const Acts::ISurfaceMaterial> material,
51-
std::vector<std::shared_ptr<const Acts::SurfacePlacementBase>>&
52-
detStore) {
53-
auto ID =
54-
static_cast<TelescopeDetectorElement::Identifier>(detStore.size());
55-
56-
std::shared_ptr<TelescopeDetectorElement> detElem;
57-
if (bounds.index() == 0) {
58-
detElem = std::make_shared<TelescopeDetectorElement>(
59-
ID, std::make_shared<Acts::Transform3>(transform),
60-
std::get<std::shared_ptr<const Acts::PlanarBounds>>(bounds),
61-
thickness, std::move(material));
62-
} else {
63-
detElem = std::make_shared<TelescopeDetectorElement>(
64-
ID, std::make_shared<Acts::Transform3>(transform),
65-
std::get<std::shared_ptr<const Acts::DiscBounds>>(bounds),
66-
thickness, std::move(material));
67-
}
68-
detStore.push_back(detElem);
69-
return detElem;
70-
};
7143
m_trackingGeometry = buildTelescopeDetector(
72-
m_nominalGeometryContext, detectorElementFactory, m_detectorStore,
73-
m_cfg.positions, m_cfg.stereos, m_cfg.offsets, m_cfg.bounds,
74-
m_cfg.thickness, static_cast<TelescopeSurfaceType>(m_cfg.surfaceType),
44+
m_nominalGeometryContext, m_detectorStore, m_cfg.positions, m_cfg.stereos,
45+
m_cfg.offsets, m_cfg.bounds, m_cfg.thickness,
46+
static_cast<TelescopeSurfaceType>(m_cfg.surfaceType),
7547
static_cast<Acts::AxisDirection>(m_cfg.binValue));
7648
}
7749

Examples/Scripts/Python/millepede_alignment.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from acts.examples import (
1212
TelescopeDetector,
13-
AlignedTelescopeDetector,
1413
Sequencer,
1514
StructureSelector,
1615
RandomNumbers,
@@ -70,18 +69,13 @@
7069
#
7170
# In the alignment, at least 4 layers are expected (layer ID 8 will
7271
# be fixed as the alignment reference).
73-
def getTelescopeDetector(misaligned: bool = False):
72+
def getTelescopeDetector():
7473
bounds = [200, 200]
7574
positions = [30, 60, 90, 120, 150, 180, 210, 240, 270]
7675
stereos = [0] * len(positions)
77-
if not misaligned:
78-
detector = TelescopeDetector(
79-
bounds=bounds, positions=positions, stereos=stereos, binValue=1
80-
)
81-
else:
82-
detector = AlignedTelescopeDetector(
83-
bounds=bounds, positions=positions, stereos=stereos, binValue=1
84-
)
76+
detector = TelescopeDetector(
77+
bounds=bounds, positions=positions, stereos=stereos, binValue=1
78+
)
8579

8680
return detector
8781

@@ -158,7 +152,7 @@ def addSolverFromMille(
158152
os.makedirs(outputDir, exist_ok=True)
159153

160154
# Instantiate the telescope detector - with alignment enabled
161-
detector = getTelescopeDetector(misaligned=True)
155+
detector = getTelescopeDetector()
162156
trackingGeometry = detector.trackingGeometry()
163157
decorators = detector.contextDecorators()
164158

Python/Examples/src/Detector.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "ActsExamples/Framework/IContextDecorator.hpp"
1717
#include "ActsExamples/GenericDetector/AlignedGenericDetector.hpp"
1818
#include "ActsExamples/GenericDetector/GenericDetector.hpp"
19-
#include "ActsExamples/TelescopeDetector/AlignedTelescopeDetector.hpp"
2019
#include "ActsExamples/TelescopeDetector/TelescopeDetector.hpp"
2120
#include "ActsExamples/Utilities/Options.hpp"
2221
#include "ActsPython/Utilities/Helpers.hpp"
@@ -92,12 +91,6 @@ void addDetector(py::module& mex) {
9291
ACTS_PYTHON_STRUCT(c, positions, stereos, offsets, bounds, thickness,
9392
surfaceType, binValue, materialDecorator, logLevel);
9493
}
95-
{
96-
auto ad = py::class_<AlignedTelescopeDetector, TelescopeDetector,
97-
std::shared_ptr<AlignedTelescopeDetector>>(
98-
mex, "AlignedTelescopeDetector")
99-
.def(py::init<const TelescopeDetector::Config&>());
100-
}
10194
}
10295

10396
} // namespace ActsPython

0 commit comments

Comments
 (0)