All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
icarus::trigger::details::TriggerPassCounters Class Reference

Tracks pass rate by discrimination threshold and trigger pattern name. More...

#include <TriggerEfficiencyPlotsBase.h>

Public Types

using Threshold_t = std::string
 
using Counter_t = icarus::ns::util::PassCounter< unsigned int >
 Type used as counter for a specific trigger. More...
 
using IndexPair_t = std::pair< std::size_t, std::size_t >
 

Public Member Functions

IndexPair_t create (Threshold_t const &threshold, std::string const &patternName)
 Creates and returns a new counter. More...
 
std::size_t thresholdIndex (Threshold_t const &threshold) const
 Returns the index of the specified threshold (max() if not registered). More...
 
std::size_t patternIndex (std::string const &patternName) const
 Returns the index of the specified pattern (max() if not registered). More...
 
Threshold_t const & threshold (std::size_t index) const
 
std::string const & patternName (std::size_t index) const
 
std::size_t nThresholds () const
 Returns the number of thresholds currently registered. More...
 
std::size_t nPatterns () const
 Returns the number of patterns currently registered. More...
 
void dump (std::ostream &out) const
 Dump all the counters on the specified stream. More...
 
Counter_t const & counter (Threshold_t const &threshold, std::string const &patternName) const
 
Counter_t const & counter (std::size_t threshold, std::string const &patternName) const
 
Counter_t const & counter (Threshold_t const &threshold, std::size_t patternName) const
 
Counter_t const & counter (std::size_t threshold, std::size_t patternName) const
 
Counter_t const & counter (IndexPair_t indices) const
 
Counter_t const & operator() (Threshold_t const &threshold, std::string const &patternName) const
 
Counter_t const & operator() (std::size_t threshold, std::string const &patternName) const
 
Counter_t const & operator() (Threshold_t const &threshold, std::size_t patternName) const
 
Counter_t const & operator() (std::size_t threshold, std::size_t patternName) const
 
Counter_t const & operator() (IndexPair_t indices) const
 
Counter_tcounter (Threshold_t const &threshold, std::string const &patternName)
 
Counter_tcounter (std::size_t threshold, std::string const &patternName)
 
Counter_tcounter (Threshold_t const &threshold, std::size_t patternName)
 
Counter_tcounter (std::size_t threshold, std::size_t patternName)
 
Counter_tcounter (IndexPair_t indices)
 
Counter_toperator() (Threshold_t const &threshold, std::string const &patternName)
 
Counter_toperator() (std::size_t threshold, std::string const &patternName)
 
Counter_toperator() (Threshold_t const &threshold, std::size_t patternName)
 
Counter_toperator() (std::size_t threshold, std::size_t patternName)
 
Counter_toperator() (IndexPair_t indices)
 
bool hasThreshold (Threshold_t const &threshold) const
 Returns whether the specified threshold is registered. More...
 
bool hasThreshold (std::size_t index) const
 
bool hasPattern (std::string const &patternName) const
 Returns whether the specified pattern is registered. More...
 
bool hasPattern (std::size_t patternIndex) const
 

Static Public Attributes

static constexpr std::size_t NoIndex = std::numeric_limits<std::size_t>::max()
 Represents the index of a threshold or pattern that is not registered. More...
 

Private Member Functions

std::size_t registerThreshold (Threshold_t const &threshold)
 Registers a new threshold in the index and returns its index (unchecked). More...
 
std::size_t registerPattern (std::string const &name)
 Registers a new pattern in the index and returns its index (unchecked). More...
 

Private Attributes

std::vector< std::vector
< Counter_t > > 
fCounters
 All counters; indices: [threshold][pattern]. More...
 
std::unordered_map
< Threshold_t, std::size_t > 
fThresholdIndex
 Map: threshold -> threshold index. More...
 
std::unordered_map
< std::string, std::size_t > 
fPatternIndex
 Map: pattern name -> pattern index. More...
 

Detailed Description

Tracks pass rate by discrimination threshold and trigger pattern name.

Definition at line 100 of file TriggerEfficiencyPlotsBase.h.

Member Typedef Documentation

Type used as counter for a specific trigger.

Definition at line 106 of file TriggerEfficiencyPlotsBase.h.

using icarus::trigger::details::TriggerPassCounters::IndexPair_t = std::pair<std::size_t, std::size_t>

