ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 More...
 

Detailed Description

template<class EnumType>
class AmbiCounter< EnumType >

Definition at line 16 of file AmbiCounter.h.

Member Typedef Documentation

◆ Categories

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

Definition at line 18 of file AmbiCounter.h.

Member Enumeration Documentation

◆ GlobalCounterIndices

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

Definition at line 20 of file AmbiCounter.h.

20  {
21  nEvents,
25  };

◆ RegionIndex

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

Definition at line 19 of file AmbiCounter.h.

19 {iBarrel , iTransi , iEndcap , iFWD = 3, nRegions=4, iForwrd = 3};

Constructor & Destructor Documentation

◆ AmbiCounter()

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

Definition at line 27 of file AmbiCounter.h.

27  : m_etaBounds(eta_bounds){
28  const std::string errMsgPrefix = "In AmbiCounter.icc, eta_bounds size must be ";
29  if (m_etaBounds.size()!=nRegions) throw std::runtime_error(errMsgPrefix + std::to_string(nRegions) + " elements long.");
30  if (not std::is_sorted(m_etaBounds.begin(), m_etaBounds.end())){
31  throw std::runtime_error(errMsgPrefix + "in ascending order.");
32  }
33  }

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 98 of file AmbiCounter.h.

98  {
99  std::stringstream out;
100  out << head;
101  if (categoryIdx >= Categories::kNCounter) throw std::out_of_range("Array index out of range in AmbiCounter::inc by region");
102  const auto & displayedArray = m_counter[idx(categoryIdx)];
103  const auto allRegionCounts = std::accumulate(displayedArray.begin(), displayedArray.end(),0);
104  out << std::setiosflags(std::ios::dec) << std::setw(iw) << allRegionCounts;
105  for (unsigned int etaBinIdx=0; etaBinIdx < nRegions; ++etaBinIdx) {
106  out << std::setiosflags(std::ios::dec) << std::setw(iw) << m_counter[idx(categoryIdx)][etaBinIdx];
107  }
108  out << "\n";
109  return out.str();
110  }

◆ etaBin()

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

Definition at line 122 of file AmbiCounter.h.

122  {
123  auto pVal = std::lower_bound(m_etaBounds.begin(), m_etaBounds.end(), val);
124  //if it's in bounds, return the value, otherwise return a nullopt
125  return (pVal!=m_etaBounds.end()) ? std::optional<size_t>(std::distance(m_etaBounds.begin(), pVal)):std::nullopt;
126  }

◆ globalCount()

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

Definition at line 113 of file AmbiCounter.h.

113  {
114  return m_globalCounter[i];
115  }

◆ idx()

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

Definition at line 37 of file AmbiCounter.h.

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

◆ increment()

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

Definition at line 59 of file AmbiCounter.h.

59  {
60  if ((category>= Categories::kNCounter) or (etaBinIdx >=nRegions)){
61  throw std::out_of_range("in AmbiCounter.icc::increment()");
62  }
63  ++m_counter[idx(category)][etaBinIdx];
64  }

◆ incrementCounterByRegion()

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

Definition at line 78 of file AmbiCounter.h.

78  {
79  // test
80  if (!track) {
82  return;
83  }
84  // use first parameter
85  if (!track->trackParameters()) {
87  } else {
88  std::array<int, nRegions> &nTracks = m_counter.at(idx(categoryIdx));
89  // @TODO make sure that list of track parameters is not empty
90  const double absEta = std::abs(track->trackParameters()->front()->eta());
91  if (const auto &possibleIdx{etaBin(absEta)}){//i.e. if it's within bounds
92  ++nTracks[possibleIdx.value()];
93  }
94  }
95  }

◆ newEvent()

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

Definition at line 48 of file AmbiCounter.h.

48  {
50  }

◆ numberOfEvents()

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

Definition at line 54 of file AmbiCounter.h.

54  {
55  return m_globalCounter[nEvents];
56  }

◆ operator+=()

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

Definition at line 66 of file AmbiCounter.h.

66  {
67  for (unsigned int i=0; i<nGlobalCounters; ++i) {
68  m_globalCounter[i]+= a.m_globalCounter[i];
69  }
70  for (size_t categoryIdx=0; categoryIdx < idx(Categories::kNCounter); ++categoryIdx) {
71  for (unsigned int etaBinIdx=0; etaBinIdx < a.m_counter[categoryIdx].size(); ++etaBinIdx) {
72  m_counter[categoryIdx][etaBinIdx] += a.m_counter[categoryIdx][etaBinIdx];
73  }
74  }
75  return *this;
76 }

◆ resetGlobalCounters()

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

Definition at line 42 of file AmbiCounter.h.

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

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 118 of file AmbiCounter.h.

◆ m_etaBounds

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

eta intervals for internal monitoring

Definition at line 120 of file AmbiCounter.h.

◆ m_globalCounter

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

Definition at line 119 of file AmbiCounter.h.


The documentation for this class was generated from the following file:
AmbiCounter::iEndcap
@ iEndcap
Definition: AmbiCounter.h:19
AmbiCounter::iFWD
@ iFWD
Definition: AmbiCounter.h:19
AmbiCounter::idx
size_t idx(const Categories &categoryIndex) const
Definition: AmbiCounter.h:37
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
AmbiCounter::iForwrd
@ iForwrd
Definition: AmbiCounter.h:19
AmbiCounter::nInvalidTracks
@ nInvalidTracks
Definition: AmbiCounter.h:22
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
AmbiCounter::iTransi
@ iTransi
Definition: AmbiCounter.h:19
AmbiCounter::nRegions
@ nRegions
Definition: AmbiCounter.h:19
AmbiCounter::m_globalCounter
std::array< int, nGlobalCounters > m_globalCounter
Definition: AmbiCounter.h:119
AmbiCounter::nTracksWithoutParam
@ nTracksWithoutParam
Definition: AmbiCounter.h:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
ReweightUtils.category
category
Definition: ReweightUtils.py:15
AmbiCounter::m_counter
std::array< std::array< int, nRegions >, static_cast< size_t >Categories::kNCounter)> m_counter
Definition: AmbiCounter.h:118
AmbiCounter::etaBin
std::optional< size_t > etaBin(const double val)
Definition: AmbiCounter.h:122
head
std::string head(std::string s, const std::string &pattern)
head of a string
Definition: computils.cxx:310
AmbiCounter::nGlobalCounters
@ nGlobalCounters
Definition: AmbiCounter.h:24
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AmbiCounter::nEvents
@ nEvents
Definition: AmbiCounter.h:21
AmbiCounter::iBarrel
@ iBarrel
Definition: AmbiCounter.h:19
a
TList * a
Definition: liststreamerinfos.cxx:10
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
AmbiCounter::m_etaBounds
const std::vector< float > & m_etaBounds
eta intervals for internal monitoring
Definition: AmbiCounter.h:120
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:234
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54