10 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_TRIGGERGATEBUILDER_H
11 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_TRIGGERGATEBUILDER_H
26 #include "fhiclcpp/types/Atom.h"
27 #include "fhiclcpp/types/Sequence.h"
38 namespace icarus::trigger {
45 struct WaveformWithBaseline;
47 class TriggerGateBuilder;
57 : std::tuple<raw::OpDetWaveform const*, icarus::WaveformBaseline const*>
62 using Base_t = std::tuple<Waveform_t const*, Baseline_t const*>;
74 {
return std::get<Waveform_t const*>(*this); }
78 {
return std::get<Baseline_t const*>(*this); }
112 = std::numeric_limits<Channel_t>::max();
155 template <
typename Stream>
160 {
return threshold() < other.threshold(); }
182 Name(
"ChannelThresholds"),
183 Comment(
"triggering thresholds [ADC counts]")
211 std::vector<ADCCounts_t>
const& thresholds
216 virtual std::vector<TriggerGates>
build
217 (std::vector<WaveformWithBaseline>
const& waveforms)
const = 0;
273 namespace icarus::trigger::details {
284 template <
typename Stream>
288 auto const nOpenGates =
fGates.size() - std::count_if(
290 [](
auto const& gate){
return gate.gate().alwaysClosed(); }
292 out << nOpenGates <<
"/" <<
fGates.size() <<
" trigger gates on threshold "
297 if (gate.alwaysClosed())
continue;
298 out <<
"\n " << gate;
307 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_TRIGGERGATEBUILDER_H
virtual void setup(detinfo::DetectorTimings const &timings)
Algorithm setup.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
std::vector< ADCCounts_t > const & channelThresholds() const
Returns all the configured thresholds.
A wrapper to trigger gate objects tracking the input of operations.
TriggerGates(ADCCounts_t threshold, GateData_t &&gates)
Constructor: acquires data of the specified gates.
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
fhicl::Sequence< ADCCounts_t::value_t > ChannelThresholds
virtual ~TriggerGateBuilder()=default
Virtual destructor. Nothing special about it, except that it's virtual.
auto gatesIn(TrackingGateColl &trackingGates)
double TimeStamp_t
us since 1970, based on TimeService
virtual void resetup(detinfo::DetectorTimings const &timings)
Resets and sets up.
pure virtual base interface for detector clocks
std::optional< detinfo::DetectorTimings > fDetTimings
LArSoft detector timing utility.
optical_tick timeStampToOpticalTick(raw::TimeStamp_t time) const
Converts a timestamp from raw::OpDetWaveform into optical ticks.
Interface to detinfo::DetectorClocks.
icarus::trigger::TrackedOpticalTriggerGate< raw::OpDetWaveform > triggergate_t
std::size_t nChannelThresholds() const
Returns the number of configured thresholds.
detinfo::DetectorTimings const & detTimings() const
Returns a detector timings object.
Container of logical gates for all triggering channels for a threshold.
bool operator<(TriggerGates const &other) const
Comparison: sorts by increasing threshold.
virtual void reset()
Algorithm reset. It will require a new setup before using it again.
virtual void doSetThresholds(std::vector< ADCCounts_t > const &thresholds)
Sets all thresholds anew.
constexpr auto TriggerGateDebugLog
void dump(Stream &out) const
Dumps the content of this set of gates into the out stream.
A value measured in the specified unit.
Simple type definitions for trigger algorithms.
ADCCounts_t fThreshold
The threshold for all the gates.
BEGIN_PROLOG vertical distance to the surface Name
virtual void resetup(detinfo::DetectorTimings const &timings, std::vector< ADCCounts_t > const &thresholds)
Resets and sets up (including a new set of thresholds).
std::vector< TriggerGates > prepareAllGates() const
TriggerGateBuilder(Config const &config)
Constructor: sets the configuration.
static constexpr bool isValidChannel(Channel_t channel)
Returns whether channel is valid.
A wrapper to trigger gate objects tracking the contributions.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
static constexpr bool isValidChannel(Channel_t channel)
std::vector< ADCCounts_t > fChannelThresholds
All single channel thresholds, sorted in increasing order.
optical_tick timeToOpticalTick(microsecond time) const
Converts a time [s] into optical ticks.
virtual std::vector< TriggerGates > build(std::vector< WaveformWithBaseline > const &waveforms) const =0
Returns a collection of TriggerGates objects sorted by threshold.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
GateData_t fGates
All the gates, at most one per channel.
std::vector< triggergate_t > GateData_t
A simple alias for a most commonly used TrackedTriggerGate type.
TriggerGates(ADCCounts_t threshold)
Constructor: no trigger gate added.
Algorithm to produce trigger gates out of optical readout waveforms.
static constexpr Channel_t InvalidChannel
Mnemonic for an invalid optical detector channel.