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

Helper data structure to store transient trigger result. More...

#include <TriggerInfo_t.h>

Classes

struct  OpeningInfo_t
 

Public Types

using optical_tick = detinfo::timescales::optical_tick
 Type alias. More...
 
using Opening_t = icarus::trigger::OpticalTriggerGateData_t::GateData_t::OpeningCount_t
 Type of gate opening level. More...
 
using LocationID_t = std::size_t
 Type for ID of trigger location. More...
 

Public Member Functions

 TriggerInfo_t ()=default
 
 TriggerInfo_t (OpeningInfo_t info)
 
Query whether the trigger fired.
bool fired () const
 Returns whether the trigger fired. More...
 
 operator bool () const
 Returns whether there is trigger information. More...
 
bool operator! () const
 Returns whether there is no trigger information. More...
 
Modify trigger information
void replace (OpeningInfo_t info)
 Sets info as the new main() trigger. More...
 
bool addAndReplaceIfEarlier (TriggerInfo_t const &other)
 If other has fired, and at an earlier tick, set a new main(). More...
 
bool addAndReplaceIfEarlier (OpeningInfo_t const &info)
 If info is earlier than main(), it is set as new main(). More...
 
void add (OpeningInfo_t info)
 
void sortOpenings ()
 Sorts all openings by time. More...
 
Access to trigger information

If the trigger did not fire, the result and behaviour of these methods are undefined.

OpeningInfo_t const & info () const
 Returns the information of the main trigger (undefined if !fired()). More...
 
optical_tick atTick () const
 Returns the time of the trigger (undefined if !fired()). More...
 
Opening_t level () const
 Returns the opening level of the trigger (undefined if !fired()). More...
 
LocationID_t location () const
 Returns the ID of the location of the trigger (undefined if !fired()). More...
 
bool hasLocation () const
 Returns if the location of the trigger is set (undefined if !fired()). More...
 
OpeningInfo_t const & main () const
 Returns the full data (undefined if !fired()). More...
 
std::vector< OpeningInfo_t >
const & 
all () const
 
std::size_t nTriggers () const
 Returns the number of registered triggers. More...
 

Private Attributes

OpeningInfo_t fMain
 Main trigger (also found in fAll), if any. More...
 
std::vector< OpeningInfo_tfAll
 

Detailed Description

Helper data structure to store transient trigger result.

This record maintains a list of all openings (add()), and has a special one (main()) which represents the "global" trigger.

Note that unless no opening is add()'ed, there is always a main() trigger.

Each trigger is described by the information in a OpeningInfo_t record. The records can be registered with add(); replace() changes the main() trigger information unconditionally, while addAndReplaceIfEarlier() replaces main() only if the argument proposes a trigger earlier than the current main().

Definition at line 50 of file TriggerInfo_t.h.

Member Typedef Documentation

Type for ID of trigger location.

Definition at line 58 of file TriggerInfo_t.h.

Type of gate opening level.

Definition at line 56 of file TriggerInfo_t.h.

Type alias.

Definition at line 52 of file TriggerInfo_t.h.

Constructor & Destructor Documentation

icarus::trigger::details::TriggerInfo_t::TriggerInfo_t ( )
default
icarus::trigger::details::TriggerInfo_t::TriggerInfo_t ( OpeningInfo_t  info)
inline

Definition at line 98 of file TriggerInfo_t.h.

98 { replace(std::move(info)); }
void replace(OpeningInfo_t info)
Sets info as the new main() trigger.
OpeningInfo_t const & info() const
Returns the information of the main trigger (undefined if !fired()).

Member Function Documentation

void icarus::trigger::details::TriggerInfo_t::add ( OpeningInfo_t  info)
inline

Adds an opening to all list (main is not affected). Not sorted. If no trigger is marked as main(), this becomes it.

Definition at line 153 of file TriggerInfo_t.h.

154  { if (fAll.empty()) fMain = info; fAll.push_back(std::move(info)); }
std::vector< OpeningInfo_t > fAll
OpeningInfo_t fMain
Main trigger (also found in fAll), if any.
OpeningInfo_t const & info() const
Returns the information of the main trigger (undefined if !fired()).
bool icarus::trigger::details::TriggerInfo_t::addAndReplaceIfEarlier ( TriggerInfo_t const &  other)
inline

If other has fired, and at an earlier tick, set a new main().

Parameters
otheranother set of triggers
Returns
whether the main() information from other was copied

