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 
14 
15 #include <stdexcept>
16 #include <string>
17 
18 namespace ActsExamples {
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::GeometryIdentifier 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) {
53  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<1, 1>(),
54  m_values[0]};
55  } else if (m_dim == 2) {
58  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<2, 2>(),
59  m_values[0], m_values[1]};
60  } else {
61  throw std::runtime_error("Dim " + std::to_string(m_dim) +
62  " currently not supported.");
63  }
64  }
65 
66  private:
69  size_t m_dim = 0u;
70  // store geo id copy to avoid indirection via truth hit
72  // need to store pointers to make the object copyable
75 
76  friend constexpr bool operator==(const SimSourceLink& lhs,
77  const SimSourceLink& rhs) {
78  return lhs.m_truthHit == rhs.m_truthHit;
79  }
80 };
81 
84 
85 } // end of namespace ActsExamples