ATLAS Offline Software
Loading...
Searching...
No Matches
AmbiCounter< EnumType > Class Template Reference

#include <AmbiCounter.h>

Collaboration diagram for AmbiCounter< EnumType >:

Public Types

enum  RegionIndex {
  iBarrel , iTransi , iEndcap , iFWD = 3 ,
  nRegions =4 , iForwrd = 3
}
enum  GlobalCounterIndices { nEvents , nInvalidTracks , nTracksWithoutParam , nGlobalCounters }
using Categories = EnumType

Public Member Functions

 AmbiCounter (const std::vector< float > &eta_bounds)
size_t idx (const Categories &categoryIndex) const
void resetGlobalCounters ()
void newEvent ()
int numberOfEvents () const
void increment (Categories category, unsigned int etaBinIdx)
AmbiCounter< EnumType > & operator+= (const AmbiCounter< EnumType > &a)
void incrementCounterByRegion (Categories categoryIdx, const Trk::Track *track)
std::string dumpRegions (const std::string &head, Categories categoryIdx, const int iw=9) const
int globalCount (GlobalCounterIndices i) const

Private Member Functions

std::optional< size_t > etaBin (const double val)

Private Attributes

std::array< std::array< int, nRegions >, static_cast< size_t >(Categories::kNCounter)> m_counter {}
std::array< int, nGlobalCountersm_globalCounter {}
const std::vector< float > & m_etaBounds
 eta intervals for internal monitoring

Detailed Description

template<class EnumType>
class AmbiCounter< EnumType >

Definition at line 17 of file AmbiCounter.h.

Member Typedef Documentation

◆ Categories

template<class EnumType>
using AmbiCounter< EnumType >::Categories = EnumType

Definition at line 19 of file AmbiCounter.h.

Member Enumeration Documentation

◆ GlobalCounterIndices

template<class EnumType>
enum AmbiCounter::GlobalCounterIndices
Enumerator
nEvents 
nInvalidTracks 
nTracksWithoutParam 
nGlobalCounters 

Definition at line 21 of file AmbiCounter.h.

◆ RegionIndex

template<class EnumType>
enum AmbiCounter::RegionIndex
Enumerator
iBarrel 
iTransi 
iEndcap 
iFWD 
nRegions 
iForwrd 

Definition at line 20 of file AmbiCounter.h.

Constructor & Destructor Documentation

◆ AmbiCounter()

template<class EnumType>
AmbiCounter< EnumType >::AmbiCounter ( const std::vector< float > & eta_bounds)
inline

Definition at line 28 of file AmbiCounter.h.

29 const std::string errMsgPrefix = "In AmbiCounter.icc, eta_bounds size must be ";
30 if (m_etaBounds.size()!=nRegions) throw std::runtime_error(errMsgPrefix + std::to_string(nRegions) + " elements long.");
31 if (not std::is_sorted(m_etaBounds.begin(), m_etaBounds.end())){
32 throw std::runtime_error(errMsgPrefix + "in ascending order.");
33 }
34 }
const std::vector< float > & m_etaBounds
eta intervals for internal monitoring

Member Function Documentation

◆ dumpRegions()

template<class EnumType>
std::string AmbiCounter< EnumType >::dumpRegions ( const std::string & head,
Categories categoryIdx,
const int iw = 9 ) const
inline

Definition at line 99 of file AmbiCounter.h.

99 {
101 out << head;
102 if (categoryIdx >= Categories::kNCounter) throw std::out_of_range("Array index out of range in AmbiCounter::inc by region");
103 const auto & displayedArray = m_counter[idx(categoryIdx)];
104 const auto allRegionCounts = std::accumulate(displayedArray.begin(), displayedArray.end(),0);
106 for (unsigned int etaBinIdx=0; etaBinIdx < nRegions; ++etaBinIdx) {
108 }
109 out << "\n";
110 return out.str();
111 }
std::array< std::array< int, nRegions >, static_cast< size_t >(Categories::kNCounter)> m_counter
size_t idx(const Categories &categoryIndex) const
Definition AmbiCounter.h:38

