ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::HitSummary Struct Reference

Summary struct to hold the hit counts on the track per MS layer. More...

#include <HitSummary.h>

Collaboration diagram for MuonR4::HitSummary:

Public Types

enum class  HitCategory : std::uint8_t {
  Precision =0 , TriggerEta , TriggerPhi , sTgcPad ,
  nCategories
}
 Category of the hit. More...
enum class  Status { OnTrack = 0 , Outlier , Hole , MaxValue }
 Contribution to the track fit. More...
using value_type = std::uint8_t
using LayerIndex = Muon::MuonStationIndex::LayerIndex
 Abrivation of the layer index.

Public Member Functions

 HitSummary ()=default
 Default constructor.
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.
value_typevalue (const HitCategory cat, const Status status, const LayerIndex layer, const bool isSmall)
 Returns the value type for a defined hit category & layer to modify the summary value.
value_type nPrecisionStations () const
 Returns the number of precision stations with at least 3 precision hits.

Static Public Member Functions

static std::string toString (const HitCategory c)
 Converts the hit category to a string.
static std::string toString (const Status s)
 Converts the status to a string.

Private Types

using Counter_t
 Abrivation to store the hits per layer.

Private Member Functions

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).
void print (std::ostream &ostr) const
 Print the summary as an ASCII table.

Private Attributes

Counter_t m_counts {}

Friends

std::ostream & operator<< (std::ostream &ostr, const HitCategory c)
std::ostream & operator<< (std::ostream &ostr, const Status s)
std::ostream & operator<< (std::ostream &ostr, const HitSummary &sum)
 Output string stream operator.

Detailed Description

Summary struct to hold the hit counts on the track per MS layer.

Summaries are categorized by MS layer (Inner / Middle / Outer / Extended), by whether the hit is a precision, trigger eta or trigger phi hit & by their contribution to the track fit. Note: Barrel extended is counted under the Extended category

Definition at line 23 of file HitSummary.h.

Member Typedef Documentation

◆ Counter_t

Initial value:
std::array<value_type, Acts::toUnderlying(HitCategory::nCategories) *
(Acts::toUnderlying(LayerIndex::LayerIndexMax) -1)*
Acts::toUnderlying(Status::MaxValue) * 2>
std::uint8_t value_type
Definition HitSummary.h:24

Abrivation to store the hits per layer.

Definition at line 99 of file HitSummary.h.

◆ LayerIndex

Abrivation of the layer index.

Definition at line 26 of file HitSummary.h.

◆ value_type

using MuonR4::HitSummary::value_type = std::uint8_t

Definition at line 24 of file HitSummary.h.

Member Enumeration Documentation

◆ HitCategory

enum class MuonR4::HitSummary::HitCategory : std::uint8_t
strong

Category of the hit.

Enumerator
Precision 
TriggerEta 

Precision hits (Mdt, NSW) on track.

TriggerPhi 

Trigger eta hits (Tgc, Rpc).

sTgcPad 

Trigger phi hits (Tgc, Rpc).

nCategories 

sTgc pad hits

Definition at line 30 of file HitSummary.h.

30 : std::uint8_t{
31 Precision=0,
32 TriggerEta,
33 TriggerPhi,
34 sTgcPad,
36
37 };

◆ Status

enum class MuonR4::HitSummary::Status
strong

Contribution to the track fit.

Enumerator
OnTrack 
Outlier 

Added to the trajectory & contributing to the fit.

Hole 

Added to the trajectory but rejected.

MaxValue 

Expected hit but missing.

Definition at line 39 of file HitSummary.h.

Constructor & Destructor Documentation

◆ HitSummary()

MuonR4::HitSummary::HitSummary ( )
default

Default constructor.

Member Function Documentation

◆ nPrecisionStations()

HitSummary::value_type MuonR4::HitSummary::nPrecisionStations ( ) const

Returns the number of precision stations with at least 3 precision hits.

Definition at line 62 of file HitSummary.cxx.

62 {
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 }
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.

◆ print()

