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

Helper to extract OpeningInfo_t from a trigger gate. More...

#include <TriggerInfo_t.h>

Classes

struct  Config_t
 Configuration of the algorithm. More...
 

Public Types

using ClockTick_t = typename GateData_t::ClockTick_t
 
using OpeningCount_t = icarus::trigger::details::TriggerInfo_t::Opening_t
 
using OpeningInfo_t = icarus::trigger::details::TriggerInfo_t::OpeningInfo_t
 
using LocationID_t = icarus::trigger::details::TriggerInfo_t::LocationID_t
 

Public Member Functions

 GateOpeningInfoExtractor (Gate_t const &gate)
 Constructor: uses default configuration. More...
 
 GateOpeningInfoExtractor (Gate_t const &gate, Config_t config)
 Constructor: sets all configuration parameters. More...
 
 GateOpeningInfoExtractor (Gate_t const &gate, OpeningCount_t threshold)
 Constructor: sets all configuration parameters. More...
 
void configure (Config_t config)
 Sets the configuration. More...
 
bool atEnd () const
 
 operator bool () const
 
bool operator! () const
 
void restart (ClockTick_t fromTick=MinTick)
 Resets the search from the specified time tick (beginning by default). More...
 
std::optional< OpeningInfo_toperator() ()
 The returned gate is at least minWidth ticks wide. More...
 
std::optional< OpeningInfo_tfindNextOpening ()
 
Configuration access
Config_t const & configuration () const
 
OpeningCount_t openThreshold () const
 
OpeningCount_t closeThreshold () const
 
unsigned int minGap () const
 
unsigned int minWidth () const
 
LocationID_t location () const
 
void setLocation (LocationID_t location)
 

Private Types

using Gate_t = Gate
 
using GateData_t = std::decay_t< decltype(gateDataIn(std::declval< Gate_t >()))>
 

Private Member Functions

ClockTick_t findOpen (ClockTick_t start) const
 
ClockTick_t findClose (ClockTick_t start) const
 
std::pair< ClockTick_t,
ClockTick_t
findNextCloseAndOpen (ClockTick_t start) const
 Returns the first closing and reopening above threshold from start on. More...
 

Private Attributes

Gate_t const & gateSrc
 
Config_t config
 
GateData_t const & gate
 
ClockTick_t nextStart = MinTick
 

Static Private Attributes

static constexpr ClockTick_t MinTick = GateData_t::MinTick
 
static constexpr ClockTick_t MaxTick = GateData_t::MaxTick
 

Detailed Description

template<typename Gate>
class icarus::trigger::details::GateOpeningInfoExtractor< Gate >

Helper to extract OpeningInfo_t from a trigger gate.

Example of usage:

{ gate, { 6U } };
while (extractOpeningInfo) {
auto info = extractOpeningInfo();
if (info) triggerInfo.add(info.value());
} // while

fills triggerInfo with all the openings equal or above level 6U. Each opening is defined as from when gate reaches a specified threshold ("opening threshold") to when it reaches or goes below another one ("closing threshold"), with no dead time afterward. The time of the opening is the time when threshold is passed, but the reported level is the maximum in the opening range. By default, the closing threshold is one less than the opening one (i.e. as soon as the level goes below the opening threshold, the gate closes).

This algorithm will not work in multi-threading.

Definition at line 30 of file TriggerInfo_t.h.

Member Typedef Documentation

template<typename Gate >
using icarus::trigger::details::GateOpeningInfoExtractor< Gate >::ClockTick_t = typename GateData_t::ClockTick_t

Definition at line 242 of file TriggerInfo_t.h.

template<typename Gate >
using icarus::trigger::details::GateOpeningInfoExtractor< Gate >::Gate_t = Gate
private

Definition at line 238 of file TriggerInfo_t.h.

template<typename Gate >
using icarus::trigger::details::GateOpeningInfoExtractor< Gate >::GateData_t = std::decay_t<decltype(gateDataIn(std::declval<Gate_t>()))>
private

Definition at line 239 of file TriggerInfo_t.h.

Definition at line 245 of file TriggerInfo_t.h.

