ATLAS Offline Software
MdtSegmentSeedGenerator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONR4_MUONPATTERNHELPERS_MDTSEGMENTSEEDGENERATOR_H
5 #define MUONR4_MUONPATTERNHELPERS_MDTSEGMENTSEEDGENERATOR_H
6 
10 #include <GaudiKernel/SystemOfUnits.h>
11 
12 
13 #include <vector>
14 #include <array>
15 
16 
17 namespace MuonR4 {
18  class ISpacePointCalibrator;
25  public:
27 
29  struct Config{
31  std::array<double, 2> thetaRange{0, 180.*Gaudi::Units::deg};
33  std::array<double, 2> interceptRange{-20.*Gaudi::Units::m, 20.*Gaudi::Units::m};
35  double hitPullCut{5.};
37  bool startWithPattern{false};
39  unsigned int busyLayerLimit{2};
41  unsigned int nMdtHitCut{3};
44  double nMdtLayHitCut{2./3.};
47  bool tightenHitCut{true};
50  bool overlapCorridor{true};
52  bool recalibSeedCircles{false};
56  bool fastSeedFit{true};
58  bool fastSegFitWithT0{false};
60  unsigned int nMaxIter{100};
62  double precCutOff{1.e-6};
63  };
69  std::vector<std::unique_ptr<CalibratedSpacePoint>> measurements{};
71  unsigned int nIter{0};
73  double chi2{0.};
75  const SpacePointBucket* parentBucket{nullptr};
76  };
77 
83  MdtSegmentSeedGenerator(const std::string& name,
84  const SegmentSeed* segmentSeed,
85  const Config& configuration);
86 
89  std::optional<DriftCircleSeed> nextSeed(const EventContext& ctx);
91  unsigned int numGenerated() const;
93  const Config& config() const;
94  private:
99  using SignComboType = std::array<int, 2>;
100  constexpr static std::array<SignComboType,4> s_signCombos{
101  std::array{ 1, 1}, std::array{ 1,-1},
102  std::array{-1,-1}, std::array{-1, 1},
103  };
105  struct SeedSolution{
107  double theta{0.};
109  double Y0{0.};
111  double dTheta{0.};
113  double dY0{0.};
117  std::vector<int> solutionSigns{};
118 
119  friend std::ostream& operator<<(std::ostream& ostr, const SeedSolution& sol) {
120  return sol.print(ostr);
121  }
122  std::ostream& print(std::ostream& ostr) const;
123  };
124 
125 
131  std::optional<DriftCircleSeed> buildSeed(const EventContext& ctx,
132  const HoughHitType& topHit,
133  const HoughHitType& bottomHit,
134  const SignComboType& signs);
140  std::vector<double> invCovs{};
142  std::vector<int> driftSigns{};
144  double covNorm{0.};
146  double T_zzyy{0.};
148  double T_yz{0.};
150  double T_rz{0.};
152  double T_ry{0.};
155  double fitY0{0.};
156  };
157 
161  SeedFitAuxilliaries{std::move(parent)}{}
163  double T_vy{0.};
165  double T_vz{0.};
167  double T_ay{0.};
169  double T_az{0.};
171  double R_vr{0.};
173  double R_vv{0.};
175  double R_va{0.};
177  double fitY0Prime{0.};
179  double fitY0TwoPrime{0.};
180  };
181 
185  SeedFitAuxilliaries estimateAuxillaries(const DriftCircleSeed& seed) const;
190  SeedFitAuxWithT0 estimateAuxillaries(const EventContext& ctx,
191  const DriftCircleSeed& seed) const;
194  void fitDriftCircles(DriftCircleSeed& seed) const;
198  void fitDriftCirclesWithT0(const EventContext& ctx,
199  DriftCircleSeed& seed) const;
201  void moveToNextCandidate();
203 
204 
205  const SegmentSeed* m_segmentSeed{nullptr};
207 
209  std::size_t m_upperLayer{0};
211  std::size_t m_lowerLayer{0};
213  std::size_t m_lowerHitIndex{0};
215  std::size_t m_upperHitIndex{0};
217  std::size_t m_signComboIndex{0};
219  std::vector<SeedSolution> m_seenSolutions{};
221  unsigned int m_nGenSeeds{0};
222 
223  };
224 }
225 
226 #endif
MuonR4::MdtSegmentSeedGenerator::m_upperHitIndex
std::size_t m_upperHitIndex
Explicit hit to pick in the selected top layer.
Definition: MdtSegmentSeedGenerator.h:215
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::fitY0
double fitY0
Prediced y0 given as the expection value of the radii divided by the inverse covariance sum.
Definition: MdtSegmentSeedGenerator.h:155
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::T_rz
double T_rz
Expectation value of T_{z} * r
Definition: MdtSegmentSeedGenerator.h:150
MuonR4::MdtSegmentSeedGenerator::SeedSolution::dTheta
double dTheta
: Uncertainty on the slope
Definition: MdtSegmentSeedGenerator.h:111
MuonR4::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:50
MuonR4::MdtSegmentSeedGenerator::numGenerated
unsigned int numGenerated() const
Returns how many seeds have been generated.
Definition: MdtSegmentSeedGenerator.cxx:88
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::parameters
SegmentFit::Parameters parameters
Seed parameters.
Definition: MdtSegmentSeedGenerator.h:67
MuonR4::MdtSegmentSeedGenerator::Config::nMdtHitCut
unsigned int nMdtHitCut
How many drift circle hits needs the seed to contain in order to be valid.
Definition: MdtSegmentSeedGenerator.h:41
MuonR4::SegmentFit::Parameters
AmgVector(toInt(ParamDefs::nPars)) Parameters
Definition: MuonHoughDefs.h:48
MuonR4::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:99
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
MuonR4::MdtSegmentSeedGenerator::Config::busyLayerLimit
unsigned int busyLayerLimit
How many drift circles may be on a layer to be used for seeding.
Definition: MdtSegmentSeedGenerator.h:39
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::T_ry
double T_ry
Expectation value of T_{y} * r
Definition: MdtSegmentSeedGenerator.h:152
MuonR4::SpacePointPerLayerSorter
The SpacePointPerLayerSorter groups the space points by their layer Identifier.
Definition: SpacePointPerLayerSorter.h:14
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::R_va
double R_va
Expectation value of r * a.
Definition: MdtSegmentSeedGenerator.h:175
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::covNorm
double covNorm
Covariance norm.
Definition: MdtSegmentSeedGenerator.h:144
SegmentSeed.h
MuonR4::MdtSegmentSeedGenerator::SeedSolution::solutionSigns
std::vector< int > solutionSigns
Vector of radial signs of the valid hits.
Definition: MdtSegmentSeedGenerator.h:117
MuonR4::MdtSegmentSeedGenerator::config
const Config & config() const
Returns the current seed configuration.
Definition: MdtSegmentSeedGenerator.cxx:37
MuonR4::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:41
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonR4::MdtSegmentSeedGenerator::estimateAuxillaries
SeedFitAuxilliaries estimateAuxillaries(const DriftCircleSeed &seed) const
Helper function to estimate the auxillary variables that remain constant during the fit.
Definition: MdtSegmentSeedGenerator.cxx:374
MuonR4::MdtSegmentSeedGenerator::SeedSolution
Cache of all solutions seen thus far.
Definition: MdtSegmentSeedGenerator.h:105
MuonR4::MdtSegmentSeedGenerator::Config::fastSeedFit
bool fastSeedFit
Toggle whether the seed is rapidly refitted.
Definition: MdtSegmentSeedGenerator.h:56
MuonR4::MdtSegmentSeedGenerator::m_nGenSeeds
unsigned int m_nGenSeeds
Counter on how many seeds have been generated.
Definition: MdtSegmentSeedGenerator.h:221
MuonR4::MdtSegmentSeedGenerator::Config::nMdtLayHitCut
double nMdtLayHitCut
Hit cut based on the fraction of collected tube layers.
Definition: MdtSegmentSeedGenerator.h:44
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::R_vr
double R_vr
Expectation value of r * v.
Definition: MdtSegmentSeedGenerator.h:171
MuonR4::MdtSegmentSeedGenerator::Config::recalibSeedCircles
bool recalibSeedCircles
Recalibrate the seed drift circles from the initial estimate
Definition: MdtSegmentSeedGenerator.h:52
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::T_vy
double T_vy
Expectation value of T_{y} * v.
Definition: MdtSegmentSeedGenerator.h:163
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::R_vv
double R_vv
Expectation value of v * v.
Definition: MdtSegmentSeedGenerator.h:173
MuonR4::MdtSegmentSeedGenerator
Helper class to generate valid seeds for the segment fit.
Definition: MdtSegmentSeedGenerator.h:24
MuonR4::MdtSegmentSeedGenerator::Config::startWithPattern
bool startWithPattern
Try at the first time the pattern seed as candidate.
Definition: MdtSegmentSeedGenerator.h:37
MuonR4::MdtSegmentSeedGenerator::m_lowerHitIndex
std::size_t m_lowerHitIndex
Explicit hit to pick in the selected bottom layer.
Definition: MdtSegmentSeedGenerator.h:213
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries
Auxillary struct to calculate fit constants.
Definition: MdtSegmentSeedGenerator.h:136
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::T_ay
double T_ay
Expectation value of T_{y} * a.
Definition: MdtSegmentSeedGenerator.h:167
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::SeedFitAuxWithT0
SeedFitAuxWithT0(SeedFitAuxilliaries &&parent)
Constructor.
Definition: MdtSegmentSeedGenerator.h:160
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::fitY0TwoPrime
double fitY0TwoPrime
Second derivative of the ftted Y0.
Definition: MdtSegmentSeedGenerator.h:179
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::T_yz
double T_yz
Expectation value of T_{y} * T_{z}.
Definition: MdtSegmentSeedGenerator.h:148
MuonR4::MdtSegmentSeedGenerator::Config
Configuration switches of the module
Definition: MdtSegmentSeedGenerator.h:29
MuonR4::MdtSegmentSeedGenerator::s_signCombos
constexpr static std::array< SignComboType, 4 > s_signCombos
Definition: MdtSegmentSeedGenerator.h:100
MuonR4::MdtSegmentSeedGenerator::Config::fastSegFitWithT0
bool fastSegFitWithT0
Toggle whether an initial t0 fit shall be executed.
Definition: MdtSegmentSeedGenerator.h:58
MuonR4::MdtSegmentSeedGenerator::SeedSolution::theta
double theta
: Theta of the line
Definition: MdtSegmentSeedGenerator.h:107
MuonR4::MdtSegmentSeedGenerator::m_cfg
Config m_cfg
Definition: MdtSegmentSeedGenerator.h:202
MuonR4::MdtSegmentSeedGenerator::SeedSolution::print
std::ostream & print(std::ostream &ostr) const
Definition: MdtSegmentSeedGenerator.cxx:31
MuonR4::SpacePointPerLayerSorter::HitVec
std::vector< const SpacePoint * > HitVec
Definition: SpacePointPerLayerSorter.h:16
MuonR4::MdtSegmentSeedGenerator::Config::thetaRange
std::array< double, 2 > thetaRange
Cut on the theta angle.
Definition: MdtSegmentSeedGenerator.h:31
MuonR4::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:169
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::fitY0Prime
double fitY0Prime
First derivative of the fitted Y0.
Definition: MdtSegmentSeedGenerator.h:177
MuonR4::MdtSegmentSeedGenerator::m_upperLayer
std::size_t m_upperLayer
Considered layer to pick the top drift circle from.
Definition: MdtSegmentSeedGenerator.h:209
MuonR4::SegmentSeed::getHitsInMax
const std::vector< HitType > & getHitsInMax() const
Returns the list of assigned hits.
Definition: SegmentSeed.cxx:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonR4::MdtSegmentSeedGenerator::SeedSolution::seedHits
HitVec seedHits
Used hits in the seed.
Definition: MdtSegmentSeedGenerator.h:115
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::driftSigns
std::vector< int > driftSigns
Vector of drfit signs.
Definition: MdtSegmentSeedGenerator.h:142
MuonR4::MdtSegmentSeedGenerator::SeedSolution::dY0
double dY0
: Uncertainty on the intercept
Definition: MdtSegmentSeedGenerator.h:113
MuonR4::MdtSegmentSeedGenerator::Config::hitPullCut
double hitPullCut
Upper cut on the hit chi2 w.r.t.
Definition: MdtSegmentSeedGenerator.h:35
MuonR4::MdtSegmentSeedGenerator::fitDriftCirclesWithT0
void fitDriftCirclesWithT0(const EventContext &ctx, DriftCircleSeed &seed) const
Refine the seed by performing a fast Mdt segment fit with t0 constraint.
Definition: MdtSegmentSeedGenerator.cxx:498
Config
Definition: dumpNPs.cxx:47
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::T_zzyy
double T_zzyy
Expectation value of T_{z}^{2} - T_{y}^{2}.
Definition: MdtSegmentSeedGenerator.h:146
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::measurements
std::vector< std::unique_ptr< CalibratedSpacePoint > > measurements
List of calibrated measurements.
Definition: MdtSegmentSeedGenerator.h:69
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:18
MuonR4::MdtSegmentSeedGenerator::~MdtSegmentSeedGenerator
~MdtSegmentSeedGenerator()
lumiFormat.array
array
Definition: lumiFormat.py:91
MuonR4::MdtSegmentSeedGenerator::SeedSolution::operator<<
friend std::ostream & operator<<(std::ostream &ostr, const SeedSolution &sol)
Definition: MdtSegmentSeedGenerator.h:119
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0
Definition: MdtSegmentSeedGenerator.h:158
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::chi2
double chi2
Seed chi2.
Definition: MdtSegmentSeedGenerator.h:73
MuonR4::MdtSegmentSeedGenerator::moveToNextCandidate
void moveToNextCandidate()
Prepares the generator to generate the seed from the next pair of drift circles.
Definition: MdtSegmentSeedGenerator.cxx:91
MuonR4::ISpacePointCalibrator
Interface class to refine the space point calibration with an external seed.
Definition: ISpacePointCalibrator.h:19
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::nIter
unsigned int nIter
Iterations to obtain the seed.
Definition: MdtSegmentSeedGenerator.h:71
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonR4::MdtSegmentSeedGenerator::Config::nMaxIter
unsigned int nMaxIter
Maximum number of iterations in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:60
MuonR4::MdtSegmentSeedGenerator::m_segmentSeed
const SegmentSeed * m_segmentSeed
Definition: MdtSegmentSeedGenerator.h:205
MuonR4::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:47
MuonR4::SegmentSeed
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition: SegmentSeed.h:14
AthMessaging.h
MuonR4::MdtSegmentSeedGenerator::m_seenSolutions
std::vector< SeedSolution > m_seenSolutions
Vector caching equivalent solutions to avoid double seeding.
Definition: MdtSegmentSeedGenerator.h:219
MuonR4::MdtSegmentSeedGenerator::Config::interceptRange
std::array< double, 2 > interceptRange
Cut on the intercept range.
Definition: MdtSegmentSeedGenerator.h:33
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::T_vz
double T_vz
Expectation value of T_{z} * v.
Definition: MdtSegmentSeedGenerator.h:165
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed::parentBucket
const SpacePointBucket * parentBucket
Pointer to the parent bucket.
Definition: MdtSegmentSeedGenerator.h:75
MuonR4::MdtSegmentSeedGenerator::DriftCircleSeed
Helper struct from a generated Mdt seed.
Definition: MdtSegmentSeedGenerator.h:65
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::invCovs
std::vector< double > invCovs
Vector of inverse covariances.
Definition: MdtSegmentSeedGenerator.h:140
MuonR4::MdtSegmentSeedGenerator::fitDriftCircles
void fitDriftCircles(DriftCircleSeed &seed) const
Refine the seed by performing a fast Mdt segment fit.
Definition: MdtSegmentSeedGenerator.cxx:418
MuonR4::MdtSegmentSeedGenerator::m_signComboIndex
std::size_t m_signComboIndex
Index of the left-right ambiguity between the circles.
Definition: MdtSegmentSeedGenerator.h:217
MuonR4::MdtSegmentSeedGenerator::Config::precCutOff
double precCutOff
Precision cut off in the fast segment fit.
Definition: MdtSegmentSeedGenerator.h:62
MuonR4::MdtSegmentSeedGenerator::Config::calibrator
const ISpacePointCalibrator * calibrator
Pointer to the space point calibrator.
Definition: MdtSegmentSeedGenerator.h:54
MuonR4::MdtSegmentSeedGenerator::m_hitLayers
SpacePointPerLayerSorter m_hitLayers
Definition: MdtSegmentSeedGenerator.h:206
MuonR4::MdtSegmentSeedGenerator::HitVec
SpacePointPerLayerSorter::HitVec HitVec
Definition: MdtSegmentSeedGenerator.h:26
SpacePointPerLayerSorter.h
MuonR4::MdtSegmentSeedGenerator::m_lowerLayer
std::size_t m_lowerLayer
Considered layer to pick the bottom drift circle from.
Definition: MdtSegmentSeedGenerator.h:211
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxilliaries::centerOfGrav
Amg::Vector3D centerOfGrav
Tube position center weigthed with inverse covariances.
Definition: MdtSegmentSeedGenerator.h:138
MuonR4::MdtSegmentSeedGenerator::SeedFitAuxWithT0::T_az
double T_az
Expectation value of T_{z} * a.
Definition: MdtSegmentSeedGenerator.h:169
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
MuonR4::MdtSegmentSeedGenerator::nextSeed
std::optional< DriftCircleSeed > nextSeed(const EventContext &ctx)
returns the next seed in the row
Definition: MdtSegmentSeedGenerator.cxx:129
MuonR4::MdtSegmentSeedGenerator::SeedSolution::Y0
double Y0
Intersecpt of the line.
Definition: MdtSegmentSeedGenerator.h:109