ATLAS Offline Software
AuxiliaryMeasurementHandler.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ActsEvent_AuxiliaryMeasurementHandler_ICC
6 #define ActsEvent_AuxiliaryMeasurementHandler_ICC
7 
8 #include "ActsGeoUtils/SurfaceEncoding.h"
9 namespace ActsTrk{
10  template <class PropOwner>
11  AuxiliaryMeasurementHandler::AuxiliaryMeasurementHandler(PropOwner* owner):
12  m_msg{owner->msgStream()},
13  m_writeKey1D{owner, "AuxiliaryMeasKey1D", ""},
14  m_writeKey2D{owner, "AuxiliaryMeasKey2D", ""},
15  m_writeKey3D{owner, "AuxiliaryMeasKey3D", ""}{}
16 
17 
18  template<size_t N> xAOD::AuxiliaryMeasurement*
19  AuxiliaryMeasurementHandler::MeasurementProvider::newMeasurement(const SurfacePtr_t& surface,
20  const ProjectorType projector,
21  const AmgSymMatrix(N)& locCov,
22  const AmgVector(N) locPos) {
23  xAOD::AuxiliaryMeasurement* meas{nullptr};
24  static_assert(N>=1 && N<=3, "Invalid measurement dimension");
25  if constexpr(N == 1) {
26  meas = m_handle1D->push_back(std::make_unique<xAOD::AuxiliaryMeasurement>());
27  assert(projector == ProjectorType::e1DimNoTime ||
28  projector == ProjectorType::e1DimRotNoTime);
29  } else if constexpr(N == 2) {
30  meas = m_handle2D->push_back(std::make_unique<xAOD::AuxiliaryMeasurement>());
31  assert(projector == ProjectorType::e2DimNoTime ||
32  projector == ProjectorType::e1DimWithTime ||
33  projector == ProjectorType::e1DimRotWithTime);
34  } else if constexpr(N == 3) {
35  meas = m_handle3D->push_back(std::make_unique<xAOD::AuxiliaryMeasurement>());
36  assert(projector == ProjectorType::e2DimWithTime);
37  }
38  meas->setMeasurement<N>(0, xAOD::toStorage(locPos), xAOD::toStorage(locCov));
39  meas->setProjector(projector);
40  auto cached_itr = m_cachedSurfs.find(surface);
41  if (cached_itr == m_cachedSurfs.end()) {
42  auto persistSurf = m_surfaceContainer.push_back(std::make_unique<xAOD::TrackSurface>());
43  encodeSurface(persistSurf, surface.get(), m_parent->m_gctx.context());
44 
45  cached_itr = m_cachedSurfs.insert(std::make_pair(surface, persistSurf)).first;
46  }
47  xAOD::AuxiliaryMeasurement::SurfLink_t link{m_surfaceContainer, cached_itr->second->index(), m_ctx};
48  meas->setSurface(surface, std::move(link));
49  return meas;
50  }
51 }
52 
53 #endif