ATLAS Offline Software
FitterHelperFunctions.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTSGEOMETRY_FITTERHELPER_H
6 #define ACTSGEOMETRY_FITTERHELPER_H
7 
8 // ATHENA
10 
11 // ACTS
12 #include "Acts/TrackFitting/GainMatrixSmoother.hpp"
13 #include "Acts/TrackFitting/GainMatrixUpdater.hpp"
14 #include "Acts/TrackFitting/MbfSmoother.hpp"
15 
16 // PACKAGE
19 
21 
22  template<typename trajectory_t>
23  Acts::Result<void> gainMatrixUpdate(const Acts::GeometryContext& gctx,
24  typename trajectory_t::TrackStateProxy trackState,
25  const Acts::Logger& logger) {
26  Acts::GainMatrixUpdater updater;
27  return updater.template operator()<trajectory_t>(gctx, trackState, logger);
28  }
29 
30  template<typename trajectory_t>
31  Acts::Result<void> gainMatrixSmoother(const Acts::GeometryContext& gctx,
32  trajectory_t& trajectory,
33  size_t entryIndex,
34  const Acts::Logger& logger) {
35  Acts::GainMatrixSmoother smoother;
36  return smoother.template operator()<trajectory_t>(gctx, trajectory, entryIndex, logger);
37  }
38 
39  template<typename trajectory_t>
40  Acts::Result<void> mbfSmoother(const Acts::GeometryContext& gctx,
41  trajectory_t& trajectory,
42  size_t entryIndex,
43  const Acts::Logger& logger) {
44  Acts::MbfSmoother smoother;
45  return smoother.template operator()<trajectory_t>(gctx, trajectory, entryIndex, logger);
46  }
47 
57  template<typename trajectory_t>
58  bool operator()(typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy state) const {
59  // can't determine an outlier w/o a measurement or predicted parameters
60  if (not state.hasCalibrated() or not state.hasPredicted()) {
61  return false;
62  }
63  return Acts::visit_measurement(
64  state.calibratedSize(),
65  [&] (auto N) -> bool {
66  constexpr size_t kMeasurementSize = decltype(N)::value;
67 
68  auto subspaceHelper = state.template projectorSubspaceHelper<kMeasurementSize>();
69 
70  typename Acts::TrackStateTraits<kMeasurementSize, true>::Calibrated calibrated{
71  state.template calibrated<Acts::MultiTrajectoryTraits::MeasurementSizeMax>().data()};
72 
73  typename Acts::TrackStateTraits<kMeasurementSize, true>::CalibratedCovariance
74  calibratedCovariance{state.template calibratedCovariance<Acts::MultiTrajectoryTraits::MeasurementSizeMax>().data()};
75 
76  // Take the projector (measurement mapping function)
77  // TODO use the subspace helper directly
78  const auto H = subspaceHelper.projector();
79 
80  const auto residual = calibrated - H * state.predicted();
81  double chi2 = (residual.transpose() * (calibratedCovariance + H * state.predictedCovariance() * H.transpose()).inverse() * residual).value();
82  return (chi2 > StateChiSquaredPerNumberDoFCut * kMeasurementSize);
83  });
84  }
85  };
86 
90  double momentumMax = std::numeric_limits<double>::max();
91 
99  template<typename trajectory_t>
100  bool operator()(typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy trackState) const {
101  // can't determine an outlier w/o a measurement or predicted parameters
102  auto momentum = std::abs(1. / trackState.filtered()[Acts::eBoundQOverP]);
103  return (momentum <= momentumMax);
104  }
105  };
106 
107 } // namespace
108 
109 #endif
ActsTrk::detail::FitterHelperFunctions::gainMatrixUpdate
Acts::Result< void > gainMatrixUpdate(const Acts::GeometryContext &gctx, typename trajectory_t::TrackStateProxy trackState, const Acts::Logger &logger)
Definition: FitterHelperFunctions.h:23
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder
Outlier finder using a Chi2 cut.
Definition: FitterHelperFunctions.h:49
H
#define H(x, y, z)
Definition: MD5.cxx:114
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
ActsDetectorElement.h
ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder::operator()
bool operator()(typename Acts::MultiTrajectory< trajectory_t >::ConstTrackStateProxy state) const
Classify a measurement as a valid one or an outlier.
Definition: FitterHelperFunctions.h:58
TRT_BaseElement.h
ActsTrk::detail::FitterHelperFunctions::ReverseFilteringLogic
Determine if the smoothing of a track should be done with or without reverse filtering.
Definition: FitterHelperFunctions.h:89
ActsTrk::detail::FitterHelperFunctions::gainMatrixSmoother
Acts::Result< void > gainMatrixSmoother(const Acts::GeometryContext &gctx, trajectory_t &trajectory, size_t entryIndex, const Acts::Logger &logger)
Definition: FitterHelperFunctions.h:31
ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder::StateChiSquaredPerNumberDoFCut
double StateChiSquaredPerNumberDoFCut
Definition: FitterHelperFunctions.h:50
ActsTrk::detail::FitterHelperFunctions::mbfSmoother
Acts::Result< void > mbfSmoother(const Acts::GeometryContext &gctx, trajectory_t &trajectory, size_t entryIndex, const Acts::Logger &logger)
Definition: FitterHelperFunctions.h:40
ActsTrk::detail::FitterHelperFunctions::ReverseFilteringLogic::operator()
bool operator()(typename Acts::MultiTrajectory< trajectory_t >::ConstTrackStateProxy trackState) const
Determine if the smoothing of a track should be done with or without reverse filtering.
Definition: FitterHelperFunctions.h:100
ActsTrk::detail::FitterHelperFunctions
Definition: FitterHelperFunctions.h:20
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14