Definition at line 108 of file TriggerEfficiencyPlotsBase.h.

Definition at line 103 of file TriggerEfficiencyPlotsBase.h.

Member Function Documentation

auto icarus::trigger::details::TriggerPassCounters::counter ( Threshold_t const &  threshold,
std::string const &  patternName 
) const

Returns the counter for the specified threshold and pattern.

Exceptions
std::out_of_rangeif not registered.

Definition at line 152 of file TriggerEfficiencyPlotsBase.cxx.

154 {
155  IndexPair_t const index
157  if (index.first == NoIndex)
158  throw std::out_of_range{ threshold };
159  if (index.second == NoIndex)
160  throw std::out_of_range{ patternName };
161  return counter(index);
162 } // icarus::trigger::details::TriggerPassCounters::counter(Threshold_t, string)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::size_t thresholdIndex(Threshold_t const &threshold) const
Returns the index of the specified threshold (max() if not registered).
std::size_t patternIndex(std::string const &patternName) const
Returns the index of the specified pattern (max() if not registered).
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( std::size_t  threshold,
std::string const &  patternName 
) const

Definition at line 167 of file TriggerEfficiencyPlotsBase.cxx.

169 {
170  IndexPair_t const index { threshold, patternIndex(patternName) };
171  if (index.first == NoIndex)
172  throw std::out_of_range{ std::to_string(threshold) };
173  if (index.second == NoIndex)
174  throw std::out_of_range{ patternName };
175  return counter(index);
176 } // icarus::trigger::details::TriggerPassCounters::counter(size_t, string)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::size_t patternIndex(std::string const &patternName) const
Returns the index of the specified pattern (max() if not registered).
std::string to_string(WindowPattern const &pattern)
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( Threshold_t const &  threshold,
std::size_t  patternName 
) const

Definition at line 181 of file TriggerEfficiencyPlotsBase.cxx.

