ATLAS Offline Software
Loading...
Searching...
No Matches
NswSegmentFinderAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUONR4_MUONPATTERNRECOGNITIONALGS_NSWSEGMENTFINDERALG_H
6#define MUONR4_MUONPATTERNRECOGNITIONALGS_NSWSEGMENTFINDERALG_H
7
11
16
17
22
24
25
27
28#include <span>
29#include <vector>
30
31
32namespace MuonR4{
33
34
36
37 public:
38 using AthReentrantAlgorithm::AthReentrantAlgorithm;
39 virtual ~NswSegmentFinderAlg() = default;
40 virtual StatusCode initialize() override;
41 virtual StatusCode execute(const EventContext& ctx) const override;
42 virtual StatusCode finalize() override;
43
44 private:
45
47 enum class StripOrient{
48 U,
49 V,
50 X,
51 P,
52 C,
54 };
55
58
59 public:
60
62
63 SeedStatistics() = default;
64
65 //dump seed statistics to the map
66 void addToStat(const MuonGMR4::SpectrometerSector* msSector,
67 unsigned int nSeeds,
68 unsigned int nExtSeeds,
69 unsigned int nSegments);
70
71 // print the seed counting stats in the end of the algorithm */
72 void printTableSeedStats(MsgStream& msg) const;
73
74 private:
75
76 struct SeedField{
78 unsigned int nSeeds{0};
80 unsigned int nExtSeeds{0};
82 unsigned int nSegments{0};
83 };
84
86 struct SectorField{
88 int8_t phi{0};
89 int8_t eta{0};
90 bool operator<(SectorField const& o) const noexcept {
91 if(chIdx != o.chIdx) {
92 return chIdx < o.chIdx;
93 }
94 if(eta != o.eta) {
95 return eta < o.eta;
96 }
97 return phi < o.phi;
98 }
99 };
100 using SeedStatistic_T = std::map<SectorField, SeedField>;
102
103 std::mutex m_mutex{};
104
105 };
106
108 StripOrient classifyStrip(const SpacePoint& spacePoint) const;
109
111
114 using HitLaySpan_t = std::vector<std::reference_wrapper<const HitVec>>;
116 using UsedHitMarker_t = std::vector<std::vector<unsigned int>>;
118 using UsedHitSpan_t = std::vector<std::reference_wrapper<std::vector<unsigned int>>>;
120 using InitialSeed_t = std::array<const SpacePoint*, 4>;
122 using InitialSeedVec_t = std::vector<InitialSeed_t>;
125 UsedHitMarker_t emptyBookKeeper(const HitLayVec& sortedSp) const;
127 using SegmentSeedVec_t = std::vector<std::unique_ptr<SegmentSeed>>;
129 using SegmentVec_t = std::vector<std::unique_ptr<Segment>>;
130
147 HitWindow hitFromIPCorridor(const SpacePoint& testHit,
148 const Amg::Vector3D& beamSpotPos,
149 const Amg::Vector3D& dirEstUp,
150 const Amg::Vector3D& dirEstDn) const;
159 void constructPreliminarySeeds(const Amg::Vector3D& beamSpot,
160 const HitLaySpan_t& combinatoricLayers,
161 const UsedHitSpan_t& usedHits,
162 InitialSeedVec_t& outVec) const;
169 std::unique_ptr<SegmentSeed> constructCombinatorialSeed(const InitialSeed_t& initialSeed,
170 const AmgSymMatrix(2)& bMatrix,
171 const HoughMaximum& max,
172 const HitLaySpan_t& extensionLayers,
173 const UsedHitSpan_t& usedHits) const;
182 std::pair<SegmentSeedVec_t, SegmentVec_t> buildSegmentsFromMM(const EventContext& ctx,
183 const ActsTrk::GeometryContext &gctx,
184 const HitLayVec& hitLayers,
185 const HoughMaximum& max,
186 const Amg::Vector3D& beamSpotPos,
187 UsedHitMarker_t& usedHits,
188 bool useOnlyMM) const;
196 std::pair<SegmentSeedVec_t, SegmentVec_t> buildSegmentsFromSTGC(const EventContext& ctx,
197 const ActsTrk::GeometryContext &gctx,
198 const HitLayVec& hitLayers,
199 const HoughMaximum& max,
200 const Amg::Vector3D& beamSpotPos,
201 UsedHitMarker_t& usedHits) const;
206 std::unique_ptr<Segment> fitSegmentSeed(const EventContext& ctx,
207 const ActsTrk::GeometryContext& gctx,
208 const SegmentSeed *patternSeed) const;
209
216 void processSegment(std::unique_ptr<Segment> segment,
217 const HitVec& seedHits,
218 const HitLayVec& hitLayers,
219 UsedHitMarker_t& usedHits,
220 SegmentVec_t& segments) const;
221
226 SegmentVec_t& segmentCandidates) const;
227
235 void markHitsAsUsed(const HitVec& spacePoints,
236 const HitLayVec& allSortHits,
237 UsedHitMarker_t& usedHitMarker,
238 unsigned int increase,
239 bool markNeighborHits) const;
240
241
248 HitVec extendHits(const Amg::Vector3D& startPos,
249 const Amg::Vector3D& direction,
250 const HitLaySpan_t& extensionLayers,
251 const UsedHitSpan_t& usedHits) const;
252
258 std::pair<SegmentSeedVec_t, SegmentVec_t>
260 const ActsTrk::GeometryContext& gctx,
261 const EventContext& ctx) const;
262
263 // read handle key for the input maxima (from a previous eta-transform)
264 SG::ReadHandleKey<EtaHoughMaxContainer> m_etaKey{this, "CombinatorialReadKey", "MuonHoughNswMaxima"};
265
266 //write handle key for the segment seeds container
267 SG::WriteHandleKey<SegmentSeedContainer> m_writeSegmentSeedKey{this, "MuonNswSegmentSeedWriteKey", "MuonNswSegmentSeeds"};
268
269 // write handle key for the segments container
270 SG::WriteHandleKey<SegmentContainer> m_writeSegmentKey{this, "MuonNswSegmentWriteKey", "MuonNswSegments"};
271
272 // access to the ACTS geometry context
273 ActsTrk::GeoContextReadKey_t m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
274
275 // access to the Muon Id Helper
276 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
277
279 ToolHandle<MuonValR4::IPatternVisualizationTool> m_visionTool{this, "VisualizationTool", ""};
280
281 //Space point calibration tool
282 ToolHandle<ISpacePointCalibrator> m_calibTool{this, "Calibrator", "" };
283
284 // Pointer to the line segment fitter
285 std::unique_ptr<SegmentFit::SegmentLineFitter> m_lineFitter{};
286
287 // Pointer to the segment ambiguity solver
288 std::unique_ptr<SegmentFit::SegmentAmbiSolver> m_ambiSolver{};
289
290 //the window in theta to search for hits in the seed extension
291 DoubleProperty m_windowTheta {this, "thetaWindow", 2.5 * Gaudi::Units::deg};
292
293 //apply a cut threshold in the pulls during the hit extension
294 DoubleProperty m_minPullThreshold{this, "maxPull", 5.};
295
296 //minimum number of hits required to form a seed after extension
297 UnsignedIntegerProperty m_minSeedHits{this, "minSeedHits", 6};
298
299 //maximum number of MM Clusters that are invalid in the seed
300 UnsignedIntegerProperty m_maxInvalidClusters{this, "maxInvalidClusters", 4};
301
302 //reject also hits from the seed even if it does not lead to succesful segment
303 BooleanProperty m_markHitsFromSeed{this, "markHitsFromSeed", true};
304
305 //flag to use only MM layers for the estimation of the initial seed of the combinatorics
306 BooleanProperty m_doOnlyMMCombinatorics{this, "doOnlyMMCombinatorics", false};
307
308 //maximum number that hit is allowed to be used
309 UnsignedIntegerProperty m_maxUsed{this, "maxHitIsUsed", 6};
310
311 //minimum number of strips required for MMClusers not to be invalid
312 UnsignedIntegerProperty m_minClusSize{this, "minClusterSize", 1};
313
314 //maximum number of chi2 cut for the segment
315 DoubleProperty m_maxChi2{this, "maxChi2", 5.};
316
317 // maximum number of clusters in the layer for the seed finding
318 UnsignedIntegerProperty m_maxClustersInLayer{this, "maxClustersInLayer", 8};
319
320 //maximum number of dY window size for killing hits on the layer from the segments
321 DoubleProperty m_maxdYWindow{this, "maxdYWindow", 4.*Gaudi::Units::cm};
322
323 //maximum tanAlpha for the seed quality check
324 DoubleProperty m_maxTanAlpha{this, "maxTanAlpha", 0.2};
325
326 //dump statistics for the seeds per sector
327 BooleanProperty m_dumpSeedStatistics{this, "dumpStatistics", true};
328
329 //dump the space points in an obj file
330 BooleanProperty m_dumpObj{this, "dumpObj", false};
331
332 std::unique_ptr<SeedStatistics> m_seedCounter ATLAS_THREAD_SAFE{};
333
335
336
337};
338
339}
340
341#endif
#define AmgSymMatrix(dim)
static Double_t P(Double_t *tt, Double_t *par)
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
std::pair< SegmentSeedVec_t, SegmentVec_t > findSegmentsFromMaximum(const HoughMaximum &max, const ActsTrk::GeometryContext &gctx, const EventContext &ctx) const
Find seed and segment from an eta hough maximum.
virtual ~NswSegmentFinderAlg()=default
void resolveAmbiguities(const ActsTrk::GeometryContext &gctx, SegmentVec_t &segmentCandidates) const
Resolve the ambiguities of the segments per chamber and return the surviving segments.
std::unique_ptr< SegmentSeed > constructCombinatorialSeed(const InitialSeed_t &initialSeed, const AmgSymMatrix(2)&bMatrix, const HoughMaximum &max, const HitLaySpan_t &extensionLayers, const UsedHitSpan_t &usedHits) const
Construct a combinatorial seed from the initial 4-layer seed hits.
UnsignedIntegerProperty m_minClusSize
std::unique_ptr< SegmentFit::SegmentLineFitter > m_lineFitter
std::pair< SegmentSeedVec_t, SegmentVec_t > buildSegmentsFromMM(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const HitLayVec &hitLayers, const HoughMaximum &max, const Amg::Vector3D &beamSpotPos, UsedHitMarker_t &usedHits, bool useOnlyMM) const
Build the final segment seed from strip like measurements using the combinatorial seeding for MicroMe...
UnsignedIntegerProperty m_maxClustersInLayer
virtual StatusCode initialize() override
UnsignedIntegerProperty m_maxInvalidClusters
virtual StatusCode execute(const EventContext &ctx) const override
std::pair< SegmentSeedVec_t, SegmentVec_t > buildSegmentsFromSTGC(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const HitLayVec &hitLayers, const HoughMaximum &max, const Amg::Vector3D &beamSpotPos, UsedHitMarker_t &usedHits) const
Build the segment for a seed from STGC 2D measurement layers directly and then attempt to append hits...
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.
std::unique_ptr< Segment > fitSegmentSeed(const EventContext &ctx, const ActsTrk::GeometryContext &gctx, const SegmentSeed *patternSeed) const
Fit the segment seeds.
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 initial seed.
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.
std::vector< std::unique_ptr< SegmentSeed > > SegmentSeedVec_t
Abbrivation of the seed vector.
void constructPreliminarySeeds(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.
void processSegment(std::unique_ptr< Segment > segment, const HitVec &seedHits, const HitLayVec &hitLayers, UsedHitMarker_t &usedHits, SegmentVec_t &segments) const
Process the segment and mark the hits if it is successfully built or not by differently mark the hits...
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.
std::vector< std::unique_ptr< Segment > > SegmentVec_t
Abbrivation of the final segment vector.
SG::WriteHandleKey< SegmentContainer > m_writeSegmentKey
ActsTrk::GeoContextReadKey_t 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::unique_ptr< SegmentFit::SegmentAmbiSolver > m_ambiSolver
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.
struct color C
SG::ReadHandleKey< GeometryContext > GeoContextReadKey_t
Abrivate the ReadHandleKey to declare the data dependency on the Geometry context.
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