ATLAS Offline Software
Loading...
Searching...
No Matches
HitSummaryDataUtils.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12namespace ActsTrk::detail {
13
14 void gatherTrackSummaryData(const typename ActsTrk::TrackContainer::ConstTrackProxy &track,
15 const std::array<unsigned short, Acts::toUnderlying(xAOD::UncalibMeasType::nTypes)>
16 &measurement_to_summary_type,
17 SumOfValues &chi2_stat_out,
18 HitSummaryData &hit_info_out,
19 std::vector<ActsTrk::TrackStateBackend::ConstTrackStateProxy::IndexType > &param_state_idx_out,
20 std::array<std::array<uint8_t, Acts::toUnderlying(HitCategory::N)>,
21 Acts::toUnderlying(xAOD::UncalibMeasType::nTypes)> &special_hit_counts_out,
22 TimeInfo &time_info)
23 {
24 chi2_stat_out.reset();
25
26 struct TimeInfoHelper { double sum{}; double sumInv2{}; double chi2{}; unsigned int n=0u;};
27 TimeInfoHelper time_info_helper;
28
29 hit_info_out.reset();
30 param_state_idx_out.clear();
31
32 const auto lastMeasurementIndex = track.tipIndex();
33 track.container().trackStateContainer().visitBackwards(
34 lastMeasurementIndex,
35 [&measurement_to_summary_type,
36 &chi2_stat_out,
37 &hit_info_out,
38 &param_state_idx_out,
39 &special_hit_counts_out,
40 &time_info_helper
41 ](const typename ActsTrk::TrackStateBackend::ConstTrackStateProxy &state) -> void
42 {
43
44 auto flag = state.typeFlags();
45 if (!state.hasReferenceSurface()) {
46 return;
47 }
49 const auto* placement = dynamic_cast<const ISurfacePlacement*>(state.referenceSurface().surfacePlacement());
50 if (placement != nullptr) {
51 det_type = toMeasType(placement->detectorType());
52 }
53
54 if (flag.hasNoExpectedHit()) {
55 // @TODO includes holes at sensor edges
56 ++special_hit_counts_out.at(Acts::toUnderlying(det_type)).at(Acts::toUnderlying(HitCategory::DeadSensor));
57 return;
58
59 }
60 if (flag.isHole()) {
61 const Amg::Vector2D localPos{state.parameters()[Acts::eBoundLoc0],
62 state.parameters()[Acts::eBoundLoc1]};
63 if (state.referenceSurface().insideBounds(localPos)) {
64 // @TODO check whether detector element is dead..
65 ++special_hit_counts_out.at(Acts::toUnderlying(det_type)).at(Acts::toUnderlying(HitCategory::Hole));
66 }
67 return;
68
69 }
70 // do not consider material states
71 if (!flag.hasMeasurement() || !state.hasUncalibratedSourceLink()) {
72 return;
73 }
74 param_state_idx_out.push_back(state.index());
75
76 // @TODO dead elements
77 auto uncalibMeas = detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink());
78 assert( uncalibMeas != nullptr );
79 assert( det_type == uncalibMeas->type());
80
81 if (measurement_to_summary_type.at(Acts::toUnderlying(uncalibMeas->type())) <
83 HitSummaryData::EHitSelection hit_selection = (flag.isOutlier()
86 if (flag.isSharedHit()) {
87 hit_selection = HitSummaryData::EHitSelection(hit_selection | HitSummaryData::SharedHitFlag);
88 }
89 if (flag.isSplitHit()) {
90 hit_selection = HitSummaryData::EHitSelection(hit_selection | HitSummaryData::SplitHitFlag);
91 }
92 if (const auto* idDetEl = getActsDetectorElement(state.referenceSurface()); idDetEl != nullptr) {
93 const auto* siDet = dynamic_cast<const InDetDD::SolidStateDetectorElementBase*>(idDetEl->upstreamDetectorElement());
94 hit_info_out.addHit(det_type, siDet, hit_selection);
95 }
96
98 if (!flag.isOutlier() && state.hasCalibrated()) {
99 // compute HGTD calibrated
100 assert( state.calibratedSize()==3);
101 auto pos = state.calibrated<3>();
102 auto cov = state.calibratedCovariance<3>();
103 time_info_helper.sum += pos[2]; // Acts time
104 time_info_helper.sumInv2 += 1./cov(2,2); // Acts time
105 time_info_helper.chi2 += state.chi2();
106 ++time_info_helper.n;
107 }
108 }
109
110 if (state.calibratedSize()>0 && !flag.isOutlier()) {
111 // from Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx
112 // processTrackState
113 double chi2add = std::min(state.chi2(),1e5f) / state.calibratedSize();
114 chi2_stat_out.add(chi2add );
115 }
116 }
117
118 });
119 hit_info_out.computeSummaries();
120 if (time_info_helper.n>1) {
121 time_info.mean = static_cast<float>(ActsTrk::timeToAthena( time_info_helper.sum / time_info_helper.n));
122 time_info.resolution = static_cast<float>(ActsTrk::timeToAthena(std::sqrt(1./time_info_helper.sumInv2)));
123 time_info.chi2 = time_info_helper.chi2;
124 }
125 else {
126 time_info.mean = static_cast<float>(ActsTrk::timeToAthena(time_info_helper.sum));
127 time_info.resolution = time_info_helper.n>0 ? static_cast<float>(ActsTrk::timeToAthena(std::sqrt(1./time_info_helper.sumInv2))) : 0.f;
128 time_info.chi2 = time_info_helper.chi2;
129 }
130 }
131
132}
const ActsDetectorElement * getActsDetectorElement(const Acts::Surface &surf)
Attempts to retrieve the ActsDetectorElement associated to the passed ActsSurface.
Extension of the interface of the Acts::SurfacePlacementBase for ATLAS.
Helper class to gather hit summary information for e.g.
void reset()
reset all summary counters to zero.
void computeSummaries()
Compute the varius summaries.
bool addHit(xAOD::UncalibMeasType det_type, const InDetDD::SolidStateDetectorElementBase *detEl, EHitSelection hit_selection)
update summaries to take the given hit into account.
Helper class to gather statistics and compute the biased variance.
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
Class to hold geometrical description of a solid state detector element.
double chi2(TH1 *h0, TH1 *h1)
Hash functions to pack the source link into unordered_maps / unordered_sets.
void gatherTrackSummaryData(const typename ActsTrk::TrackContainer::ConstTrackProxy &track, const std::array< unsigned short, Acts::toUnderlying(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, Acts::toUnderlying(HitCategory::N)>, Acts::toUnderlying(xAOD::UncalibMeasType::nTypes)> &special_hit_counts_out, TimeInfo &time_info)
Helper to gather track summary information from the track states of the specified track.
constexpr double timeToAthena(T actsT)
Converts a time unit from Acts to Athena units.
xAOD::UncalibMeasType toMeasType(const DetectorType dType)
Conversts the detector type to an uncalibrated measurement type.
Eigen::Matrix< double, 2, 1 > Vector2D
UncalibMeasType
Define the type of the uncalibrated measurement.
@ numberOfTrackSummaryTypes