ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalPatternFinder.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_GLOBALPATTERNFINDER__H
5#define MUONR4_FASTRECONSTRUCTIONALGS_GLOBALPATTERNFINDER__H
6
13
14#include "Acts/Utilities/KDTree.hpp"
15
16
18
27
29 public:
35 using SpacePointContainerVec = std::vector<const SpacePointContainer*>;
37 using PatternVec = std::vector<GlobalPattern>;
39 using BucketPerContainer = std::unordered_map<const SpacePointContainer*, std::vector<const SpacePointBucket*>>;
43 using PatternHitVisualInfoVec = std::vector<PatternHitVisualInfo>;
44
46 struct Config {
48 double thetaSearchWindow {0.033};
50 unsigned int maxMissedLayerHits {2};
52 double baseRWindow {25};
54 double minZDiff4Line {10};
56 double minRDiff4Line {40};
58 double phiTolerance {0.1};
60 unsigned int minBendingTriggerHits {3};
62 unsigned int minBendingPrecisionHits {0};
64 bool useMdtHits {true};
66 bool seedFromMdt {false};
68 unsigned int maxSeedAttempts {2};
70 std::vector<LayerIndex> layerSeedings{LayerIndex::Middle, LayerIndex::Outer};
75 };
76
80 GlobalPatternFinder(const std::string& name,
81 Config&& config);
82
90 const SpacePointContainerVec& spacepoints,
91 BucketPerContainer& outBuckets) const;
92
93 private:
95 struct HitPayload{
105 HitPayload(const SpacePoint* hit,
109 unsigned layerNum,
110 double R,
111 double Z,
112 double phi);
117 HitPayload(const SpacePoint* hit,
119 double phi);
121 const SpacePoint* hit{nullptr};
123 const SpacePointBucket* bucket{nullptr};
129 unsigned layerNum{0u};
131 double R{0.};
133 double Z{0.};
135 double phi{0.};
137 bool operator==(const HitPayload& other) const;
138 };
139
140 using SearchTree_t = Acts::KDTree<2, HitPayload, double, std::array, 5>;
142 using TreeNode = std::pair<SearchTree_t::coordinate_t, HitPayload>;
144 enum class SeedCoords : std::uint8_t{
149 };
150
156 PatternState(const HitPayload& seed,
157 const int sectorCoord,
158 const double seedTheta);
159 PatternState() = delete;
164 void addHit(const HitPayload& hit,
165 const double residual,
166 const double acceptWindow);
172 void overWriteHit(const HitPayload& oldHit,
173 const HitPayload& newHit,
174 const double newResidual,
175 const double newAcceptWindow);
179 const HitPayload& getNthLastHit(const std::size_t n) const;
183 bool isInPattern(const HitPayload& hit) const;
185 void finalizePatternEta();
187 void finalizePatternPhi();
189 bool operator==(const PatternState& other) const;
191 std::unordered_map<StIndex, std::vector<HitPayload>> hitsPerStation{};
194 std::vector<StIndex> stations{};
198 int sectorCoord{-1};
199 int sector1{0};
200 int sector2{0};
202 double theta{0.};
203 double phi{0.};
205 unsigned nPrecisionHits{0};
207 unsigned nPhiHits{0};
211 double lastResidual{0.};
212 double lastAccepWindow{0.};
214 bool isOverlap{false};
216 unsigned nInsertedHits{0};
218 unsigned nMissedLayerHits{0};
220 Acts::CloneablePtr<PatternHitVisualInfo> visualInfo{nullptr};
222 void print(std::ostream& ostr) const;
223 friend std::ostream& operator<<(std::ostream& ostr, const PatternState& candidate) {
224 candidate.print(ostr);
225 return ostr;
226 }
227 };
228 using PatternStateVec = std::vector<PatternState>;
229
230
236 const SpacePointContainerVec& spacepoints) const;
242 PatternStateVec findPatternsInEta(const SearchTree_t& orderedSpacepoints,
243 PatternHitVisualInfoVec* visualInfo = nullptr) const;
251 void extendPatterns(PatternStateVec& activePatterns,
252 const HitPayload& test,
253 const HitPayload& seed,
254 const HitPayload& prevCandidate,
255 PatternHitVisualInfoVec* visualInfo = nullptr) const;
257 enum class CompatibilityResult : std::int8_t{
264 };
265
271
277 const HitPayload& test,
278 const PatternState& pattern) const;
285 double computeLineSlope(const HitPayload& lastPatHit,
286 const HitPayload& seed,
287 const bool useSeed2Beamspot,
288 const Amg::Vector3D& beamSpot) const;
294 double computeResidual(const HitPayload& testHit,
295 const HitPayload& seed,
296 const double lineSlope) const;
305 double computeAcceptanceWindow(const HitPayload& testHit,
306 const HitPayload& seed,
307 const HitPayload& lastPatHit,
308 const double lineSlope,
309 const bool useSeed2Beamspot,
310 const Amg::Vector3D& beamSpot) const;
316 PatternHitVisualInfoVec* visualInfo = nullptr) const;
327 bool isPhiCompatible(const double testPhi,
328 const PatternState& pattern) const;
332 GlobalPattern convertToPattern(const PatternState& candidate) const;
336 PatternVec convertToPattern(const PatternStateVec& candidates) const;
343
347 LayerOrdering checkLayerOrdering(const HitPayload& hit1,
348 const HitPayload& hit2) const;
353 void addVisualInfo(const PatternState& candidate,
355 PatternHitVisualInfoVec* visualInfo) const;
356
361 };
362}
363
364
365#endif
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
std::vector< const SpacePointContainer * > SpacePointContainerVec
Abrivation for a vector of space-point containers.
LayerOrdering checkLayerOrdering(const HitPayload &hit1, const HitPayload &hit2) const
Method to check the logical layer ordering of two hits.
std::pair< SearchTree_t::coordinate_t, HitPayload > TreeNode
Type alias for a tree node, formed by a hit payload and its indexing coordinates.
CompatibilityResult
: Enum for the possible outcomes of the line compatibility test of one pattern against one test hit
@ eBranchPattern
Test successfull with multiple pattern hits in the same logical measurement layer,...
@ eAddHit
Test successfull, add the hit to the pattern.
LineCompatibilityResult checkLineCompatibility(const HitPayload &seed, const HitPayload &test, const PatternState &pattern) const
Method to check the line compatibility of a test hit with a given pattern.
PatternStateVec resolveOverlaps(PatternStateVec &&toResolve, PatternHitVisualInfoVec *visualInfo=nullptr) const
Method to remove overlapping patterns.
std::vector< PatternHitVisualInfo > PatternHitVisualInfoVec
Abrivation for a vector of visual information objects.
MuonValR4::IFastRecoVisualizationTool::PatternHitVisualInfo PatternHitVisualInfo
Type alias for the visual information of a pattern.
SearchTree_t constructTree(const ActsTrk::GeometryContext &gctx, const SpacePointContainerVec &spacepoints) const
Method to construct the search tree by filling it up with spacepoints from the given containers.
void addVisualInfo(const PatternState &candidate, PatternHitVisualInfo::PatternStatus status, PatternHitVisualInfoVec *visualInfo) const
Helper function to add visual information of a given pattern (which is usually going to be destroyed)...
void extendPatterns(PatternStateVec &activePatterns, const HitPayload &test, const HitPayload &seed, const HitPayload &prevCandidate, PatternHitVisualInfoVec *visualInfo=nullptr) const
Function testing pattern compatibility of a set of active patterns (patterns produced from the same s...
Config m_cfg
Global Pattern Recognition configuration.
bool isPhiCompatible(const double testPhi, const PatternState &pattern) const
Method to check the phi compatibility of a test hit with a given pattern.
std::vector< GlobalPattern > PatternVec
Abrivation for a vector of global patterns.
double computeAcceptanceWindow(const HitPayload &testHit, const HitPayload &seed, const HitPayload &lastPatHit, const double lineSlope, const bool useSeed2Beamspot, const Amg::Vector3D &beamSpot) const
Method to compute the acceptance window in global R for a given pattern line and test hit.
Muon::MuonStationIndex::StIndex StIndex
Type alias for the station index.
LayerOrdering
Enum to express the logical measurement layer ordering given two hits.
double computeLineSlope(const HitPayload &lastPatHit, const HitPayload &seed, const bool useSeed2Beamspot, const Amg::Vector3D &beamSpot) const
Helper method to compute the line slope between the seed and the last hit in a given pattern in the R...
void addPhiOnlyHits(const ActsTrk::GeometryContext &gctx, PatternStateVec &patterns) const
Method to add phi-only measurements to existing PatternStates.
GlobalPatternFinder(const std::string &name, Config &&config)
Standard constructor.
std::vector< PatternState > PatternStateVec
PatternVec findPatterns(const ActsTrk::GeometryContext &gctx, const SpacePointContainerVec &spacepoints, BucketPerContainer &outBuckets) const
Main methods steering the pattern finding.
SeedCoords
Abrivation of the seed coordinates.
@ eSector
Expanded sector coordinate of the associated spectrometer sector
SpacePointPerLayerSorter m_spSorter
Spacepoint sorter per logical measurement layer.
GlobalPattern convertToPattern(const PatternState &candidate) const
Method to convert a PatternState into a GlobalPattern object.
std::unordered_map< const SpacePointContainer *, std::vector< const SpacePointBucket * > > BucketPerContainer
Abrivation for a collection of space-point buckets grouped by their corresponding input container.
PatternStateVec findPatternsInEta(const SearchTree_t &orderedSpacepoints, PatternHitVisualInfoVec *visualInfo=nullptr) const
Method steering the building of patterns in eta.
double computeResidual(const HitPayload &testHit, const HitPayload &seed, const double lineSlope) const
Method to compute the residual in globalR given the pattern line and test hit.
Acts::KDTree< 2, HitPayload, double, std::array, 5 > SearchTree_t
Definition of the search tree class.
Muon::MuonStationIndex::LayerIndex LayerIndex
Type alias for the station layer index.
Data class to represent an eta maximum in hough space.
: 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...
Helper tool to visualize a pattern recogntion incident or a certain stage of the segment fit.
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
std::vector< std::string > patterns
Definition listroot.cxx:187
Eigen::Matrix< double, 3, 1 > Vector3D
DataVector< SpacePointBucket > SpacePointContainer
Abrivation of the space point container type.
StIndex
enum to classify the different station layers in the muon spectrometer
LayerIndex
enum to classify the different layers in the muon spectrometer
bool useMdtHits
Toggle the utilization of MDT hits to build patterns.
unsigned int minBendingTriggerHits
Minimum number of trigger hits in the bending direction required to accept a pattern.
double thetaSearchWindow
Size of theta window in radiants to search for comapatible hits with a pattern, tailored to the targe...
bool seedFromMdt
Toggle the seeding from MDT hits.
const Muon::IMuonIdHelperSvc * idHelperSvc
Pointer to the idHelperSvc.
std::vector< LayerIndex > layerSeedings
Vector configuring the seeding layers.
double phiTolerance
Maximum phi difference in radiants allowed between two hits.
double baseRWindow
Base radial compatibility window (in mm).
double minRDiff4Line
Minimum difference in global R between the seed and the pattern hit to be used to compute the pattern...
unsigned int maxMissedLayerHits
Maximum number of missed candidate hits in different measurement layers during pattern building.
const MuonValR4::IFastRecoVisualizationTool * visionTool
Pointer to the visualization tool.
double minZDiff4Line
Minimum difference in global Z between the seed and the pattern hit to be used to compute the pattern...
unsigned int maxSeedAttempts
Maximum number of attempts to build a pattern from hits already used in existing patterns.
unsigned int minBendingPrecisionHits
Minimum number of precision hits in the bending direction required to accept a pattern.
Hit information stored during pattern building.
HitPayload(const SpacePoint *hit, const SpacePointBucket *bucket, const SpacePointContainer *container, StIndex station, unsigned layerNum, double R, double Z, double phi)
Full constructor for eta hits.
const SpacePoint * hit
Pointer to the underlying hit.
const SpacePointBucket * bucket
Pointer to the parent bucket.
const SpacePointContainer * container
Pointer to the parent container.
unsigned layerNum
Logical layer number in the sector frame.
bool operator==(const HitPayload &other) const
Equal operator: it compares the underlying hit.
: Small struct to encapsulate the checkLineCompatibility result
Pattern state object storing pattern information during construction.
Acts::CloneablePtr< PatternHitVisualInfo > visualInfo
Pointer to Visual Information for pattern visualization.
double lastResidual
Residual & acceptance window of the last inserted hit (needed when replacing a hit)
void addHit(const HitPayload &hit, const double residual, const double acceptWindow)
Add a hit to the pattern and update the internal state.
BucketPerContainer bucketsPerContainer
Map of spacepoint buckets per spacepoint container associated to the pattern.
double meanNormResidual2
Mean over eta hits of the square of their residual divided by acceptance window.
unsigned nMissedLayerHits
Number of missed candidate hits in different measurement layers during pattern building.
bool isInPattern(const HitPayload &hit) const
Check wheter a hit is present in the pattern.
int sectorCoord
expanded sector coordinate & the two corresponding physical sectors
double theta
Average theta & average phi of the pattern.
std::vector< StIndex > stations
Pattern hit stations to save the filling order.
void print(std::ostream &ostr) const
Print the pattern candidate and stream operator.
unsigned nInsertedHits
Number of inserted hits during one of the two search stages (from seed outward and from seed inward)
void finalizePatternEta()
Finalize the pattern building in eta and update its state.
bool operator==(const PatternState &other) const
Equal operator, it checks the hit-per-station map.
void finalizePatternPhi()
Finalize the pattern building in phi and update its state.
unsigned nPrecisionHits
Counts of precision measurements / non-precision in bending direction / phi measurements.
std::unordered_map< StIndex, std::vector< HitPayload > > hitsPerStation
Map collection of hits per station.
bool isOverlap
Flag to indicate if the pattern is overlapping with another one, used during overlap removal.
friend std::ostream & operator<<(std::ostream &ostr, const PatternState &candidate)
PatternState(const HitPayload &seed, const int sectorCoord, const double seedTheta)
Constructor taking the seed information.
const HitPayload & getNthLastHit(const std::size_t n) const
Get the nth last inserted hit.
void overWriteHit(const HitPayload &oldHit, const HitPayload &newHit, const double newResidual, const double newAcceptWindow)
Overwrite a hit in the pattern and update the internal state.
Structure to hold visual information about a pattern.