Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GainMatrixUpdater.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GainMatrixUpdater.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
19 
20 #include <cassert>
21 #include <system_error>
22 #include <tuple>
23 
24 namespace Acts {
25 
30  false>::Parameters predicted;
34  false>::Parameters filtered;
37  // This is used to build a covariance matrix view in the .cpp file
38  double* calibrated;
41  false>::Projector projector;
42  unsigned int calibratedSize;
43  };
44 
45  public:
53  template <typename traj_t>
55  typename traj_t::TrackStateProxy trackState,
56  Direction direction = Direction::Forward,
57  const Logger& logger = getDummyLogger()) const {
58  (void)gctx;
59  ACTS_VERBOSE("Invoked GainMatrixUpdater");
60 
61  // there should be a calibrated measurement
62  assert(trackState.hasCalibrated());
63  // we should have predicted state set
64  assert(trackState.hasPredicted());
65  // filtering should not have happened yet, but is allocated, therefore set
66  assert(trackState.hasFiltered());
67 
68  // read-only handles. Types are eigen maps to backing storage
69  // const auto predicted = trackState.predicted();
70  // const auto predictedCovariance = trackState.predictedCovariance();
71 
73  "Predicted parameters: " << trackState.predicted().transpose());
74  ACTS_VERBOSE("Predicted covariance:\n" << trackState.predictedCovariance());
75 
76  // read-write handles. Types are eigen maps into backing storage.
77  // This writes directly into the trajectory storage
78  // auto filtered = trackState.filtered();
79  // auto filteredCovariance = trackState.filteredCovariance();
80 
81  auto [chi2, error] = visitMeasurement(
83  trackState.predicted(),
84  trackState.predictedCovariance(),
85  trackState.filtered(),
86  trackState.filteredCovariance(),
87  // This abuses an incorrectly sized vector / matrix to access the
88  // data pointer! This works (don't use the matrix as is!), but be
89  // careful!
90  trackState
91  .template calibrated<
93  .data(),
94  trackState
95  .template calibratedCovariance<
97  .data(),
98  trackState.projector(),
99  trackState.calibratedSize(),
100  },
101  direction, logger);
102 
103  trackState.chi2() = chi2;
104 
106  }
107 
108  private:
109  std::tuple<double, std::error_code> visitMeasurement(
110  InternalTrackState trackState, Direction direction,
111  const Logger& logger) const;
112 };
113 
114 } // namespace Acts