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 #ifndef JUG_RECO_SourceLinks_HH
4 #define JUG_RECO_SourceLinks_HH
5 
6 #include "Acts/EventData/Measurement.hpp"
8 
9 #include <stdexcept>
10 #include <string>
11 #include "edm4hep/Geant4Particle.h"
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  * @todo Allow multiple truth hits e.g. for merged hits.
25  *
26  */
27 class SourceLink {
28 
29  private:
30  Acts::BoundVector m_values;
31  Acts::BoundMatrix m_cov;
32  size_t m_dim = 2;
33  // store geo id copy to avoid indirection via truth hit
34  int32_t m_index;
35  Acts::GeometryIdentifier m_geometryId;
36  // need to store pointers to make the object copyable
37  const Acts::Surface* m_surface;
38  //const ActsFatras::Hit* m_truthHit;
39  const eicd::TrackerHit* m_Hit ;
40 
41  public:
42  SourceLink(const Acts::Surface& surface, //const ActsFatras::Hit& truthHit,
43  size_t dim, int32_t index, Acts::BoundVector values, Acts::BoundMatrix cov)
44  : m_values(values),
45  m_cov(cov),
46  m_dim(dim),
47  m_index(index),
48  m_geometryId(0),//truthHit.geometryId()),
49  m_surface(&surface){}
50  //m_truthHit(&truthHit) {}
51  /// Must be default_constructible to satisfy SourceLinkConcept.
52  SourceLink() = default;
53  SourceLink(SourceLink&&) = default;
54  SourceLink(const SourceLink&) = default;
56  SourceLink& operator=(const SourceLink&) = default;
57 
58  constexpr Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
59  constexpr const Acts::Surface& referenceSurface() const { return *m_surface; }
60  //constexpr const ActsFatras::Hit& truthHit() const { return *m_truthHit; }
61 
62  Acts::FittableMeasurement<SourceLink> operator*() const {
63  if (m_dim == 0) {
64  throw std::runtime_error("Cannot create dim 0 measurement");
65  } else if (m_dim == 1) {
66  return Acts::Measurement<SourceLink, Acts::BoundIndices,
67  Acts::eBoundLoc0>{
68  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<1, 1>(),
69  m_values[0]};
70  } else if (m_dim == 2) {
71  return Acts::Measurement<SourceLink, Acts::BoundIndices,
72  Acts::eBoundLoc0, Acts::eBoundLoc1>{
73  m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<2, 2>(),
74  m_values[0], m_values[1]};
75  } else {
76  throw std::runtime_error("Dim " + std::to_string(m_dim) +
77  " currently not supported.");
78  }
79  }
80 
81  friend constexpr bool operator==(const SourceLink& lhs,
82  const SourceLink& rhs) {
83 
84  return (lhs.geometryId() == rhs.geometryId()) && (lhs.m_index == rhs.m_index);
85  //lhs.m_truthHit == rhs.m_truthHit;
86  }
87  friend constexpr bool operator!=(const SourceLink& lhs,
88  const SourceLink& rhs) {
89  return not(lhs == rhs);
90  }
91 };
92 
93 /// Store source links ordered by geometry identifier.
95 } // namespace Jug
96 
97 #endif
Jug::GeometryIdMultiset
boost::container::flat_multiset< T, detail::CompareGeometryId > GeometryIdMultiset
Definition: GeometryContainers.hpp:71
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