Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ActsInspectTruthContentAlg.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ActsInterop/TableUtils.h"
6 
7 
8 namespace ActsTrk {
9 
10  template <typename row_t,
11  typename coll_t,
12  typename stat_t>
13  StatusCode ActsInspectTruthContentAlg::printStatTables(const std::string& objectCollectionName,
14  const stat_t& stat) const
15  {
16  constexpr std::size_t NROW = static_cast<std::size_t>(row_t::kNStat);
17  constexpr std::size_t NCOL = static_cast<std::size_t>(coll_t::nTypes);
18  constexpr std::size_t TOTROW = static_cast<std::size_t>(row_t::kNTotal);
19  static_assert( std::same_as<stat_t,
20  std::array<
21  std::array<std::size_t, NCOL>, NROW>> );
22 
23  // labels have to follow the enum
24  std::array<std::string, NROW> stat_labels;
25  for (std::size_t i(0); i<NROW; ++i) {
26  stat_labels[i] = to_label(static_cast<row_t>(i));
27  }
28 
29  std::array<std::string, NROW - 1> ratio_labels {};
30  for (std::size_t i(1); i< stat_labels.size(); ++i) {
31  ratio_labels[i-1] = stat_labels[i] + " / total";
32  }
33 
34  std::size_t max_label_width = TableUtils::maxLabelWidth(ratio_labels);
35 
36  std::array<std::string, NCOL> categories {};
37  for (std::size_t i(0); i<categories.size(); ++i) {
38  categories[i] = to_string( static_cast<coll_t>(i) );
39  }
40 
41  std::stringstream table_out;
42  table_out << makeTable(stat,
43  stat_labels,
44  categories)
45  .columnWidth(12)
46  .dumpFooter(false)
47  .minLabelWidth(max_label_width);
48 
49  // define ratios
50  std::array<
51  std::array<float, NCOL>,
52  NROW - 1> ratioStat {};
53 
54  // fill ratios
55  for (std::size_t i(1); i<NROW; ++i) {
56  for (std::size_t j(0); j<NCOL; ++j) {
57  if (stat[TOTROW][j] == 0) ratioStat[i-1][j] = 0;
58  else ratioStat[i-1][j] = stat[i][j] * 1. / stat[TOTROW][j];
59  }
60  }
61 
62  table_out << makeTable(ratioStat,
63  ratio_labels,
64  categories)
65  .columnWidth(12)
66  .dumpHeader(false)
67  .minLabelWidth(max_label_width);
68 
69  ATH_MSG_INFO(objectCollectionName << " statistics:" << std::endl
70  << table_out.str());
71 
72  return StatusCode::SUCCESS;
73  }
74 
75  // -------------------------------------------------------------------- //
76 
77  template <typename stat_t>
78  StatusCode ActsInspectTruthContentAlg::copyStatTable(const stat_t& contextual,
79  stat_t& global) const {
80  std::lock_guard<std::mutex> lock(m_mutex);
81  for (std::size_t i(0); i<contextual.size(); ++i) {
82  for (std::size_t j(0); j<contextual[i].size(); ++j) {
83  global[i][j] += contextual[i][j];
84  }
85  }
86  return StatusCode::SUCCESS;
87  }
88 
89  // -------------------------------------------------------------------- //
90 
91  inline std::string ActsInspectTruthContentAlg::to_string(xAOD::UncalibMeasType type) const {
92  switch(type) {
93  case (xAOD::UncalibMeasType::Other):
94  return "Other";
95  case (xAOD::UncalibMeasType::PixelClusterType):
96  return "Pixel";
97  case (xAOD::UncalibMeasType::StripClusterType):
98  return "Strip";
99  case (xAOD::UncalibMeasType::MdtDriftCircleType):
100  return "MDT";
101  case (xAOD::UncalibMeasType::RpcStripType):
102  return "RPC";
103  case (xAOD::UncalibMeasType::TgcStripType):
104  return "TGC";
105  case (xAOD::UncalibMeasType::MMClusterType):
106  return "MM";
107  case (xAOD::UncalibMeasType::sTgcStripType):
108  return "sTGC";
109  case (xAOD::UncalibMeasType::HGTDClusterType):
110  return "HGTD";
111  default:
112  return "Unknown";
113  }
114  }
115 
116  inline std::string ActsInspectTruthContentAlg::to_string(ActsInspectTruthContentAlg::SeedType type) const {
117  switch(type) {
118  case (ActsInspectTruthContentAlg::SeedType::PPP):
119  return "PPP";
120  case (ActsInspectTruthContentAlg::SeedType::SSS):
121  return "SSS";
122  case (ActsInspectTruthContentAlg::SeedType::PPS):
123  return "PPS";
124  case (ActsInspectTruthContentAlg::SeedType::PSS):
125  return "PSS";
126  case (ActsInspectTruthContentAlg::SeedType::Others):
127  return "Others";
128  default:
129  return "Unknown";
130  }
131  }
132 
133 
134  inline std::string ActsInspectTruthContentAlg::to_string(ActsInspectTruthContentAlg::TrackType type) const {
135  switch(type) {
136  case (ActsInspectTruthContentAlg::TrackType::Main):
137  return "Collection";
138  default:
139  return "Unknown";
140  }
141  }
142 
143 
144  inline std::string ActsInspectTruthContentAlg::to_label(ActsInspectTruthContentAlg::EStatClusters type) const {
145  switch(type) {
146  case (ActsInspectTruthContentAlg::EStatClusters::kNTotal):
147  return "Total number of Clusters";
148  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersFromPrimaries):
149  return "Clusters with barcode < 200k";
150  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWithNoBarcode):
151  return "Clusters with no barcode";
152  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith1Contribution):
153  return "Clusters with 1 contribution";
154  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith1ValidContribution):
155  return "Clusters with 1 contribution (all < 200k)";
156  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith2Contribution):
157  return "Clusters with 2 contributions";
158  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith2ValidContribution):
159  return "Clusters with 2 contributions (all < 200k)";
160  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith3Contribution):
161  return "Clusters with 3+ contributions";
162  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith3ValidContribution):
163  return "Clusters with 3+ contributions (all < 200k)";
164  case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith200kBarcode):
165  return "Clusters with barcode >= 200k";
166  default:
167  return "Unknown";
168  }
169  }
170 
171  inline std::string ActsInspectTruthContentAlg::to_label(ActsInspectTruthContentAlg::EStatSeeds type) const {
172  switch(type) {
173  case (ActsInspectTruthContentAlg::EStatSeeds::kNTotal):
174  return "Total number of Seeds";
175  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith0Matches):
176  return "Seeds with 0 clusters with barcode < 200k";
177  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith1Matches):
178  return "Seeds with 1 clusters with barcode < 200k";
179  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith2Matches):
180  return "Seeds with 2 clusters with barcode < 200k";
181  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith3Matches):
182  return "Seeds with 3 clusters with barcode < 200k";
183  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith4Matches):
184  return "Seeds with 4 clusters with barcode < 200k";
185  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith5Matches):
186  return "Seeds with 5 clusters with barcode < 200k";
187  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith6Matches):
188  return "Seeds with 6 clusters with barcode < 200k";
189  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame2Matches):
190  return "Seeds with 2 clusters with barcode < 200k (all same)";
191  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame3Matches):
192  return "Seeds with 3 clusters with barcode < 200k (all same)";
193  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame4Matches):
194  return "Seeds with 4 clusters with barcode < 200k (all same)";
195  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame5Matches):
196  return "Seeds with 5 clusters with barcode < 200k (all same)";
197  case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame6Matches):
198  return "Seeds with 6 clusters with barcode < 200k (all same)";
199  default:
200  return "Unknown";
201  }
202  }
203 
204 
205  inline std::string ActsInspectTruthContentAlg::to_label(ActsInspectTruthContentAlg::EStatTracks type) const {
206  switch(type) {
207  case (ActsInspectTruthContentAlg::EStatTracks::kNTotal):
208  return "Total number of Tracks";
209  case (ActsInspectTruthContentAlg::EStatTracks::kNFullMatch):
210  return "Tracks with only clusters with barcodes <200k";
211  case (ActsInspectTruthContentAlg::EStatTracks::kNPerfectMatch):
212  return "Tracks with only clusters with barcodes <200k (all same)";
213  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks0Holes):
214  return "Tracks with 0 holes";
215  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks1Holes):
216  return "Tracks with 1 holes";
217  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks2Holes):
218  return "Tracks with 2 holes";
219  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks3Holes):
220  return "Tracks with 3+ holes";
221  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks0Outliers):
222  return "Tracks with 0 outliers";
223  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks1Outliers):
224  return "Tracks with 1 outliers";
225  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks2Outliers):
226  return "Tracks with 2 outliers";
227  case (ActsInspectTruthContentAlg::EStatTracks::kNTracks3Outliers):
228  return "Tracks with 3+ outliers";
229  default:
230  return "Unknown";
231  }
232  }
233 
234 
235 } // namespace
236