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 
15 // PACKAGE
18 
20  template<typename trajectory_t>
21  Acts::Result<void> gainMatrixUpdate(const Acts::GeometryContext& gctx,
22  typename trajectory_t::TrackStateProxy trackState,
23  Acts::Direction direction,
24  const Acts::Logger& logger) {
25  Acts::GainMatrixUpdater updater;
26  return updater.template operator()<trajectory_t>(gctx, trackState, direction, logger);
27  }
28 
29  template<typename trajectory_t>
30  Acts::Result<void> gainMatrixSmoother(const Acts::GeometryContext& gctx,
31  trajectory_t& trajectory,
32  size_t entryIndex,
33  const Acts::Logger& logger) {
34  Acts::GainMatrixSmoother smoother;
35  return smoother.template operator()<trajectory_t>(gctx, trajectory, entryIndex, logger);
36  }
37 
47  template<typename trajectory_t>
48  bool operator()(typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy state) const {
49  // can't determine an outlier w/o a measurement or predicted parameters
50  if (not state.hasCalibrated() or not state.hasPredicted()) {
51  return false;
52  }
53  return Acts::visit_measurement(
54  state.calibratedSize(),
55  [&] (auto N) -> bool {
56  constexpr size_t kMeasurementSize = decltype(N)::value;
57 
58  typename Acts::TrackStateTraits<kMeasurementSize, true>::Measurement calibrated{
59  state.template calibrated<Acts::MultiTrajectoryTraits::MeasurementSizeMax>().data()};
60 
61  typename Acts::TrackStateTraits<kMeasurementSize, true>::MeasurementCovariance
62  calibratedCovariance{state.template calibratedCovariance<Acts::MultiTrajectoryTraits::MeasurementSizeMax>().data()};
63 
64  // Take the projector (measurement mapping function)
65  const auto H =
66  state.projector()
67  .template topLeftCorner<kMeasurementSize, Acts::BoundIndices::eBoundSize>()
68  .eval();
69 
70  const auto residual = calibrated - H * state.predicted();
71  double chi2 = (residual.transpose() * (calibratedCovariance + H * state.predictedCovariance() * H.transpose()).inverse() * residual).value();
72  return (chi2 > StateChiSquaredPerNumberDoFCut * kMeasurementSize);
73  });
74  }
75  };
76 
80  double momentumMax = std::numeric_limits<double>::max();
81 
89  template<typename trajectory_t>
90  bool operator()(typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy trackState) const {
91  // can't determine an outlier w/o a measurement or predicted parameters
92  auto momentum = std::abs(1. / trackState.filtered()[Acts::eBoundQOverP]);
93  return (momentum <= momentumMax);
94  }
95  };
96 
97 } // namespace
98 
99 #endif
ActsTrk::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:90
max
#define max(a, b)
Definition: cfImp.cxx:41
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
ActsTrk::FitterHelperFunctions
Definition: FitterHelperFunctions.h:19
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
ActsTrk::FitterHelperFunctions::gainMatrixSmoother
Acts::Result< void > gainMatrixSmoother(const Acts::GeometryContext &gctx, trajectory_t &trajectory, size_t entryIndex, const Acts::Logger &logger)
Definition: FitterHelperFunctions.h:30
ActsTrk::FitterHelperFunctions::ATLASOutlierFinder::StateChiSquaredPerNumberDoFCut
double StateChiSquaredPerNumberDoFCut
Definition: FitterHelperFunctions.h:40
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:522
ActsDetectorElement.h
TRT_BaseElement.h
ActsTrk::FitterHelperFunctions::gainMatrixUpdate
Acts::Result< void > gainMatrixUpdate(const Acts::GeometryContext &gctx, typename trajectory_t::TrackStateProxy trackState, Acts::Direction direction, const Acts::Logger &logger)
Definition: FitterHelperFunctions.h:21
ActsTrk::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:48
ActsTrk::FitterHelperFunctions::ReverseFilteringLogic
Determine if the smoothing of a track should be done with or without reverse filtering.
Definition: FitterHelperFunctions.h:79
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14
ActsTrk::FitterHelperFunctions::ATLASOutlierFinder
Outlier finder using a Chi2 cut.
Definition: FitterHelperFunctions.h:39