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

Algorithm verifying the topology from trigger gates. More...

#include <WindowTopologyAlg.h>

Inheritance diagram for icarus::trigger::WindowTopologyVerification:
icarus::ns::util::mfLoggingClass

Public Types

using TriggerGates_t = icarus::trigger::WindowTopologyAlg::TriggerGates_t
 Type of sets of trigger gates. More...
 
using TriggerGatesPerCryostat_t = icarus::trigger::WindowTopologyAlg::TriggerGatesPerCryostat_t
 Type of sets of trigger gates, grouped by cryostat. More...
 

Public Member Functions

 WindowTopologyVerification (icarus::trigger::WindowChannelMap topology, std::string const &logCategory="WindowTopologyVerification")
 Constructor. More...
 
 WindowTopologyVerification (std::string const &logCategory="WindowTopologyVerification")
 Constructor. More...
 
bool hasTopology () const
 Returns whether a window topology is set (see setTopology()). More...
 
void setTopology (icarus::trigger::WindowChannelMap topology)
 Resets the topology to be verified against. More...
 
void clearTopology ()
 Forgets the current topology. Set a new one with setTopology(). More...
 
WindowChannelMap const & getTopology () const
 
std::string verify (TriggerGatesPerCryostat_t const &gates) const
 Verifies that gates match the topology current set up. More...
 
std::string verify (TriggerGates_t const &gates) const
 
void operator() (TriggerGatesPerCryostat_t const &gates) const
 Verifies that gates match the topology current set up. More...
 
void operator() (TriggerGates_t const &gates) const
 

Private Types

using InputTriggerGate_t = icarus::trigger::WindowTopologyAlg::InputTriggerGate_t
 Type of trigger gate used for input to the algorithm. More...
 

Private Member Functions

std::string verifyGate (std::size_t iWindow, InputTriggerGate_t const &gate) const
 
template<typename Gates >
void verifyOrThrow (Gates const &gates) const
 Implementation of operator(). More...
 

Private Attributes

std::optional
< icarus::trigger::WindowChannelMap
fWindowMap
 The reference topology to check against. More...
 

Additional Inherited Members

- Protected Member Functions inherited from icarus::ns::util::mfLoggingClass
 mfLoggingClass (std::string const &logCategory)
 Constructor: initializes with the specified log category. More...
 
std::string logCategory () const
 Returns the logging category string for this object. More...
 
mfLoggingClass const & loggingClass () const
 Returns this object (as a logging class object). More...
 
