ATLAS Offline Software
MdtSegmentFitter.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 MUONPATTERNHELPERS_MDTSEGMENTFITTER_H
5 #define MUONPATTERNHELPERS_MDTSEGMENTFITTER_H
6 
10 
14 
15 namespace MuonR4{
16  class ISpacePointCalibrator;
17  class CalibratedSpacePoint;
18 }
19 
20 namespace MuonR4::SegmentFit{
22  public:
23  using HitType = std::unique_ptr<CalibratedSpacePoint>;
24  using HitVec = std::vector<HitType>;
25 
26  struct Config{
28  unsigned int nMaxCalls{100};
30  double tolerance{1.e-7};
38  bool doTimeFit{true};
40  bool reCalibrate{false};
42  bool useSecOrderDeriv{false};
45  bool useFastFit{true};
47  unsigned int nParsOutOfBounds{1};
51  unsigned int noMoveIter{2};
53  using RangeArray = std::array<std::array<double,2>, Acts::toUnderlying(ParamDefs::nPars)>;
55  static RangeArray defaultRanges();
56 
58  };
62  MdtSegmentFitter(const std::string& name,
63  Config&& config);
64 
65  SegmentFitResult fitSegment(const EventContext& ctx,
66  HitVec&& calibHits,
67  const Parameters& startPars,
68  const Amg::Transform3D& localToGlobal) const;
69  private:
75  bool recalibrate(const EventContext& ctx,
76  const Line_t& segmentLine,
77  SegmentFitResult& fitResult) const;
80  bool updateHitSummary(SegmentFitResult& fitResult) const;
83  void centerAlongWire(SegmentFitResult& fitResult) const;
85  void updateDriftSigns(const Line_t& segmentLine, SegmentFitResult& fitRes)const;
87  enum class UpdateStatus{
88  allOkay = 0,
89  smallStep = 1,
90  outOfBounds = 2,
91  noChange = 3,
92  };
103  template <unsigned int nDim>
105  Parameters& previousPars,
106  Parameters& currGrad,
107  Parameters& prevGrad,
108  const AmgSymMatrix(5)& hessian) const;
109 
110  template <unsigned int nDim>
111  void blockCovariance(const AmgSymMatrix(5)& hessian,
112  SegmentFit::Covariance& covariance) const;
113 
114 
115  };
116 }
117 
118 
119 #endif
MuonR4::SegmentFit::MdtSegmentFitter::UpdateStatus
UpdateStatus
Status update of the parameter update.
Definition: MdtSegmentFitter.h:87
MuonR4::SegmentFit
Definition: MuonHoughDefs.h:33
MuonR4::SegmentFit::MdtSegmentFitter
Definition: MdtSegmentFitter.h:21
python.SystemOfUnits.mm
float mm
Definition: SystemOfUnits.py:98
MuonR4::SegmentFit::MdtSegmentFitter::UpdateStatus::noChange
@ noChange
The parameters drifted out of bounds -> Abortion.
MuonR4::SegmentFit::MdtSegmentFitter::UpdateStatus::smallStep
@ smallStep
Ordinary parameter update keep calibration switched on.
MuonR4::SegmentFit::MdtSegmentFitter::updateHitSummary
bool updateHitSummary(SegmentFitResult &fitResult) const
Updates the hit summary from the contributing hits.
Definition: MdtSegmentFitter.cxx:106
MuonR4::SegmentFit::MdtSegmentFitter::UpdateStatus::outOfBounds
@ outOfBounds
Step size is small enough that calibration can be skipped.
SegmentSeed.h
MuonR4::SegmentFit::MdtSegmentFitter::Config::RangeArray
std::array< std::array< double, 2 >, Acts::toUnderlying(ParamDefs::nPars)> RangeArray
Allowed parameter ranges.
Definition: MdtSegmentFitter.h:53
MuonR4::SegmentFit::MdtSegmentFitter::Config::nMaxCalls
unsigned int nMaxCalls
How many calls shall be executed.
Definition: MdtSegmentFitter.h:28
MuonR4::SegmentFit::MdtSegmentFitter::centerAlongWire
void centerAlongWire(SegmentFitResult &fitResult) const
Moves the segment to the average x0 position, if the segment does not contain any measurement.
Definition: MdtSegmentFitter.cxx:137
MuonR4::SegmentFit::MdtSegmentFitter::Config::ranges
RangeArray ranges
Definition: MdtSegmentFitter.h:57
MuonR4::SegmentFit::MdtSegmentFitter::Config::useSecOrderDeriv
bool useSecOrderDeriv
Switch toggling whether the second order derivative shall be included.
Definition: MdtSegmentFitter.h:42
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
MuonR4::SegmentFit::Covariance
AmgSymMatrix(Acts::toUnderlying(ParamDefs::nPars)) Covariance
Definition: MuonHoughDefs.h:46
MuonR4::SegmentFit::MdtSegmentFitter::Config::defaultRanges
static RangeArray defaultRanges()
Function that returns a set of predefined ranges for testing.
Definition: MdtSegmentFitter.cxx:57
GeoPrimitives.h
MuonR4::SegmentFit::MdtSegmentFitter::Config::spatialCalibCuttOff
double spatialCalibCuttOff
Cutoff on the spatial paramater update to keep calibration on.
Definition: MdtSegmentFitter.h:36
MuonR4::SegmentFit::MdtSegmentFitter::Config::doTimeFit
bool doTimeFit
Switch toggling whether the T0 shall be fitted or not.
Definition: MdtSegmentFitter.h:38
MuonR4::SegmentFit::MdtSegmentFitter::blockCovariance
void blockCovariance(const AmgSymMatrix(5)&hessian, SegmentFit::Covariance &covariance) const
Definition: MdtSegmentFitter.cxx:366
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonR4::SegmentFit::MdtSegmentFitter::HitType
std::unique_ptr< CalibratedSpacePoint > HitType
Definition: MdtSegmentFitter.h:23
MuonR4::SegmentFit::MdtSegmentFitter::Config::angularCalibCutOff
double angularCalibCutOff
Cutoff on the angular parameter update to keep the calibration on.
Definition: MdtSegmentFitter.h:33
MuonR4::SegmentFit::MdtSegmentFitter::Config::reCalibrate
bool reCalibrate
Switch toggling whether the calibrator shall be called at each iteration.
Definition: MdtSegmentFitter.h:40
MuonR4::SegmentFit::MdtSegmentFitter::fitSegment
SegmentFitResult fitSegment(const EventContext &ctx, HitVec &&calibHits, const Parameters &startPars, const Amg::Transform3D &localToGlobal) const
Definition: MdtSegmentFitter.cxx:149
MuonR4::SegmentFit::MdtSegmentFitter::HitVec
std::vector< HitType > HitVec
Definition: MdtSegmentFitter.h:24
MuonR4::SegmentFit::MdtSegmentFitter::Config::useFastFit
bool useFastFit
Use the fast Straw line fitter if there are only Mdt measurements to fit.
Definition: MdtSegmentFitter.h:45
Config
Definition: dumpNPs.cxx:47
MuonR4::SegmentFit::MdtSegmentFitter::m_cfg
Config m_cfg
Definition: MdtSegmentFitter.h:70
tolerance
Definition: suep_shower.h:17
MuonR4::SegmentFit::MdtSegmentFitter::Config::noMoveIter
unsigned int noMoveIter
How many iterations with changes below tolerance.
Definition: MdtSegmentFitter.h:51
MuonR4::SegmentFit::MdtSegmentFitter::UpdateStatus::allOkay
@ allOkay
MuonR4::SegmentFit::MdtSegmentFitter::updateDriftSigns
void updateDriftSigns(const Line_t &segmentLine, SegmentFitResult &fitRes) const
Update the signs of the measurement.
Definition: MdtSegmentFitter.cxx:72
MuonR4::SegmentFit::MdtSegmentFitter::updateParameters
UpdateStatus updateParameters(Parameters &currentPars, Parameters &previousPars, Parameters &currGrad, Parameters &prevGrad, const AmgSymMatrix(5)&hessian) const
Update step of the segment parameters using the Hessian and the gradient.
Definition: MdtSegmentFitter.cxx:384
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonR4::SegmentFit::HitVec
SegmentFitResult::HitVec HitVec
Definition: MdtSegmentFitter.cxx:54
python.SystemOfUnits.mrad
float mrad
Definition: SystemOfUnits.py:127
MuonR4::ISpacePointCalibrator
Interface class to refine the space point calibration with an external seed.
Definition: ISpacePointCalibrator.h:24
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonR4::SegmentFit::MdtSegmentFitter::Config::nParsOutOfBounds
unsigned int nParsOutOfBounds
Abort the fit as soon as more than n parameters leave the fit range.
Definition: MdtSegmentFitter.h:47
MuonR4::SegmentFit::MdtSegmentFitter::MdtSegmentFitter
MdtSegmentFitter(const std::string &name, Config &&config)
Standard constructor.
Definition: MdtSegmentFitter.cxx:68
SegmentFitterEventData.h
HoughEventData.h
AthMessaging.h
MuonR4::SegmentFit::Line_t
SeedingAux::Line_t Line_t
Abrivation of the line with partial derivatives.
Definition: MuonHoughDefs.h:39
MuonR4::SegmentFitResult
Definition: SegmentFitterEventData.h:46
MuonR4::SegmentFit::MdtSegmentFitter::Config
Definition: MdtSegmentFitter.h:26
MuonR4::SegmentFit::Parameters
AmgVector(Acts::toUnderlying(ParamDefs::nPars)) Parameters
Definition: MuonHoughDefs.h:45
MuonR4::SegmentFit::MdtSegmentFitter::recalibrate
bool recalibrate(const EventContext &ctx, const Line_t &segmentLine, SegmentFitResult &fitResult) const
Recalibrate the measurements participating the fit based on the best straight-line knowledge.
Definition: MdtSegmentFitter.cxx:79
MuonR4::SegmentFit::MdtSegmentFitter::Config::calibrator
const ISpacePointCalibrator * calibrator
Pointer to the calibrator tool.
Definition: MdtSegmentFitter.h:49