22 #include "messagefacility/MessageLogger/MessageLogger.h"
23 #include "cetlib_except/exception.h"
35 template <
typename Comp = std::less<raw::Channel_t>>
36 struct ChannelComparison {
38 using Comparer_t = Comp;
42 constexpr ChannelComparison(): comp() {}
43 constexpr ChannelComparison(Comparer_t comp): comp(comp) {}
45 template <
typename A,
typename B>
46 constexpr
bool operator() (
A const&
a, B
const& b)
const
47 {
return comp(channelOf(a), channelOf(b)); }
58 template <
typename Gate,
typename OpDetInfo>
61 {
return channelOf(gate.
gate()); }
79 template <
typename SeqValueType>
80 struct FHiCLsequenceWrapper {
81 SeqValueType seqValue;
83 FHiCLsequenceWrapper(SeqValueType seqValue): seqValue(seqValue) {}
86 operator std::vector<T>()
const
87 {
return { seqValue.cbegin(), seqValue.cend() }; }
100 auto icarus::trigger::TriggerGateBuilder::TriggerGates::gateFor
105 auto iGate = std::lower_bound
106 (fGates.begin(), fGates.end(), waveform, ::ChannelComparison<>());
107 if (iGate != fGates.end()) {
109 <<
"Appending waveform to trigger gate (thr=" << threshold()
110 <<
") of channel " << channel;
111 iGate->tracking().add(&waveform);
116 <<
"Creating a new trigger gate (thr=" << threshold()
117 <<
") for channel " << channel;
119 iGate = fGates.emplace(iGate, triggergate_t::TriggerGate_t{ channel });
121 iGate->tracking().add(&waveform);
130 : fChannelThresholds(FHiCLsequenceWrapper(config.ChannelThresholds()))
137 throw cet::exception(
"TriggerGateBuilder")
138 <<
"icarus::trigger::TriggerGateBuilder does not support"
139 " negative thresholds (like "
150 fDetTimings = timings;
178 std::vector<TriggerGates> allGates;
179 allGates.reserve(nChannelThresholds());
180 for (
auto threshold: channelThresholds()) allGates.emplace_back(threshold);
virtual void setup(detinfo::DetectorTimings const &timings)
Algorithm setup.
ChannelID_t channel() const
Returns the channel associated to the gate data.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
A wrapper to trigger gate objects tracking the input of operations.
Algorithm to produce trigger gates out of optical readout waveforms.
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
double TimeStamp_t
us since 1970, based on TimeService
optical_tick timeStampToOpticalTick(raw::TimeStamp_t time) const
Converts a timestamp from raw::OpDetWaveform into optical ticks.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Container of logical gates for all triggering channels for a threshold.
Logical multi-level gate associated to one or more readout channels.
constexpr auto TriggerGateDebugLog
A value measured in the specified unit.
A trigger gate data object for optical detector electronics.
timescale_traits< OpticalTimeCategory >::time_point_t optical_time
A point in time on the optical detector electronics time scale.
std::vector< TriggerGates > prepareAllGates() const
TriggerGateBuilder(Config const &config)
Constructor: sets the configuration.
A wrapper to trigger gate objects tracking the contributions.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
std::vector< ADCCounts_t > fChannelThresholds
All single channel thresholds, sorted in increasing order.
TriggerGate_t const & gate() const &
Returns the enclosed gate.
optical_tick timeToOpticalTick(microsecond time) const
Converts a time [s] into optical ticks.
A class exposing an upgraded interface of detinfo::DetectorClocksData.