◆ etaBin()

template<class EnumType>
std::optional< size_t > AmbiCounter< EnumType >::etaBin ( const double val)
inlineprivate

Definition at line 123 of file AmbiCounter.h.

123 {
124 auto pVal = std::lower_bound(m_etaBounds.begin(), m_etaBounds.end(), val);
125 //if it's in bounds, return the value, otherwise return a nullopt
127 }

◆ globalCount()

template<class EnumType>
int AmbiCounter< EnumType >::globalCount ( GlobalCounterIndices i) const
inline

Definition at line 114 of file AmbiCounter.h.

114 {
115 return m_globalCounter[i];
116 }
std::array< int, nGlobalCounters > m_globalCounter

◆ idx()

template<class EnumType>
size_t AmbiCounter< EnumType >::idx ( const Categories & categoryIndex) const
inline

Definition at line 38 of file AmbiCounter.h.

38 {
39 return static_cast<size_t>(categoryIndex);
40 }

◆ increment()

template<class EnumType>
void AmbiCounter< EnumType >::increment ( Categories category,
unsigned int etaBinIdx )
inline

Definition at line 60 of file AmbiCounter.h.

60 {
62 throw std::out_of_range("in AmbiCounter.icc::increment()");
63 }
65 }

◆ incrementCounterByRegion()

template<class EnumType>
void AmbiCounter< EnumType >::incrementCounterByRegion ( Categories categoryIdx,
const Trk::Track * track )
inline

Definition at line 79 of file AmbiCounter.h.

79 {
80 // test
81 if (!track) {
83 return;
84 }
85 // use first parameter
86 if (!track->trackParameters()) {
88 } else {
90 // @TODO make sure that list of track parameters is not empty
91 const double absEta = std::abs(track->trackParameters()->front()->eta());
92 if (const auto &possibleIdx{etaBin(absEta)}){//i.e. if it's within bounds
93 ++nTracks[possibleIdx.value()];
94 }
95 }
96 }
std::optional< size_t > etaBin(const double val)

◆ newEvent()

template<class EnumType>
void AmbiCounter< EnumType >::newEvent ( )
inline

Definition at line 49 of file AmbiCounter.h.

49 {
51 }

◆ numberOfEvents()

template<class EnumType>
int AmbiCounter< EnumType >::numberOfEvents ( ) const
inline

Definition at line 55 of file AmbiCounter.h.

55 {
57 }

◆ operator+=()

template<class EnumType>
AmbiCounter< EnumType > & AmbiCounter< EnumType >::operator+= ( const AmbiCounter< EnumType > & a)
inline

Definition at line 67 of file AmbiCounter.h.

67 {
68 for (unsigned int i=0; i<nGlobalCounters; ++i) {
70 }
72 for (unsigned int etaBinIdx=0; etaBinIdx < a.m_counter[categoryIdx].size(); ++etaBinIdx) {
74 }
75 }
76 return *this;
77}

◆ resetGlobalCounters()

template<class EnumType>
void AmbiCounter< EnumType >::resetGlobalCounters ( )
inline

Definition at line 43 of file AmbiCounter.h.

43 {
44 m_globalCounter.fill(0);
45 }

Member Data Documentation

◆ m_counter

template<class EnumType>
std::array<std::array<int, nRegions>,static_cast<size_t>(Categories::kNCounter)> AmbiCounter< EnumType >::m_counter {}
private

Definition at line 119 of file AmbiCounter.h.

119{};

◆ m_etaBounds

template<class EnumType>
const std::vector<float>& AmbiCounter< EnumType >::m_etaBounds
private

eta intervals for internal monitoring

Definition at line 121 of file AmbiCounter.h.

◆ m_globalCounter

template<class EnumType>
std::array<int,nGlobalCounters> AmbiCounter< EnumType >::m_globalCounter {}
private

Definition at line 120 of file AmbiCounter.h.

120{};

The documentation for this class was generated from the following file: