ATLAS Offline Software
MdtSegmentSeedGenerator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONR4_MUONPATTERNHELPERS_MDTSEGMENTSEEDGENERATOR_H
5 #define MUONR4_MUONPATTERNHELPERS_MDTSEGMENTSEEDGENERATOR_H
6 
8 #include <ActsInterop/Logger.h>
11 
12 #include <vector>
13 #include <array>
14 
15 #include "Acts/Seeding/CompositeSpacePointLineSeeder.hpp"
16 namespace MuonR4{
17  class ISpacePointCalibrator;
18  class CalibratedSpacePoint;
19 }
20 
21 namespace MuonR4::SegmentFit {
28  public:
29  using LineSeeder_t = Acts::Experimental::CompositeSpacePointLineSeeder;
32  struct Config{
34  std::array<double, 2> thetaRange{0, 180.*Gaudi::Units::deg};
36  std::array<double, 2> interceptRange{-20.*Gaudi::Units::m, 20.*Gaudi::Units::m};
38  double hitPullCut{5.};
40  bool startWithPattern{false};
42  unsigned int busyLayerLimit{2};
44  unsigned int nMdtHitCut{3};
47  double nMdtLayHitCut{2./3.};
50  bool tightenHitCut{true};
53  bool overlapCorridor{true};
55  bool recalibSeedCircles{false};
59  unsigned int nMaxIter{100};
61  double precCutOff{1.e-6};
62  };
68  std::vector<std::unique_ptr<CalibratedSpacePoint>> measurements{};
70  unsigned int nIter{0};
72  double chi2{0.};
74  const SpacePointBucket* parentBucket{nullptr};
76  unsigned int nMdt{0};
77  };
78 
84  MdtSegmentSeedGenerator(const std::string& name,
85  const SegmentSeed* segmentSeed,
86  const Config& configuration);
87 
90  std::optional<DriftCircleSeed> nextSeed(const EventContext& ctx);
92  unsigned int numGenerated() const;
94  const Config& config() const;
95  private:
96  using TangentLine = LineSeeder_t::TwoCircleTangentPars;
97  using TangentAmbi = LineSeeder_t::TangentAmbi;
98  static constexpr std::array<TangentAmbi, 4> s_signCombos{TangentAmbi::LL, TangentAmbi::RR,
99  TangentAmbi::LR, TangentAmbi::RL};
101  struct SeedSolution : public TangentLine {
105  std::vector<int> solutionSigns{};
107  bool isValid{true};
109  friend std::ostream& operator<<(std::ostream& ostr, const SeedSolution& sol) {
110  return sol.print(ostr);
111  }
112  std::ostream& print(std::ostream& ostr) const;
113  };
116  bool isValidLine(const TangentLine& solution) const;
120  Line_t::ParamVector constructLinePars(const double theta, const double y0) const;
126  std::optional<DriftCircleSeed> buildSeed(const EventContext& ctx,
127  const HoughHitType& topHit,
128  const HoughHitType& bottomHit,
129  const TangentAmbi ambi);
131  void moveToNextCandidate();
133  static SeedingAux::Config translate(const Config& cfg);
135 
138  const SegmentSeed* m_segmentSeed{nullptr};
140 
142  std::size_t m_upperLayer{0};
144  std::size_t m_lowerLayer{0};
146  std::size_t m_lowerHitIndex{0};
148  std::size_t m_upperHitIndex{0};
150  std::size_t m_signComboIndex{0};
152  std::vector<SeedSolution> m_seenSolutions{};
154  unsigned int m_nGenSeeds{0};
155 
156  };
157 }
158 #endif
MuonR4::SegmentFit::MdtSegmentSeedGenerator::config
const Config & config() const
Returns the current seed configuration.
Definition: MdtSegmentSeedGenerator.cxx:58
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::startWithPattern
bool startWithPattern
Try at the first time the pattern seed as candidate.
Definition: MdtSegmentSeedGenerator.h:40
MuonR4::SegmentFit
Definition: MuonHoughDefs.h:34
MuonR4::SpacePointPerLayerSplitter
The SpacePointPerLayerSplitter takes a set of spacepoints already sorted by layer Identifier (see Muo...
Definition: SpacePointPerLayerSplitter.h:16
MuonR4::SegmentFit::MdtSegmentSeedGenerator::TangentAmbi
LineSeeder_t::TangentAmbi TangentAmbi
Definition: MdtSegmentSeedGenerator.h:97
MuonR4::SpacePointBucket
: The muon space point bucket represents a collection of points that will bre processed together in t...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:21
SegmentSeed.h
MuonR4::SegmentFit::MdtSegmentSeedGenerator::nextSeed
std::optional< DriftCircleSeed > nextSeed(const EventContext &ctx)
returns the next seed in the row
Definition: MdtSegmentSeedGenerator.cxx:190
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::nIter
unsigned int nIter
Iterations to obtain the seed.
Definition: MdtSegmentSeedGenerator.h:70
MuonR4::SegmentFit::MdtSegmentSeedGenerator::LineSeeder_t
Acts::Experimental::CompositeSpacePointLineSeeder LineSeeder_t
Definition: MdtSegmentSeedGenerator.h:29
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonR4::SegmentFit::MdtSegmentSeedGenerator::buildSeed
std::optional< DriftCircleSeed > buildSeed(const EventContext &ctx, const HoughHitType &topHit, const HoughHitType &bottomHit, const TangentAmbi ambi)
Tries to build the seed from the two hits.
Definition: MdtSegmentSeedGenerator.cxx:269
MuonR4::SegmentFit::MdtSegmentSeedGenerator
Helper class to generate valid seeds for the segment fit.
Definition: MdtSegmentSeedGenerator.h:27
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::print
std::ostream & print(std::ostream &ostr) const
Definition: MdtSegmentSeedGenerator.cxx:52
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::hitPullCut
double hitPullCut
Upper cut on the hit chi2 w.r.t.
Definition: MdtSegmentSeedGenerator.h:38
MuonR4::SpacePointPerLayerSplitter::HitVec
std::vector< const SpacePoint * > HitVec
Definition: SpacePointPerLayerSplitter.h:18
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::measurements
std::vector< std::unique_ptr< CalibratedSpacePoint > > measurements
List of calibrated measurements.
Definition: MdtSegmentSeedGenerator.h:68
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::busyLayerLimit
unsigned int busyLayerLimit
How many drift circles may be on a layer to be used for seeding.
Definition: MdtSegmentSeedGenerator.h:42
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::calibrator
const MuonR4::ISpacePointCalibrator * calibrator
Pointer to the space point calibrator.
Definition: MdtSegmentSeedGenerator.h:57
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::chi2
double chi2
Seed chi2.
Definition: MdtSegmentSeedGenerator.h:72
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::nMdtLayHitCut
double nMdtLayHitCut
Hit cut based on the fraction of collected tube layers.
Definition: MdtSegmentSeedGenerator.h:47
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::seedHits
HitVec seedHits
Used hits in the seed.
Definition: MdtSegmentSeedGenerator.h:103
MuonR4::SegmentFit::MdtSegmentSeedGenerator::MdtSegmentSeedGenerator
MdtSegmentSeedGenerator(const std::string &name, const SegmentSeed *segmentSeed, const Config &configuration)
Standard constructor taking the segmentSeed to start with and then few configuration tunes.
Definition: MdtSegmentSeedGenerator.cxx:63
SpacePointPerLayerSplitter.h
MuonR4::SegmentFit::MdtSegmentSeedGenerator::~MdtSegmentSeedGenerator
~MdtSegmentSeedGenerator()
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::tightenHitCut
bool tightenHitCut
Once a seed with even more than initially required hits is found, reject all following seeds with les...
Definition: MdtSegmentSeedGenerator.h:50
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config
Configuration switches of the module
Definition: MdtSegmentSeedGenerator.h:32
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_hitLayers
SpacePointPerLayerSplitter m_hitLayers
Definition: MdtSegmentSeedGenerator.h:139
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_nGenSeeds
unsigned int m_nGenSeeds
Counter on how many seeds have been generated.
Definition: MdtSegmentSeedGenerator.h:154
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::solutionSigns
std::vector< int > solutionSigns
Vector of radial signs of the valid hits.
Definition: MdtSegmentSeedGenerator.h:105
MuonR4::SegmentFit::MdtSegmentSeedGenerator::translate
static SeedingAux::Config translate(const Config &cfg)
Translate the SeedGenerator config to a Seed auxillary config.
MuonR4::SegmentSeed::getHitsInMax
const std::vector< HitType > & getHitsInMax() const
Returns the list of assigned hits.
Definition: SegmentSeed.cxx:48
MuonR4::SegmentFit::Parameters
Acts::Experimental::CompositeSpacePointLineFitter::ParamVec_t Parameters
Definition: MuonHoughDefs.h:46
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_upperHitIndex
std::size_t m_upperHitIndex
Explicit hit to pick in the selected top layer.
Definition: MdtSegmentSeedGenerator.h:148
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::precCutOff
double precCutOff
Precision cut off in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:61
MuonR4::SegmentFit::MdtSegmentSeedGenerator::TangentLine
LineSeeder_t::TwoCircleTangentPars TangentLine
Definition: MdtSegmentSeedGenerator.h:96
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_upperLayer
std::size_t m_upperLayer
Considered layer to pick the top drift circle from.
Definition: MdtSegmentSeedGenerator.h:142
MuonR4::SegmentFit::MdtSegmentSeedGenerator::s_signCombos
static constexpr std::array< TangentAmbi, 4 > s_signCombos
Definition: MdtSegmentSeedGenerator.h:98
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::parentBucket
const SpacePointBucket * parentBucket
Pointer to the parent bucket.
Definition: MdtSegmentSeedGenerator.h:74
Config
Definition: dumpNPs.cxx:47
MuonR4::SpacePoint
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:24
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::nMdt
unsigned int nMdt
number of Mdt hits on the seed
Definition: MdtSegmentSeedGenerator.h:76
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::recalibSeedCircles
bool recalibSeedCircles
Recalibrate the seed drift circles from the initial estimate
Definition: MdtSegmentSeedGenerator.h:55
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::thetaRange
std::array< double, 2 > thetaRange
Cut on the theta angle.
Definition: MdtSegmentSeedGenerator.h:34
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_lowerHitIndex
std::size_t m_lowerHitIndex
Explicit hit to pick in the selected bottom layer.
Definition: MdtSegmentSeedGenerator.h:146
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution
Cache of all solutions seen thus far.
Definition: MdtSegmentSeedGenerator.h:101
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::parameters
Parameters parameters
Seed parameters.
Definition: MdtSegmentSeedGenerator.h:66
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::overlapCorridor
bool overlapCorridor
Check whether a new seed candidate shares the same left-right solution with already accepted ones Rej...
Definition: MdtSegmentSeedGenerator.h:53
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed
Helper struct from a generated Mdt seed.
Definition: MdtSegmentSeedGenerator.h:64
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_line
Line_t m_line
Line to instantiate the seed parameters.
Definition: MdtSegmentSeedGenerator.h:137
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
MuonR4::ISpacePointCalibrator
Interface class to refine the space point calibration with an external seed.
Definition: ISpacePointCalibrator.h:33
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::operator<<
friend std::ostream & operator<<(std::ostream &ostr, const SeedSolution &sol)
Outstream operator.
Definition: MdtSegmentSeedGenerator.h:109
MuonR4::SegmentFit::MdtSegmentSeedGenerator::moveToNextCandidate
void moveToNextCandidate()
Prepares the generator to generate the seed from the next pair of drift circles.
Definition: MdtSegmentSeedGenerator.cxx:123
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_seenSolutions
std::vector< SeedSolution > m_seenSolutions
Vector caching equivalent solutions to avoid double seeding.
Definition: MdtSegmentSeedGenerator.h:152
MuonR4::SegmentFit::MdtSegmentSeedGenerator::isValidLine
bool isValidLine(const TangentLine &solution) const
Checks whether the intercept and the angle are witihn the allowed ranges.
Definition: MdtSegmentSeedGenerator.cxx:248
MuonR4::SegmentSeed
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition: SegmentSeed.h:14
AthMessaging.h
MuonR4::SegmentFit::Line_t
SeedingAux::Line_t Line_t
Abrivation of the line with partial derivatives.
Definition: MuonHoughDefs.h:40
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::isValid
bool isValid
valid seed
Definition: MdtSegmentSeedGenerator.h:107
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::nMaxIter
unsigned int nMaxIter
Maximum number of iterations in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:59
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_segmentSeed
const SegmentSeed * m_segmentSeed
Definition: MdtSegmentSeedGenerator.h:138
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_cfg
Config m_cfg
Definition: MdtSegmentSeedGenerator.h:134
Logger.h
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_signComboIndex
std::size_t m_signComboIndex
Index of the left-right ambiguity between the circles.
Definition: MdtSegmentSeedGenerator.h:150
MuonR4::SegmentFit::MdtSegmentSeedGenerator::HitVec
SpacePointPerLayerSplitter::HitVec HitVec
Definition: MdtSegmentSeedGenerator.h:30
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::nMdtHitCut
unsigned int nMdtHitCut
How many drift circle hits needs the seed to contain in order to be valid.
Definition: MdtSegmentSeedGenerator.h:44
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_lowerLayer
std::size_t m_lowerLayer
Considered layer to pick the bottom drift circle from.
Definition: MdtSegmentSeedGenerator.h:144
MuonR4::SegmentFit::MdtSegmentSeedGenerator::constructLinePars
Line_t::ParamVector constructLinePars(const double theta, const double y0) const
Construct the 3D-Line parameters from the estimates theta & y0 from the tangent line.
Definition: MdtSegmentSeedGenerator.cxx:233
MuonR4::SegmentFit::MdtSegmentSeedGenerator::numGenerated
unsigned int numGenerated() const
Returns how many seeds have been generated.
Definition: MdtSegmentSeedGenerator.cxx:120
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::interceptRange
std::array< double, 2 > interceptRange
Cut on the intercept range.
Definition: MdtSegmentSeedGenerator.h:36
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106