ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalPatternFinderDefs.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONR4_FASTRECONSTRUCTIONALGS_PATTERNFINDERUTILITIES__H
5#define MUONR4_FASTRECONSTRUCTIONALGS_PATTERNFINDERUTILITIES__H
6
8
12
13namespace MuonR4::FastReco{
15
17
26 explicit HitPayload(const Acts::GeometryContext& gctx,
27 const SpacePoint* sp,
29 const Amg::Transform3D& localToGlobal);
31 Amg::Vector3D sensorDir(const Acts::GeometryContext& gctx) const;
32
38 double residualVariance(const Acts::GeometryContext& gctx,
39 const Amg::Vector3D& contractionVector,
40 const bool isProjected) const;
41
43 Amg::Vector3D position{Amg::Vector3D::Zero()};
45 const SpacePoint* spacePoint{nullptr};
47 const SpacePointBucket* bucket{nullptr};
49 double phiCov{0.};
51 double stripAngle{0.};
53 StIndex station{toStationIndex(spacePoint->msSector()->chamberIndex())};
55 uint8_t locLayer{static_cast<uint8_t>(s_spSorter.sectorLayerNum(*spacePoint))};
61 bool operator==(const HitPayload& other) const;
63 const SpacePoint* operator->() const { return spacePoint; }
65 const SpacePoint& operator*() const { return *spacePoint; }
66 };
67
75
81 const HitPayload* hit{nullptr};
83 uint8_t globLayer{0u};
84 // Forward commonly used accessors for convenience
85 const HitPayload* operator->() const { return hit; }
86 const HitPayload& operator*() const { return *hit; }
87 const SpacePoint* sp() const { return hit->spacePoint; }
88 bool operator==(const CandidateHit& other) const { return *hit == *other.hit; }
89 bool operator==(const HitPayload& other) const { return *hit == other; }
90 // Print and stream operator
91 friend std::ostream& operator<<(std::ostream& ostr, const CandidateHit& c) {
92 c.print(ostr);
93 return ostr;
94 }
95 void print(std::ostream& ostr) const;
96 };
97
107
113
120 explicit PatternState(const CandidateHit& seed,
121 const std::int8_t expSector,
122 const Config* cfg,
123 const Acts::Logger* logger);
126 PatternState(PatternState&& other) noexcept = default;
129 PatternState& operator=(PatternState&& other) noexcept = default;
132 PatternState(const PatternState& other) = default;
135 PatternState& operator=(const PatternState& other) = default;
137 ~PatternState() =default;
142 void addHit(const CandidateHit& hit,
143 const double residual,
144 const double resSigma);
150 void overWriteHit(const CandidateHit& newHit,
151 const double newResidual,
152 const double newResSigma);
157 LineTestRes checkLineComp(const Acts::GeometryContext& gctx,
158 const CandidateHit& testHit,
159 const Amg::Vector3D& beamSpot);
163 LineTestRes computeLineResidual(const Acts::GeometryContext& gctx,
164 const CandidateHit& testHit) const;
170 Amg::Vector3D projToPhiPlane(const Acts::GeometryContext& gctx,
171 const HitPayload& hit) const;
175 bool isPhiCompatible(const HitPayload& hit) const;
179 bool isInPattern(const HitPayload& hit) const;
182 void moveLineAnchorHit(const CandidateHit& refHit);
185 void updateLineParameters(const Acts::GeometryContext& gctx,
186 const Amg::Vector3D& beamSpot);
188 void updatePatternPhi();
190 double getMeanResidual2() const;
192 uint8_t nBendingLayers() const;
196 uint8_t nStations(const bool onlyGoodStations) const;
198 std::vector<const SpacePointBucket*> getParentBuckets() const;
200 const Acts::Logger& logger() const {
201 return *m_logger;
202 }
203
205 const Config* cfg{nullptr};
207 const Acts::Logger* m_logger{nullptr};
209 Acts::CloneablePtr<PatHitVisual> visualInfo{nullptr};
217 Amg::Vector3D bendPlaneNorm{Amg::Vector3D::Zero()};
221 Amg::Vector3D linePos{Amg::Vector3D::Zero()};
222 Amg::Vector3D lineDir{Amg::Vector3D::Zero()};
224 double leverArm{0.};
228 double lastResidual{0.};
229 double lastResSigma{0.};
231 double patPhi{0.};
233 double patTheta{0.};
235 double patPhiCov{0.};
237 ExpandedSector expSect{static_cast<int8_t>(0)};
239 uint8_t nPrecisionLayers{0u};
240 uint8_t nTriggerLayers{0u};
241 uint8_t nPhiLayers{0u};
243 bool isFinalized{false};
245 bool isOverlap{false};
247 bool useBeamspot{false};
249 bool needLineUpdate{false};
250
252 std::array<std::vector<CandidateHit>, s_nStations> hitsPerStation{};
254 std::vector<HitPayload> phiOnlyHits{};
255
257 bool operator==(const PatternState& other) const = delete;
259 void print(std::ostream& ostr, bool detailed) const;
260 };
261
267 bool detailed = false;
268
270 friend std::ostream& operator<<(std::ostream& os, const PatternPrintView& v) {
271 v.pat.print(os, v.detailed);
272 return os;
273 }
274 };
275
276}
277
278#endif
bool hit(const Container &ids, int pdgId)
static Double_t sp
Acts::KDTree< 2, const HitPayload *, double, std::array, 50 > SearchTree_t
Definition of the search tree class.
Muon::MuonStationIndex::StIndex StIndex
Type alias for the station index.
static const int s_nStations
Number of stations.
static PatternPrintView detailed(const PatternState &p)
Print the pattern state with detailed information.
: The muon space point bucket represents a collection of points that will bre processed together in t...
The SpacePointPerLayerSorter sort two given space points by their layer Identifier.
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
GlobalPatternFinder::StIndex StIndex
LineTestDecision
: Enum for possible outcomes of pattern line compatibility test
@ eRejectHit
Test failed, discard the hit.
@ eBranchPattern
Test successfull with multiple pattern hits on same layer, branch the pattern.
@ eAddHit
Test successfull, add hit to pattern.
static const SpacePointPerLayerSorter s_spSorter
bool isPrecisionHit(const SpacePoint &hit)
Returns whether the uncalibrated spacepoint is a precision hit (Mdt, micromegas, stgc strips).
StIndex toStationIndex(ChIndex index)
convert ChIndex into StIndex
Small wrapper for candidate hits used to build patterns.
uint8_t globLayer
Global measurement layer number.
friend std::ostream & operator<<(std::ostream &ostr, const CandidateHit &c)
const HitPayload * hit
Pointer to the underlying hit.
Configuration object for the patter finder.
Base class for hit struct containing hit information.
uint8_t locLayer
Layer number in the sector frame.
double phiCov
Cached angular covariance [rad^2] of the hit in the phi angle.
HitPayload(const Acts::GeometryContext &gctx, const SpacePoint *sp, const SpacePointBucket *bucket, const Amg::Transform3D &localToGlobal)
Constructor with parameters.
const SpacePoint & operator*() const
Dereference operator: it allows to access the underlying hit.
const SpacePoint * spacePoint
Pointer to the underlying hit.
const SpacePointBucket * bucket
Pointer to the parent bucket.
double residualVariance(const Acts::GeometryContext &gctx, const Amg::Vector3D &contractionVector, const bool isProjected) const
Hit contribution contribution to the residual variance due to its intrinsic position uncertainty.
Amg::Vector3D sensorDir(const Acts::GeometryContext &gctx) const
Sensor direction.
bool operator==(const HitPayload &other) const
Equal operator: it compares the underlying hit.
double stripAngle
Strip angle when the strips are non-orthogonal.
const SpacePoint * operator->() const
Arrow operator: it allows to access the underlying hit.
A view of the pattern state for printing purposes.
friend std::ostream & operator<<(std::ostream &os, const PatternPrintView &v)
Print the pattern print view.
const PatternState & pat
The pattern state to be printed.
Pattern state object storing pattern information during construction.
PatternState(const CandidateHit &seed, const std::int8_t expSector, const Config *cfg, const Acts::Logger *logger)
Constructor taking the seed information.
void moveLineAnchorHit(const CandidateHit &refHit)
Move the line anchor hit given a reference hit.
double lastResidual
Residual & residual uncertainty of the last inserted hit (needed when replacing a hit).
double meanNormResidual2
Mean over eta hits of the square of their residual divided by residual uncertainty.
Amg::Vector3D projToPhiPlane(const Acts::GeometryContext &gctx, const HitPayload &hit) const
Project a certain hit position onto the bending plane where the pattern is defined.
bool isInPattern(const HitPayload &hit) const
Check wheter a hit is present in the pattern.
void updateLineParameters(const Acts::GeometryContext &gctx, const Amg::Vector3D &beamSpot)
Update the line parameters based on the current hits.
uint8_t nStations(const bool onlyGoodStations) const
Method returning the number of stations.
Amg::Vector3D linePos
Position and direction of the pattern line.
bool useBeamspot
Whether we used the beamspot to compute the line parameters.
PatternState(PatternState &&other) noexcept=default
Move constructor.
PatternState(const PatternState &other)=default
Copy constructor.
double leverArm
Distance between the two points defining the pattern line.
bool needLineUpdate
Whether we need to update the pattern line the next time we find a hit in a new layer.
std::vector< HitPayload > phiOnlyHits
Array holding phi-only hits.
std::vector< const SpacePointBucket * > getParentBuckets() const
Get the buckets associated with the pattern.
bool isFinalized
Flag to indicate if the pattern has been finalized.
Amg::Vector3D bendPlaneNorm
Normal vector to the bending plane where the pattern lies.
uint8_t nBendingLayers() const
Return the number of layers in bending coordinate.
Acts::CloneablePtr< PatHitVisual > visualInfo
Pointer to Visual Information for pattern visualization.
CandidateHit prevLayerHit
Last hit in the second-to-last layer.
void addHit(const CandidateHit &hit, const double residual, const double resSigma)
Add a hit to the pattern and update the internal state.
PatternState & operator=(const PatternState &other)=default
Copy assignment operator.
std::array< std::vector< CandidateHit >, s_nStations > hitsPerStation
Map collection of hits per station.
void print(std::ostream &ostr, bool detailed) const
Print the pattern candidate.
LineTestRes checkLineComp(const Acts::GeometryContext &gctx, const CandidateHit &testHit, const Amg::Vector3D &beamSpot)
Method checking line compatibility of a test hit against the pattern.
bool isOverlap
Flag to indicate if the pattern is overlapping with another one, used during overlap removal.
bool isPhiCompatible(const HitPayload &hit) const
Method to check the phi compatibility of a test hit with a given pattern.
void updatePatternPhi()
Helper method to update the pattern phi and bending plane normal.
void overWriteHit(const CandidateHit &newHit, const double newResidual, const double newResSigma)
Overwrite the hits on the last layer with the new one.
double patPhi
Pattern phi, which is the phi of the bending plane where the pattern lies.
const Acts::Logger & logger() const
Return the logger.
PatternState & operator=(PatternState &&other) noexcept=default
Move assignment operator.
uint8_t nPrecisionLayers
Counts of precision / non-precision / phi layers.
LineTestRes computeLineResidual(const Acts::GeometryContext &gctx, const CandidateHit &testHit) const
Method to compute the residual of a test hit against the pattern line.
double getMeanResidual2() const
Return the mean normalized residual squared.
bool operator==(const PatternState &other) const =delete
Patterns are considered identical if they have the same hit content.
double patTheta
Pattern theta, which is the value of the seed hit.
std::vector< HitPayload > stripPayloads
Vector of strip hits.
: Small struct to encapsulate the result of the line compatibility test