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 namespace MuonR4{
16  class ISpacePointCalibrator;
17  class CalibratedSpacePoint;
18 }
19 
20 namespace MuonR4::SegmentFit {
27  public:
30  struct Config{
32  std::array<double, 2> thetaRange{0, 180.*Gaudi::Units::deg};
34  std::array<double, 2> interceptRange{-20.*Gaudi::Units::m, 20.*Gaudi::Units::m};
36  double hitPullCut{5.};
38  bool startWithPattern{false};
40  unsigned int busyLayerLimit{2};
42  unsigned int nMdtHitCut{3};
45  double nMdtLayHitCut{2./3.};
48  bool tightenHitCut{true};
51  bool overlapCorridor{true};
53  bool recalibSeedCircles{false};
57  unsigned int nMaxIter{100};
59  double precCutOff{1.e-6};
60  };
66  std::vector<std::unique_ptr<CalibratedSpacePoint>> measurements{};
68  unsigned int nIter{0};
70  double chi2{0.};
72  const SpacePointBucket* parentBucket{nullptr};
74  unsigned int nMdt{0};
75  };
76 
82  MdtSegmentSeedGenerator(const std::string& name,
83  const SegmentSeed* segmentSeed,
84  const Config& configuration);
85 
88  std::optional<DriftCircleSeed> nextSeed(const EventContext& ctx);
90  unsigned int numGenerated() const;
92  const Config& config() const;
93  private:
98  using SignComboType = std::array<int, 2>;
99  constexpr static std::array<SignComboType,4> s_signCombos{
100  std::array{ 1, 1}, std::array{ 1,-1},
101  std::array{-1,-1}, std::array{-1, 1},
102  };
104  struct SeedSolution{
106  double theta{0.};
108  double y0{0.};
110  double dTheta{0.};
112  double dY0{0.};
116  std::vector<int> solutionSigns{};
118  bool isValid{true};
120  friend std::ostream& operator<<(std::ostream& ostr, const SeedSolution& sol) {
121  return sol.print(ostr);
122  }
123  std::ostream& print(std::ostream& ostr) const;
124  };
129  template <Acts::Experimental::CompositeSpacePoint SpacePoint_t>
130  SeedSolution estimateTangentLine(const SpacePoint_t& topHit, const SpacePoint_t& bottomHit,
131  const SignComboType& signs) const;
135  Line_t::ParamVector constructLinePars(const double theta, const double y0) const;
141  std::optional<DriftCircleSeed> buildSeed(const EventContext& ctx,
142  const HoughHitType& topHit,
143  const HoughHitType& bottomHit,
144  const SignComboType& signs);
146  void moveToNextCandidate();
148  static SeedingAux::Config translate(const Config& cfg);
150 
153  const SegmentSeed* m_segmentSeed{nullptr};
155 
157  std::size_t m_upperLayer{0};
159  std::size_t m_lowerLayer{0};
161  std::size_t m_lowerHitIndex{0};
163  std::size_t m_upperHitIndex{0};
165  std::size_t m_signComboIndex{0};
167  std::vector<SeedSolution> m_seenSolutions{};
169  unsigned int m_nGenSeeds{0};
170 
171  };
172 }
174 
175 #endif
MuonR4::SegmentFit::MdtSegmentSeedGenerator::config
const Config & config() const
Returns the current seed configuration.
Definition: MdtSegmentSeedGenerator.cxx:59
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::theta
double theta
: Theta of the line
Definition: MdtSegmentSeedGenerator.h:106
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::startWithPattern
bool startWithPattern
Try at the first time the pattern seed as candidate.
Definition: MdtSegmentSeedGenerator.h:38
MuonR4::SegmentFit
Definition: MuonHoughDefs.h:33
MuonR4::SpacePointPerLayerSplitter
The SpacePointPerLayerSplitter takes a set of spacepoints already sorted by layer Identifier (see Muo...
Definition: SpacePointPerLayerSplitter.h:16
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:191
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:68
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonR4::SegmentFit::MdtSegmentSeedGenerator
Helper class to generate valid seeds for the segment fit.
Definition: MdtSegmentSeedGenerator.h:26
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::print
std::ostream & print(std::ostream &ostr) const
Definition: MdtSegmentSeedGenerator.cxx:53
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::y0
double y0
Intersecpt of the line.
Definition: MdtSegmentSeedGenerator.h:108
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::hitPullCut
double hitPullCut
Upper cut on the hit chi2 w.r.t.
Definition: MdtSegmentSeedGenerator.h:36
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:66
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:40
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::calibrator
const MuonR4::ISpacePointCalibrator * calibrator
Pointer to the space point calibrator.
Definition: MdtSegmentSeedGenerator.h:55
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::chi2
double chi2
Seed chi2.
Definition: MdtSegmentSeedGenerator.h:70
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::nMdtLayHitCut
double nMdtLayHitCut
Hit cut based on the fraction of collected tube layers.
Definition: MdtSegmentSeedGenerator.h:45
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::seedHits
HitVec seedHits
Used hits in the seed.
Definition: MdtSegmentSeedGenerator.h:114
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:64
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:48
MuonR4::SegmentFit::MdtSegmentSeedGenerator::buildSeed
std::optional< DriftCircleSeed > buildSeed(const EventContext &ctx, const HoughHitType &topHit, const HoughHitType &bottomHit, const SignComboType &signs)
Tries to build the seed from the two hits.
Definition: MdtSegmentSeedGenerator.cxx:249
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config
Configuration switches of the module
Definition: MdtSegmentSeedGenerator.h:30
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_hitLayers
SpacePointPerLayerSplitter m_hitLayers
Definition: MdtSegmentSeedGenerator.h:154
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_nGenSeeds
unsigned int m_nGenSeeds
Counter on how many seeds have been generated.
Definition: MdtSegmentSeedGenerator.h:169
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::solutionSigns
std::vector< int > solutionSigns
Vector of radial signs of the valid hits.
Definition: MdtSegmentSeedGenerator.h:116
MuonR4::SegmentFit::MdtSegmentSeedGenerator::estimateTangentLine
SeedSolution estimateTangentLine(const SpacePoint_t &topHit, const SpacePoint_t &bottomHit, const SignComboType &signs) const
Estimate the line tangential to two space points for a given left/right pattern.
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:38
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SignComboType
std::array< int, 2 > SignComboType
Sign combinations to draw the 4 lines tangent to 2 drift circles The first two are indicating whether...
Definition: MdtSegmentSeedGenerator.h:98
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_upperHitIndex
std::size_t m_upperHitIndex
Explicit hit to pick in the selected top layer.
Definition: MdtSegmentSeedGenerator.h:163
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::precCutOff
double precCutOff
Precision cut off in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:59
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:157
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::parentBucket
const SpacePointBucket * parentBucket
Pointer to the parent bucket.
Definition: MdtSegmentSeedGenerator.h:72
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:74
lumiFormat.array
array
Definition: lumiFormat.py:91
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::recalibSeedCircles
bool recalibSeedCircles
Recalibrate the seed drift circles from the initial estimate
Definition: MdtSegmentSeedGenerator.h:53
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::thetaRange
std::array< double, 2 > thetaRange
Cut on the theta angle.
Definition: MdtSegmentSeedGenerator.h:32
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_lowerHitIndex
std::size_t m_lowerHitIndex
Explicit hit to pick in the selected bottom layer.
Definition: MdtSegmentSeedGenerator.h:161
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution
Cache of all solutions seen thus far.
Definition: MdtSegmentSeedGenerator.h:104
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed::parameters
Parameters parameters
Seed parameters.
Definition: MdtSegmentSeedGenerator.h:64
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:51
MuonR4::SegmentFit::MdtSegmentSeedGenerator::DriftCircleSeed
Helper struct from a generated Mdt seed.
Definition: MdtSegmentSeedGenerator.h:62
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_line
Line_t m_line
Line to instantiate the seed parameters.
Definition: MdtSegmentSeedGenerator.h:152
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
MuonR4::ISpacePointCalibrator
Interface class to refine the space point calibration with an external seed.
Definition: ISpacePointCalibrator.h:24
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::operator<<
friend std::ostream & operator<<(std::ostream &ostr, const SeedSolution &sol)
Outstream operator.
Definition: MdtSegmentSeedGenerator.h:120
MuonR4::SegmentFit::MdtSegmentSeedGenerator::moveToNextCandidate
void moveToNextCandidate()
Prepares the generator to generate the seed from the next pair of drift circles.
Definition: MdtSegmentSeedGenerator.cxx:124
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:167
MuonR4::SegmentFit::MdtSegmentSeedGenerator::s_signCombos
constexpr static std::array< SignComboType, 4 > s_signCombos
Definition: MdtSegmentSeedGenerator.h:99
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:39
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::isValid
bool isValid
valid seed
Definition: MdtSegmentSeedGenerator.h:118
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::nMaxIter
unsigned int nMaxIter
Maximum number of iterations in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:57
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_segmentSeed
const SegmentSeed * m_segmentSeed
Definition: MdtSegmentSeedGenerator.h:153
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_cfg
Config m_cfg
Definition: MdtSegmentSeedGenerator.h:149
Logger.h
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::dTheta
double dTheta
: Uncertainty on the slope
Definition: MdtSegmentSeedGenerator.h:110
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_signComboIndex
std::size_t m_signComboIndex
Index of the left-right ambiguity between the circles.
Definition: MdtSegmentSeedGenerator.h:165
MdtSegmentSeedGenerator.icc
MuonR4::SegmentFit::MdtSegmentSeedGenerator::HitVec
SpacePointPerLayerSplitter::HitVec HitVec
Definition: MdtSegmentSeedGenerator.h:28
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:42
MuonR4::SegmentFit::Parameters
AmgVector(Acts::toUnderlying(ParamDefs::nPars)) Parameters
Definition: MuonHoughDefs.h:45
MuonR4::SegmentFit::MdtSegmentSeedGenerator::m_lowerLayer
std::size_t m_lowerLayer
Considered layer to pick the bottom drift circle from.
Definition: MdtSegmentSeedGenerator.h:159
MuonR4::SegmentFit::MdtSegmentSeedGenerator::SeedSolution::dY0
double dY0
: Uncertainty on the intercept
Definition: MdtSegmentSeedGenerator.h:112
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:121
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::interceptRange
std::array< double, 2 > interceptRange
Cut on the intercept range.
Definition: MdtSegmentSeedGenerator.h:34
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32