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;
170 std::unique_ptr<SegmentSeed> constructCombinatorialSeed(const InitialSeed_t& initialSeed,
171 const AmgSymMatrix(2)& bMatrix,
172 const HoughMaximum& max,
173 const ActsTrk::GeometryContext& gctx,
174 const HitLaySpan_t& extensionLayers,
175 const UsedHitSpan_t& usedHits) const;
184 std::pair<SegmentSeedVec_t, SegmentVec_t> buildSegmentsFromMM(const EventContext& ctx,
185 const ActsTrk::GeometryContext &gctx,
186 const HitLayVec& hitLayers,
187 const HoughMaximum& max,
188 const Amg::Vector3D& beamSpotPos,
189 UsedHitMarker_t& usedHits,
190 bool useOnlyMM) const;
199 std::pair<SegmentSeedVec_t, SegmentVec_t> buildSegmentsFromSTGC(const EventContext& ctx,
200 const ActsTrk::GeometryContext &gctx,
201 const HitLayVec& hitLayers,
202 const HoughMaximum& max,
203 const Amg::Vector3D& beamSpotPos,
204 UsedHitMarker_t& usedHits,
205 bool usePad) const;
210 std::unique_ptr<Segment> fitSegmentSeed(const EventContext& ctx,
211 const ActsTrk::GeometryContext& gctx,
212 const SegmentSeed *patternSeed) const;
213
220 void processSegment(std::unique_ptr<Segment> segment,
221 const HitVec& seedHits,
222 const HitLayVec& hitLayers,
223 UsedHitMarker_t& usedHits,
224 SegmentVec_t& segments) const;
225
230 SegmentVec_t& segmentCandidates) const;
231
239 void markHitsAsUsed(const HitVec& spacePoints,
240 const HitLayVec& allSortHits,
241 UsedHitMarker_t& usedHitMarker,
242 unsigned int increase,
243 bool markNeighborHits) const;
244
245
252 HitVec extendHits(const Amg::Vector3D& startPos,
253 const Amg::Vector3D& direction,
254 const HitLaySpan_t& extensionLayers,
255 const UsedHitSpan_t& usedHits) const;
256
262 std::pair<SegmentSeedVec_t, SegmentVec_t>
264 const ActsTrk::GeometryContext& gctx,
265 const EventContext& ctx) const;
266
267 // read handle key for the input maxima (from a previous eta-transform)
268 SG::ReadHandleKey<EtaHoughMaxContainer> m_etaKey{this, "CombinatorialReadKey", "MuonHoughNswMaxima"};
269
270 //write handle key for the segment seeds container
271 SG::WriteHandleKey<SegmentSeedContainer> m_writeSegmentSeedKey{this, "MuonNswSegmentSeedWriteKey", "MuonNswSegmentSeeds"};
272
273 // write handle key for the segments container
274 SG::WriteHandleKey<SegmentContainer> m_writeSegmentKey{this, "MuonNswSegmentWriteKey", "MuonNswSegments"};
275
276 // access to the ACTS geometry context
277 ActsTrk::GeoContextReadKey_t m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
278
279 // access to the Muon Id Helper
280 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
281
283 ToolHandle<MuonValR4::IPatternVisualizationTool> m_visionTool{this, "VisualizationTool", ""};
284
285 //Space point calibration tool
286 ToolHandle<ISpacePointCalibrator> m_calibTool{this, "Calibrator", "" };
287
288 // Pointer to the line segment fitter
289 std::unique_ptr<SegmentFit::SegmentLineFitter> m_lineFitter{};
290
291 // Pointer to the segment ambiguity solver
292 std::unique_ptr<SegmentFit::SegmentAmbiSolver> m_ambiSolver{};
293
294 //the window in theta to search for hits in the seed extension
295 DoubleProperty m_windowTheta {this, "thetaWindow", 2.5 * Gaudi::Units::deg};
296
297 //apply a cut threshold in the pulls during the hit extension
298 DoubleProperty m_minPullThreshold{this, "maxPull", 10.};
299
300 //minimum number of hits required to form a seed after extension
301 UnsignedIntegerProperty m_minSeedHits{this, "minSeedHits", 6};
302
303 //maximum number of MM Clusters that are invalid in the seed
304 UnsignedIntegerProperty m_maxInvalidClusters{this, "maxInvalidClusters", 4};
305
306 //reject also hits from the seed even if it does not lead to succesful segment
307 BooleanProperty m_markHitsFromSeed{this, "markHitsFromSeed", true};
308
309 //skip stgc seed from the same multilayer
310 BooleanProperty m_skipSameMultilayer{this, "skipSameMultilayer", true};
311
312 //flag to use only MM layers for the estimation of the initial seed of the combinatorics
313 BooleanProperty m_doOnlyMMCombinatorics{this, "doOnlyMMCombinatorics", false};
314
315 //maximum number that hit is allowed to be used
316 UnsignedIntegerProperty m_maxUsed{this, "maxHitIsUsed", 6};
317
318 //minimum number of strips required for MMClusers not to be invalid
319 UnsignedIntegerProperty m_minClusSize{this, "minClusterSize", 1};
320
321 //maximum number of chi2 cut for the segment
322 DoubleProperty m_maxChi2{this, "maxChi2", 5.};
323
324 // maximum number of clusters in the layer for the seed finding
325 UnsignedIntegerProperty m_maxClustersInLayer{this, "maxClustersInLayer", 8};
326
327 //maximum number of dY window size for killing hits on the layer from the segments
328 DoubleProperty m_maxdYWindow{this, "maxdYWindow", 2.*Gaudi::Units::cm};
329
330 //maximum tanAlpha for the seed quality check
331 DoubleProperty m_maxTanAlpha{this, "maxTanAlpha", 0.4};
332
333 //dump statistics for the seeds per sector
334 BooleanProperty m_dumpSeedStatistics{this, "dumpStatistics", true};
335
336 //dump the space points in an obj file
337 BooleanProperty m_dumpObj{this, "dumpObj", false};
338
339 std::unique_ptr<SeedStatistics> m_seedCounter ATLAS_THREAD_SAFE{};
340
342
343
344};
345
346}
347
348#endif
#define AmgSymMatrix(dim)
static Double_t P(Double_t *tt, Double_t *par)
#define X(x)
Definition SiHitPlots.h:102
Property holding a SG store/key/clid from which a WriteHandle is made.
struct TBPatternUnitContext Unknown
#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::unique_ptr< SegmentSeed > constructCombinatorialSeed(const InitialSeed_t &initialSeed, const AmgSymMatrix(2)&bMatrix, const HoughMaximum &max, const ActsTrk::GeometryContext &gctx, const HitLaySpan_t &extensionLayers, const UsedHitSpan_t &usedHits) const
Construct a combinatorial seed from the initial 4-layer seed hits.
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.
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
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::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, bool usePad) const
Build the segment for a seed from STGC 2D measurement layers directly and then attempt to append hits...
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.
@ 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