void MuonR4::HitSummary::print ( std::ostream & ostr) const
private

Print the summary as an ASCII table.

Definition at line 76 of file HitSummary.cxx.

76 {
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,
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 }
size_t size() const
Number of registered mappings.
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
row
Appending html table to final .html summary file.
static std::string toString(const HitCategory c)
Converts the hit category to a string.
@ TriggerPhi
Trigger eta hits (Tgc, Rpc).
Definition HitSummary.h:33
@ sTgcPad
Trigger phi hits (Tgc, Rpc).
Definition HitSummary.h:34
@ TriggerEta
Precision hits (Mdt, NSW) on track.
Definition HitSummary.h:32

◆ toString() [1/2]

std::string MuonR4::HitSummary::toString ( const HitCategory c)
static

Converts the hit category to a string.

Definition at line 16 of file HitSummary.cxx.

16 {
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 }
HitCategory
Category of the hit.
Definition HitSummary.h:30

◆ toString() [2/2]

std::string MuonR4::HitSummary::toString ( const Status s)
static

Converts the status to a string.

Definition at line 27 of file HitSummary.cxx.

27 {
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 }
Status
Contribution to the track fit.
Definition HitSummary.h:39
@ Hole
Added to the trajectory but rejected.
Definition HitSummary.h:42
@ Outlier
Added to the trajectory & contributing to the fit.
Definition HitSummary.h:41
@ MaxValue
Expected hit but missing.
Definition HitSummary.h:43

◆ translate()

unsigned MuonR4::HitSummary::translate ( const HitCategory cat,
const Status status,
LayerIndex layer,
const bool isSmall ) const
private

Translates the 4 classification indices to a unique consecutive number (used for storage access).

Parameters
catHit category
statusContribution to the fit
layerSpectrometer layer
isSmallSmall sectors

Map the barrel extended -> extended index

Definition at line 37 of file HitSummary.cxx.

38 {
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 }
bool isSmall(const ChIndex index)
Returns true if the chamber index is in a small sector.
constexpr int toInt(const EnumType enumVal)
@ layer
Definition HitInfo.h:79

◆ value() [1/2]

HitSummary::value_type & MuonR4::HitSummary::value ( const HitCategory cat,
const Status status,
const LayerIndex layer,
const bool isSmall )

Returns the value type for a defined hit category & layer to modify the summary value.

Parameters
catHit category
statusContribution to the fit
layerSpectrometer layer
isSmallSmall sectors

Definition at line 57 of file HitSummary.cxx.

58 {
59 return m_counts[translate(cat, status, layer, isSmall)];
60 }
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).

◆ value() [2/2]

HitSummary::value_type MuonR4::HitSummary::value ( const HitCategory cat,
const Status status,
const LayerIndex layer,
const bool isSmall ) const

Returns the value type for a defined hit category & layer.

Parameters
catHit category
statusContribution to the fit
layerSpectrometer layer
isSmallSmall sectors

Definition at line 52 of file HitSummary.cxx.

53 {
54 return m_counts[translate(cat, status, layer, isSmall)];
55 }

◆ operator<< [1/3]

std::ostream & operator<< ( std::ostream & ostr,
const HitCategory c )
friend

Definition at line 48 of file HitSummary.h.

48 {
49 return (ostr<<toString(c));
50 }

◆ operator<< [2/3]

std::ostream & operator<< ( std::ostream & ostr,
const HitSummary & sum )
friend

Output string stream operator.

Definition at line 78 of file HitSummary.h.

78 {
79 sum.print(ostr);
80 return ostr;
81 }

◆ operator<< [3/3]

std::ostream & operator<< ( std::ostream & ostr,
const Status s )
friend

Definition at line 54 of file HitSummary.h.

54 {
55 return (ostr<<toString(s));
56 }

Member Data Documentation

◆ m_counts

Counter_t MuonR4::HitSummary::m_counts {}
private

Definition at line 103 of file HitSummary.h.

103{};

The documentation for this struct was generated from the following files: