ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimSourceLink.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SimSourceLink.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2019 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 
11 #include <stdexcept>
12 #include <string>
13 
17 
18 namespace FW {
19 
27  public:
30  : m_values(values),
31  m_cov(cov),
32  m_dim(dim),
33  m_geometryId(truthHit.geometryId()),
34  m_surface(&surface),
35  m_truthHit(&truthHit) {}
37  SimSourceLink() = default;
38  SimSourceLink(SimSourceLink&&) = default;
39  SimSourceLink(const SimSourceLink&) = default;
41  SimSourceLink& operator=(const SimSourceLink&) = default;
42 
43  constexpr Acts::GeometryID geometryId() const { return m_geometryId; }
44  constexpr const Acts::Surface& referenceSurface() const { return *m_surface; }
45  constexpr const ActsFatras::Hit& truthHit() const { return *m_truthHit; }
46 
48  if (m_dim == 0) {
49  throw std::runtime_error("Cannot create dim 0 measurement");
50  } else if (m_dim == 1) {
52  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<1, 1>(),
53  m_values[0]};
54  } else if (m_dim == 2) {
57  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<2, 2>(),
58  m_values[0], m_values[1]};
59  } else {
60  throw std::runtime_error("Dim " + std::to_string(m_dim) +
61  " currently not supported.");
62  }
63  }
64 
65  private:
68  size_t m_dim = 0u;
69  // store geo id copy to avoid indirection via truth hit
71  // need to store pointers to make the object copyable
74 
75  friend constexpr bool operator==(const SimSourceLink& lhs,
76  const SimSourceLink& rhs) {
77  return lhs.m_truthHit == rhs.m_truthHit;
78  }
79 };
80 
83 
84 } // end of namespace FW