Juggler
Juggling algorithms and event processing using gaudi framework
SourceLinks.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later
2 // Copyright (C) 2022 Whitney Armstrong
3 
4 #ifndef JUG_RECO_SourceLinks_HH
5 #define JUG_RECO_SourceLinks_HH
6 
7 #include "Acts/EventData/Measurement.hpp"
9 
10 #include <stdexcept>
11 #include <string>
12 
13 #include "eicd/TrackerHitCollection.h"
14 
15 
16 namespace Jug {
17 
18 /** Source Link for simulation in the acts-framework.
19  *
20  * https://github.com/acts-project/acts/blob/master/Core/include/Acts/EventData/SourceLinkConcept.hpp
21  * The source link stores the measuremts, surface, and the associated simulated
22  * truth hit.
23  *
24  */
25 class SourceLink {
26 
27  private:
28  Acts::BoundVector m_values;
29  Acts::BoundMatrix m_cov;
30  size_t m_dim = 2;
31  // store geo id copy to avoid indirection via truth hit
32  int32_t m_index;
33  Acts::GeometryIdentifier m_geometryId;
34  // need to store pointers to make the object copyable
35  const Acts::Surface* m_surface;
36  //const ActsFatras::Hit* m_truthHit;
37  const eicd::TrackerHit* m_Hit ;
38 
39  public:
40  SourceLink(const Acts::Surface& surface, //const ActsFatras::Hit& truthHit,
41  size_t dim, int32_t index, Acts::BoundVector values, Acts::BoundMatrix cov)
42  : m_values(values),
43  m_cov(cov),
44  m_dim(dim),
45  m_index(index),
46  m_geometryId(0),//truthHit.geometryId()),
47  m_surface(&surface){}
48  //m_truthHit(&truthHit) {}
49  /// Must be default_constructible to satisfy SourceLinkConcept.
50  SourceLink() = default;
51  SourceLink(SourceLink&&) = default;
52  SourceLink(const SourceLink&) = default;
54  SourceLink& operator=(const SourceLink&) = default;
55 
56  constexpr Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
57  constexpr const Acts::Surface& referenceSurface() const { return *m_surface; }
58  //constexpr const ActsFatras::Hit& truthHit() const { return *m_truthHit; }
59 
60  Acts::FittableMeasurement<SourceLink> operator*() const {
61  if (m_dim == 0) {
62  throw std::runtime_error("Cannot create dim 0 measurement");
63  } else if (m_dim == 1) {
64  return Acts::Measurement<SourceLink, Acts::BoundIndices,
65  Acts::eBoundLoc0>{
66  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<1, 1>(),
67  m_values[0]};
68  } else if (m_dim == 2) {
69  return Acts::Measurement<SourceLink, Acts::BoundIndices,
70  Acts::eBoundLoc0, Acts::eBoundLoc1>{
71  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<2, 2>(),
72  m_values[0], m_values[1]};
73  } else {
74  throw std::runtime_error("Dim " + std::to_string(m_dim) +
75  " currently not supported.");
76  }
77  }
78 
79  friend constexpr bool operator==(const SourceLink& lhs,
80  const SourceLink& rhs) {
81 
82  return (lhs.geometryId() == rhs.geometryId()) && (lhs.m_index == rhs.m_index);
83  //lhs.m_truthHit == rhs.m_truthHit;
84  }
85  friend constexpr bool operator!=(const SourceLink& lhs,
86  const SourceLink& rhs) {
87  return not(lhs == rhs);
88  }
89 };
90 
91 /// Store source links ordered by geometry identifier.
92 using SourceLinkContainer = GeometryIdMultiset<SourceLink>;
93 } // namespace Jug
94 
95 #endif
Jug::SourceLinkContainer
GeometryIdMultiset< SourceLink > SourceLinkContainer
Store source links ordered by geometry identifier.
Definition: SourceLinks.h:94
Jug::Measurement
::Acts::BoundVariantMeasurement< IndexSourceLink > Measurement
Variable measurement type that can contain all possible combinations.
Definition: Measurement.hpp:18
Jug
Definition: DD4hepBField.h:22
GeometryContainers.hpp