File indexing completed on 2025-12-13 09:21:24
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Seeding/CompositeSpacePointLineSeeder.hpp"
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Utilities/MathHelpers.hpp"
0013 #include "Acts/Utilities/VectorHelpers.hpp"
0014
0015 #include <format>
0016
0017 namespace {
0018
0019
0020 constexpr double inDeg(const double rad) {
0021 using namespace Acts::UnitLiterals;
0022 return rad / 1._degree;
0023 }
0024 }
0025
0026 namespace Acts::Experimental {
0027
0028 using SeedParam_t = CompositeSpacePointLineSeeder::SeedParam_t;
0029 using TangentAmbi = CompositeSpacePointLineSeeder::TangentAmbi;
0030
0031 CompositeSpacePointLineSeeder::CompositeSpacePointLineSeeder(
0032 const Config& cfg, std::unique_ptr<const Logger> logger)
0033 : m_cfg(cfg), m_logger(std::move(logger)) {}
0034
0035 TangentAmbi CompositeSpacePointLineSeeder::encodeAmbiguity(
0036 const int signTop, const int signBottom) {
0037 assert(Acts::abs(signTop) == 1 && Acts::abs(signBottom) == 1);
0038 using enum TangentAmbi;
0039 if (signTop == 1 && signBottom == 1) {
0040 static_assert(s_signCombo[toUnderlying(RR)][0] == 1 &&
0041 s_signCombo[toUnderlying(RR)][1] == 1);
0042 return RR;
0043 } else if (signTop == 1 && signBottom == -1) {
0044 static_assert(s_signCombo[toUnderlying(RL)][0] == 1 &&
0045 s_signCombo[toUnderlying(RL)][1] == -1);
0046
0047 return RL;
0048 } else if (signTop == -1 && signBottom == 1) {
0049 static_assert(s_signCombo[toUnderlying(LR)][0] == -1 &&
0050 s_signCombo[toUnderlying(LR)][1] == 1);
0051 return LR;
0052 }
0053 static_assert(s_signCombo[toUnderlying(LL)][0] == -1 &&
0054 s_signCombo[toUnderlying(LL)][1] == -1);
0055 return LL;
0056 }
0057
0058 std::string CompositeSpacePointLineSeeder::toString(const TangentAmbi ambi) {
0059 switch (ambi) {
0060 using enum TangentAmbi;
0061 case RR:
0062 return "Right - Right";
0063 case RL:
0064 return "Right - Left";
0065 case LR:
0066 return "Left - Right";
0067 case LL:
0068 return "Left - Left";
0069 }
0070 return "Undefined";
0071 }
0072
0073 CompositeSpacePointLineSeeder::Line_t CompositeSpacePointLineSeeder::makeLine(
0074 const SeedParam_t& pars) const {
0075 using enum ParIdx;
0076 using Aux_t = detail::CompSpacePointAuxiliaries;
0077 ACTS_VERBOSE(__func__ << "() - Create line from parameters "
0078 << std::format("{:}: {:.2f}, ", Aux_t::parName(x0),
0079 pars[toUnderlying(x0)])
0080 << std::format("{:}: {:.2f}, ", Aux_t::parName(y0),
0081 pars[toUnderlying(y0)])
0082 << std::format("{:}: {:.3f}, ", Aux_t::parName(theta),
0083 inDeg(pars[toUnderlying(theta)]))
0084 << std::format("{:}: {:.3f}", Aux_t::parName(phi),
0085 inDeg(pars[toUnderlying(phi)])));
0086 return std::make_pair(
0087 Vector3{pars[toUnderlying(x0)], pars[toUnderlying(y0)], 0.},
0088 makeDirectionFromPhiTheta(pars[toUnderlying(phi)],
0089 pars[toUnderlying(theta)]));
0090 }
0091
0092 SeedParam_t CompositeSpacePointLineSeeder::combineWithPattern(
0093 const Line_t& tangentSeed, const SeedParam_t& patternParams) const {
0094 SeedParam_t result{patternParams};
0095 using enum ParIdx;
0096 const auto& [seedPos, seedDir] = tangentSeed;
0097 result[toUnderlying(y0)] = seedPos.y();
0098 const Vector patternDir = makeLine(result).second;
0099 const double tanAlpha = patternDir.x() / patternDir.z();
0100 const double tanBeta = seedDir.y() / seedDir.z();
0101 const Vector3 dir = makeDirectionFromAxisTangents(tanAlpha, tanBeta);
0102 result[toUnderlying(phi)] = VectorHelpers::phi(dir);
0103 result[toUnderlying(theta)] = VectorHelpers::theta(dir);
0104 return result;
0105 }
0106
0107 void CompositeSpacePointLineSeeder::TwoCircleTangentPars::print(
0108 std::ostream& ostr) const {
0109 ostr << toString(ambi);
0110 ostr << ", "
0111 << std::format("theta: {:.3f} pm {:.3f}", inDeg(theta), inDeg(dTheta));
0112 ostr << ", " << std::format("y_{{0}}: {:.2f} : pm {:.2f}", y0, dY0);
0113 }
0114 bool CompositeSpacePointLineSeeder::isValidLine(
0115 const TwoCircleTangentPars& tangentPars) const {
0116 if (m_cfg.thetaRange[0] < m_cfg.thetaRange[1] &&
0117 (tangentPars.theta < m_cfg.thetaRange[0] ||
0118 tangentPars.theta > m_cfg.thetaRange[1])) {
0119 ACTS_VERBOSE(__func__ << "() " << __LINE__
0120 << " - Theta parameter out of range: "
0121 << std::format("{:.3f} ,allowed: [{:.3f};{:.3f}].",
0122 inDeg(tangentPars.theta),
0123 inDeg(m_cfg.thetaRange[0]),
0124 inDeg(m_cfg.thetaRange[1])));
0125 return false;
0126 }
0127 if (m_cfg.interceptRange[0] < m_cfg.interceptRange[1] &&
0128 (tangentPars.y0 < m_cfg.interceptRange[0] ||
0129 tangentPars.y0 > m_cfg.interceptRange[1])) {
0130 ACTS_VERBOSE(__func__ << "() " << __LINE__
0131 << " - Interscept parameter out of range: "
0132 << std::format("{:.2f}, allowed: [{:.2f};{:.2f}].",
0133 tangentPars.y0,
0134 m_cfg.interceptRange[0],
0135 m_cfg.interceptRange[1]));
0136 return false;
0137 }
0138 return true;
0139 }
0140 }