8 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_DETAILS_TRIGGERINFO_T_H
9 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_DETAILS_TRIGGERINFO_T_H
23 #include <type_traits>
28 namespace icarus::trigger::details {
64 = std::numeric_limits<std::size_t>::max();
154 {
if (
fAll.empty())
fMain = info;
fAll.push_back(std::move(info)); }
192 std::vector<OpeningInfo_t>
const&
all()
const {
return fAll; }
206 std::vector<OpeningInfo_t>
fAll;
236 template <
typename Gate>
239 using GateData_t = std::decay_t<decltype(gateDataIn(std::declval<Gate_t>()))>;
264 : openThreshold(openThreshold), closeThreshold(closeThreshold)
386 if (!other.
fired())
return false;
388 bool const hadFired = fired();
391 fAll.reserve(nTriggers() + other.
nTriggers());
394 if (hadFired && (other.
atTick() >= atTick()))
return false;
396 fMain = other.
main();
406 if (info.
tick >= atTick())
return false;
416 template <
typename Gate>
418 -> std::optional<OpeningInfo_t>
420 if (atEnd())
return {};
427 std::tie(closing, nextStart) = findNextCloseAndOpen(nextStart);
428 if (nextStart == MaxTick)
break;
430 (closing - start < static_cast<ClockDiff_t>(minWidth()))
431 || (nextStart - closing < static_cast<ClockDiff_t>(minGap()))
434 return std::optional<OpeningInfo_t>{ std::in_place,
436 gate.openingCount(gate.findMaxOpen(start, closing)),
443 template <
typename Gate>
447 ClockTick_t const closing = (gate.openingCount(start) > closeThreshold())
448 ? findClose(start): start;
449 return { closing, findOpen(closing) };
455 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_DETAILS_TRIGGERINFO_T_H
bool addAndReplaceIfEarlier(TriggerInfo_t const &other)
If other has fired, and at an earlier tick, set a new main().
bool fired() const
Returns whether the trigger fired.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
std::vector< OpeningInfo_t > const & all() const
void sortOpenings()
Sorts all openings by time.
LocationID_t location() const
Returns the ID of the location of the trigger (undefined if !fired()).
OpeningInfo_t const & main() const
Returns the full data (undefined if !fired()).
bool hasLocation() const
Returns if the location of the trigger is set (undefined if !fired()).
bool operator<(OpeningInfo_t const &other) const
Comparison: order from time.
static constexpr LocationID_t UnknownLocation
ID for a trigger in unknown location.
std::vector< OpeningInfo_t > fAll
Helper data structure to store transient trigger result.
optical_tick tick
Tick at which the trigger fired.
LocationID_t locationID
Identified of the trigger location.
A trigger gate data object for optical detector electronics.
void replace(OpeningInfo_t info)
Sets info as the new main() trigger.
std::size_t LocationID_t
Type for ID of trigger location.
OpeningInfo_t fMain
Main trigger (also found in fAll), if any.
bool hasLocation() const
Returns whether the location is set.
OpeningInfo_t(optical_tick tick, Opening_t level=0U, std::size_t locationID=UnknownLocation)
Constructor: specify tick, the rest is optional.
Opening_t level
Maximum level on the main trigger opening.
unsigned int OpeningCount_t
Type of count of number of open channels.
A wrapper to trigger gate objects tracking the contributions.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
icarus::trigger::OpticalTriggerGateData_t::GateData_t::OpeningCount_t Opening_t
Type of gate opening level.
optical_tick atTick() const
Returns the time of the trigger (undefined if !fired()).
TriggerInfo_t(OpeningInfo_t info)
Data types for detinfo::DetectorTimings.
Opening_t level() const
Returns the opening level of the trigger (undefined if !fired()).
decltype(auto) gateDataIn(Gate &&gate)
Returns the trigger data (a TriggerGateData) from the specofied gate.
OpeningInfo_t()=default
Default constructor.
OpeningInfo_t const & info() const
Returns the information of the main trigger (undefined if !fired()).
void add(OpeningInfo_t info)
detinfo::timescales::optical_tick optical_tick
Type alias.
std::size_t nTriggers() const
Returns the number of registered triggers.
bool operator!() const
Returns whether there is no trigger information.