Logical multi-level gate. More...
#include <TriggerGateData.h>
Classes | |
struct | CompareTick |
Comparison by tick number. More... | |
Public Types | |
using | triggergatedata_t = TriggerGateData< Tick, TickInterval > |
This type. More... | |
using | ClockTick_t = Tick |
Type of a point in time, measured in ticks. More... | |
using | ClockTicks_t = TickInterval |
Type of a time interval, measured in ticks. More... | |
using | OpeningCount_t = unsigned int |
Type of count of number of open channels. More... | |
using | OpeningDiff_t = std::make_signed_t< OpeningCount_t > |
Type representing a variation of open channels. More... | |
Public Member Functions | |
TriggerGateData () | |
Constructor: a closed gate for the channel in waveform . More... | |
bool | operator== (TriggerGateData const &) const |
bool | operator!= (TriggerGateData const &) const |
Query | |
ClockTick_t | lastTick () const |
Returns the number of ticks this gate covers. More... | |
OpeningCount_t | openingCount (ClockTick_t tick) const |
Returns the opening count of the gate at the specified tick . More... | |
bool | alwaysClosed () const |
Returns whether this gate never opened. More... | |
bool | isOpen (ClockTick_t tick) const |
Returns whether the gate is open at all at the specified tick . More... | |
ClockTick_t | findOpen (OpeningCount_t minOpening=1U, ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const |
Returns the tick at which the gate opened. More... | |
ClockTick_t | findClose (OpeningCount_t minOpening=1U, ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const |
Returns the tick at which the gate closed. More... | |
ClockTick_t | findMaxOpen (ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const |
Returns the tick at which the gate has the maximum opening. More... | |
std::pair< OpeningCount_t, OpeningCount_t > | openingRange (ClockTick_t start, ClockTick_t end) const |
Returns the range of trigger opening values in the specified range. More... | |
Gate opening and closing operations | |
void | setOpeningAt (ClockTick_t tick, OpeningCount_t openingCount) |
Changes the opening to match openingCount at the specified time. More... | |
void | openAt (ClockTick_t tick, OpeningDiff_t count) |
Open this gate at the specified time (increase the opening by count ). More... | |
void | openAt (ClockTick_t tick) |
Open this gate at the specified time (increase the opening by 1). More... | |
void | openBetween (ClockTick_t start, ClockTick_t end, OpeningDiff_t count=1) |
Open this gate at specified start tick, and close it at end tick. More... | |
void | openFor (ClockTick_t tick, ClockTicks_t length, OpeningDiff_t count=1) |
Open this gate at the specified time, and close it length ticks later. More... | |
void | closeAt (ClockTick_t tick, OpeningDiff_t count) |
Close this gate at the specified time (decrease the opening by count ). More... | |
void | closeAt (ClockTick_t tick) |
Close this gate at the specified time. More... | |
void | closeAllAt (ClockTick_t tick) |
Completely close this gate at the specified time. More... | |
void | clear () |
Sets the gate levels in the state at construction. More... | |
Static Public Attributes | |
static constexpr ClockTick_t | MinTick = std::numeric_limits<ClockTick_t>::min() |
An unbearably small tick number. More... | |
static constexpr ClockTick_t | MaxTick = std::numeric_limits<ClockTick_t>::max() |
An unbearably large tick number. More... | |
Protected Types | |
using | EventType = details::TriggerGateEventType |
using | Status = details::TriggerGateStatus< ClockTick_t, OpeningCount_t > |
using | GateEvolution_t = std::vector< Status > |
Type to describe the time evolution of the gate. More... | |
Protected Member Functions | |
TriggerGateData (GateEvolution_t &&gateLevel) | |
Protected constructor: set the data directly. More... | |
Private Types | |
using | status_iterator = typename GateEvolution_t::iterator |
using | status_const_iterator = typename GateEvolution_t::const_iterator |
Private Member Functions | |
std::optional < status_const_iterator > | findLastStatusFor (ClockTick_t tick) const |
Returns a const-iterator to the status current at tick , or no value. More... | |
std::optional< status_iterator > | findLastStatusFor (ClockTick_t tick) |
Returns an iterator to the status current at tick , or no value. More... | |
status_iterator | findLastStatusForTickOrThrow (ClockTick_t tick) |
status_const_iterator | findLastStatusForTickOrThrow (ClockTick_t tick) const |
template<typename Op > | |
status_const_iterator | findStatus (Op op, ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const |
Returns an iterator to the first status for which op(status) is true. More... | |
status_const_iterator | findOpenStatus (OpeningCount_t minOpening=1U, ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const |
Returns an iterator to the first open status (. More... | |
status_const_iterator | findCloseStatus (OpeningCount_t minOpening=1U, ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const |
Returns an iterator to the first close status (. More... | |
status_const_iterator | findMaxOpenStatus (ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const |
Returns an iterator to the maximum open status (. More... | |
void | compact () |
Maintenance operation: removes unconsequential stati. More... | |
Static Private Member Functions | |
static GateEvolution_t | startingGateLevel () |
Helper returning the starting state of the levels at construction time. More... | |
Private Attributes | |
GateEvolution_t | fGateLevel |
Evolution of the gate in time. More... | |
Static Private Attributes | |
static Status const | NewGateStatus |
A new gate starts with this status: opening level set to 0. More... | |
Friends | |
std::ostream & | operator (std::ostream &, triggergatedata_t const &) |
std::ostream & | operator (std::ostream &, Status const &) |
Combination operations | |
triggergatedata_t & | Min (triggergatedata_t const &other) |
Combines with a gate, keeping the minimum opening among the two. More... | |
triggergatedata_t & | Max (triggergatedata_t const &other) |
Combines with a gate, keeping the maximum opening among the two. More... | |
triggergatedata_t & | Sum (triggergatedata_t const &other) |
Combines with a gate, keeping the sum of openings of the two. More... | |
triggergatedata_t & | Mul (triggergatedata_t const &other) |
Combines with a gate, keeping the product of openings of the two. More... | |
static triggergatedata_t | Min (triggergatedata_t const &a, triggergatedata_t const &b) |
Returns a gate with the minimum opening between the specified two. More... | |
static triggergatedata_t | Max (triggergatedata_t const &a, triggergatedata_t const &b) |
Returns a gate with the maximum opening between the specified two. More... | |
static triggergatedata_t | Sum (triggergatedata_t const &a, triggergatedata_t const &b) |
Returns a gate with opening sum of the specified two. More... | |
static triggergatedata_t | Mul (triggergatedata_t const &a, triggergatedata_t const &b) |
Returns a gate with opening product of the specified two. More... | |
template<typename Op > | |
static triggergatedata_t | SymmetricCombination (Op &&op, triggergatedata_t const &a, triggergatedata_t const &b, ClockTicks_t aDelay=ClockTicks_t{}, ClockTicks_t bDelay=ClockTicks_t{}) |
Returns a gate combination of the openings of two other gates. More... | |
Logical multi-level gate.
Tick | type used to count the ticks |
TickInterval | type used to quantify tick difference |
A TriggerGate
object tracks a logical multi-level gate, that is a gate whose level can be not only 0
or 1
, but an arbitrary integral number. The gate level is defined as a positive number. The general convention is that a level of 0
means the gate is closed, while any other level (typically 1
) means it's open. In a multi-level gate, one can choose to interpret the gate as open only if it reaches a chosen level higher than 1
. The time domain of the gate is measured in ticks, which in this context are optical detector clock ticks defined on the electronics time scale. That means that tick #0 is set at the origin of that time scale. The gate is unlimited, i.e. it can accommodate changes on any time tick from #0 on (up to the machine limitations, MaxTick
). For practical purposes, lastTick()
is instrumental to find the tick of the last gate change.
Internally, the gate is represented by "events". The first event, at tick #0, sets the level of the gate to the lowest possible (0
, closed). Each event may change the level at a given tick and all the following ones until MaxTick
. An actual gate is therefore defined by two events, an opening event (that is an increase in level) and a closing one (a shift of the same amount in the opposite direction).
Definition at line 86 of file TriggerGateData.h.
using icarus::trigger::TriggerGateData< Tick, TickInterval >::ClockTick_t = Tick |
Type of a point in time, measured in ticks.
Definition at line 140 of file TriggerGateData.h.
using icarus::trigger::TriggerGateData< Tick, TickInterval >::ClockTicks_t = TickInterval |
Type of a time interval, measured in ticks.
Definition at line 143 of file TriggerGateData.h.
|
protected |
Definition at line 410 of file TriggerGateData.h.
|
protected |
Type to describe the time evolution of the gate.
Definition at line 414 of file TriggerGateData.h.
using icarus::trigger::TriggerGateData< Tick, TickInterval >::OpeningCount_t = unsigned int |
Type of count of number of open channels.
Definition at line 146 of file TriggerGateData.h.
using icarus::trigger::TriggerGateData< Tick, TickInterval >::OpeningDiff_t = std::make_signed_t<OpeningCount_t> |
Type representing a variation of open channels.
Definition at line 149 of file TriggerGateData.h.
|
protected |
Definition at line 411 of file TriggerGateData.h.
|
private |
Definition at line 431 of file TriggerGateData.h.
|
private |
Definition at line 430 of file TriggerGateData.h.
using icarus::trigger::TriggerGateData< Tick, TickInterval >::triggergatedata_t = TriggerGateData<Tick, TickInterval> |
This type.
Definition at line 137 of file TriggerGateData.h.
|
inline |
Constructor: a closed gate for the channel in waveform
.
Definition at line 164 of file TriggerGateData.h.
|
inlineprotected |
Protected constructor: set the data directly.
Definition at line 417 of file TriggerGateData.h.
|
inline |
Returns whether this gate never opened.
Definition at line 178 of file TriggerGateData.h.
|
inline |
Sets the gate levels in the state at construction.
Definition at line 283 of file TriggerGateData.h.
|
inline |
Completely close this gate at the specified time.
Definition at line 280 of file TriggerGateData.h.
|
inline |
Close this gate at the specified time (decrease the opening by count
).
Definition at line 273 of file TriggerGateData.h.
|
inline |
Close this gate at the specified time.
Definition at line 277 of file TriggerGateData.h.
|
private |
Maintenance operation: removes unconsequential stati.
ClockTick_t icarus::trigger::TriggerGateData< Tick, TickInterval >::findClose | ( | OpeningCount_t | minOpening = 1U , |
ClockTick_t | start = MinTick , |
||
ClockTick_t | end = MaxTick |
||
) | const |
Returns the tick at which the gate closed.
minOpening | minimum count to consider the gate open (default: 1 ) |
start | first tick to check _(by default, the first available one)_ |
end | if getting to this tick, give up _(by default, to the end)_ |
end
if never findOpen()
The closing is defined as the opening count being changed to strictly below minOpening
.
If the count is already below minOpening
at the specified start
tick, the current level is ignored and only the next change which keeps the gate closed is reported.
|
private |
Returns an iterator to the first close status (.
findClose()
).
|
private |
Returns a const-iterator to the status current at tick
, or no value.
|
private |
Returns an iterator to the status current at tick
, or no value.
|
private |
Returns an iterator to the status current at tick
.
cet::exception | if tick can't be handled |
|
private |
Returns a const-iterator to the status current at tick
.
cet::exception | if tick can't be handled |
ClockTick_t icarus::trigger::TriggerGateData< Tick, TickInterval >::findMaxOpen | ( | ClockTick_t | start = MinTick , |
ClockTick_t | end = MaxTick |
||
) | const |
Returns the tick at which the gate has the maximum opening.
start | first tick to check _(by default, the first available one)_ |
end | if getting to this tick, give up _(by default, to the end)_ |
end
if never
|
private |
Returns an iterator to the maximum open status (.
findMaxOpen()
). ClockTick_t icarus::trigger::TriggerGateData< Tick, TickInterval >::findOpen | ( | OpeningCount_t | minOpening = 1U , |
ClockTick_t | start = MinTick , |
||
ClockTick_t | end = MaxTick |
||
) | const |
Returns the tick at which the gate opened.
minOpening | minimum count to consider the gate open _(default: 1 )_ |
start | first tick to check (by default, the first available one) |
end | if getting to this tick, give up (by default, to the end) |
end
if never findClose()
, findMaxOpen()
If the count is already above (or equal to) minOpening
at the specified start
tick, the current level is ignored and only the next change which keeps the gate open is reported.
|
private |
Returns an iterator to the first open status (.
findOpen()
).
|
private |
Returns an iterator to the first status for which op(status)
is true.
|
inline |
Returns whether the gate is open at all at the specified tick
.
Definition at line 181 of file TriggerGateData.h.
|
inline |
Returns the number of ticks this gate covers.
Definition at line 172 of file TriggerGateData.h.
triggergatedata_t& icarus::trigger::TriggerGateData< Tick, TickInterval >::Max | ( | triggergatedata_t const & | other | ) |
|
static |
triggergatedata_t& icarus::trigger::TriggerGateData< Tick, TickInterval >::Min | ( | triggergatedata_t const & | other | ) |
Combines with a gate, keeping the minimum opening among the two.
other | gate to combine to |
Max()
Multi-level equivalent of an and logical operation.
|
static |
Returns a gate with the minimum opening between the specified two.
a | first gate |
b | second gate |
a
and b
Max()
Multi-level equivalent of an and logical operation.
triggergatedata_t& icarus::trigger::TriggerGateData< Tick, TickInterval >::Mul | ( | triggergatedata_t const & | other | ) |
|
static |
|
inline |
Open this gate at the specified time (increase the opening by count
).
Definition at line 259 of file TriggerGateData.h.
|
inline |
Open this gate at the specified time (increase the opening by 1).
Definition at line 263 of file TriggerGateData.h.
void icarus::trigger::TriggerGateData< Tick, TickInterval >::openBetween | ( | ClockTick_t | start, |
ClockTick_t | end, | ||
OpeningDiff_t | count = 1 |
||
) |
Open this gate at specified start
tick, and close it at end
tick.
|
inline |
Open this gate at the specified time, and close it length
ticks later.
Definition at line 269 of file TriggerGateData.h.
OpeningCount_t icarus::trigger::TriggerGateData< Tick, TickInterval >::openingCount | ( | ClockTick_t | tick | ) | const |
Returns the opening count of the gate at the specified tick
.
std::pair<OpeningCount_t, OpeningCount_t> icarus::trigger::TriggerGateData< Tick, TickInterval >::openingRange | ( | ClockTick_t | start, |
ClockTick_t | end | ||
) | const |
Returns the range of trigger opening values in the specified range.
start | the first tick to consider |
end | the first tick to exclude |
This method returns the lowest opening value seen in the tick range, and the lowest opening value above that one not seen in the same range. Therefore, a gate always closed (opening value 0
) in the full range will return { 0, 1 }
, a gate always opened (opening value 1
) will return { 1, 2 }
, a gate which opened or closed within the tick range will return { 0, 2 }
. In case the tick range is empty, the returned value contains the same value for both extremes.
This function does not describe where the two extreme counts were found.
bool icarus::trigger::TriggerGateData< Tick, TickInterval >::operator!= | ( | TriggerGateData< Tick, TickInterval > const & | ) | const |
bool icarus::trigger::TriggerGateData< Tick, TickInterval >::operator== | ( | TriggerGateData< Tick, TickInterval > const & | ) | const |
void icarus::trigger::TriggerGateData< Tick, TickInterval >::setOpeningAt | ( | ClockTick_t | tick, |
OpeningCount_t | openingCount | ||
) |
Changes the opening to match openingCount
at the specified time.
|
staticprivate |
Helper returning the starting state of the levels at construction time.
triggergatedata_t& icarus::trigger::TriggerGateData< Tick, TickInterval >::Sum | ( | triggergatedata_t const & | other | ) |
|
static |
Returns a gate with opening sum of the specified two.
a | first gate |
b | second gate |
a
and b
Max()
|
static |
Returns a gate combination of the openings of two other gates.
Op | binary operation: OpeningCount_t (x2) to OpeningCount_t |
op | symmetric binary combination operation |
a | first gate |
b | second gate |
aDelay | ticks of delay to be added to the first gate |
bDelay | ticks of delay to be added to the second gate |
a
and b
For this algorithm to work, the operation needs to be symmetric, i.e. op(c1, c2) == op(c2, c1)
for every valid combinations of counts c1
and c2
.
|
friend |
|
friend |
|
private |
Evolution of the gate in time.
Definition at line 451 of file TriggerGateData.h.
|
static |
An unbearably large tick number.
Definition at line 160 of file TriggerGateData.h.
|
static |
An unbearably small tick number.
Definition at line 156 of file TriggerGateData.h.
|
staticprivate |
A new gate starts with this status: opening level set to 0.
Definition at line 448 of file TriggerGateData.h.