ATLAS Offline Software
TrackingSurfaceHelper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 #ifndef TRACKINGSURFACEHELPER_H
5 #define TRACKINGSURFACEHELPER_H
6 
10 #include "Acts/Surfaces/Surface.hpp"
11 
12 #include <stdexcept>
13 
17 {
18 public:
19  static constexpr unsigned int s_NMeasTypes = 4; // depends on definition in UncalibMeasType
21  TrackingSurfaceHelper(std::array<std::vector< const Acts::Surface *>, s_NMeasTypes> &&acts_surfaces)
22  : m_actsSurfaces(std::move(acts_surfaces))
23  {}
24  // return mutable reference to allow filling the vector by element.
25  std::vector< const Acts::Surface *> &actsSurfaces(xAOD::UncalibMeasType type) {
26  assert(static_cast<std::size_t>(type) < m_actsSurfaces.size());
27  return m_actsSurfaces[static_cast<std::size_t>(type)];
28  }
30  assert(static_cast<std::size_t>(type) < m_siDetectorElements.size() );
31  m_siDetectorElements[static_cast<unsigned int>(type)] = det_element_collection;
32  }
33  const Acts::Surface &associatedActsSurface(const xAOD::UncalibratedMeasurement &measurement) const {
34  assert(static_cast<std::size_t>(measurement.type()) < m_actsSurfaces.size()
35  && measurement.identifierHash() < m_actsSurfaces[ static_cast<unsigned int>(measurement.type()) ].size() );
36  const Acts::Surface *acts_surface = m_actsSurfaces[ static_cast<unsigned int>(measurement.type()) ].at( measurement.identifierHash() );
37  assert( acts_surface);
38  return *acts_surface;
39  }
41  // @TODO always do a runtime check ?
42  assert(static_cast<std::size_t>(measurement.type()) < m_siDetectorElements.size()
43  && m_siDetectorElements[ static_cast<unsigned int>(measurement.type()) ]);
45  element = m_siDetectorElements[ static_cast<unsigned int>( measurement.type()) ]
46  ->getDetectorElement(measurement.identifierHash());
47 
48  const Trk::Surface *surface = element ? &(element->surface()) : nullptr;
49  if (!surface) throw std::runtime_error("No associated surface for xAOD::UncalibratedMeasurement");
50  return *surface;
51  }
52 private:
53  std::array<const InDetDD::SiDetectorElementCollection *, s_NMeasTypes> m_siDetectorElements {};
54  std::array<std::vector< const Acts::Surface *>, s_NMeasTypes> m_actsSurfaces;
55 };
56 #endif
TrackingSurfaceHelper
Simple helper class which allows to access the tracking surface associated to a certain (Si-)measurem...
Definition: TrackingSurfaceHelper.h:17
xAOD::UncalibratedMeasurement_v1::identifierHash
DetectorIDHashType identifierHash() const
Returns the IdentifierHash of the measurement (corresponds to the detector element IdentifierHash)
UncalibratedMeasurement.h
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
TrackingSurfaceHelper::TrackingSurfaceHelper
TrackingSurfaceHelper()
Definition: TrackingSurfaceHelper.h:20
TrackingSurfaceHelper::setSiDetectorElements
void setSiDetectorElements(xAOD::UncalibMeasType type, const InDetDD::SiDetectorElementCollection *det_element_collection)
Definition: TrackingSurfaceHelper.h:29
InDetDD::SolidStateDetectorElementBase::surface
Trk::Surface & surface()
Element Surface.
TrackingSurfaceHelper::associatedSurface
const Trk::Surface & associatedSurface(const xAOD::UncalibratedMeasurement &measurement) const
Definition: TrackingSurfaceHelper.h:40
TrackingSurfaceHelper::actsSurfaces
std::vector< const Acts::Surface * > & actsSurfaces(xAOD::UncalibMeasType type)
Definition: TrackingSurfaceHelper.h:25
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
TrackingSurfaceHelper::s_NMeasTypes
static constexpr unsigned int s_NMeasTypes
Definition: TrackingSurfaceHelper.h:19
xAOD::UncalibratedMeasurement_v1::type
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
lumiFormat.array
array
Definition: lumiFormat.py:98
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SiDetectorElementCollection.h
SiDetectorElement.h
TrackingSurfaceHelper::associatedActsSurface
const Acts::Surface & associatedActsSurface(const xAOD::UncalibratedMeasurement &measurement) const
Definition: TrackingSurfaceHelper.h:33
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::UncalibMeasType
UncalibMeasType
Define the type of the uncalibrated measurement.
Definition: MeasurementDefs.h:24
TrackingSurfaceHelper::m_actsSurfaces
std::array< std::vector< const Acts::Surface * >, s_NMeasTypes > m_actsSurfaces
Definition: TrackingSurfaceHelper.h:54
TrackingSurfaceHelper::m_siDetectorElements
std::array< const InDetDD::SiDetectorElementCollection *, s_NMeasTypes > m_siDetectorElements
Definition: TrackingSurfaceHelper.h:53
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
TrackingSurfaceHelper::TrackingSurfaceHelper
TrackingSurfaceHelper(std::array< std::vector< const Acts::Surface * >, s_NMeasTypes > &&acts_surfaces)
Definition: TrackingSurfaceHelper.h:21