ATLAS Offline Software
Loading...
Searching...
No Matches
NswSegmentFinderAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUONR4_MUONPATTERNRECOGNITIONALGS_NSWSEGMENTFINDERALG_H
6#define MUONR4_MUONPATTERNRECOGNITIONALGS_NSWSEGMENTFINDERALG_H
7
11
15
20
22
23
25
26#include <span>
27#include <vector>
28
29
30namespace MuonR4{
31
32
34
35 public:
36 using AthReentrantAlgorithm::AthReentrantAlgorithm;
37 virtual ~NswSegmentFinderAlg() = default;
38 virtual StatusCode initialize() override;
39 virtual StatusCode execute(const EventContext& ctx) const override;
40 virtual StatusCode finalize() override;
41
42 private:
43
45 enum class StripOrient{
46 U,
47 V,
48 X,
49 P,
50 C,
52 };
53
56
57 public:
58
60
61 SeedStatistics() = default;
62
63 //dump seed statistics to the map
64 void addToStat(const MuonGMR4::SpectrometerSector* msSector,
65 unsigned int nSeeds,
66 unsigned int nExtSeeds,
67 unsigned int nSegments);
68
69 // print the seed counting stats in the end of the algorithm */
70 void printTableSeedStats(MsgStream& msg) const;
71
72 private:
73
74 struct SeedField{
76 unsigned int nSeeds{0};
78 unsigned int nExtSeeds{0};
80 unsigned int nSegments{0};
81 };
82
84 struct SectorField{
86 int8_t phi{0};
87 int8_t eta{0};
88 bool operator<(SectorField const& o) const noexcept {
89 if(chIdx != o.chIdx) {
90 return chIdx < o.chIdx;
91 }
92 if(eta != o.eta) {
93 return eta < o.eta;
94 }
95 return phi < o.phi;
96 }
97 };
98 using SeedStatistic_T = std::map<SectorField, SeedField>;
100
101 std::mutex m_mutex{};
102
103 };
104
106 StripOrient classifyStrip(const SpacePoint& spacePoint) const;
107
109
112 using HitLaySpan_t = std::vector<std::reference_wrapper<const HitVec>>;
114 using UsedHitMarker_t = std::vector<std::vector<unsigned int>>;
116 using UsedHitSpan_t = std::vector<std::reference_wrapper<std::vector<unsigned int>>>;
118 using InitialSeed_t = std::array<const SpacePoint*, 4>;
120 using InitialSeedVec_t = std::vector<InitialSeed_t>;
123 UsedHitMarker_t emptyBookKeeper(const HitLayVec& sortedSp) const;
124
141 HitWindow hitFromIPCorridor(const SpacePoint& testHit,
142 const Amg::Vector3D& beamSpotPos,
143 const Amg::Vector3D& dirEstUp,
144 const Amg::Vector3D& dirEstDn) const;
153 void constructPrelimnarySeeds(const Amg::Vector3D& beamSpot,
154 const HitLaySpan_t& combinatoricLayers,
155 const UsedHitSpan_t& usedHits,
156 InitialSeedVec_t& outVec) const;
164 std::unique_ptr<SegmentSeed> buildSegmentSeed(const InitialSeed_t& initialSeed,
165 const AmgSymMatrix(2)& bMatrix,
166 const HoughMaximum& max,
167 const HitLaySpan_t& extensionLayers,
168 const UsedHitSpan_t& usedHits) const;
173 std::unique_ptr<Segment> fitSegmentSeed(const EventContext& ctx,
174 const ActsTrk::GeometryContext& gctx,
175 const SegmentSeed *patternSeed) const;
176
184 void markHitsAsUsed(const HitVec& spacePoints,
185 const HitLayVec& allSortHits,
186 UsedHitMarker_t& usedHitMarker,
187 unsigned int increase,
188 bool markNeighborHits) const;
189
190
197 HitVec extendHits(const Amg::Vector3D& startPos,
198 const Amg::Vector3D& direction,
199 const HitLaySpan_t& extensionLayers,
200 const UsedHitSpan_t& usedHits) const;
201
207 std::pair<std::vector<std::unique_ptr<SegmentSeed>>, std::vector<std::unique_ptr<Segment>>>
209 const ActsTrk::GeometryContext& gctx,
210 const EventContext& ctx) const;
211
212 // read handle key for the input maxima (from a previous eta-transform)
213 SG::ReadHandleKey<EtaHoughMaxContainer> m_etaKey{this, "CombinatorialReadKey", "MuonHoughNswMaxima"};
214
215 //write handle key for the segment seeds container
216 SG::WriteHandleKey<SegmentSeedContainer> m_writeSegmentSeedKey{this, "MuonNswSegmentSeedWriteKey", "MuonNswSegmentSeeds"};
217
218 // write handle key for the segments container
219 SG::WriteHandleKey<SegmentContainer> m_writeSegmentKey{this, "MuonNswSegmentWriteKey", "MuonNswSegments"};
220
221 // access to the ACTS geometry context
222 SG::ReadHandleKey<ActsTrk::GeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
223
224 // access to the Muon Id Helper
225 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
226
228 ToolHandle<MuonValR4::IPatternVisualizationTool> m_visionTool{this, "VisualizationTool", ""};
229
230 //Space point calibration tool
231 ToolHandle<ISpacePointCalibrator> m_calibTool{this, "Calibrator", "" };
232
233 // Pointer to the line segment fitter
234 std::unique_ptr<SegmentFit::SegmentLineFitter> m_lineFitter{};
235
236 //the window in theta to search for hits in the seed extension
237 DoubleProperty m_windowTheta {this, "thetaWindow", 0.5 * Gaudi::Units::deg};
238
239 //apply a cut threshold in the pulls during the hit extension
240 DoubleProperty m_minPullThreshold{this, "maxPull", 5.};
241
242 //minimum number of hits required to form a seed after extension
243 UnsignedIntegerProperty m_minSeedHits{this, "minSeedHits", 4};
244
245 //maximum number of MM Clusters that are invalid in the seed
246 UnsignedIntegerProperty m_maxInvalidClusters{this, "maxInvalidClusters", 4};
247
248 //reject also hits from the seed even if it does not lead to succesful segment
249 BooleanProperty m_markHitsFromSeed{this, "markHitsFromSeed", true};
250
251 //maximum number that hit is allowed to be used
252 UnsignedIntegerProperty m_maxUsed{this, "maxHitIsUsed", 6};
253
254 //minimum number of strips required for MMClusers not to be invalid
255 UnsignedIntegerProperty m_minClusSize{this, "minClusterSize", 1};
256
257 //maximum number of chi2 cut for the segment
258 DoubleProperty m_maxChi2{this, "maxChi2", 6.};
259
260 // maximum number of clusters in the layer for the seed finding
261 UnsignedIntegerProperty m_maxClustersInLayer{this, "maxClustersInLayer", 8};
262
263 //maximum number of dY window size for killing hits on the layer from the segments
264 DoubleProperty m_maxdYWindow{this, "maxdYWindow", 4.*Gaudi::Units::cm};
265
266 //dump statistics for the seeds per sector
267 BooleanProperty m_dumpSeedStatistics{this, "dumpStatistics", true};
268
269 std::unique_ptr<SeedStatistics> m_seedCounter ATLAS_THREAD_SAFE{};
270
272
273
274};
275
276}
277
278#endif
#define AmgSymMatrix(dim)
Property holding a SG store/key/clid from which a WriteHandle is made.
#define max(a, b)
Definition cfImp.cxx:41
An algorithm that can be simultaneously executed in multiple threads.
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
Data class to represent an eta maximum in hough space.
void addToStat(const MuonGMR4::SpectrometerSector *msSector, unsigned int nSeeds, unsigned int nExtSeeds, unsigned int nSegments)
std::map< SectorField, SeedField > SeedStatistic_T
const MuonGMR4::MuonDetectorManager * m_detMgr
UnsignedIntegerProperty m_maxUsed
virtual ~NswSegmentFinderAlg()=default
std::unique_ptr< SegmentSeed > buildSegmentSeed(const InitialSeed_t &initialSeed, const AmgSymMatrix(2)&bMatrix, const HoughMaximum &max, const HitLaySpan_t &extensionLayers, const UsedHitSpan_t &usedHits) const
Build the final seed from the initial seed hits and then attempt to append hits from the complementar...
std::pair< std::vector< std::unique_ptr< SegmentSeed > >, std::vector< std::unique_ptr< Segment > > > findSegmentsFromMaximum(const HoughMaximum &max, const ActsTrk::GeometryContext &gctx, const EventContext &ctx) const
Find seed and segment from an eta hough maximum.
UnsignedIntegerProperty m_minClusSize
std::unique_ptr< SegmentFit::SegmentLineFitter > m_lineFitter
UnsignedIntegerProperty m_maxClustersInLayer
virtual StatusCode initialize() override
UnsignedIntegerProperty m_maxInvalidClusters
virtual StatusCode execute(const EventContext &ctx) const override
HitWindow
To fastly check whether a hit is roughly compatible with a muon trajectory a narrow corridor is opene...
@ inside
The hit is below the predefined corridor.
@ tooHigh
The hit is inside the defined window and hence an initial candidate.
void constructPrelimnarySeeds(const Amg::Vector3D &beamSpot, const HitLaySpan_t &combinatoricLayers, const UsedHitSpan_t &usedHits, InitialSeedVec_t &outVec) const
Construct a set of prelimnary seeds from the selected combinatoric layers.
std::unique_ptr< Segment > fitSegmentSeed(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const SegmentSeed *patternSeed) const
Fit the segment seed.
ToolHandle< MuonValR4::IPatternVisualizationTool > m_visionTool
Pattern visualization tool.
std::vector< std::reference_wrapper< const HitVec > > HitLaySpan_t
Abbrivation of the space comprising multiple hit vectors without copy.
std::array< const SpacePoint *, 4 > InitialSeed_t
Abbrivation of the.
SG::WriteHandleKey< SegmentSeedContainer > m_writeSegmentSeedKey
HitWindow hitFromIPCorridor(const SpacePoint &testHit, const Amg::Vector3D &beamSpotPos, const Amg::Vector3D &dirEstUp, const Amg::Vector3D &dirEstDn) const
The hit is above the predefined corridor.
void markHitsAsUsed(const HitVec &spacePoints, const HitLayVec &allSortHits, UsedHitMarker_t &usedHitMarker, unsigned int increase, bool markNeighborHits) const
Hits that are used in a good seed/segment built should be flagged as used and not contribute to other...
UsedHitMarker_t emptyBookKeeper(const HitLayVec &sortedSp) const
Constructs an empty HitMarker from the split space points.
virtual StatusCode finalize() override
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SpacePointPerLayerSplitter::HitLayVec HitLayVec
SpacePointPerLayerSplitter::HitVec HitVec
std::vector< InitialSeed_t > InitialSeedVec_t
Vector of initial seeds.
StripOrient classifyStrip(const SpacePoint &spacePoint) const
Determines the orientation of the strip space point.
StripOrient
Enumeration to classify the orientation of a NSW strip.
@ X
Stereo strips with negative angle.
@ V
Stereo strips with positive angle.
@ Unknown
Combined 2D space point (sTGC wire + strip / sTgc pad)
SG::WriteHandleKey< SegmentContainer > m_writeSegmentKey
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
std::vector< std::vector< unsigned int > > UsedHitMarker_t
Abbrivation of the container book keeping whether a hit is used or not.
ToolHandle< ISpacePointCalibrator > m_calibTool
HitVec extendHits(const Amg::Vector3D &startPos, const Amg::Vector3D &direction, const HitLaySpan_t &extensionLayers, const UsedHitSpan_t &usedHits) const
Extend the seed with the hits from the other layers.
UnsignedIntegerProperty m_minSeedHits
SG::ReadHandleKey< EtaHoughMaxContainer > m_etaKey
std::vector< std::reference_wrapper< std::vector< unsigned int > > > UsedHitSpan_t
Abbrivation of the container to pass a subset of markers wtihout copy.
std::unique_ptr< SeedStatistics > m_seedCounter ATLAS_THREAD_SAFE
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition SegmentSeed.h:14
std::vector< const SpacePoint * > HitVec
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
SpacePointPerLayerSplitter::HitVec HitVec
ChIndex
enum to classify the different chamber layers in the muon spectrometer
bool operator<(SectorField const &o) const noexcept
unsigned int nExtSeeds
number of successfully extended seeds
unsigned int nSeeds
number of total seeds constructed
unsigned int nSegments
number of segments constucted