ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonPhaseII
Event
MuonTrackEvent
src
HitSummary.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
MuonTrackEvent/HitSummary.h
"
5
6
#include <cassert>
7
namespace
{
8
std::string whiteSpaces(std::size_t n) {
9
std::string
s
{};
10
s
.assign(n,
' '
);
11
return
s
;
12
}
13
}
14
15
namespace
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
) {
42
layer =
LayerIndex::Extended
;
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
}
51
HitSummary::value_type
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
}
56
HitSummary::value_type
&
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
62
HitSummary::value_type
HitSummary::nPrecisionStations
()
const
{
63
value_type
precisionStations{0} ;
64
for
(
const
auto
lay: {
LayerIndex::Inner
,
LayerIndex::Middle
,
LayerIndex::Outer
,
LayerIndex::Extended
,
LayerIndex::BarrelExtended
}){
65
for
(
const
bool
small: {
false
,
true
}) {
66
if
(
value
(
HitCategory::Precision
, Status::OnTrack, lay, small) > 2) {
67
++precisionStations;
68
// if the large sector has more than 2 hits we should not check the small one to avoid double counting
69
break
;
70
}
71
}
72
}
73
return
precisionStations;
74
}
75
76
void
HitSummary::print
(std::ostream& ostr)
const
{
77
using
ColumnArray_t = std::array<std::string, 6>;
78
std::vector<ColumnArray_t> summaryTable{ColumnArray_t{
"layer"
,
"sector"
,
"type"
,
79
"on-track"
,
"outlier"
,
"hole"
}};
80
81
for
(
const
auto
lay: {
LayerIndex::Inner
,
LayerIndex::Middle
,
LayerIndex::Extended
,
82
LayerIndex::Outer
}){
83
for
(
const
bool
small: {
false
,
true
}) {
84
for
(
const
auto
cat : {
HitCategory::Precision
,
HitCategory::TriggerEta
,
85
HitCategory::TriggerPhi
,
HitCategory::sTgcPad
}){
86
const
unsigned
onTrk =
value
(cat, Status::OnTrack, lay, small);
87
const
unsigned
outlier =
value
(cat, Status::Outlier, lay, small);
88
const
unsigned
hole =
value
(cat, Status::Hole, lay, small);
89
if
(onTrk + outlier + hole == 0u) {
90
continue
;
91
}
92
summaryTable.emplace_back(ColumnArray_t{
Muon::MuonStationIndex::layerName
(lay),
93
(small ?
"small"
:
"large"
),
94
toString
(cat), std::to_string(onTrk),
95
std::to_string(outlier), std::to_string(hole)});
96
}
97
}
98
}
99
std::array<std::size_t, 6> widths{};
100
for
(
const
ColumnArray_t& row : summaryTable) {
101
for
(std::size_t c = 0 ; c < row.size(); ++c) {
102
widths[c] = std::max(widths[c], row[c].
size
());
103
}
104
}
105
for
(
const
ColumnArray_t& row : summaryTable) {
106
ostr<<
"|"
;
107
for
(std::size_t c = 0; c < row.size(); ++c) {
108
const
std::size_t W = widths[c] - row[c].size();
109
const
std::size_t nWL = (W - W % 2) / 2;
110
const
std::size_t nWR = (W - W % 2) / 2 + W%2;
111
ostr<<
" "
<<whiteSpaces(nWL)<<row[c]<<whiteSpaces(nWR)<<
" |"
;
112
}
113
ostr<<std::endl;
114
}
115
}
116
}
HitSummary.h
size
size_t size() const
Number of registered mappings.
MuonR4
This header ties the generic definitions in this package.
Definition
GlobalPattern.h:14
Muon::MuonStationIndex
Definition
MuonStationIndex.h:14
Muon::MuonStationIndex::layerName
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
Definition
MuonStationIndex.cxx:154
Muon::MuonStationIndex::isSmall
bool isSmall(const ChIndex index)
Returns true if the chamber index is in a small sector.
Muon::MuonStationIndex::toInt
constexpr int toInt(const EnumType enumVal)
Definition
MuonStationIndex.h:62
Muon::MuonStationIndex::LayerIndex::BarrelExtended
@ BarrelExtended
EE.
Definition
MuonStationIndex.h:43
Muon::MuonStationIndex::LayerIndex::Inner
@ Inner
Definition
MuonStationIndex.h:41
Muon::MuonStationIndex::LayerIndex::Middle
@ Middle
Definition
MuonStationIndex.h:41
Muon::MuonStationIndex::LayerIndex::Outer
@ Outer
Definition
MuonStationIndex.h:41
Muon::MuonStationIndex::LayerIndex::Extended
@ Extended
Definition
MuonStationIndex.h:42
python.SystemOfUnits.s
float s
Definition
SystemOfUnits.py:147
A
hold the test vectors and ease the comparison
MuonR4::HitSummary::print
void print(std::ostream &ostr) const
Print the summary as an ASCII table.
Definition
HitSummary.cxx:76
MuonR4::HitSummary::value_type
std::uint8_t value_type
Definition
HitSummary.h:24
MuonR4::HitSummary::LayerIndex
Muon::MuonStationIndex::LayerIndex LayerIndex
Abrivation of the layer index.
Definition
HitSummary.h:26
MuonR4::HitSummary::nPrecisionStations
value_type nPrecisionStations() const
Returns the number of precision stations with at least 3 precision hits.
Definition
HitSummary.cxx:62
MuonR4::HitSummary::m_counts
Counter_t m_counts
Definition
HitSummary.h:103
MuonR4::HitSummary::translate
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).
Definition
HitSummary.cxx:37
MuonR4::HitSummary::toString
static std::string toString(const HitCategory c)
Converts the hit category to a string.
Definition
HitSummary.cxx:16
MuonR4::HitSummary::HitCategory
HitCategory
Category of the hit.
Definition
HitSummary.h:30
MuonR4::HitSummary::HitCategory::nCategories
@ nCategories
sTgc pad hits
Definition
HitSummary.h:35
MuonR4::HitSummary::HitCategory::TriggerPhi
@ TriggerPhi
Trigger eta hits (Tgc, Rpc).
Definition
HitSummary.h:33
MuonR4::HitSummary::HitCategory::Precision
@ Precision
Definition
HitSummary.h:31
MuonR4::HitSummary::HitCategory::sTgcPad
@ sTgcPad
Trigger phi hits (Tgc, Rpc).
Definition
HitSummary.h:34
MuonR4::HitSummary::HitCategory::TriggerEta
@ TriggerEta
Precision hits (Mdt, NSW) on track.
Definition
HitSummary.h:32
MuonR4::HitSummary::Status
Status
Contribution to the track fit.
Definition
HitSummary.h:39
MuonR4::HitSummary::Status::OnTrack
@ OnTrack
Definition
HitSummary.h:40
MuonR4::HitSummary::Status::Hole
@ Hole
Added to the trajectory but rejected.
Definition
HitSummary.h:42
MuonR4::HitSummary::Status::Outlier
@ Outlier
Added to the trajectory & contributing to the fit.
Definition
HitSummary.h:41
MuonR4::HitSummary::Status::MaxValue
@ MaxValue
Expected hit but missing.
Definition
HitSummary.h:43
MuonR4::HitSummary::value
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.
Definition
HitSummary.cxx:52
Generated on
for ATLAS Offline Software by
1.17.0