Definition at line 243 of file TriggerInfo_t.h.

Definition at line 244 of file TriggerInfo_t.h.

Constructor & Destructor Documentation

template<typename Gate >
icarus::trigger::details::GateOpeningInfoExtractor< Gate >::GateOpeningInfoExtractor ( Gate_t const &  gate)
inline

Constructor: uses default configuration.

Parameters
gatethe gate to operate on
configconfiguration of the algorithm
See Also
configure()

Definition at line 280 of file TriggerInfo_t.h.

282  {}
GateOpeningInfoExtractor(Gate_t const &gate)
Constructor: uses default configuration.
template<typename Gate >
icarus::trigger::details::GateOpeningInfoExtractor< Gate >::GateOpeningInfoExtractor ( Gate_t const &  gate,
Config_t  config 
)
inline

Constructor: sets all configuration parameters.

Parameters
gatethe gate to operate on
configconfiguration of the algorithm (see configure())

Definition at line 289 of file TriggerInfo_t.h.

290  : gateSrc(gate), config(std::move(config)), gate(gateDataIn(gateSrc))
291  { restart(); }
void restart(ClockTick_t fromTick=MinTick)
Resets the search from the specified time tick (beginning by default).
decltype(auto) gateDataIn(Gate &&gate)
Returns the trigger data (a TriggerGateData) from the specofied gate.
template<typename Gate >
icarus::trigger::details::GateOpeningInfoExtractor< Gate >::GateOpeningInfoExtractor ( Gate_t const &  gate,
OpeningCount_t  threshold 
)
inline

Constructor: sets all configuration parameters.

Parameters
gatethe gate to operate on
thresholdboth opening and closing threshold
See Also
configure()

Definition at line 299 of file TriggerInfo_t.h.

300  : GateOpeningInfoExtractor(gate, Config_t{ threshold })
301  {}
GateOpeningInfoExtractor(Gate_t const &gate)
Constructor: uses default configuration.

Member Function Documentation

template<typename Gate >
bool icarus::trigger::details::GateOpeningInfoExtractor< Gate >::atEnd ( ) const
inline

Definition at line 324 of file TriggerInfo_t.h.

template<typename Gate >
OpeningCount_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::closeThreshold ( ) const
inline
template<typename Gate >
Config_t const& icarus::trigger::details::GateOpeningInfoExtractor< Gate >::configuration ( ) const
inline

Definition at line 336 of file TriggerInfo_t.h.

template<typename Gate >
void icarus::trigger::details::GateOpeningInfoExtractor< Gate >::configure ( Config_t  config)
inline

Sets the configuration.

Constructor: sets all configuration parameters.

Parameters
gatethe gate to operate on
configconfiguration of the algorithm

The configuration includes:

  • openThreshold, closeThreshold: the opening and closing thresholds
  • minWidth: minimum width of each opening range
  • minGap: minimum gap between successive opening ranges
  • location: location ID to add to the produced OpeningInfo_t records

Definition at line 315 of file TriggerInfo_t.h.

template<typename Gate >
ClockTick_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::findClose ( ClockTick_t  start) const
inlineprivate

Definition at line 368 of file TriggerInfo_t.h.

369  { return gate.findClose(closeThreshold() + 1, start); }
template<typename Gate >
auto icarus::trigger::details::GateOpeningInfoExtractor< Gate >::findNextCloseAndOpen ( ClockTick_t  start) const
private

Returns the first closing and reopening above threshold from start on.

Definition at line 445 of file TriggerInfo_t.h.

446 {
447  ClockTick_t const closing = (gate.openingCount(start) > closeThreshold())
448  ? findClose(start): start;
449  return { closing, findOpen(closing) };
450 } // icarus::trigger::details::GateOpeningInfoExtractor<>::findNextCloseAndOpen()
ClockTick_t findClose(ClockTick_t start) const
typename GateData_t::ClockTick_t ClockTick_t
ClockTick_t findOpen(ClockTick_t start) const
template<typename Gate >
auto icarus::trigger::details::GateOpeningInfoExtractor< Gate >::findNextOpening ( )

