ATLAS Offline Software
Loading...
Searching...
No Matches
HitSummary.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include <cassert>
7namespace{
8 std::string whiteSpaces(std::size_t n) {
9 std::string s{};
10 s.assign(n, ' ');
11 return s;
12 }
13}
14
15namespace MuonR4{
16 std::string HitSummary::toString(const HitCategory c) {
17 switch (c) {
18 using enum HitCategory;
19 case Precision: return "Precision";
20 case TriggerEta: return "TriggerEta";
21 case TriggerPhi: return "TriggerPhi";
22 case sTgcPad: return "sTgcPad";
23 case nCategories: return "nCategories";
24 }
25 return "Unknown";
26 }
27 std::string HitSummary::toString(const Status s) {
28 switch(s) {
29 using enum Status;
30 case OnTrack: return "OnTrack";
31 case Outlier: return "Outlier";
32 case Hole: return "Hole";
33 case MaxValue: return "MaxValue";
34 }
35 return "Unknown";
36 }
37 unsigned HitSummary::translate(const HitCategory cat, const Status status,
38 LayerIndex layer, const bool isSmall) const {
39 using namespace Muon::MuonStationIndex;
41 if (layer == LayerIndex::BarrelExtended) {
43 }
44 constexpr unsigned A = toInt(Status::MaxValue);
45 constexpr unsigned AxB = A * toInt(HitCategory::nCategories);
46 constexpr unsigned AxBxC = 2 *AxB;
47 const unsigned idx = AxBxC*toInt(layer) + AxB*toInt(isSmall) + A*toInt(cat) + toInt(status);
48 assert(idx < m_counts.size());
49 return idx;
50 }
52 HitSummary::value(const HitCategory cat, const Status status,
53 const LayerIndex layer, const bool isSmall) const {
54 return m_counts[translate(cat, status, layer, isSmall)];
55 }
57 HitSummary::value(const HitCategory cat, const Status status,
58 const LayerIndex layer, const bool isSmall) {
59 return m_counts[translate(cat, status, layer, isSmall)];
60 }
61 void HitSummary::print(std::ostream& ostr) const {
62 using ColumnArray_t = std::array<std::string, 6>;
63 std::vector<ColumnArray_t> summaryTable{ColumnArray_t{"layer", "sector", "type",
64 "on-track", "outlier", "hole"}};
65
68 for (const bool small: {false, true}) {
69 for (const auto cat : {HitCategory::Precision, HitCategory::TriggerEta,
71 const unsigned onTrk = value(cat, Status::OnTrack, lay, small);
72 const unsigned outlier = value(cat, Status::Outlier, lay, small);
73 const unsigned hole = value(cat, Status::Hole, lay, small);
74 if (onTrk + outlier + hole == 0u) {
75 continue;
76 }
77 summaryTable.emplace_back(ColumnArray_t{Muon::MuonStationIndex::layerName(lay),
78 (small ? "small" : "large"),
79 toString(cat), std::to_string(onTrk),
80 std::to_string(outlier), std::to_string(hole)});
81 }
82 }
83 }
84 std::array<std::size_t, 6> widths{};
85 for (const ColumnArray_t& row : summaryTable) {
86 for (std::size_t c = 0 ; c < row.size(); ++c) {
87 widths[c] = std::max(widths[c], row[c].size());
88 }
89 }
90 for (const ColumnArray_t& row : summaryTable) {
91 ostr<<"|";
92 for (std::size_t c = 0; c < row.size(); ++c) {
93 const std::size_t W = widths[c] - row[c].size();
94 const std::size_t nWL = (W - W % 2) / 2;
95 const std::size_t nWR = (W - W % 2) / 2 + W%2;
96 ostr<<" "<<whiteSpaces(nWL)<<row[c]<<whiteSpaces(nWR)<<" |";
97 }
98 ostr<<std::endl;
99 }
100 }
101}
This header ties the generic definitions in this package.
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
bool isSmall(const ChIndex index)
Returns true if the chamber index is in a small sector.
constexpr int toInt(const EnumType enumVal)
hold the test vectors and ease the comparison
void print(std::ostream &ostr) const
Print the summary as an ASCII table.
std::uint8_t value_type
Definition HitSummary.h:23
Muon::MuonStationIndex::LayerIndex LayerIndex
Abrivation of the layer index.
Definition HitSummary.h:25
Counter_t m_counts
Definition HitSummary.h:91
unsigned translate(const HitCategory cat, const Status status, LayerIndex layer, const bool isSmall) const
Translates the 4 classification indices to a unique consecutive number (used for storage access)
static std::string toString(const HitCategory c)
Converts the hit category to a string.
HitCategory
Category of the hit.
Definition HitSummary.h:29
@ TriggerPhi
Trigger eta hits (Tgc, Rpc)
Definition HitSummary.h:32
@ sTgcPad
Trigger phi hits (Tgc, Rpc)
Definition HitSummary.h:33
@ TriggerEta
Precision hits (Mdt, NSW) on track.
Definition HitSummary.h:31
Status
Contribution to the track fit.
Definition HitSummary.h:38
@ Hole
Added to the trajectory but rejected.
Definition HitSummary.h:41
@ Outlier
Added to the trajectory & contributing to the fit.
Definition HitSummary.h:40
@ MaxValue
Expected hit but missing.
Definition HitSummary.h:42
value_type value(const HitCategory cat, const Status status, const LayerIndex layer, const bool isSmall) const
Returns the value type for a defined hit category & layer.