ATLAS Offline Software
Loading...
Searching...
No Matches
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
18
20
21 template<typename trajectory_t>
22 Acts::Result<void> gainMatrixUpdate(const Acts::GeometryContext& gctx,
23 typename trajectory_t::TrackStateProxy trackState,
24 const Acts::Logger& logger) {
25 Acts::GainMatrixUpdater updater;
26 return updater.template operator()<trajectory_t>(gctx, trackState, 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
38 template<typename trajectory_t>
39 Acts::Result<void> mbfSmoother(const Acts::GeometryContext& gctx,
40 trajectory_t& trajectory,
41 size_t entryIndex,
42 const Acts::Logger& logger) {
43 Acts::MbfSmoother smoother;
44 return smoother.template operator()<trajectory_t>(gctx, trajectory, entryIndex, logger);
45 }
46
49 double StateChiSquaredPerNumberDoFCut = std::numeric_limits<double>::max();
56 template<typename trajectory_t>
57 bool operator()(typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy state) const {
58 // can't determine an outlier w/o a measurement or predicted parameters
59 if (not state.hasCalibrated() or not state.hasPredicted()) {
60 return false;
61 }
62 return Acts::visit_measurement(
63 state.calibratedSize(),
64 [&] (auto N) -> bool {
65 constexpr size_t kMeasurementSize = decltype(N)::value;
66
67 auto subspaceHelper = state.template projectorSubspaceHelper<kMeasurementSize>();
68
69 typename Acts::TrackStateTraits<kMeasurementSize, true>::Calibrated calibrated{
70 state.template calibrated<Acts::kMeasurementSizeMax>().data()};
71
72 typename Acts::TrackStateTraits<kMeasurementSize, true>::CalibratedCovariance
73 calibratedCovariance{state.template calibratedCovariance<Acts::kMeasurementSizeMax>().data()};
74
75 // Take the projector (measurement mapping function)
76 // TODO use the subspace helper directly
77 const auto H = subspaceHelper.projector();
78
79 const auto residual = calibrated - H * state.predicted();
80 double chi2 = (residual.transpose() * (calibratedCovariance + H * state.predictedCovariance() * H.transpose()).inverse() * residual).value();
81 return (chi2 > StateChiSquaredPerNumberDoFCut * kMeasurementSize);
82 });
83 }
84 };
85
89 double momentumMax = std::numeric_limits<double>::max();
90
98 template<typename trajectory_t>
99 bool operator()(typename Acts::MultiTrajectory<trajectory_t>::ConstTrackStateProxy trackState) const {
100 // can't determine an outlier w/o a measurement or predicted parameters
101 auto momentum = std::abs(1. / trackState.filtered()[Acts::eBoundQOverP]);
102 return (momentum <= momentumMax);
103 }
104 };
105
106} // namespace
107
108#endif
#define H(x, y, z)
Definition MD5.cxx:114
double chi2(TH1 *h0, TH1 *h1)
static Root::TMsgLogger logger("iLumiCalc")
Acts::Result< void > gainMatrixUpdate(const Acts::GeometryContext &gctx, typename trajectory_t::TrackStateProxy trackState, const Acts::Logger &logger)
Acts::Result< void > gainMatrixSmoother(const Acts::GeometryContext &gctx, trajectory_t &trajectory, size_t entryIndex, const Acts::Logger &logger)
Acts::Result< void > mbfSmoother(const Acts::GeometryContext &gctx, trajectory_t &trajectory, size_t entryIndex, const Acts::Logger &logger)
bool operator()(typename Acts::MultiTrajectory< trajectory_t >::ConstTrackStateProxy state) const
Classify a measurement as a valid one or an outlier.
Determine if the smoothing of a track should be done with or without reverse filtering.
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.