ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
residual_calculator.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file residual_calculator.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 // Acts include(s)
13 
14 namespace Acts {
16 namespace detail {
27 template <ParID_t... params>
28 struct residual_calculator;
29 
31 template <typename R, ParID_t... params>
32 struct residual_calculator_impl;
33 
34 template <ParID_t... params>
35 struct residual_calculator {
36  using ParVector_t = ActsVector<ParValue_t, sizeof...(params)>;
37 
38  static ParVector_t result(const ParVector_t& test, const ParVector_t& ref) {
39  ParVector_t result;
40  residual_calculator_impl<ParVector_t, params...>::calculate(result, test,
41  ref, 0);
42  return result;
43  }
44 };
45 
46 template <typename R, ParID_t first, ParID_t... others>
47 struct residual_calculator_impl<R, first, others...> {
48  static void calculate(R& result, const R& test, const R& ref,
49  unsigned int pos) {
50  result(pos) = BoundParameterType<first>::getDifference(test(pos), ref(pos));
51  residual_calculator_impl<R, others...>::calculate(result, test, ref,
52  pos + 1);
53  }
54 };
55 
56 template <typename R, ParID_t last>
57 struct residual_calculator_impl<R, last> {
58  static void calculate(R& result, const R& test, const R& ref,
59  unsigned int pos) {
60  result(pos) = BoundParameterType<last>::getDifference(test(pos), ref(pos));
61  }
62 };
64 } // namespace detail
66 } // namespace Acts