4#ifndef MUONR4_FASTRECONSTRUCTIONALGS_GLOBALPATTERNFINDER__H
5#define MUONR4_FASTRECONSTRUCTIONALGS_GLOBALPATTERNFINDER__H
14#include "Acts/Utilities/KDTree.hpp"
39 using BucketPerContainer = std::unordered_map<const SpacePointContainer*, std::vector<const SpacePointBucket*>>;
70 std::vector<LayerIndex>
layerSeedings{LayerIndex::Middle, LayerIndex::Outer};
140 using SearchTree_t = Acts::KDTree<2, HitPayload, double, std::array, 5>;
142 using TreeNode = std::pair<SearchTree_t::coordinate_t, HitPayload>;
158 const double seedTheta);
165 const double residual,
166 const double acceptWindow);
174 const double newResidual,
175 const double newAcceptWindow);
220 Acts::CloneablePtr<PatternHitVisualInfo>
visualInfo{
nullptr};
222 void print(std::ostream& ostr)
const;
224 candidate.
print(ostr);
287 const bool useSeed2Beamspot,
296 const double lineSlope)
const;
308 const double lineSlope,
309 const bool useSeed2Beamspot,
348 const HitPayload& hit2)
const;
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
@ eRejectHit
Test failed, discard the 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...
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
std::vector< std::string > patterns
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.
StIndex station
Station index.
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
CompatibilityResult 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.
unsigned nBendingTriggerHits
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.