ATLAS Offline Software
MdtSegmentFitter.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 MUONPATTERNHELPERS_MDTSEGMENTFITTER_H
5 #define MUONPATTERNHELPERS_MDTSEGMENTFITTER_H
6 
8 
13 #include <GaudiKernel/SystemOfUnits.h>
14 
15 
16 namespace MuonR4{
17  class ISpacePointCalibrator;
19  public:
22  using HitType = std::unique_ptr<CalibratedSpacePoint>;
23  using HitVec = std::vector<HitType>;
24 
25  struct Config{
27  unsigned int nMaxCalls{100};
29  double tolerance{1.e-5};
31  bool doTimeFit{true};
33  unsigned int nParsOutOfBounds{1};
37  unsigned int noMoveIter{2};
39  using RangeArray = std::array<std::array<double,2>, SegmentFit::toInt(ParamDefs::nPars)>;
41  static RangeArray defaultRanges();
42 
44 
45  };
46 
47 
48  MdtSegmentFitter(const std::string& name,
49  Config&& config);
50 
51  SegmentFitResult fitSegment(const EventContext& ctx,
52  HitVec&& calibHits,
53  const Parameters& startPars,
54  const Amg::Transform3D& localToGlobal) const;
55  private:
57 
61  using LinePartialArray = std::array<Amg::Vector3D, toInt(ParamDefs::nPars)>;
65  void updateLinePartials(const Parameters& fitPars,
66  LinePartialArray& linePartials) const;
67 
77  const Amg::Vector3D& segPos,
78  const Amg::Vector3D& segDir,
79  const LinePartialArray& linePartials,
80  const ParamDefs fitPar);
81 
82 
93  const double offset,
94  const Amg::Vector3D& segPos,
95  const Amg::Vector3D& segDir,
96  const LinePartialArray& linePartials,
97  const ParamDefs fitPar);
98 
110  const LinePartialArray& residualPartials,
111  const MeasCov_t& measCovariance,
112  AmgVector(5)& gradient,
113  AmgSymMatrix(5)& hessian,
114  double& chi2,
115  int startPar) const;
116 
117 
118  enum class UpdateStatus{
119  allOkay = 0,
120  outOfBounds = 1,
121  noChange = 2,
122  };
133  template <unsigned int nDim>
135  Parameters& previousPars,
136  Parameters& currGrad,
137  Parameters& prevGrad,
138  const AmgSymMatrix(5)& hessian) const;
139 
140  template <unsigned int nDim>
141  void blockCovariance(const AmgSymMatrix(5)& hessian,
142  SegmentFit::Covariance& covariance) const;
143 
144 
145  };
146 }
147 
148 
149 #endif
MuonR4::MdtSegmentFitter
Definition: MdtSegmentFitter.h:18
MuonR4::SegmentFit::ParamDefs
ParamDefs
This file defines the parameter enums in the Trk namespace.
Definition: MuonHoughDefs.h:29
MuonR4::MdtSegmentFitter::blockCovariance
void blockCovariance(const AmgSymMatrix(5)&hessian, SegmentFit::Covariance &covariance) const
Definition: MdtSegmentFitter.cxx:459
MuonR4::SegmentFit::Parameters
AmgVector(toInt(ParamDefs::nPars)) Parameters
Definition: MuonHoughDefs.h:48
MuonR4::MdtSegmentFitter::UpdateStatus
UpdateStatus
Definition: MdtSegmentFitter.h:118
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
MuonR4::MdtSegmentFitter::Parameters
SegmentFit::Parameters Parameters
Definition: MdtSegmentFitter.h:21
SegmentSeed.h
MuonR4::MdtSegmentFitter::partialPlaneIntersect
static Amg::Vector3D partialPlaneIntersect(const Amg::Vector3D &normal, const double offset, const Amg::Vector3D &segPos, const Amg::Vector3D &segDir, const LinePartialArray &linePartials, const ParamDefs fitPar)
Calculates the partial derivative of the intersection point between the segment line and the measurem...
Definition: MdtSegmentFitter.cxx:55
MuonR4::MdtSegmentFitter::UpdateStatus::outOfBounds
@ outOfBounds
MuonR4::HitVec
SpacePointPerLayerSorter::HitVec HitVec
Definition: SpacePointPerLayerSorter.cxx:9
MuonR4::MdtSegmentFitter::Config::noMoveIter
unsigned int noMoveIter
How many iterations with changes below tolerance.
Definition: MdtSegmentFitter.h:37
MuonR4::MdtSegmentFitter::fitSegment
SegmentFitResult fitSegment(const EventContext &ctx, HitVec &&calibHits, const Parameters &startPars, const Amg::Transform3D &localToGlobal) const
Definition: MdtSegmentFitter.cxx:137
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
MuonR4::MdtSegmentFitter::Config::calibrator
const ISpacePointCalibrator * calibrator
Pointer to the calibrator tool.
Definition: MdtSegmentFitter.h:35
MuonR4::MdtSegmentFitter::partialClosestApproach
static Amg::Vector3D partialClosestApproach(const MuonR4::CalibratedSpacePoint &sp, const Amg::Vector3D &segPos, const Amg::Vector3D &segDir, const LinePartialArray &linePartials, const ParamDefs fitPar)
Calculates the partial derivative of the point of closest approach to the meausrement's wire w....
Definition: MdtSegmentFitter.cxx:77
CalibratedSpacePoint.h
MuonR4::MdtSegmentFitter::Config::ranges
RangeArray ranges
Definition: MdtSegmentFitter.h:43
GeoPrimitives.h
MuonR4::MdtSegmentFitter::UpdateStatus::noChange
@ noChange
MuonR4::MdtSegmentFitter::MeasCov_t
CalibratedSpacePoint::Covariance_t MeasCov_t
Updates the chi2, its Gradient & Hessian from the measurement residual.
Definition: MdtSegmentFitter.h:108
AmgVector
AmgVector(4) T2BSTrackFilterTool
Definition: T2BSTrackFilterTool.cxx:114
MuonR4::MdtSegmentFitter::HitType
std::unique_ptr< CalibratedSpacePoint > HitType
Definition: MdtSegmentFitter.h:22
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
MuonR4::MdtSegmentFitter::Config
Definition: MdtSegmentFitter.h:25
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonR4::MdtSegmentFitter::Config::nParsOutOfBounds
unsigned int nParsOutOfBounds
Abort the fit as soon as more than n parameters leave the fit range.
Definition: MdtSegmentFitter.h:33
MuonR4::MdtSegmentFitter::updateDerivatives
void updateDerivatives(const Amg::Vector3D &residual, const LinePartialArray &residualPartials, const MeasCov_t &measCovariance, AmgVector(5)&gradient, AmgSymMatrix(5)&hessian, double &chi2, int startPar) const
Definition: MdtSegmentFitter.cxx:437
Config
Definition: dumpNPs.cxx:47
lumiFormat.array
array
Definition: lumiFormat.py:91
tolerance
Definition: suep_shower.h:17
MuonR4::MdtSegmentFitter::m_cfg
Config m_cfg
Definition: MdtSegmentFitter.h:56
MuonR4::MdtSegmentFitter::updateLinePartials
void updateLinePartials(const Parameters &fitPars, LinePartialArray &linePartials) const
Updates the partial derivaitves of the line w.r.t the fit parameters.
Definition: MdtSegmentFitter.cxx:117
MuonR4::MdtSegmentFitter::MdtSegmentFitter
MdtSegmentFitter(const std::string &name, Config &&config)
Definition: MdtSegmentFitter.cxx:50
MuonR4::MdtSegmentFitter::Config::nMaxCalls
unsigned int nMaxCalls
How many calls shall be executed.
Definition: MdtSegmentFitter.h:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
MuonR4::MdtSegmentFitter::UpdateStatus::allOkay
@ allOkay
MuonR4::ISpacePointCalibrator
Interface class to refine the space point calibration with an external seed.
Definition: ISpacePointCalibrator.h:19
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::MdtSegmentFitter::Config::RangeArray
std::array< std::array< double, 2 >, SegmentFit::toInt(ParamDefs::nPars)> RangeArray
Allowed parameter ranges.
Definition: MdtSegmentFitter.h:39
MuonR4::MdtSegmentFitter::LinePartialArray
std::array< Amg::Vector3D, toInt(ParamDefs::nPars)> LinePartialArray
Store the partial derivative of the line w.r.t.
Definition: MdtSegmentFitter.h:61
MuonR4::SegmentFit::Covariance
AmgSymMatrix(toInt(ParamDefs::nPars)) Covariance
Definition: MuonHoughDefs.h:49
SegmentFitterEventData.h
MuonR4::MdtSegmentFitter::Config::doTimeFit
bool doTimeFit
Switch toggling whether the T0 shall be fitted or not.
Definition: MdtSegmentFitter.h:31
MuonR4::MdtSegmentFitter::HitVec
std::vector< HitType > HitVec
Definition: MdtSegmentFitter.h:23
MuonR4::CalibratedSpacePoint
The calibrated Space point is created during the calibration process.
Definition: CalibratedSpacePoint.h:15
AthMessaging.h
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
MuonR4::SegmentFitResult
Definition: SegmentFitterEventData.h:50
MuonR4::MdtSegmentFitter::Config::defaultRanges
static RangeArray defaultRanges()
Function that returns a set of predefined ranges for testing.
Definition: MdtSegmentFitter.cxx:39
MuonR4::AmgSymMatrix
const AmgSymMatrix(2) &SpacePoint
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:150
MuonR4::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:475
MuonR4::CalibratedSpacePoint::Covariance_t
std::variant< AmgSymMatrix(2), AmgSymMatrix(3)> Covariance_t
The spatial covariance matrix of the calibrated space point.
Definition: CalibratedSpacePoint.h:49