Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TrackFindingMeasurements.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 namespace ActsTrk::detail {
11 
12  TrackFindingMeasurements::TrackFindingMeasurements(std::size_t nMeasurementContainerMax)
13  : m_measurementOffsets(nMeasurementContainerMax, 0ul) {}
14 
15  void TrackFindingMeasurements::addMeasurements(std::size_t typeIndex,
16  const xAOD::UncalibratedMeasurementContainer &clusterContainer,
17  const DetectorElementToActsGeometryIdMap &detectorElementToGeoid)
18  {
19  if (typeIndex < m_measurementOffsets.size())
21 
22  if (m_measurementRanges.empty()) {
23  // try to reserve needed space,
24  // this however will reserve more than necessary not just the space needed for the surfaces of
25  // all the measurements that are going to be added (e.g. pixel+strips).
26  m_measurementRanges.reserve(detectorElementToGeoid.size());
27  }
28  m_measurementRanges.setContainer(typeIndex, &clusterContainer);
29 
32  MeasurementRange *currentRange = nullptr;
33 
34  std::size_t n_elements = clusterContainer.size();;
35  std::size_t sl_idx = 0;
36  for( ; sl_idx < n_elements; ++sl_idx) {
37  const auto *measurement = clusterContainer[sl_idx];
38  if (measurement->identifierHash() != lastIdHash or
39  measurement->type() != lastMeasurementType)
40  {
41  if (currentRange) {
42  currentRange->updateEnd(typeIndex, sl_idx);
43  }
44  lastIdHash = measurement->identifierHash();
45  lastMeasurementType = measurement->type();
46 
47  Acts::GeometryIdentifier measurementSurfaceId = ActsTrk::getSurfaceGeometryIdOfMeasurement(detectorElementToGeoid,
48  *measurement);
49  if (measurementSurfaceId.value() == 0u) {
50  // @TODO improve error message.
51  throw std::domain_error("No Acts surface associated to measurement");
52  }
53 
54  // start with en empty range which is updated later.
55  auto ret = m_measurementRanges.insert( std::make_pair( measurementSurfaceId.value(),
56  MeasurementRange( typeIndex, sl_idx, sl_idx) ));
57  if (!ret.second) {
58  std::stringstream msg;
59  msg << "Measurement not clustered by identifierHash / geometryId. New measurement "
60  << sl_idx << " with geo Id " << measurementSurfaceId
61  << " type = " << static_cast<unsigned int>(measurement->type())
62  << " idHash=" << measurement->identifierHash()
63  << " but already recorded for this geo ID the range : [" << ret.first->second.containerIndex() << "]"
64  << ret.first->second.elementBeginIndex()
65  << " .. " << ret.first->second.elementEndIndex()
66  << (ret.first->second.isConsistentRange() ? "" : " !Container index inconsistent or not in increasing order!");
67  throw std::runtime_error(msg.str());
68  }
69  currentRange = &ret.first->second;
70  }
71  }
72 
73  if (currentRange) {
74  currentRange->updateEnd(typeIndex, sl_idx);
75  }
76 
77  m_measurementsTotal += clusterContainer.size();
78  }
79 
80 } // namespace ActsTrk::detail
ActsTrk::getSurfaceGeometryIdOfMeasurement
Acts::GeometryIdentifier getSurfaceGeometryIdOfMeasurement(const DetectorElementToActsGeometryIdMap &detector_element_to_geoid, const xAOD::UncalibratedMeasurement &measurement)
Definition: SurfaceOfMeasurementUtil.h:24
ActsTrk::DetectorElementToActsGeometryIdMap
Definition: DetectorElementToActsGeometryIdMap.h:31
ActsTrk::detail::MeasurementRange::updateEnd
void updateEnd(std::size_t container_idx, unsigned int end_element_idx)
Definition: AtlasUncalibSourceLinkAccessor.h:51
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
ActsTrk::detail::TrackFindingMeasurements::TrackFindingMeasurements
TrackFindingMeasurements(std::size_t nMeasurementContainerMax)
Definition: TrackFindingMeasurements.cxx:12
ActsTrk::detail::MeasurementRange
Definition: AtlasUncalibSourceLinkAccessor.h:24
TrackFindingMeasurements.h
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
xAOD::Other
@ Other
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:46
ActsTrk::detail::TrackFindingMeasurements::m_measurementsTotal
std::size_t m_measurementsTotal
Definition: TrackFindingMeasurements.h:38
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ActsTrk::detail::TrackFindingMeasurements::addMeasurements
void addMeasurements(std::size_t typeIndex, const xAOD::UncalibratedMeasurementContainer &clusterContainer, const DetectorElementToActsGeometryIdMap &detectorElementToGeoid)
Definition: TrackFindingMeasurements.cxx:15
ActsTrk::detail::TrackFindingMeasurements::m_measurementRanges
ActsTrk::detail::MeasurementRangeList m_measurementRanges
Definition: TrackFindingMeasurements.h:37
xAOD::DetectorIDHashType
unsigned int DetectorIDHashType
@ detector ID element hash
Definition: MeasurementDefs.h:43
SurfaceOfMeasurementUtil.h
ActsTrk::detail::GenMeasurementRangeList::setContainer
void setContainer(unsigned int container_index, const xAOD::UncalibratedMeasurementContainer *container)
Definition: AtlasUncalibSourceLinkAccessor.h:88
ActsTrk::detail::TrackFindingMeasurements::m_measurementOffsets
std::vector< std::size_t > m_measurementOffsets
Definition: TrackFindingMeasurements.h:35
xAOD::UncalibMeasType
UncalibMeasType
Define the type of the uncalibrated measurement.
Definition: MeasurementDefs.h:25
ActsTrk::detail
Definition: Decoration.h:15
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
DetectorElementToActsGeometryIdMap.h