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 nCategories: return "nCategories";
23 }
24 return "Unknown";
25 }
26 std::string HitSummary::toString(const Status s) {
27 switch(s) {
28 using enum Status;
29 case OnTrack: return "OnTrack";
30 case Outlier: return "Outlier";
31 case Hole: return "Hole";
32 case MaxValue: return "MaxValue";
33 }
34 return "Unknown";
35 }
36 unsigned HitSummary::translate(const HitCategory cat, const Status status,
37 LayerIndex layer, const bool isSmall) const {
38 using namespace Muon::MuonStationIndex;
40 if (layer == LayerIndex::BarrelExtended) {
42 }
43 constexpr unsigned A = toInt(Status::MaxValue);
44 constexpr unsigned AxB = A * toInt(HitCategory::nCategories);
45 constexpr unsigned AxBxC = 2 *AxB;
46 const unsigned idx = AxBxC*toInt(layer) + AxB*toInt(isSmall) + A*toInt(cat) + toInt(status);
47 assert(idx < m_counts.size());
48 return idx;
49 }
51 HitSummary::value(const HitCategory cat, const Status status,
52 const LayerIndex layer, const bool isSmall) const {
53 return m_counts[translate(cat, status, layer, isSmall)];
54 }
56 HitSummary::value(const HitCategory cat, const Status status,
57 const LayerIndex layer, const bool isSmall) {
58 return m_counts[translate(cat, status, layer, isSmall)];
59 }
60 void HitSummary::print(std::ostream& ostr) const {
61 using ColumnArray_t = std::array<std::string, 6>;
62 std::vector<ColumnArray_t> summaryTable{ColumnArray_t{"layer", "sector", "type",
63 "on-track", "outlier", "hole"}};
64
67 for (const bool small: {false, true}) {
68 for (const auto cat : {HitCategory::Precision, HitCategory::TriggerEta,
70 const unsigned onTrk = value(cat, Status::OnTrack, lay, small);
71 const unsigned outlier = value(cat, Status::Outlier, lay, small);
72 const unsigned hole = value(cat, Status::Hole, lay, small);
73 if (onTrk + outlier + hole == 0u) {
74 continue;
75 }
76 summaryTable.emplace_back(ColumnArray_t{Muon::MuonStationIndex::layerName(lay),
77 (small ? "small" : "large"),
78 toString(cat), std::to_string(onTrk),
79 std::to_string(outlier), std::to_string(hole)});
80 }
81 }
82 }
83 std::array<std::size_t, 6> widths{};
84 for (const ColumnArray_t& row : summaryTable) {
85 for (std::size_t c = 0 ; c < row.size(); ++c) {
86 widths[c] = std::max(widths[c], row[c].size());
87 }
88 }
89 for (const ColumnArray_t& row : summaryTable) {
90 ostr<<"|";
91 for (std::size_t c = 0; c < row.size(); ++c) {
92 const std::size_t W = widths[c] - row[c].size();
93 const std::size_t nWL = (W - W % 2) / 2;
94 const std::size_t nWR = (W - W % 2) / 2 + W%2;
95 ostr<<" "<<whiteSpaces(nWL)<<row[c]<<whiteSpaces(nWR)<<" |";
96 }
97 ostr<<std::endl;
98 }
99 }
100}
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:89
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
@ nCategories
Trigger phi hits (Tgc, Rpc)
Definition HitSummary.h:33
@ TriggerPhi
Trigger eta hits (Tgc, Rpc)
Definition HitSummary.h:32
@ TriggerEta
Precision hits (Mdt, NSW) on track.
Definition HitSummary.h:31
Status
Contribution to the track fit.
Definition HitSummary.h:36
@ Hole
Added to the trajectory but rejected.
Definition HitSummary.h:39
@ Outlier
Added to the trajectory & contributing to the fit.
Definition HitSummary.h:38
@ MaxValue
Expected hit but missing.
Definition HitSummary.h:40
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.