ATLAS Offline Software
Loading...
Searching...
No Matches
PtEstimationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
22
23#include "PtEstimationTool.h"
24
25#include <algorithm>
26#include <cmath>
27
28namespace {
29
30// Convert a segment slope m into an angle in the (z, R) plane
31float thetaFromSlope(float m) {
32 return std::atan(m);
33}
34
35// Compute the signed distance of point (z, r) from the line through (z1, r1) and (z2, r2)
36float pointToLineDistance(float z, float r,
37 float z1, float r1,
38 float z2, float r2) {
39 const float dz = z2 - z1;
40 const float dr = r2 - r1;
41 const float den = std::hypot(dz, dr);
42
43 // Protect against degenerate input geometry
44 if (den < 1.e-6f) {
45 return 0.f;
46 }
47
48 return ((z - z1) * dr - (r - r1) * dz) / den;
49}
50
51} // namespace
52
53namespace L0MDT {
54
56 ATH_MSG_DEBUG("Initializing " << name());
57
58 return StatusCode::SUCCESS;
59}
60
61std::optional<PtEstimate> PtEstimationTool::estimatePt(const Segment* biSeg,
62 const Segment* bmSeg,
63 const Segment* boSeg) const {
64 const bool hasBI = (biSeg != nullptr);
65 const bool hasBM = (bmSeg != nullptr);
66 const bool hasBO = (boSeg != nullptr);
67
68 const unsigned int nStations = static_cast<unsigned int>(hasBI) +
69 static_cast<unsigned int>(hasBM) +
70 static_cast<unsigned int>(hasBO);
71
72 // A meaningful geometric proxy needs at least two stations
73 if (nStations < 2) {
74 ATH_MSG_DEBUG("PtEstimationTool: fewer than 2 stations available, no pT proxy computed");
75 return std::nullopt;
76 }
77
78 PtEstimate result{};
79 result.nStations = nStations;
80
81 // --------------------------------------------------------------------------
82 // Two-station mode
83 //
84 // This branch estimates a toy pT proxy from the change in segment angle.
85 // This is only a bending proxy and is not a calibrated momentum estimate.
86 // --------------------------------------------------------------------------
87 if (nStations == 2) {
88 const Segment* inner = nullptr;
89 const Segment* outer = nullptr;
90
91 if (hasBI && hasBM) {
92 inner = biSeg;
93 outer = bmSeg;
94 } else if (hasBI && hasBO) {
95 inner = biSeg;
96 outer = boSeg;
97 } else if (hasBM && hasBO) {
98 inner = bmSeg;
99 outer = boSeg;
100 }
101
102 if (!inner || !outer) {
103 ATH_MSG_WARNING("PtEstimationTool: invalid 2-station configuration");
104 return std::nullopt;
105 }
106
107 const float thetaInner = thetaFromSlope(inner->m());
108 const float thetaOuter = thetaFromSlope(outer->m());
109
110 result.deltaBeta = thetaOuter - thetaInner;
111 result.pt = estimateTwoStationPt(result.deltaBeta);
112
113 ATH_MSG_DEBUG("Temporary 2-station pT proxy | "
114 << "deltaBeta=" << result.deltaBeta
115 << " ptProxy=" << result.pt);
116
117 return result;
118 }
119
120 // --------------------------------------------------------------------------
121 // Three-station mode
122 //
123 // This branch estimates a toy pT proxy from sagitta and lever arm.
124 // The result is purely geometric and ignores magnetic field and calibration.
125 // --------------------------------------------------------------------------
126 const float sagitta = pointToLineDistance(
127 bmSeg->zRef(), bmSeg->rRef(),
128 biSeg->zRef(), biSeg->rRef(),
129 boSeg->zRef(), boSeg->rRef());
130
131 const float leverArm = std::hypot(
132 boSeg->zRef() - biSeg->zRef(),
133 boSeg->rRef() - biSeg->rRef());
134
135 result.sagitta = sagitta;
136 result.leverArm = leverArm;
137 result.pt = estimateThreeStationPt(result.sagitta, result.leverArm);
138
139 ATH_MSG_DEBUG("Temporary 3-station pT proxy | "
140 << "sagitta=" << result.sagitta
141 << " leverArm=" << result.leverArm
142 << " ptProxy=" << result.pt);
143
144 return result;
145}
146
147// Convert a 2-station angular deflection into a toy pT proxy
148float PtEstimationTool::estimateTwoStationPt(float deltaBeta) const {
149 // Protection against vanishing angular difference
150 constexpr float minAbsDeltaBeta = 1.e-4f;
151
152 // Purely ad hoc scale factor for a temporary proxy
153 constexpr float kToyPtScale = 1000.f;
154
155 const float absDeltaBeta = std::max(std::abs(deltaBeta), minAbsDeltaBeta);
156
157 // Temporary proxy: larger bending -> lower pT proxy
158 return kToyPtScale / absDeltaBeta;
159}
160
161// Convert a 3-station sagitta into a toy pT proxy
162float PtEstimationTool::estimateThreeStationPt(float sagitta, float leverArm) const {
163 // Protection against vanishing sagitta
164 constexpr float minAbsSagitta = 1.e-3f;
165
166 // Purely ad hoc scale factor for a temporary proxy
167 constexpr float kToyPtScale = 1.e-3f;
168
169 const float absSagitta = std::max(std::abs(sagitta), minAbsSagitta);
170
171 // Temporary proxy: pT ~ L^2 / sagitta
172 return kToyPtScale * leverArm * leverArm / absSagitta;
173}
174
175} // namespace L0MDT
176
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define z
float estimateTwoStationPt(float deltaBeta) const
Compute a toy pT proxy from the angular deflection between two stations.
virtual StatusCode initialize() override
float estimateThreeStationPt(float sagitta, float leverArm) const
Compute a toy pT proxy from the sagitta and lever arm of a three-station track.
virtual std::optional< PtEstimate > estimatePt(const Segment *biSeg, const Segment *bmSeg, const Segment *boSeg) const override
Estimate the transverse momentum from up to three MDT segment references.
Class describing a reconstructed MDT segment used by the L0Muon trigger.
float rRef() const
float zRef() const
float m() const
int r
Definition globals.cxx:22
Compact Segment Finder algorithm overview.
Output struct holding the result of a pT estimation.