ATLAS Offline Software
SpacePointCollector.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTSTRK_SPACEPOINT_COLLECTOR_H
6 #define ACTSTRK_SPACEPOINT_COLLECTOR_H
7 
8 #include "TrkSurfaces/Surface.h"
9 
10 // EDMs
12 
13 #include <math.h>
14 #include <cmath>
15 #include "Acts/EventData/SpacePointContainer.hpp"
16 #include "Acts/Definitions/Algebra.hpp"
17 
18 namespace ActsTrk {
19 
21  public:
22  friend Acts::SpacePointContainer<ActsTrk::SpacePointCollector, Acts::detail::RefHolder>;
23 
25 
26  SpacePointCollector(std::vector<const ValueType*>& externalStorage);
27 
33 
34  std::size_t size_impl() const;
35 
36  float x_impl(std::size_t idx) const;
37  float y_impl(std::size_t idx) const;
38  float z_impl(std::size_t idx) const;
39 
40  float varianceR_impl(std::size_t idx) const;
41  float varianceZ_impl(std::size_t idx) const;
42 
43  const ValueType& get_impl(std::size_t idx) const;
44 
45  std::any component_impl(Acts::HashedString key, std::size_t n) const {
46  using namespace Acts::HashedStringLiteral;
47 
48  const ValueType& sp = get_impl(n);
49  static const SG::ConstAccessor<xAOD::ArrayFloat3> topStripDirAcc("topStripDirection");
50  if (not topStripDirAcc.isAvailable(sp)) {
51  throw std::runtime_error("no such component " + std::to_string(key) + " for this space point");
52  }
53 
54  switch (key) {
55  case "TopStripVector"_hash:
56  return Acts::Vector3( sp.topHalfStripLength() * sp.topStripDirection().cast<double>() );
57  case "BottomStripVector"_hash:
58  return Acts::Vector3( sp.bottomHalfStripLength() * sp.bottomStripDirection().cast<double>() );
59  case "StripCenterDistance"_hash:
60  return Acts::Vector3( sp.stripCenterDistance().cast<double>() );
61  case "TopStripCenterPosition"_hash:
62  return Acts::Vector3( sp.topStripCenter().cast<double>() );
63  default:
64  throw std::runtime_error("no such component " + std::to_string(key));
65  }
66  }
67 
68  private:
69  const std::vector<const ValueType*>& storage() const;
70  std::vector<const ValueType*>& storage();
71 
72  private:
73  // xAOD::SpacePointContainer
74  std::vector<const ValueType*>* m_storage {nullptr};
75  };
76 
77  inline std::size_t
79  { return storage().size(); }
80 
81  inline float
82  SpacePointCollector::x_impl(std::size_t idx) const
83  { return storage()[idx]->x(); }
84 
85  inline float
86  SpacePointCollector::y_impl(std::size_t idx) const
87  { return storage()[idx]->y(); }
88 
89  inline float
90  SpacePointCollector::z_impl(std::size_t idx) const
91  { return storage()[idx]->z(); }
92 
93  inline float
95  { return storage()[idx]->varianceR(); }
96 
97  inline float
99  { return storage()[idx]->varianceZ(); }
100 
101  inline const typename SpacePointCollector::ValueType&
103  {
104  return *storage()[idx];
105  }
106 
107  inline const std::vector<const typename SpacePointCollector::ValueType*>&
109  { return *m_storage; }
110 
111  inline std::vector<const typename SpacePointCollector::ValueType*>&
113  { return *m_storage; }
114 
115 } // namespace ActsTrk
116 
117 #endif
ActsTrk::SpacePointCollector::SpacePointCollector
SpacePointCollector(std::vector< const ValueType * > &externalStorage)
Definition: SpacePointCollector.cxx:9
ActsTrk::SpacePointCollector
Definition: SpacePointCollector.h:20
xAOD::SpacePoint_v1::bottomHalfStripLength
float bottomHalfStripLength() const
xAOD::SpacePoint_v1::stripCenterDistance
ConstVectorMap stripCenterDistance() const
Definition: SpacePoint_v1.cxx:73
Surface.h
xAOD::SpacePoint_v1::topStripDirection
ConstVectorMap topStripDirection() const
Definition: SpacePoint_v1.cxx:63
ActsTrk::SpacePointCollector::z_impl
float z_impl(std::size_t idx) const
Definition: SpacePointCollector.h:90
xAOD::SpacePoint_v1::topHalfStripLength
float topHalfStripLength() const
Return details.
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
xAOD::SpacePoint
SpacePoint_v1 SpacePoint
Definition: Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/SpacePoint.h:12
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
ActsTrk::SpacePointCollector::x_impl
float x_impl(std::size_t idx) const
Definition: SpacePointCollector.h:82
xAOD::SpacePoint_v1::bottomStripDirection
ConstVectorMap bottomStripDirection() const
Definition: SpacePoint_v1.cxx:68
ActsTrk::SpacePointCollector::size_impl
std::size_t size_impl() const
Definition: SpacePointCollector.h:78
Acts
Definition: ChamberAssembleTool.h:18
beamspotman.n
n
Definition: beamspotman.py:731
ActsTrk::SpacePointCollector::varianceR_impl
float varianceR_impl(std::size_t idx) const
Definition: SpacePointCollector.h:94
ActsTrk::SpacePointCollector::SpacePointCollector
SpacePointCollector(const SpacePointCollector &)=delete
ActsTrk::SpacePointCollector::m_storage
std::vector< const ValueType * > * m_storage
Definition: SpacePointCollector.h:74
ActsTrk::SpacePointCollector::get_impl
const ValueType & get_impl(std::size_t idx) const
Definition: SpacePointCollector.h:102
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
ActsTrk::SpacePointCollector::storage
const std::vector< const ValueType * > & storage() const
Definition: SpacePointCollector.h:108
calibdata.delete
list delete
Definition: calibdata.py:46
ActsTrk::SpacePointCollector::SpacePointCollector
SpacePointCollector(SpacePointCollector &&) noexcept=default
SpacePointContainer.h
ActsTrk::SpacePointCollector::varianceZ_impl
float varianceZ_impl(std::size_t idx) const
Definition: SpacePointCollector.h:98
ActsTrk::SpacePointCollector::y_impl
float y_impl(std::size_t idx) const
Definition: SpacePointCollector.h:86
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:54
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
ActsTrk::SpacePointCollector::component_impl
std::any component_impl(Acts::HashedString key, std::size_t n) const
Definition: SpacePointCollector.h:45
xAOD::SpacePoint_v1::topStripCenter
ConstVectorMap topStripCenter() const
Definition: SpacePoint_v1.cxx:78
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37