If other has fired() earlier than this one (or if this one hasn't fired at all), the main trigger of other is adopted. In any case all openings from other are add()'ed to this one.

Definition at line 384 of file TriggerInfo_t.h.

385 {
386  if (!other.fired()) return false;
387 
388  bool const hadFired = fired();
389 
390  // register all triggers anyway; do not sort, do not resolve duplicates
391  fAll.reserve(nTriggers() + other.nTriggers());
392  for (OpeningInfo_t const& info: other.all()) add(info);
393 
394  if (hadFired && (other.atTick() >= atTick())) return false;
395 
396  fMain = other.main();
397  return true;
398 } // icarus::trigger::details::TriggerInfo_t::addAndReplaceIfEarlier()
bool fired() const
Returns whether the trigger fired.
std::vector< OpeningInfo_t > fAll
OpeningInfo_t fMain
Main trigger (also found in fAll), if any.
optical_tick atTick() const
Returns the time of the trigger (undefined if !fired()).
OpeningInfo_t const & info() const
Returns the information of the main trigger (undefined if !fired()).
std::size_t nTriggers() const
Returns the number of registered triggers.
bool icarus::trigger::details::TriggerInfo_t::addAndReplaceIfEarlier ( OpeningInfo_t const &  info)
inline

If info is earlier than main(), it is set as new main().

Parameters
infothe opening information candidate as new main()
Returns
whether main() was updated.

If info is earlier tick than main() (or if there is no main() yet, i.e. it has not fired()), info becomes the new main(). In all cases info is added (add()).

Definition at line 403 of file TriggerInfo_t.h.

404 {
405  add(info);
406  if (info.tick >= atTick()) return false;
407 
408  fMain = info;
409  return true;
410 } // icarus::trigger::details::TriggerInfo_t::addAndReplaceIfEarlier()
optical_tick tick
Tick at which the trigger fired.
Definition: TriggerInfo_t.h:67
OpeningInfo_t fMain
Main trigger (also found in fAll), if any.
optical_tick atTick() const
Returns the time of the trigger (undefined if !fired()).
OpeningInfo_t const & info() const
Returns the information of the main trigger (undefined if !fired()).
std::vector<OpeningInfo_t> const& icarus::trigger::details::TriggerInfo_t::all ( ) const
inline

Returns all the registered opening in the current order (not resorted).

See Also
sortOpenings()

Definition at line 192 of file TriggerInfo_t.h.

192 { return fAll; }
std::vector< OpeningInfo_t > fAll
optical_tick icarus::trigger::details::TriggerInfo_t::atTick ( ) const
inline

Returns the time of the trigger (undefined if !fired()).

Definition at line 176 of file TriggerInfo_t.h.

176 { return main().tick; }
OpeningInfo_t const & main() const
Returns the full data (undefined if !fired()).
optical_tick tick
Tick at which the trigger fired.
Definition: TriggerInfo_t.h:67
bool icarus::trigger::details::TriggerInfo_t::fired ( ) const
inline

Returns whether the trigger fired.

Definition at line 108 of file TriggerInfo_t.h.

108 { return !fAll.empty(); }
std::vector< OpeningInfo_t > fAll
bool icarus::trigger::details::TriggerInfo_t::hasLocation ( ) const
inline

Returns if the location of the trigger is set (undefined if !fired()).

Definition at line 185 of file TriggerInfo_t.h.

185 { return main().hasLocation(); }
OpeningInfo_t const & main() const
Returns the full data (undefined if !fired()).
bool hasLocation() const
Returns whether the location is set.
Definition: TriggerInfo_t.h:86
OpeningInfo_t const& icarus::trigger::details::TriggerInfo_t::info ( ) const
inline

Returns the information of the main trigger (undefined if !fired()).

Definition at line 173 of file TriggerInfo_t.h.

173 { return main(); }
OpeningInfo_t const & main() const
Returns the full data (undefined if !fired()).
Opening_t icarus::trigger::details::TriggerInfo_t::level ( ) const
inline

Returns the opening level of the trigger (undefined if !fired()).

Definition at line 179 of file TriggerInfo_t.h.

179 { return main().level; }
OpeningInfo_t const & main() const
Returns the full data (undefined if !fired()).
Opening_t level
Maximum level on the main trigger opening.
Definition: TriggerInfo_t.h:69
LocationID_t icarus::trigger::details::TriggerInfo_t::location ( ) const
inline

Returns the ID of the location of the trigger (undefined if !fired()).

Definition at line 182 of file TriggerInfo_t.h.

182 { return main().locationID; }
OpeningInfo_t const & main() const
Returns the full data (undefined if !fired()).
LocationID_t locationID
Identified of the trigger location.
Definition: TriggerInfo_t.h:72
OpeningInfo_t const& icarus::trigger::details::TriggerInfo_t::main ( ) const
inline

Returns the full data (undefined if !fired()).

Definition at line 188 of file TriggerInfo_t.h.

188 { return fMain; }
OpeningInfo_t fMain
Main trigger (also found in fAll), if any.
std::size_t icarus::trigger::details::TriggerInfo_t::nTriggers ( ) const
inline

Returns the number of registered triggers.

Definition at line 195 of file TriggerInfo_t.h.

195 { return all().size(); }
std::vector< OpeningInfo_t > const & all() const
icarus::trigger::details::TriggerInfo_t::operator bool ( ) const
inline

Returns whether there is trigger information.

Definition at line 111 of file TriggerInfo_t.h.

111 { return fired(); }
bool fired() const
Returns whether the trigger fired.
bool icarus::trigger::details::TriggerInfo_t::operator! ( ) const
inline

Returns whether there is no trigger information.

Definition at line 114 of file TriggerInfo_t.h.

114 { return !fired(); }
bool fired() const
Returns whether the trigger fired.
void icarus::trigger::details::TriggerInfo_t::replace ( OpeningInfo_t  info)
inline

Sets info as the new main() trigger.

Definition at line 125 of file TriggerInfo_t.h.

126  { fMain = info; add(std::move(info)); }
OpeningInfo_t fMain
Main trigger (also found in fAll), if any.
OpeningInfo_t const & info() const
Returns the information of the main trigger (undefined if !fired()).
void icarus::trigger::details::TriggerInfo_t::sortOpenings ( )
inline

Sorts all openings by time.

Definition at line 157 of file TriggerInfo_t.h.

157 { std::sort(fAll.begin(), fAll.end()); }
std::vector< OpeningInfo_t > fAll

Member Data Documentation

std::vector<OpeningInfo_t> icarus::trigger::details::TriggerInfo_t::fAll
private

Definition at line 206 of file TriggerInfo_t.h.

OpeningInfo_t icarus::trigger::details::TriggerInfo_t::fMain
private

Main trigger (also found in fAll), if any.

Information about all global trigger candidates.

Definition at line 203 of file TriggerInfo_t.h.


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