ATLAS Offline Software
HitSummaryDataUtils.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 #include "Acts/Surfaces/BoundaryTolerance.hpp"
11 
13 
14 namespace ActsTrk::detail {
15 
16  void gatherTrackSummaryData(const ActsTrk::TrackContainer &tracksContainer,
17  const typename ActsTrk::TrackContainer::ConstTrackProxy &track,
21  &measurement_to_summary_type,
22  SumOfValues &chi2_stat_out,
23  HitSummaryData &hit_info_out,
24  std::vector<ActsTrk::TrackStateBackend::ConstTrackStateProxy::IndexType > &param_state_idx_out,
26  to_underlying(xAOD::UncalibMeasType::nTypes)> &special_hit_counts_out)
27  {
28  chi2_stat_out.reset();
29 
30  hit_info_out.reset();
31  param_state_idx_out.clear();
32 
33  const auto lastMeasurementIndex = track.tipIndex();
34  tracksContainer.trackStateContainer().visitBackwards(
35  lastMeasurementIndex,
36  [&siDetEleColl,
37  &measurement_to_summary_type,
38  &chi2_stat_out,
39  &hit_info_out,
40  &param_state_idx_out,
41  &special_hit_counts_out
42  ](const typename ActsTrk::TrackStateBackend::ConstTrackStateProxy &state) -> void
43  {
44 
45  auto flag = state.typeFlags();
46  if (flag.test(Acts::TrackStateFlag::HoleFlag)) {
47  xAOD::UncalibMeasType det_type = xAOD::UncalibMeasType::Other;
48  if (state.hasReferenceSurface()) {
49  if (state.referenceSurface().associatedDetectorElement()) {
50  const ActsDetectorElement *
51  actsDetEl = dynamic_cast<const ActsDetectorElement *>(state.referenceSurface().associatedDetectorElement());
52  if (actsDetEl) {
53  const InDetDD::SiDetectorElement *
54  detEl = dynamic_cast<const InDetDD::SiDetectorElement *>(actsDetEl->upstreamDetectorElement());
55  if (detEl) {
56  if (detEl->isPixel()) {
57  det_type = xAOD::UncalibMeasType::PixelClusterType;
58  }
59  else if (detEl->isSCT()) {
60  det_type = xAOD::UncalibMeasType::StripClusterType;
61  }
62  }
63  }
64  }
65  }
66 
67  Acts::BoundaryTolerance tolerance = Acts::BoundaryTolerance::AbsoluteBound(
68  // local0 tolerance
70  || state.referenceSurface().bounds().type() != Acts::SurfaceBounds::eAnnulus)
71  ? 0.0 : std::numeric_limits<double>::infinity(),
72  // local1 tolerance
74  || state.referenceSurface().bounds().type() == Acts::SurfaceBounds::eAnnulus)
75  ? 0.0 : std::numeric_limits<double>::infinity()
76  );
77  Acts::Vector2 localPos(state.predicted()[Acts::eBoundLoc0],state.predicted()[Acts::eBoundLoc1]);
78  if (state.referenceSurface().insideBounds(localPos,tolerance)) {
79  // @TODO check whether detector element is dead..
80  // if (dead) {
81  // ++specialHitCounts.at(to_underlying(det_type)).at(HitCategory::DeadSensor);
82  // } else {
83  ++special_hit_counts_out.at(to_underlying(det_type)).at(HitCategory::Hole);
84  }
85 
86  }
87  else if (flag.test(Acts::TrackStateFlag::MeasurementFlag)) {
88  // do not consider material states
89  param_state_idx_out.push_back(state.index());
90  }
91  // @TODO dead elements
92 
93  if (state.hasUncalibratedSourceLink()) {
94  auto sl = state.getUncalibratedSourceLink().template get<ActsTrk::ATLASUncalibSourceLink>();
95  assert( sl != nullptr );
96  const xAOD::UncalibratedMeasurement &uncalibMeas = getUncalibratedMeasurement(sl);
97  if (measurement_to_summary_type.at(to_underlying(uncalibMeas.type())) < xAOD::numberOfTrackSummaryTypes ) {
98  if (static_cast<unsigned int>(to_underlying(uncalibMeas.type())) < siDetEleColl.size()) {
99  hit_info_out.addHit(siDetEleColl[to_underlying(uncalibMeas.type())],
100  uncalibMeas.identifierHash(),
101  (flag.test(Acts::TrackStateFlag::OutlierFlag)
102  ? HitSummaryData::Outlier
103  : HitSummaryData::Hit));
104  }
105  }
106  if (state.calibratedSize()>0 && !flag.test(Acts::TrackStateFlag::OutlierFlag)) {
107  // from Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx
108  // processTrackState
109  double chi2add = std::min(state.chi2(),1e5f) / state.calibratedSize();
110  chi2_stat_out.add(chi2add );
111  }
112  }
113 
114  });
115  hit_info_out.computeSummaries();
116  }
117 
118 }
ActsTrk::detail::HitSummaryData::computeSummaries
void computeSummaries()
Compute the varius summaries.
Definition: HitSummaryDataUtils.h:161
ActsTrk::TrackContainer
Definition: TrackContainer.h:31
ActsTrk::detail::SumOfValues
Helper class to gather statistics and compute the biased variance.
Definition: HitSummaryDataUtils.h:235
ActsTrk::detail::gatherTrackSummaryData
void gatherTrackSummaryData(const ActsTrk::TrackContainer &tracksContainer, const typename ActsTrk::TrackContainer::ConstTrackProxy &track, const std::array< const InDetDD::SiDetectorElementCollection *, to_underlying(xAOD::UncalibMeasType::nTypes)> &siDetEleColl, const std::array< unsigned short, to_underlying(xAOD::UncalibMeasType::nTypes)> &measurement_to_summary_type, SumOfValues &chi2_stat_out, HitSummaryData &hit_info_out, std::vector< ActsTrk::TrackStateBackend::ConstTrackStateProxy::IndexType > &param_state_idx_out, std::array< std::array< uint8_t, to_underlying(HitCategory::N)>, to_underlying(xAOD::UncalibMeasType::nTypes)> &special_hit_counts_out)
Helper to gather track summary information from the track states of the specified track.
Definition: HitSummaryDataUtils.cxx:16
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
ActsTrk::detail::to_underlying
constexpr std::underlying_type< T_EnumClass >::type to_underlying(T_EnumClass an_enum)
Helper to convert class enum into an integer.
Definition: HitSummaryDataUtils.h:25
HitSummaryDataUtils.h
ActsTrk::detail::HitSummaryData
Helper class to gather hit summary information for e.g.
Definition: HitSummaryDataUtils.h:39
master.flag
bool flag
Definition: master.py:29
ActsTrk::detail::HitCategory::N
@ N
Definition: HitSummaryDataUtils.h:33
ActsDetectorElement.h
MeasurementDefs.h
lumiFormat.array
array
Definition: lumiFormat.py:91
tolerance
Definition: suep_shower.h:17
xAOD::UncalibMeasType::nTypes
@ nTypes
SiDetectorElementCollection.h
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
ActsTrk::detail
Definition: Decoration.h:14
ActsTrk::detail::SumOfValues::reset
void reset()
Definition: HitSummaryDataUtils.h:241
TrackContainer.h
xAOD::UncalibMeasType::PixelClusterType
@ PixelClusterType
ActsTrk::detail::HitSummaryData::reset
void reset()
reset all summary counters to zero.
Definition: HitSummaryDataUtils.h:104