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