mf::LogError mfLogError (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogError() stream for logging. More...
 
mf::LogWarning mfLogWarning (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogWarning() stream for logging. More...
 
mf::LogProblem mfLogProblem (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogProblem() stream for logging. More...
 
mf::LogInfo mfLogInfo (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogInfo() stream for logging. More...
 
mf::LogVerbatim mfLogVerbatim (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogVerbatim() stream for logging. More...
 
mf::LogDebug mfLogDebug (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogDebug() stream for logging. More...
 
mf::LogTrace mfLogTrace (std::string const &file={}, int const lineNumber=0) const
 Returns a mf::LogTrace() stream for logging. More...
 

Detailed Description

Algorithm verifying the topology from trigger gates.

The algorithm needs to be provided a reference topology information. It will then analyze any set of trigger gates to confirm that their grouping matches the one defined in that topology.

Definition at line 215 of file WindowTopologyAlg.h.

Member Typedef Documentation

Type of trigger gate used for input to the algorithm.

Definition at line 300 of file WindowTopologyAlg.h.

Type of sets of trigger gates.

Definition at line 225 of file WindowTopologyAlg.h.

Type of sets of trigger gates, grouped by cryostat.

Definition at line 229 of file WindowTopologyAlg.h.

Constructor & Destructor Documentation

icarus::trigger::WindowTopologyVerification::WindowTopologyVerification ( icarus::trigger::WindowChannelMap  topology,
std::string const &  logCategory = "WindowTopologyVerification" 
)
inline

Constructor.

Parameters
topologythe window topology to be verified against
logCategorycategory tag for messages from this algorithm

Definition at line 407 of file WindowTopologyAlg.h.

412  , fWindowMap(std::move(topology))
413 {}
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
Helper for logging classes.
std::string logCategory() const
Returns the logging category string for this object.
icarus::trigger::WindowTopologyVerification::WindowTopologyVerification ( std::string const &  logCategory = "WindowTopologyVerification")
inline

Constructor.

Parameters
logCategorycategory tag for messages from this algorithm

Topology must be set up with setTopology() before any verification can occur.

Definition at line 417 of file WindowTopologyAlg.h.

421 {}
Helper for logging classes.
std::string logCategory() const
Returns the logging category string for this object.

Member Function Documentation

void icarus::trigger::WindowTopologyVerification::clearTopology ( )
inline

Forgets the current topology. Set a new one with setTopology().

Definition at line 442 of file WindowTopologyAlg.h.

443  { return fWindowMap.reset(); }
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
auto icarus::trigger::WindowTopologyVerification::getTopology ( ) const
inline

Returns the current window topology.

Exceptions
std::bad_optional_accessif no topology has been set

Definition at line 436 of file WindowTopologyAlg.h.

438  { return fWindowMap.value(); }
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
bool icarus::trigger::WindowTopologyVerification::hasTopology ( ) const
inline

Returns whether a window topology is set (see setTopology()).

Definition at line 425 of file WindowTopologyAlg.h.

426  { return fWindowMap.has_value(); }
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
void icarus::trigger::WindowTopologyVerification::operator() ( TriggerGatesPerCryostat_t const &  gates) const
inline

Verifies that gates match the topology current set up.

Parameters
gatesthe set of gates to match to the topology
Exceptions
cet::exception(category: WindowTopologyVerification) if no window topology is set up yet
cet::exception(category: WindowTopologyVerification) if verification fails
See Also
verify()

Definition at line 454 of file WindowTopologyAlg.h.

455  { verifyOrThrow(gates); }
void verifyOrThrow(Gates const &gates) const
Implementation of operator().
void icarus::trigger::WindowTopologyVerification::operator() ( TriggerGates_t const &  gates) const
inline

Definition at line 448 of file WindowTopologyAlg.h.

449  { verifyOrThrow(gates); }
void verifyOrThrow(Gates const &gates) const
Implementation of operator().
void icarus::trigger::WindowTopologyVerification::setTopology ( icarus::trigger::WindowChannelMap  topology)
inline

Resets the topology to be verified against.

Definition at line 431 of file WindowTopologyAlg.h.

432  { fWindowMap = std::move(topology); }
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
std::string icarus::trigger::WindowTopologyVerification::verify ( TriggerGatesPerCryostat_t const &  gates) const

Verifies that gates match the topology current set up.

Parameters
gatesthe set of gates to match to the topology
Returns
a composite error message (empty on success)
Exceptions
cet::exception(category: WindowTopologyVerification) if no window topology is set up yet

Gates can be specified either as a collection, or as a set of collections, one per cryostat.

Definition at line 344 of file WindowTopologyAlg.cxx.

345 {
346  /*
347  * Verifies that the `gates` are in the expected order and have
348  * the expected channel content.
349  */
350 
351  if (!hasTopology()) {
352  throw cet::exception("WindowTopologyVerification")
353  << "verify() called without any window topology set to be verified.\n";
354  }
355 
356  std::size_t iWindow = 0U;
357  std::string errorMsg; // if this stays `empty()` there is no error
358  for (auto const& cryoGates: gates) {
359  for (auto const& gate: cryoGates) {
360 
361  // if error message is `empty()` there is no error
362  std::string const windowError = verifyGate(iWindow++, gate);
363 
364  if (!windowError.empty()) errorMsg += windowError + '\n';
365 
366  } // for gates in cryostat
367  } // for cryostats
368 
369  return errorMsg;
370 
371 } // icarus::trigger::WindowTopologyVerification::verifyTopologicalMap()
bool hasTopology() const
Returns whether a window topology is set (see setTopology()).
std::string verifyGate(std::size_t iWindow, InputTriggerGate_t const &gate) const
std::string icarus::trigger::WindowTopologyVerification::verify ( TriggerGates_t const &  gates) const

Definition at line 314 of file WindowTopologyAlg.cxx.

315 {
316  /*
317  * Verifies that the `gates` are in the expected order and have
318  * the expected channel content.
319  */
320 
321  if (!hasTopology()) {
322  throw cet::exception("WindowTopologyVerification")
323  << "verify() called without any window topology set to be verified.\n";
324  }
325 
326  std::size_t iWindow = 0U;
327  std::string errorMsg; // if this stays `empty()` there is no error
328  for (auto const& gate: gates) {
329 
330  // if error message is `empty()` there is no error
331  std::string const windowError = verifyGate(iWindow++, gate);
332 
333  if (!windowError.empty()) errorMsg += windowError + '\n';
334 
335  } // for gates
336 
337  return errorMsg;
338 
339 } // icarus::trigger::WindowTopologyVerification::verify()
bool hasTopology() const
Returns whether a window topology is set (see setTopology()).
std::string verifyGate(std::size_t iWindow, InputTriggerGate_t const &gate) const
std::string icarus::trigger::WindowTopologyVerification::verifyGate ( std::size_t  iWindow,
InputTriggerGate_t const &  gate 
) const
private

Checks that the specified gate matched the window with index iWindow.

Returns
message describing the failure, empty on success

Definition at line 376 of file WindowTopologyAlg.cxx.

377 {
378  std::string errors; // if this stays `empty()` there is no error
379 
380  WindowChannelMap::WindowInfo_t const& windowInfo = fWindowMap->info(iWindow);
381 
382  auto const channelInWindow
383  = [begin=windowInfo.channels.cbegin(),end=windowInfo.channels.cend()]
384  (raw::Channel_t channel)
385  { return std::binary_search(begin, end, channel); }
386  ;
387 
388  for (raw::Channel_t const channel: gate.channels()) {
389  if (channelInWindow(channel)) continue;
390  if (errors.empty()) {
391  errors =
392  "channels not in window #" + std::to_string(windowInfo.index)
393  + ":";
394  } // if first error
395  errors += " " + std::to_string(channel);
396  } // for all channels in gate
397 
398  return errors;
399 } // icarus::trigger::WindowTopologyVerification::verifyGate()
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
std::string to_string(WindowPattern const &pattern)
template<typename Gates >
void icarus::trigger::WindowTopologyVerification::verifyOrThrow ( Gates const &  gates) const
private

Implementation of operator().

Definition at line 490 of file WindowTopologyAlg.h.

491 {
492 
493  std::string const errorMsg = verify(gates);
494  if (errorMsg.empty()) return;
495 
496  // put together the exception message and throw it.
497  throw cet::exception("WindowTopologyVerification")
498  << "Some channels from trigger gates do not match the previous window allocation:\n"
499  << errorMsg
500  << "\n"
501  << "Window allocation: "
502  << fWindowMap.value()
503  ;
504 
505 } // icarus::trigger::WindowTopologyVerification::operator()
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
std::string verify(TriggerGatesPerCryostat_t const &gates) const
Verifies that gates match the topology current set up.

Member Data Documentation

std::optional<icarus::trigger::WindowChannelMap> icarus::trigger::WindowTopologyVerification::fWindowMap
private

The reference topology to check against.

Definition at line 220 of file WindowTopologyAlg.h.


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