ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Measurement.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Measurement.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 #include <memory>
11 #include <ostream>
12 #include <type_traits>
13 #include <utility>
20 
21 namespace Acts {
22 
23 // forward declarations
24 class Surface;
25 
50 template <typename source_link_t, ParID_t... params>
51 class Measurement {
52  // check type conditions
53  static_assert(SourceLinkConcept<source_link_t>,
54  "Source link does not fulfill SourceLinkConcept");
55 
56  private:
57  // private typedefs
58 
60  using ParSet_t = ParameterSet<params...>;
61 
62  public:
69 
71  Measurement() = delete;
72 
92  template <typename... Tail>
93  Measurement(std::shared_ptr<const Surface> surface,
94  const source_link_t& source, CovMatrix_t cov,
95  typename std::enable_if<sizeof...(Tail) + 1 == sizeof...(params),
96  ParValue_t>::type head,
97  Tail... values)
98  : m_oParameters(std::move(cov), head, values...),
99  m_pSurface(std::move(surface)),
100  m_sourceLink(source) {
101  assert(m_pSurface);
102  }
103 
105  virtual ~Measurement() = default;
106 
115  m_pSurface(copy.m_pSurface),
116  m_sourceLink(copy.m_sourceLink) {}
117 
125  : m_oParameters(std::move(other.m_oParameters)),
126  m_pSurface(std::move(other.m_pSurface)),
127  m_sourceLink(std::move(other.m_sourceLink)) {}
128 
135  Measurement<source_link_t, params...>& operator=(
137  // check for self-assignment
138  if (&rhs != this) {
140  m_pSurface = rhs.m_pSurface;
142  }
143  return *this;
144  }
145 
152  Measurement<source_link_t, params...>& operator=(
154  m_oParameters = std::move(rhs.m_oParameters);
155  m_pSurface = std::move(rhs.m_pSurface);
156  m_sourceLink = std::move(rhs.m_sourceLink);
157  return *this;
158  }
159 
169  template <ParID_t parameter>
170  ParValue_t get() const {
171  return m_oParameters.template getParameter<parameter>();
172  }
173 
182 
187 
197  template <ParID_t parameter>
199  return m_oParameters.template getUncertainty<parameter>();
200  }
201 
205  static constexpr unsigned int size() { return ParSet_t::size(); }
206 
213  const Acts::Surface& referenceSurface() const { return *m_pSurface; }
214 
221  const source_link_t& sourceLink() const { return m_sourceLink; }
222 
239  ParVector_t residual(const TrackParameters& trackPars) const {
240  return m_oParameters.residual(trackPars.getParameterSet());
241  }
242 
247  virtual bool operator==(
248  const Measurement<source_link_t, params...>& rhs) const {
249  return ((m_oParameters == rhs.m_oParameters) &&
250  (*m_pSurface == *rhs.m_pSurface) &&
251  (m_sourceLink == rhs.m_sourceLink));
252  }
253 
260  return !(*this == rhs);
261  }
262 
265 
266  friend std::ostream& operator<<(
267  std::ostream& out, const Measurement<source_link_t, params...>& m) {
268  m.print(out);
269  return out;
270  }
271 
272  protected:
273  virtual std::ostream& print(std::ostream& out) const {
274  out << sizeof...(params) << "D measurement: ";
275  int dummy[sizeof...(params)] = {(out << params << ", ", 0)...};
276  dummy[0] = dummy[0];
277  out << std::endl;
278  out << "measured values:" << std::endl;
279  out << parameters() << std::endl;
280  out << "covariance matrix:" << std::endl;
281  out << covariance() << std::endl;
282  return out;
283  }
284 
285  private:
287  std::shared_ptr<const Surface>
289 
290  source_link_t m_sourceLink;
291 };
292 
297 template <typename source_link_t>
299  template <Acts::ParID_t... pars>
300  struct meas_factory {
301  using type = Measurement<source_link_t, pars...>;
302  };
303 
304  using type =
305  typename detail::type_generator_t<meas_factory, eBoundParametersSize>;
306 };
307 
311 template <typename source_link_t>
312 using FittableMeasurement =
314 
315 } // namespace Acts