Definition at line 417 of file TriggerInfo_t.h.

419 {
420  if (atEnd()) return {};
421 
422  using ClockDiff_t = decltype( ClockTick_t{} - ClockTick_t{} );
423 
424  ClockTick_t const start = nextStart;
425  ClockTick_t closing;
426  do {
427  std::tie(closing, nextStart) = findNextCloseAndOpen(nextStart);
428  if (nextStart == MaxTick) break;
429  } while(
430  (closing - start < static_cast<ClockDiff_t>(minWidth()))
431  || (nextStart - closing < static_cast<ClockDiff_t>(minGap()))
432  );
433 
434  return std::optional<OpeningInfo_t>{ std::in_place,
436  gate.openingCount(gate.findMaxOpen(start, closing)),
437  location()
438  };
439 } // icarus::trigger::details::GateOpeningInfoExtractor<>::findNextOpening()
std::pair< ClockTick_t, ClockTick_t > findNextCloseAndOpen(ClockTick_t start) const
Returns the first closing and reopening above threshold from start on.
typename GateData_t::ClockTick_t ClockTick_t
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
template<typename Gate >
ClockTick_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::findOpen ( ClockTick_t  start) const
inlineprivate

Definition at line 366 of file TriggerInfo_t.h.

367  { return gate.findOpen(openThreshold(), start); }
template<typename Gate >
LocationID_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::location ( ) const
inline
template<typename Gate >
unsigned int icarus::trigger::details::GateOpeningInfoExtractor< Gate >::minGap ( ) const
inline
template<typename Gate >
unsigned int icarus::trigger::details::GateOpeningInfoExtractor< Gate >::minWidth ( ) const
inline
template<typename Gate >
OpeningCount_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::openThreshold ( ) const
inline
template<typename Gate >
icarus::trigger::details::GateOpeningInfoExtractor< Gate >::operator bool ( ) const
inline

Definition at line 325 of file TriggerInfo_t.h.

325 { return !atEnd(); }
template<typename Gate >
bool icarus::trigger::details::GateOpeningInfoExtractor< Gate >::operator! ( ) const
inline

Definition at line 326 of file TriggerInfo_t.h.

template<typename Gate >
std::optional<OpeningInfo_t> icarus::trigger::details::GateOpeningInfoExtractor< Gate >::operator() ( )
inline

The returned gate is at least minWidth ticks wide.

Definition at line 319 of file TriggerInfo_t.h.

319 { return findNextOpening(); }
std::optional< OpeningInfo_t > findNextOpening()
template<typename Gate >
void icarus::trigger::details::GateOpeningInfoExtractor< Gate >::restart ( ClockTick_t  fromTick = MinTick)
inline

Resets the search from the specified time tick (beginning by default).

Definition at line 329 of file TriggerInfo_t.h.

330  { nextStart = findOpen(fromTick); }
ClockTick_t findOpen(ClockTick_t start) const
template<typename Gate >
void icarus::trigger::details::GateOpeningInfoExtractor< Gate >::setLocation ( LocationID_t  location)
inline

Member Data Documentation

template<typename Gate >
Config_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::config
private

Definition at line 357 of file TriggerInfo_t.h.

template<typename Gate >
GateData_t const& icarus::trigger::details::GateOpeningInfoExtractor< Gate >::gate
private

Definition at line 361 of file TriggerInfo_t.h.

template<typename Gate >
Gate_t const& icarus::trigger::details::GateOpeningInfoExtractor< Gate >::gateSrc
private

Definition at line 356 of file TriggerInfo_t.h.

template<typename Gate >
constexpr ClockTick_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::MaxTick = GateData_t::MaxTick
staticprivate

Definition at line 352 of file TriggerInfo_t.h.

template<typename Gate >
constexpr ClockTick_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::MinTick = GateData_t::MinTick
staticprivate

Definition at line 351 of file TriggerInfo_t.h.

template<typename Gate >
ClockTick_t icarus::trigger::details::GateOpeningInfoExtractor< Gate >::nextStart = MinTick
private

Definition at line 363 of file TriggerInfo_t.h.


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