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
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
50 double StateChiSquaredPerNumberDoFCut = std::numeric_limits<double>::max();
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
#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.