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/BoundaryCheck.hpp"
11 
12 #include "HitSummaryDataUtils.h"
13 
14 namespace ActsTrk {
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::BoundaryCheck bcheck(//check local0 ?
69  || state.referenceSurface().bounds().type() != Acts::SurfaceBounds::eAnnulus),
70  // check local1
72  || state.referenceSurface().bounds().type() == Acts::SurfaceBounds::eAnnulus)
73  // @TODO tolerances ?
74  );
75  Acts::Vector2 localPos(state.predicted()[Acts::eBoundLoc0],state.predicted()[Acts::eBoundLoc1]);
76  if (state.referenceSurface().insideBounds(localPos,bcheck)) {
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  hit_info_out.addHit(siDetEleColl[to_underlying(uncalibMeas.type())],
98  uncalibMeas.identifierHash(),
99  (flag.test(Acts::TrackStateFlag::OutlierFlag)
100  ? HitSummaryData::Outlier
101  : HitSummaryData::Hit));
102  }
103  }
104  if (state.calibratedSize()>0 && !flag.test(Acts::TrackStateFlag::OutlierFlag)) {
105  // from Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx
106  // processTrackState
107  double chi2add = std::min(state.chi2(),1e5f) / state.calibratedSize();
108  chi2_stat_out.add(chi2add );
109  }
110  }
111 
112  });
113  hit_info_out.computeSummaries();
114  }
115 
116 }
ActsTrk::TrackContainer
Definition: TrackContainer.h:31
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
ActsTrk::SumOfValues
Helper class to gather statistics and compute the biased variance.
Definition: HitSummaryDataUtils.h:234
ActsTrk::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
HitSummaryDataUtils.h
ActsTrk::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
ActsTrk::HitSummaryData::reset
void reset()
reset all summary counters to zero.
Definition: HitSummaryDataUtils.h:103
master.flag
bool flag
Definition: master.py:29
ActsDetectorElement.h
MeasurementDefs.h
lumiFormat.array
array
Definition: lumiFormat.py:98
xAOD::UncalibMeasType::nTypes
@ nTypes
ActsTrk::SumOfValues::reset
void reset()
Definition: HitSummaryDataUtils.h:240
SiDetectorElementCollection.h
ActsTrk::HitSummaryData::computeSummaries
void computeSummaries()
Compute the varius summaries.
Definition: HitSummaryDataUtils.h:160
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:34
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
TrackContainer.h
ActsTrk::HitCategory::N
@ N
Definition: HitSummaryDataUtils.h:32
xAOD::UncalibMeasType::PixelClusterType
@ PixelClusterType
ActsTrk::HitSummaryData
Helper class to gather hit summary information for e.g.
Definition: HitSummaryDataUtils.h:38