10 #ifndef ICARUSCODE_PMT_TRIGGER_UTILITIES_TRACKEDTRIGGERGATE_H
11 #define ICARUSCODE_PMT_TRIGGER_UTILITIES_TRACKEDTRIGGERGATE_H
24 #include <type_traits>
29 namespace icarus::trigger {
39 template <
typename Gate,
typename TrackedType>
42 template <
typename Gate,
typename TrackedType>
43 std::ostream&
operator<<
52 template <
typename Gate>
56 template <typename Gate>
57 decltype(auto)
gateIn(Gate&& gate);
61 template <typename TrackingGateColl>
62 auto
gatesIn(TrackingGateColl& trackingGates);
99 template <typename Gate, typename TrackedType>
115 void add(TrackedType tracked);
121 std::size_t nTracked()
const;
124 bool hasTracked()
const;
127 auto getTracked()
const;
132 TrackedTriggerGate() =
default;
158 decltype(
auto) channels()
const {
return gate().channels(); }
171 namespace icarus::trigger {
175 template <
typename T>
178 template <
typename Gate,
typename TrackedType>
185 template <
typename T>
197 template <
typename Gate,
typename TrackedType>
199 (TrackedType tracked)
200 { fTracked.insert(std::move(tracked)); }
204 template <
typename Gate,
typename TrackedType>
211 template <
typename Gate,
typename TrackedType>
215 {
return fTracked.size(); }
219 template <
typename Gate,
typename TrackedType>
223 {
return !(fTracked.empty()); }
227 template <
typename Gate,
typename TrackedType>
236 namespace icarus::trigger::details {
238 template <
typename T,
typename =
void>
241 template <
typename Gate>
244 std::
enable_if_t<icarus::trigger::isReadoutTriggerGate<Gate>::value>
248 template <
typename T>
249 static decltype(
auto) gateFrom(T&& gate) {
return std::forward<T>(gate); }
253 {
return std::move(gateFrom(std::move(gate)).gateLevels()); }
254 static decltype(
auto) gateDataFrom(Gate
const& gate)
255 {
return gateFrom(gate).gateLevels(); }
256 static decltype(
auto) gateDataFrom(Gate& gate)
257 {
return gateFrom(gate).gateLevels(); }
260 template <
typename Gate>
266 template <
typename T>
267 static decltype(
auto) gateFrom(T&& gate)
268 {
return std::forward<T>(gate).gate(); }
269 template <
typename T>
270 static decltype(
auto) gateDataFrom(T&& gate)
271 {
return gateDataIn(gateFrom(std::forward<T>(gate))); }
274 template <
typename Tick,
typename TickInterval>
279 template <
typename T>
280 static decltype(
auto) gateDataFrom(T&& gate)
281 {
return std::forward<T>(gate); }
288 template <
typename Gate,
typename TrackedType>
289 std::ostream& icarus::trigger::operator<<
291 {
return out <<
gateIn(gate); }
295 template <
typename Gate>
296 decltype(
auto) icarus::trigger::
gateIn(Gate&& gate) {
297 return details::GateExtractorImpl<std::decay_t<Gate>>::gateFrom
298 (std::forward<Gate>(gate));
303 template <
typename Gate>
304 decltype(
auto) icarus::trigger::
gateDataIn(Gate&& gate) {
305 return details::GateExtractorImpl<std::decay_t<Gate>>::gateDataFrom
306 (std::forward<Gate>(gate));
311 template <
typename TrackingGateColl>
318 auto getGate = [](
auto& gate) -> decltype(
auto) {
return gateIn(gate); };
333 #endif // ICARUSCODE_PMT_TRIGGER_UTILITIES_TRACKEDTRIGGERGATE_H
TrackedTriggerGate(TriggerGate_t gate)
Constructor: copies the data of the specified gate (no tracking added).
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
An object with a begin and end iterator.
A wrapper to trigger gate objects tracking the input of operations.
constexpr bool isTrackedTriggerGate_v
Whether T is some form of TrackedTriggerGate`.
TriggerGate_t && gate()&&
auto getTracked() const
Returns an iterable of all tracked objects.
std::size_t nTracked() const
Returns the number of objects currently tracked;.
TrackingInfo & tracking()
auto gatesIn(TrackingGateColl &trackingGates)
void add(TrackedType tracked)
Add an object to the list of tracked objects, if it's not present yet.
TriggerGate_t fGate
Local copy of the gate information.
TrackingInfo const & tracking() const
Returns the tracking information.
auto make_transformed_span(BIter begin, EIter end, Op &&op)
Tracked information. Interface is pretty minimal so far.
Trait returning whether T is some form of TrackedTriggerGate`.
auto end(FixedBins< T, C > const &) noexcept
typename std::enable_if< B, T >::type enable_if_t
Gate TriggerGate_t
Gate type being wrapped.
auto begin(FixedBins< T, C > const &) noexcept
TrackingInfo fTracking
Tracking information.
std::set< Tracked_t > fTracked
All tracked objects.
TriggerGate_t const & gate() const &
Returns the enclosed gate.
bool hasTracked() const
Whether any tracked object is present.
A trigger gate data object associated to one or more channels.
Logical multi-level gate.
decltype(auto) gateDataIn(Gate &&gate)
Returns the trigger data (a TriggerGateData) from the specofied gate.
decltype(auto) gateIn(Gate &&gate)
Returns the trigger gate (a ReadoutTriggerGate) from the specified gate.
TrackedType Tracked_t
Type for tracking.