Skip to content

Commit 55b7fa0

Browse files
authored
Merge branch 'main' into ref-cleanup-geo-conversion
2 parents d0cd28f + 8b339f4 commit 55b7fa0

13 files changed

Lines changed: 348 additions & 559 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is part of the ACTS project.
2+
//
3+
// Copyright (C) 2016 CERN for the benefit of the ACTS project
4+
//
5+
// This Source Code Form is subject to the terms of the Mozilla Public
6+
// License, v. 2.0. If a copy of the MPL was not distributed with this
7+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
#pragma once
10+
11+
#include <array>
12+
13+
namespace Acts {
14+
15+
/// Collection of outer strip space point details, used for the calibration.
16+
struct OuterStripSpacePointCalibrationDetails final {
17+
/// Center of the outer strip.
18+
std::array<float, 3> outerCenter;
19+
/// Separation vector from the inner strip center to the outer strip center.
20+
std::array<float, 3> innerToOuterSeparation;
21+
/// Half vector of the outer strip, pointing from the center to one end of the
22+
/// strip.
23+
std::array<float, 3> outerHalfVector;
24+
/// Half vector of the inner strip, pointing from the center to one end of the
25+
/// strip.
26+
std::array<float, 3> innerHalfVector;
27+
};
28+
29+
/// Derived collection of outer strip space point details, used for the
30+
/// calibration.
31+
struct OuterStripSpacePointCalibrationDetailsDerived final {
32+
/// Cross product of the separation vector from the inner strip center to the
33+
/// outer strip center with the inner half vector.
34+
std::array<float, 3> innerToOuterSeparationCrossInnerHalfVector;
35+
/// Cross product of the separation vector from the inner strip center to the
36+
/// outer strip center with the outer half vector.
37+
std::array<float, 3> innerToOuterSeparationCrossOuterHalfVector;
38+
/// Cross product of the inner half vector with the outer half vector.
39+
std::array<float, 3> innerCrossOuterHalfVector;
40+
/// Center of the outer strip.
41+
std::array<float, 3> outerCenter;
42+
/// Half vector of the outer strip, pointing from the center to one end of
43+
/// the strip.
44+
std::array<float, 3> outerHalfVector;
45+
};
46+
47+
} // namespace Acts
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// This file is part of the ACTS project.
2+
//
3+
// Copyright (C) 2016 CERN for the benefit of the ACTS project
4+
//
5+
// This Source Code Form is subject to the terms of the Mozilla Public
6+
// License, v. 2.0. If a copy of the MPL was not distributed with this
7+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
#pragma once
10+
11+
#include "Acts/EventData/StripSpacePointCalibrationDetails.hpp"
12+
13+
#include <Eigen/Core>
14+
15+
namespace Acts {
16+
17+
/// Derives the strip space point calibration details.
18+
/// @param sp The strip space point calibration details
19+
/// @return The derived strip space point calibration details
20+
OuterStripSpacePointCalibrationDetailsDerived
21+
deriveOuterStripSpacePointCalibrationDetails(
22+
const OuterStripSpacePointCalibrationDetails& sp);
23+
24+
/// Calibrates the strip space point using the assumed particle direction and
25+
/// the strip space point calibration details.
26+
/// @note This function does not check if the calibrated space point lies within the strip.
27+
/// @param sp The strip space point calibration details
28+
/// @param direction The assumed particle direction
29+
/// @return The calibrated outer strip space point
30+
Eigen::Vector3f calibrateOuterStripSpacePoint(
31+
const Eigen::Vector3f& direction,
32+
const OuterStripSpacePointCalibrationDetailsDerived& sp);
33+
34+
} // namespace Acts
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// This file is part of the ACTS project.
2+
//
3+
// Copyright (C) 2016 CERN for the benefit of the ACTS project
4+
//
5+
// This Source Code Form is subject to the terms of the Mozilla Public
6+
// License, v. 2.0. If a copy of the MPL was not distributed with this
7+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
#pragma once
10+
11+
#include "Acts/EventData/StripSpacePointCalibrationDetails.hpp"
12+
#include "Acts/Utilities/detail/StdArrayLinalg.hpp"
13+
14+
#include <cmath>
15+
16+
namespace Acts::detail {
17+
18+
// Intentionally not using Eigen here as there is a noticeable performance
19+
// (10-20%) penalty for small vector sizes.
20+
21+
inline OuterStripSpacePointCalibrationDetailsDerived
22+
deriveOuterStripSpacePointCalibrationDetails(const std::array<float, 3>& ihv,
23+
const std::array<float, 3>& ohv,
24+
const std::array<float, 3>& iosv,
25+
const std::array<float, 3>& oc) {
26+
OuterStripSpacePointCalibrationDetailsDerived result{};
27+
result.innerCrossOuterHalfVector = stdArrayCross(ihv, ohv);
28+
result.innerToOuterSeparationCrossOuterHalfVector = stdArrayCross(iosv, ohv);
29+
result.innerToOuterSeparationCrossInnerHalfVector = stdArrayCross(iosv, ihv);
30+
result.outerCenter = oc;
31+
result.outerHalfVector = ohv;
32+
return result;
33+
}
34+
35+
inline OuterStripSpacePointCalibrationDetailsDerived
36+
deriveOuterStripSpacePointCalibrationDetails(
37+
const OuterStripSpacePointCalibrationDetails& sp) {
38+
return deriveOuterStripSpacePointCalibrationDetails(
39+
sp.innerHalfVector, sp.outerHalfVector, sp.innerToOuterSeparation,
40+
sp.outerCenter);
41+
}
42+
43+
inline bool calibrateOuterStripSpacePoint(
44+
const std::array<float, 3>& direction,
45+
const std::array<float, 3>& ihvCrossOhv,
46+
const std::array<float, 3>& iosvCrossOhv,
47+
const std::array<float, 3>& iosvCrossIhv, const std::array<float, 3>& oc,
48+
const std::array<float, 3>& ohv, std::array<float, 3>& calibrated,
49+
const float tolerance) {
50+
// scale = innerStripHalfVector dot (outerStripHalfVector cross direction)
51+
const float scale = stdArrayDot(direction, ihvCrossOhv);
52+
53+
// sInner = innerToOuterSeparationVector dot (outerStripHalfVector cross
54+
// direction) Check if direction is inside the inner detector element
55+
const float sInner = stdArrayDot(direction, iosvCrossOhv);
56+
if (std::abs(sInner) > std::abs(scale) * tolerance) {
57+
return false;
58+
}
59+
60+
// sOuter = innerToOuterSeparationVector dot (innerStripHalfVector cross
61+
// direction) Check if direction is inside the outer detector element
62+
const float sOuter = stdArrayDot(direction, iosvCrossIhv);
63+
if (std::abs(sOuter) > std::abs(scale) * tolerance) {
64+
return false;
65+
}
66+
67+
// Corrected position using the outer strip center and direction
68+
const float sOuterNorm = sOuter / scale;
69+
calibrated = stdArrayAddScaled(oc, ohv, sOuterNorm);
70+
return true;
71+
}
72+
73+
inline bool calibrateOuterStripSpacePoint(
74+
const std::array<float, 3>& direction,
75+
const OuterStripSpacePointCalibrationDetailsDerived& sp,
76+
std::array<float, 3>& calibrated, const float tolerance) {
77+
return detail::calibrateOuterStripSpacePoint(
78+
direction, sp.innerCrossOuterHalfVector,
79+
sp.innerToOuterSeparationCrossOuterHalfVector,
80+
sp.innerToOuterSeparationCrossInnerHalfVector, sp.outerCenter,
81+
sp.outerHalfVector, calibrated, tolerance);
82+
}
83+
84+
} // namespace Acts::detail
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file is part of the ACTS project.
2+
//
3+
// Copyright (C) 2016 CERN for the benefit of the ACTS project
4+
//
5+
// This Source Code Form is subject to the terms of the Mozilla Public
6+
// License, v. 2.0. If a copy of the MPL was not distributed with this
7+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
#pragma once
10+
11+
#include <array>
12+
#include <cstddef>
13+
#include <span>
14+
15+
#include <Eigen/Core>
16+
17+
namespace Acts::detail {
18+
19+
template <typename T, std::size_t N>
20+
std::array<T, N> stdArrayCopy(const std::span<const T, N> arr) {
21+
std::array<T, N> result{};
22+
for (std::size_t i = 0; i < N; ++i) {
23+
result[i] = arr[i];
24+
}
25+
return result;
26+
}
27+
28+
template <typename T, int N>
29+
std::array<T, N> stdArrayCopy(const Eigen::Vector<T, N>& arr)
30+
requires(N > 0)
31+
{
32+
std::array<T, N> result{};
33+
for (std::size_t i = 0; i < N; ++i) {
34+
result[i] = arr[i];
35+
}
36+
return result;
37+
}
38+
39+
template <typename T, std::size_t N>
40+
Eigen::Vector<T, N> stdArrayToEigen(const std::array<T, N>& arr) {
41+
Eigen::Vector<T, N> result;
42+
for (std::size_t i = 0; i < N; ++i) {
43+
result[i] = arr[i];
44+
}
45+
return result;
46+
}
47+
48+
template <typename T, std::size_t N>
49+
std::array<T, N> stdArrayAddScaled(const std::array<T, N>& a,
50+
const std::array<T, N>& b, const T scale) {
51+
std::array<T, N> result{};
52+
for (std::size_t i = 0; i < N; ++i) {
53+
result[i] = a[i] + b[i] * scale;
54+
}
55+
return result;
56+
}
57+
58+
template <typename T, std::size_t N>
59+
T stdArrayDot(const std::array<T, N>& a, const std::array<T, N>& b) {
60+
T result = 0;
61+
for (std::size_t i = 0; i < N; ++i) {
62+
result += a[i] * b[i];
63+
}
64+
return result;
65+
}
66+
67+
template <typename T>
68+
std::array<T, 3> stdArrayCross(const std::array<T, 3>& a,
69+
const std::array<T, 3>& b) {
70+
std::array<T, 3> result{};
71+
result[0] = a[1] * b[2] - a[2] * b[1];
72+
result[1] = a[2] * b[0] - a[0] * b[2];
73+
result[2] = a[0] * b[1] - a[1] * b[0];
74+
return result;
75+
}
76+
77+
} // namespace Acts::detail

0 commit comments

Comments
 (0)