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