183 {
184  IndexPair_t const index
186  if (index.first == NoIndex)
187  throw std::out_of_range{ threshold };
188  if (index.second == NoIndex)
189  throw std::out_of_range{ std::to_string(pattern) };
190  return counter(index);
191 } // icarus::trigger::details::TriggerPassCounters::counter(Threshold_t, size_t)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::size_t thresholdIndex(Threshold_t const &threshold) const
Returns the index of the specified threshold (max() if not registered).
std::string to_string(WindowPattern const &pattern)
Threshold_t const & threshold(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( std::size_t  threshold,
std::size_t  patternName 
) const

Definition at line 196 of file TriggerEfficiencyPlotsBase.cxx.

198 {
199  IndexPair_t const index { threshold, pattern };
200  if (index.first == NoIndex)
201  throw std::out_of_range{ std::to_string(threshold) };
202  if (index.second == NoIndex)
203  throw std::out_of_range{ std::to_string(pattern) };
204  return counter(index);
205 } // icarus::trigger::details::TriggerPassCounters::counter(size_t, size_t)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::string to_string(WindowPattern const &pattern)
Threshold_t const & threshold(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( IndexPair_t  indices) const

Definition at line 210 of file TriggerEfficiencyPlotsBase.cxx.

211 {
212  if (!hasThreshold(indices.first))
213  throw std::out_of_range{ std::to_string(indices.first) };
214 
215  auto const& thrCounters = fCounters[indices.first];
216  if (indices.second >= thrCounters.size())
217  throw std::out_of_range{ std::to_string(indices.second) };
218 
219  return thrCounters[indices.second];
220 } // icarus::trigger::details::TriggerPassCounters::counter(IndexPair_t)
std::vector< std::vector< Counter_t > > fCounters
All counters; indices: [threshold][pattern].
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
std::string to_string(WindowPattern const &pattern)
bool hasThreshold(Threshold_t const &threshold) const
Returns whether the specified threshold is registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( Threshold_t const &  threshold,
std::string const &  patternName 
)

Definition at line 225 of file TriggerEfficiencyPlotsBase.cxx.

226 {
227  IndexPair_t const index
229  if (index.first == NoIndex)
230  throw std::out_of_range{ threshold };
231  if (index.second == NoIndex)
232  throw std::out_of_range{ patternName };
233  return counter(index);
234 } // icarus::trigger::details::TriggerPassCounters::counter(Threshold_t, string)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::size_t thresholdIndex(Threshold_t const &threshold) const
Returns the index of the specified threshold (max() if not registered).
std::size_t patternIndex(std::string const &patternName) const
Returns the index of the specified pattern (max() if not registered).
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( std::size_t  threshold,
std::string const &  patternName 
)

Definition at line 239 of file TriggerEfficiencyPlotsBase.cxx.

240 {
241  IndexPair_t const index { threshold, patternIndex(patternName) };
242  if (index.first == NoIndex)
243  throw std::out_of_range{ std::to_string(threshold) };
244  if (index.second == NoIndex)
245  throw std::out_of_range{ patternName };
246  return counter(index);
247 } // icarus::trigger::details::TriggerPassCounters::counter(size_t, string)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::size_t patternIndex(std::string const &patternName) const
Returns the index of the specified pattern (max() if not registered).
std::string to_string(WindowPattern const &pattern)
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( Threshold_t const &  threshold,
std::size_t  patternName 
)

Definition at line 252 of file TriggerEfficiencyPlotsBase.cxx.

253 {
254  IndexPair_t const index
256  if (index.first == NoIndex)
257  throw std::out_of_range{ threshold };
258  if (index.second == NoIndex)
259  throw std::out_of_range{ std::to_string(pattern) };
260  return counter(index);
261 } // icarus::trigger::details::TriggerPassCounters::counter(Threshold_t, size_t)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::size_t thresholdIndex(Threshold_t const &threshold) const
Returns the index of the specified threshold (max() if not registered).
std::string to_string(WindowPattern const &pattern)
Threshold_t const & threshold(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( std::size_t  threshold,
std::size_t  patternName 
)

Definition at line 266 of file TriggerEfficiencyPlotsBase.cxx.

267 {
268  IndexPair_t const index { threshold, pattern };
269  if (index.first == NoIndex)
270  throw std::out_of_range{ std::to_string(threshold) };
271  if (index.second == NoIndex)
272  throw std::out_of_range{ std::to_string(pattern) };
273  return counter(index);
274 } // icarus::trigger::details::TriggerPassCounters::counter(size_t, size_t)
std::pair< std::size_t, std::size_t > IndexPair_t
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::string to_string(WindowPattern const &pattern)
Threshold_t const & threshold(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::counter ( IndexPair_t  indices)

Definition at line 278 of file TriggerEfficiencyPlotsBase.cxx.

280 {
281  if (!hasThreshold(indices.first))
282  throw std::out_of_range{ std::to_string(indices.first) };
283 
284  auto& thrCounters = fCounters[indices.first];
285  if (indices.second >= thrCounters.size())
286  throw std::out_of_range{ std::to_string(indices.second) };
287 
288  return thrCounters[indices.second];
289 } // icarus::trigger::details::TriggerPassCounters::counter(IndexPair_t)
std::vector< std::vector< Counter_t > > fCounters
All counters; indices: [threshold][pattern].
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
std::string to_string(WindowPattern const &pattern)
bool hasThreshold(Threshold_t const &threshold) const
Returns whether the specified threshold is registered.
auto icarus::trigger::details::TriggerPassCounters::create ( Threshold_t const &  threshold,
std::string const &  patternName 
)

Creates and returns a new counter.

Returns
the specified counter

If the counter already exists, it is returned.

Definition at line 89 of file TriggerEfficiencyPlotsBase.cxx.

90 {
91 
92  std::size_t thrIndex = thresholdIndex(threshold);
93  if (thrIndex == NoIndex) thrIndex = registerThreshold(threshold);
94 
95  std::size_t patIndex = patternIndex(patternName);
96  if (patIndex == NoIndex) patIndex = registerPattern(patternName);
97 
98  if (thrIndex >= nThresholds())
99  fCounters.resize(thrIndex + 1U, std::vector<Counter_t>{ nPatterns() });
100 
101  if (patIndex >= nPatterns()) {
102  for (auto& thrCounters: fCounters) thrCounters.resize(patIndex + 1U);
103  }
104 
105  assert(hasThreshold(thrIndex));
106  assert(hasPattern(patIndex));
107  return { thrIndex, patIndex };
108 
109 } // icarus::trigger::details::TriggerPassCounters::create()
std::size_t nThresholds() const
Returns the number of thresholds currently registered.
std::vector< std::vector< Counter_t > > fCounters
All counters; indices: [threshold][pattern].
std::size_t thresholdIndex(Threshold_t const &threshold) const
Returns the index of the specified threshold (max() if not registered).
bool hasPattern(std::string const &patternName) const
Returns whether the specified pattern is registered.
std::size_t registerPattern(std::string const &name)
Registers a new pattern in the index and returns its index (unchecked).
std::size_t patternIndex(std::string const &patternName) const
Returns the index of the specified pattern (max() if not registered).
std::size_t registerThreshold(Threshold_t const &threshold)
Registers a new threshold in the index and returns its index (unchecked).
Threshold_t const & threshold(std::size_t index) const
std::size_t nPatterns() const
Returns the number of patterns currently registered.
bool hasThreshold(Threshold_t const &threshold) const
Returns whether the specified threshold is registered.
std::string const & patternName(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
void icarus::trigger::details::TriggerPassCounters::dump ( std::ostream &  out) const

Dump all the counters on the specified stream.

Definition at line 358 of file TriggerEfficiencyPlotsBase.cxx.

359 {
360  out << "Triggers for " << nThresholds() << " thresholds and " << nPatterns()
361  << " patterns:";
362  for (auto const iThr: util::counter(nThresholds())) {
363 
364  assert(hasThreshold(iThr));
365  out << "\n threshold " << threshold(iThr) << " [#" << iThr << "]:";
366  unsigned int nonEmptyPatterns = 0U;
367  for (auto const iPat: util::counter(nPatterns())) {
368  assert(hasPattern(iPat));
369  auto const& counts = counter(iThr, iPat);
370  if (counts.empty()) continue;
371  out << "\n " << patternName(iPat) << " [#" << iPat << "]: "
372  << counts.passed() << " / " << counts.total();
373  ++nonEmptyPatterns;
374  } // for patterns
375  if (nonEmptyPatterns == 0) out << " no events";
376 
377  } // for threshold
378  out << "\n";
379 } // icarus::trigger::details::TriggerPassCounters::dump()
std::size_t nThresholds() const
Returns the number of thresholds currently registered.
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
bool hasPattern(std::string const &patternName) const
Returns whether the specified pattern is registered.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
counts_as<> counts
Number of ADC counts, represented by signed short int.
Definition: electronics.h:116
Threshold_t const & threshold(std::size_t index) const
std::size_t nPatterns() const
Returns the number of patterns currently registered.
bool hasThreshold(Threshold_t const &threshold) const
Returns whether the specified threshold is registered.
std::string const & patternName(std::size_t index) const
bool icarus::trigger::details::TriggerPassCounters::hasPattern ( std::string const &  patternName) const

Returns whether the specified pattern is registered.

Definition at line 306 of file TriggerEfficiencyPlotsBase.cxx.

307  { return fPatternIndex.find(patternName) != fPatternIndex.end(); }
std::unordered_map< std::string, std::size_t > fPatternIndex
Map: pattern name -&gt; pattern index.
std::string const & patternName(std::size_t index) const
bool icarus::trigger::details::TriggerPassCounters::hasPattern ( std::size_t  patternIndex) const

Definition at line 312 of file TriggerEfficiencyPlotsBase.cxx.

313  { return patternIndex < nPatterns(); }
std::size_t patternIndex(std::string const &patternName) const
Returns the index of the specified pattern (max() if not registered).
std::size_t nPatterns() const
Returns the number of patterns currently registered.
bool icarus::trigger::details::TriggerPassCounters::hasThreshold ( Threshold_t const &  threshold) const

Returns whether the specified threshold is registered.

Definition at line 294 of file TriggerEfficiencyPlotsBase.cxx.

295  { return fThresholdIndex.find(threshold) != fThresholdIndex.end(); }
std::unordered_map< Threshold_t, std::size_t > fThresholdIndex
Map: threshold -&gt; threshold index.
Threshold_t const & threshold(std::size_t index) const
bool icarus::trigger::details::TriggerPassCounters::hasThreshold ( std::size_t  index) const

Definition at line 300 of file TriggerEfficiencyPlotsBase.cxx.

301  { return thresholdIndex < nThresholds(); }
std::size_t nThresholds() const
Returns the number of thresholds currently registered.
std::size_t thresholdIndex(Threshold_t const &threshold) const
Returns the index of the specified threshold (max() if not registered).
std::size_t icarus::trigger::details::TriggerPassCounters::nPatterns ( ) const

Returns the number of patterns currently registered.

Definition at line 118 of file TriggerEfficiencyPlotsBase.cxx.

119  { return fCounters.empty()? 0U: fCounters.front().size(); }
std::vector< std::vector< Counter_t > > fCounters
All counters; indices: [threshold][pattern].
std::size_t icarus::trigger::details::TriggerPassCounters::nThresholds ( ) const

Returns the number of thresholds currently registered.

Definition at line 113 of file TriggerEfficiencyPlotsBase.cxx.

114  { return fCounters.size(); }
std::vector< std::vector< Counter_t > > fCounters
All counters; indices: [threshold][pattern].
Counter_t const& icarus::trigger::details::TriggerPassCounters::operator() ( Threshold_t const &  threshold,
std::string const &  patternName 
) const
inline

Definition at line 139 of file TriggerEfficiencyPlotsBase.h.

140  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t const& icarus::trigger::details::TriggerPassCounters::operator() ( std::size_t  threshold,
std::string const &  patternName 
) const
inline

Definition at line 142 of file TriggerEfficiencyPlotsBase.h.

143  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t const& icarus::trigger::details::TriggerPassCounters::operator() ( Threshold_t const &  threshold,
std::size_t  patternName 
) const
inline

Definition at line 145 of file TriggerEfficiencyPlotsBase.h.

146  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t const& icarus::trigger::details::TriggerPassCounters::operator() ( std::size_t  threshold,
std::size_t  patternName 
) const
inline

Definition at line 148 of file TriggerEfficiencyPlotsBase.h.

149  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t const& icarus::trigger::details::TriggerPassCounters::operator() ( IndexPair_t  indices) const
inline

Definition at line 150 of file TriggerEfficiencyPlotsBase.h.

151  { return counter(indices); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
Counter_t& icarus::trigger::details::TriggerPassCounters::operator() ( Threshold_t const &  threshold,
std::string const &  patternName 
)
inline

Definition at line 161 of file TriggerEfficiencyPlotsBase.h.

162  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t& icarus::trigger::details::TriggerPassCounters::operator() ( std::size_t  threshold,
std::string const &  patternName 
)
inline

Definition at line 163 of file TriggerEfficiencyPlotsBase.h.

164  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t& icarus::trigger::details::TriggerPassCounters::operator() ( Threshold_t const &  threshold,
std::size_t  patternName 
)
inline

Definition at line 165 of file TriggerEfficiencyPlotsBase.h.

166  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t& icarus::trigger::details::TriggerPassCounters::operator() ( std::size_t  threshold,
std::size_t  patternName 
)
inline

Definition at line 167 of file TriggerEfficiencyPlotsBase.h.

168  { return counter(threshold, patternName); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
Threshold_t const & threshold(std::size_t index) const
std::string const & patternName(std::size_t index) const
Counter_t& icarus::trigger::details::TriggerPassCounters::operator() ( IndexPair_t  indices)
inline

Definition at line 169 of file TriggerEfficiencyPlotsBase.h.

169 { return counter(indices); }
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
std::size_t icarus::trigger::details::TriggerPassCounters::patternIndex ( std::string const &  patternName) const

Returns the index of the specified pattern (max() if not registered).

Definition at line 327 of file TriggerEfficiencyPlotsBase.cxx.

328 {
329  auto const iIndex = fPatternIndex.find(patternName);
330  return (iIndex == fPatternIndex.end())? NoIndex: iIndex->second;
331 } // icarus::trigger::details::TriggerPassCounters::patternIndex()
std::unordered_map< std::string, std::size_t > fPatternIndex
Map: pattern name -&gt; pattern index.
std::string const & patternName(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.
auto icarus::trigger::details::TriggerPassCounters::patternName ( std::size_t  index) const

Returns the name of the pattern with the specified index.

Exceptions
std::out_of_rangeif the index is not available

Definition at line 347 of file TriggerEfficiencyPlotsBase.cxx.

348 {
349  // reverse lookup: slow...
350  for (auto const& [ name, patIndex ]: fPatternIndex)
351  if (patIndex == index) return name;
352  throw std::out_of_range{ std::to_string(index) };
353 } // icarus::trigger::details::TriggerPassCounters::patternName()
std::unordered_map< std::string, std::size_t > fPatternIndex
Map: pattern name -&gt; pattern index.
std::string to_string(WindowPattern const &pattern)
then echo fcl name
std::size_t icarus::trigger::details::TriggerPassCounters::registerPattern ( std::string const &  name)
private

Registers a new pattern in the index and returns its index (unchecked).

Definition at line 138 of file TriggerEfficiencyPlotsBase.cxx.

139 {
140  assert(!hasPattern(name));
141 
142  std::size_t const newIndex = nPatterns();
143  fPatternIndex[name] = newIndex;
144 
145  assert(hasPattern(name));
146  return newIndex;
147 } // icarus::trigger::details::TriggerPassCounters::registerPattern()
std::unordered_map< std::string, std::size_t > fPatternIndex
Map: pattern name -&gt; pattern index.
bool hasPattern(std::string const &patternName) const
Returns whether the specified pattern is registered.
std::size_t nPatterns() const
Returns the number of patterns currently registered.
then echo fcl name
std::size_t icarus::trigger::details::TriggerPassCounters::registerThreshold ( Threshold_t const &  threshold)
private

Registers a new threshold in the index and returns its index (unchecked).

Definition at line 124 of file TriggerEfficiencyPlotsBase.cxx.

125 {
126  assert(!hasThreshold(threshold));
127 
128  std::size_t const newIndex = nThresholds();
129  fThresholdIndex[threshold] = newIndex;
130 
131  assert(hasThreshold(threshold));
132  return newIndex;
133 } // icarus::trigger::details::TriggerPassCounters::registerThreshold()
std::size_t nThresholds() const
Returns the number of thresholds currently registered.
std::unordered_map< Threshold_t, std::size_t > fThresholdIndex
Map: threshold -&gt; threshold index.
Threshold_t const & threshold(std::size_t index) const
bool hasThreshold(Threshold_t const &threshold) const
Returns whether the specified threshold is registered.
auto icarus::trigger::details::TriggerPassCounters::threshold ( std::size_t  index) const

Returns the value of the threshold with the specified index.

Exceptions
std::out_of_rangeif the index is not available

Definition at line 336 of file TriggerEfficiencyPlotsBase.cxx.

337 {
338  // reverse lookup: slow...
339  for (auto const& [ threshold, thrIndex ]: fThresholdIndex)
340  if (thrIndex == index) return threshold;
341  throw std::out_of_range{ std::to_string(index) };
342 } // icarus::trigger::details::TriggerPassCounters::threshold()
std::unordered_map< Threshold_t, std::size_t > fThresholdIndex
Map: threshold -&gt; threshold index.
std::string to_string(WindowPattern const &pattern)
Threshold_t const & threshold(std::size_t index) const
std::size_t icarus::trigger::details::TriggerPassCounters::thresholdIndex ( Threshold_t const &  threshold) const

Returns the index of the specified threshold (max() if not registered).

Definition at line 318 of file TriggerEfficiencyPlotsBase.cxx.

319 {
320  auto const iIndex = fThresholdIndex.find(threshold);
321  return (iIndex == fThresholdIndex.end())? NoIndex: iIndex->second;
322 } // icarus::trigger::details::TriggerPassCounters::thresholdIndex()
std::unordered_map< Threshold_t, std::size_t > fThresholdIndex
Map: threshold -&gt; threshold index.
Threshold_t const & threshold(std::size_t index) const
static constexpr std::size_t NoIndex
Represents the index of a threshold or pattern that is not registered.

Member Data Documentation

std::vector<std::vector<Counter_t> > icarus::trigger::details::TriggerPassCounters::fCounters
private

All counters; indices: [threshold][pattern].

Definition at line 211 of file TriggerEfficiencyPlotsBase.h.

std::unordered_map<std::string, std::size_t> icarus::trigger::details::TriggerPassCounters::fPatternIndex
private

Map: pattern name -> pattern index.

Definition at line 217 of file TriggerEfficiencyPlotsBase.h.

std::unordered_map<Threshold_t, std::size_t> icarus::trigger::details::TriggerPassCounters::fThresholdIndex
private

Map: threshold -> threshold index.

Definition at line 214 of file TriggerEfficiencyPlotsBase.h.

constexpr std::size_t icarus::trigger::details::TriggerPassCounters::NoIndex = std::numeric_limits<std::size_t>::max()
static

Represents the index of a threshold or pattern that is not registered.

Definition at line 112 of file TriggerEfficiencyPlotsBase.h.


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