All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Classes | Typedefs | Functions | Variables
icarus::trigger Namespace Reference

Namespaces

 details
 
 GateOps
 Gate operations expressed as generic functions.
 
 ns
 

Classes

class  BeamGateInfoFromTracks
 Writes a set collection of beam gates into each event. More...
 
class  PMTverticalSlicingAlg
 Algorithm clustering PMT according to their position. More...
 
class  OpDetWaveformMetaMaker
 Extracts and saves the time coverage of optical detector waveforms. More...
 
class  ApplyBeamGateClass
 Helper applying a beam gate to any gate. More...
 
class  BeamGateMaker
 Simple utility to generate gates around beam time. More...
 
struct  BeamGateStruct
 Object representing a time gate, with a start and and end. More...
 
class  DynamicTriggerGateBuilder
 Dynamic gate builder. More...
 
class  FixedTriggerGateBuilder
 Fixed-length gate builder. More...
 
class  ManagedTriggerGateBuilder
 Base interface for gate builders. More...
 
class  TriggerGateIndex
 Associates each optical detector channel to a gate. More...
 
class  SlidingWindowCombinerAlg
 
class  SlidingWindowDefinitionAlg
 Groups optical detector channels into windows based on position. More...
 
class  SlidingWindowPatternAlg
 Applies sliding window patterns to discriminated waveforms. More...
 
struct  WaveformWithBaseline
 Object to carry around waveform ant its baseline. More...
 
class  TriggerGateBuilder
 Algorithm to produce trigger gates out of optical readout waveforms. More...
 
class  WindowChannelMap
 Information about composition and topology of trigger sliding windows. More...
 
struct  WindowPattern
 Specification of the requirement of sliding window firing pattern. More...
 
class  WindowTopologyAlg
 Algorithm to create trigger window topology information. More...
 
class  WindowTopologyVerification
 Algorithm verifying the topology from trigger gates. More...
 
class  WindowTopologyManager
 Class to extract and verify a window topology from trigger gates. More...
 
class  DiscriminatePMTwaveforms
 Produces discriminated optical waveforms. More...
 
class  DiscriminatePMTwaveformsByChannel
 Produces discriminated optical waveforms. More...
 
class  DumpTriggerGateData
 Produces plots to inform trigger design. More...
 
struct  DynamicTriggerGateBuilderTool
 Dynamic gate builder tool. More...
 
class  ExtractEnergyDepositionSummary
 Produces energy deposition summary data products. More...
 
class  FixBeamGateInfo
 Rewrites a set collection of beam gates into each event. More...
 
struct  dumpRecipe
 
struct  FixedTriggerGateBuilderTool
 Fixed gate builder tool. More...
 
class  LVDSgates
 Combines discriminated PMT outputs into V1730 LVDS gates. More...
 
class  MajorityTriggerEfficiencyPlots
 Produces plots about trigger simulation and trigger efficiency. More...
 
class  MajorityTriggerCombiner
 Combines a group of trigger gates for majority trigger. Glorified Sum(). More...
 
class  CryostatTriggerCombiner
 Combines cryostat triggers via OR. Glorified Max(). More...
 
class  GeometryChannelSplitter
 Combines cryostat triggers via OR. Glorified Max(). More...
 
class  MajorityTriggerSimulation
 Simulates a "majority" trigger. More...
 
class  MakeTriggerSimulationTree
 Make ROOT tree with information about event and trigger input. More...
 
class  SlidingWindowTrigger
 Combines trigger channels (V1730 LVDS gates) into sliding windows. More...
 
class  SlidingWindowTriggerEfficiencyPlots
 Produces plots about trigger simulation and trigger efficiency. More...
 
class  SlidingWindowTriggerSimulation
 Simulates a sliding window trigger. More...
 
class  TriggerEfficiencyPlots
 Produces plots about trigger simulation and trigger efficiency. More...
 
class  TriggerEfficiencyPlotsBase
 Helper class to produce plots about trigger simulation and trigger efficiency. More...
 
class  TriggerSimulationOnGates
 Simulates a sliding window trigger at specified gate times. More...
 
class  OpDetWaveformMetaMatcher
 Object to facilitate the discovery of the raw::OpDetWaveform a sbn::OpDetWaveformMeta objects comes from. More...
 
class  PlotSandbox
 A helper to manage ROOT objects with consistent naming. More...
 
struct  isTrackedTriggerGate
 Trait returning whether T is some form of TrackedTriggerGate`. More...
 
class  TrackedTriggerGate
 A wrapper to trigger gate objects tracking the input of operations. More...
 
class  TriggerGateReader
 Assembles and returns trigger gates from serialized data. More...
 
class  WriteBeamGateInfo
 Writes a set collection of beam gates into each event. More...
 
class  MultiChannelOpticalTriggerGate
 Logical multi-level gate associated to one or more channels. More...
 
class  OpticalTriggerGate
 Logical multi-level gate associated to one or more waveforms. More...
 
struct  ReadoutTriggerGateTag
 All ReadoutTriggerGate template instances derive from this tag. More...
 
class  ReadoutTriggerGate
 Logical multi-level gate associated to one or more readout channels. More...
 
struct  ReadoutTriggerGateError
 Base class for all exceptions from icarus::trigger::ReadoutTriggerGate. More...
 
struct  NoChannelError
 No channel associated to the readout gate. More...
 
struct  MoreThanOneChannelError
 More than one channel associated to the readout gate. More...
 
struct  isReadoutTriggerGate
 Type traits: Gate type derives from a ReadoutTriggerGate instance. More...
 
class  SingleChannelOpticalTriggerGate
 Logical multi-level gate associated to a optical detector channel. More...
 
class  TriggerGateData
 Logical multi-level gate. More...
 

Typedefs

using ADCCounts_t = util::quantities::counts_as< raw::ADC_Count_t >
 ADC counts for optical detector readout. More...
 
using WindowPatterns_t = std::vector< WindowPattern >
 A list of window patterns. More...
 
template<typename TrackedType >
using TrackedOpticalTriggerGate = icarus::trigger::TrackedTriggerGate< icarus::trigger::OpticalTriggerGateData_t, TrackedType const * >
 TrackedTriggerGate wrapper to trigger gate type commonly stored. More...
 
using OpDetWaveformDataProductMap_t = util::DataProductPointerMap_t< raw::OpDetWaveform >
 Map util::DataProductPointerMap_t for raw::OpDetWaveform objects. More...
 
using OpDetWaveformMetaDataProductMap_t = util::DataProductPointerMap_t< sbn::OpDetWaveformMeta >
 Map util::DataProductPointerMap_t for sbn::OpDetWaveformMeta objects. More...
 
using triggerLocation = sbn::triggerLocation
 
using triggerSource = sbn::triggerSource
 
using TriggerGateTick_t = util::quantities::tick::value_t
 Tick point. More...
 
using TriggerGateTicks_t = util::quantities::tick::value_t
 Tick interval. More...
 
using OpticalTriggerGateData_t = icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t >
 Type of trigger gate data serialized into art data products. More...
 

Functions

ApplyBeamGateClass makeApplyBeamGate (util::quantities::intervals::microseconds duration, util::quantities::intervals::microseconds delay, detinfo::DetectorClocksData const &clockData, std::string const &logCategory="ApplyBeamGateClass")
 Returns a new ApplyBeamGateClass object with the specified gate. More...
 
ApplyBeamGateClass makeApplyBeamGate (util::quantities::intervals::microseconds duration, detinfo::DetectorClocksData const &clockData, std::string const &logCategory="ApplyBeamGateClass")
 Returns a new ApplyBeamGateClass object with the specified gate. More...
 
std::ostream & operator<< (std::ostream &out, icarus::trigger::ApplyBeamGateClass const &gate)
 
BeamGateStruct makeBeamGateStruct (detinfo::DetectorTimings const &detTimings, util::quantities::intervals::microseconds duration, util::quantities::intervals::microseconds delay=util::quantities::intervals::microseconds{0.0})
 Creates a BeamGateStruct object of specified duration and start. More...
 
template<typename Time >
std::ostream & operator<< (std::ostream &out, icarus::trigger::BeamGateStruct::TimeRange< Time > const &range)
 
std::ostream & operator<< (std::ostream &, WindowChannelMap const &)
 
std::string to_string (WindowPattern const &pattern)
 
DiscriminatePMTwaveformsByChannel::ChannelInfo_t convert (DiscriminatePMTwaveformsByChannel::ChannelConfig const &config)
 
std::ostream & operator<< (std::ostream &out, dumpRecipe const &dr)
 
FixBeamGateInfo::BeamChangeRecipe convert (FixBeamGateInfo::Config::ChangeGate const &config)
 
template<typename Gate , typename TrackedType >
std::ostream & operator<< (std::ostream &out, TrackedTriggerGate< Gate, TrackedType > const &gate)
 
template<typename Gates >
std::vector
< icarus::trigger::OpticalTriggerGateData_t
transformIntoOpticalTriggerGate (Gates &&gates)
 Returns the trigger gates in serializable format. More...
 
template<typename OpDetInfo = sbn::OpDetWaveformMeta>
std::tuple< std::vector
< icarus::trigger::OpticalTriggerGateData_t >
, art::Assns
< icarus::trigger::OpticalTriggerGateData_t,
OpDetInfo > > 
transformIntoOpticalTriggerGate (std::vector< icarus::trigger::TrackedOpticalTriggerGate< OpDetInfo >> &&gates, art::PtrMaker< icarus::trigger::OpticalTriggerGateData_t > const &makeGatePtr, util::DataProductPointerMap_t< OpDetInfo > const &opDetInfoPtrs)
 Returns the trigger gates in serializable format. More...
 
template<typename OpDetInfo >
std::vector
< icarus::trigger::TrackedOpticalTriggerGate
< OpDetInfo > > 
FillTriggerGates (std::vector< icarus::trigger::OpticalTriggerGateData_t > const &gates, art::Assns< icarus::trigger::OpticalTriggerGateData_t, OpDetInfo > const &gateToWaveformInfo)
 Creates a gate object out of trigger gate data products. More...
 
template<typename OpDetInfo = sbn::OpDetWaveformMeta, typename Event >
std::vector
< icarus::trigger::TrackedOpticalTriggerGate
< OpDetInfo > > 
ReadTriggerGates (Event const &event, art::InputTag const &dataTag)
 Assembles and returns trigger gates from serialized data. More...
 
template<typename Tick , typename TickInterval , typename ChannelIDType >
auto compactdump (ReadoutTriggerGate< Tick, TickInterval, ChannelIDType > const &gate) -> details::CompactFormatter< ReadoutTriggerGate< Tick, TickInterval, ChannelIDType >>
 Manipulator-like function for compact format of trigger gates. More...
 
sim::BeamGateInfo convert (WriteBeamGateInfo::Config::GateConfig const &config)
 
MultiChannelOpticalTriggerGate sumTriggerGates (std::vector< SingleChannelOpticalTriggerGate > const &gates)
 
std::ostream & operator<< (std::ostream &, OpticalTriggerGate const &)
 
template<typename Tick , typename TickInterval , typename ChannelIDType >
std::ostream & operator<< (std::ostream &, ReadoutTriggerGate< Tick, TickInterval, ChannelIDType > const &)
 
template<typename TK , typename TI >
std::ostream & operator<< (std::ostream &, TriggerGateData< TK, TI > const &)
 
template<typename TK , typename TI >
std::ostream & operator<< (std::ostream &, typename TriggerGateData< TK, TI >::Status const &)
 
`icarus::trigger::TrackedTriggerGate` simple helpers
template<typename Gate >
decltype(auto) gateDataIn (Gate &&gate)
 Returns the trigger data (a TriggerGateData) from the specofied gate. More...
 
template<typename Gate >
decltype(auto) gateIn (Gate &&gate)
 Returns the trigger gate (a ReadoutTriggerGate) from the specified gate. More...
 
template<typename TrackingGateColl >
auto gatesIn (TrackingGateColl &trackingGates)
 
Gate operations

Currently the following operations are supported:

Operations on more than one gate can take a sequence (begin and end iterators), a collection or an arbitrary number of gates.

template<typename GateObj >
GateObj discriminate (GateObj const &gate, typename GateObj::OpeningCount_t threshold=1U, typename GateObj::OpeningCount_t pass=1U, typename GateObj::OpeningCount_t fail=0U)
 Returns a discriminated version of gate. More...
 
template<typename BIter , typename EIter >
auto sumGatesSequence (BIter const begin, EIter const end)
 Sums a sequence of gates. More...
 
template<typename GateColl >
auto sumGates (GateColl const &gates)
 Sums all the gates in a collection. More...
 
template<typename AGate , typename BGate , typename... OTrigGates>
auto sumGates (AGate A, BGate const &B, OTrigGates const &...others)
 Sums all the specified gates. More...
 
template<typename BIter , typename EIter >
auto mulGatesSequence (BIter const begin, EIter const end)
 Multiplies a sequence of gates. More...
 
template<typename GateColl >
auto mulGates (GateColl const &gates)
 Multiplies all the gates in a collection. More...
 
template<typename AGate , typename BGate , typename... OTrigGates>
auto mulGates (AGate A, BGate const &B, OTrigGates const &...others)
 Multiplies all the specified gates. More...
 
template<typename BIter , typename EIter >
auto maxGatesSequence (BIter const begin, EIter const end)
 Computes the gate with the maximum opening of a sequence of gates. More...
 
template<typename GateColl >
auto maxGates (GateColl const &gates)
 Computes the gate with the maximum opening of gates from collection. More...
 
template<typename AGate , typename BGate , typename... OTrigGates>
auto maxGates (AGate A, BGate const &B, OTrigGates const &...others)
 Computes the gate with the maximum opening of the specified gates. More...
 
template<typename BIter , typename EIter >
auto minGatesSequence (BIter const begin, EIter const end)
 Computes the gate with the minimum opening of a sequence of gates. More...
 
template<typename GateColl >
auto minGates (GateColl const &gates)
 Computes the gate with the minimum opening of gates from collection. More...
 
template<typename AGate , typename BGate , typename... OTrigGates>
auto minGates (AGate A, BGate const &B, OTrigGates const &...others)
 Computes the gate with the minimum opening of the specified gates. More...
 
template<typename Op , typename AGate , typename BGate , typename... OGates>
AGate OpGates (Op op, AGate A, BGate const &B, OGates const &...others)
 Applies an operation to two gates. More...
 
template<typename Op , typename GateColl >
auto OpGateColl (Op op, GateColl const &gates)
 Computes the result of an operation on all gates from collection. More...
 
template<typename Op , typename BIter , typename EIter >
auto OpGatesSequence (Op op, BIter const begin, EIter const end)
 Computes the result of an operation on all gates in the sequence. More...
 

Variables

template<typename T >
constexpr bool isTrackedTriggerGate_v = isTrackedTriggerGate<T>::value
 Whether T is some form of TrackedTriggerGate`. More...
 
static constexpr std::size_t kEast = sbn::bits::value<triggerLocation>(triggerLocation::CryoEast)
 
static constexpr std::size_t kWest = sbn::bits::value<triggerLocation>(triggerLocation::CryoWest)
 
static constexpr std::size_t kNTriggerLocation = sbn::bits::value<triggerLocation>(triggerLocation::NBits)
 
static constexpr std::size_t kBNB = sbn::bits::value<triggerSource>(triggerSource::BNB)
 
static constexpr std::size_t kNuMI = sbn::bits::value<triggerSource>(triggerSource::NuMI)
 
static constexpr std::size_t kOffBeamBNB = sbn::bits::value<triggerSource>(triggerSource::OffbeamBNB)
 
static constexpr std::size_t kOffBeamNuMI = sbn::bits::value<triggerSource>(triggerSource::OffbeamNuMI)
 
static constexpr std::size_t kCalibration = sbn::bits::value<triggerSource>(triggerSource::Calib)
 
static constexpr std::size_t kNTriggerSource = sbn::bits::value<triggerSource>(triggerSource::NBits)
 
Exceptions associated to `icarus::trigger::ReadoutTriggerGate` class
template<typename Gate >
constexpr bool isReadoutTriggerGate_v = isReadoutTriggerGate<Gate>::value
 Flag: true if Gate type derives from a ReadoutTriggerGate instance. More...
 

Optical detector windows

An optical detector window is just a group of optical detectors. For trigger, these windows comprise contiguous optical detectors, and may overlap for better coverage.

The algorithm SlidingWindowDefinitionAlg allows the creation of "sliding" windows. The information on a single window is encoded in a standard container (TriggerWindowChannels_t), with a unique channel number representing each detector in the window in no particular order.

Definitions ("aliases") are here provided for convenience, together with a couple of functions to print the content of a window or a set of windows.

using TriggerWindowChannels_t = std::vector< raw::Channel_t >
 Type of optical detector channel list in a window. More...
 
using TriggerWindowDefs_t = std::vector< TriggerWindowChannels_t >
 Definition of all windows. More...
 
void printTriggerWindowChannels (std::ostream &out, TriggerWindowChannels_t const &window)
 Prints the composition of the optical detector window inline. More...
 
void printTriggerWindowDefs (std::ostream &out, TriggerWindowDefs_t const &windows)
 Prints the composition of all windows in long format. More...
 
auto dumpTriggerWindowChannels (TriggerWindowChannels_t const &window) -> details::DumpTriggerWindowChannelWrapper
 
auto dumpTriggerWindowDefs (TriggerWindowDefs_t const &windows) -> details::DumpTriggerWindowDefWrapper
 

Typedef Documentation

ADC counts for optical detector readout.

Definition at line 40 of file TriggerTypes.h.

Map util::DataProductPointerMap_t for raw::OpDetWaveform objects.

Definition at line 45 of file TriggerDataUtils.h.

Map util::DataProductPointerMap_t for sbn::OpDetWaveformMeta objects.

Definition at line 49 of file TriggerDataUtils.h.

Type of trigger gate data serialized into art data products.

Definition at line 44 of file OpticalTriggerGate.h.

TrackedTriggerGate wrapper to trigger gate type commonly stored.

Template Parameters
TrackedTypetype of tracked objects

The data in the gate, of type icarus::trigger::OpticalTriggerGateData_t, is accessed via gate() and it is owned (i.e. if its source is a data product, this is a copy of that data and not a reference to it).

Tracking information stores pointers to existing TrackedType objects (typically raw::OpDetWaveform or sbn::OpDetWaveformMeta).

Definition at line 38 of file TrackedOpticalTriggerGate.h.

Tick point.

Definition at line 37 of file OpticalTriggerGate.h.

Tick interval.

Definition at line 38 of file OpticalTriggerGate.h.

using icarus::trigger::triggerLocation = typedef sbn::triggerLocation

Definition at line 360 of file BeamBits.h.

using icarus::trigger::triggerSource = typedef sbn::triggerSource

Definition at line 361 of file BeamBits.h.

Type of optical detector channel list in a window.

Definition at line 43 of file SlidingWindowDefs.h.

Definition of all windows.

Definition at line 46 of file SlidingWindowDefs.h.

using icarus::trigger::WindowPatterns_t = typedef std::vector<WindowPattern>

A list of window patterns.

Definition at line 25 of file WindowPattern.h.

Function Documentation

template<typename Tick , typename TickInterval , typename ChannelIDType >
auto icarus::trigger::compactdump ( ReadoutTriggerGate< Tick, TickInterval, ChannelIDType > const &  gate) -> details::CompactFormatter<ReadoutTriggerGate<Tick, TickInterval, ChannelIDType>>

Manipulator-like function for compact format of trigger gates.

Template Parameters
Ticktemplate type Tick for ReadoutTriggerGate
TickIntervaltemplate type TickInterval for ReadoutTriggerGate
ChannelIDTypetemplate type ChannelIDType for ReadoutTriggerGate
Parameters
gatethe gate to be formatted
Returns
a wrapper with the parameters to format the gate

This helper function is always used in the context of the insertion of a trigger gate data object into an output stream:

#include <iostream>
// ...
std::vector<icarus::trigger::OpticalTriggerGate> LVDSgates;
// ...
for (auto const& [ iGate, gate ]: util::enumerate(LVDSgates))
std::cout << "[" << iGate << "] " << compactdump(gate) << std::endl;

The loop will print all the LVDSgates in "compact" mode, one per line, prepended by their position in the collection.

Technical note: compactdump() in the example is found by the compiler via Koenig lookup.

Definition at line 79 of file TriggerGateDataFormatting.h.

81  { return { details::GateWrapper{ gate } }; }
GateWrapper(Gate const &) -> GateWrapper< Gate >
sim::BeamGateInfo icarus::trigger::convert ( WriteBeamGateInfo::Config::GateConfig const &  config)

Definition at line 187 of file WriteBeamGateInfo_module.cc.

188  {
189  // nanoseconds is the standard unit for simulation and for sim::BeamGateInfo
191  return sim::BeamGateInfo{
192  config.Start().convertInto<nanoseconds>().value() // start
193  , config.Duration().convertInto<nanoseconds>().value() // width
194  , config.getBeamType() // type
195  };
196 
197  } // convert(GateConfig)
double Start() const
Definition: BeamGateInfo.h:30
nanoseconds_as<> nanoseconds
Type of time interval stored in nanoseconds, in double precision.
Definition: spacetime.h:270
temporary value
nanosecond nanoseconds
Alias for common language habits.
Definition: spacetime.h:139
FixBeamGateInfo::BeamChangeRecipe icarus::trigger::convert ( FixBeamGateInfo::Config::ChangeGate const &  config)

Definition at line 364 of file FixBeamGateInfo_module.cc.

365  {
366  using ChangeGate = FixBeamGateInfo::Config::ChangeGate;
367  return FixBeamGateInfo::BeamChangeRecipe{
368  ChangeGate::convert(config.Select()) // selectGates
369  , ChangeGate::convert(config.Start()) // start
370  , ChangeGate::convert(config.Width()) // width
371  };
372  } // convert(FixBeamGateInfo::Config::ChangeGate)
TimeTrackTreeStorage::TriggerInputSpec_t convert(TimeTrackTreeStorage::Config::TriggerSpecConfig const &config)
DiscriminatePMTwaveformsByChannel::ChannelInfo_t icarus::trigger::convert ( DiscriminatePMTwaveformsByChannel::ChannelConfig const &  config)

Definition at line 456 of file DiscriminatePMTwaveformsByChannel_module.cc.

457  {
458  return DiscriminatePMTwaveformsByChannel::ChannelInfo_t{
459  config.Channel(), // channel
460  util::fhicl::getOptionalValue(config.Baseline), // baseline
461  util::fhicl::getOptionalValue(config.Threshold) // threshold
462  };
463  } // icarus::trigger::convert()
std::optional< typename Optional::value_type > getOptionalValue(Optional const &parameter)
Returns the value of an optional parameter as std::optional.
Definition: FHiCLutils.h:188
template<typename GateObj >
GateObj icarus::trigger::discriminate ( GateObj const &  gate,
typename GateObj::OpeningCount_t  threshold = 1U,
typename GateObj::OpeningCount_t  pass = 1U,
typename GateObj::OpeningCount_t  fail = 0U 
)

Returns a discriminated version of gate.

Template Parameters
GateObjtype of gate being discriminated (and returned)
Parameters
gatethe gate to be discriminated
threshold(default: 1) the discrimination threshold
pass(default: 1) discriminated gate value on test pass
fail(default: 0) discriminated gate value on test fail
Returns
a gate resulting from the discrimination of gate.
See Also
gateAbove(), gateBelow()

A new gate of the same type as the input gate is returned. This gate has two opening count values: either pass, in the time intervals where the gate is at or above threshold, or fail, in the time intervals where the gate is below threshold.

Examples:

auto const discrGate = discriminate(gate, 5U, 0U, 5U);
auto const discrGateNeg = discriminate(gate, 5U, 5U, 0U);

will have discrGate as a gate with value 0U wherever gate has opening count 4 or less, and 5U where gate has opening count 5 or more. The gatediscrGateNeg has the two opening values swapped and therefore results the complement of discrGate.

Definition at line 411 of file TriggerGateOperations.h.

417 {
418  // we copy the gate hoping that the copy constructor takes care of everything
419  // else that we don't want to touch...
420  // that includes tracking information, if any, which is preserved untouched
421  auto discrGate { gate };
422 
423  auto const closeToOpen
424  = static_cast<typename GateObj::OpeningDiff_t>(pass - fail);
425 
426  // ... except for the data, which we do want to touch:
427  discrGate.clear();
428 
429  // set the starting level according to the discrimination
430  auto lastTick = discrGate.MinTick;
431  if (gate.openingCount(lastTick) < threshold) {
432  // gate starts from fail (most "normal" case)
433  discrGate.setOpeningAt(lastTick, fail);
434  }
435  else {
436  // gate starts from pass!
437  discrGate.setOpeningAt(lastTick, pass);
438 
439  // bring it to fail
440  lastTick = gate.findClose(threshold, ++lastTick);
441  if (lastTick != gate.MaxTick) discrGate.closeAt(lastTick, closeToOpen);
442  } // if started from above threshold
443 
444  // we are at a fail state now
445  while (lastTick < gate.MaxTick) {
446 
447  // bring it to pass...
448  lastTick = gate.findOpen(threshold, ++lastTick);
449  if (lastTick == gate.MaxTick) break;
450  discrGate.openAt(lastTick, closeToOpen);
451 
452  // ... back to fail...
453  lastTick = gate.findClose(threshold, ++lastTick);
454  if (lastTick == gate.MaxTick) break;
455  discrGate.closeAt(lastTick, closeToOpen);
456 
457  } // while last tick
458 
459  return discrGate;
460 } // icarus::trigger::discriminate()
auto icarus::trigger::dumpTriggerWindowChannels ( TriggerWindowChannels_t const &  window) -> details::DumpTriggerWindowChannelWrapper
inline

Helper for printing a TriggerWindowChannels_t into a stream.

Example:

TriggerWindowChannels_t window; // ... filled with some channels

Definition at line 117 of file SlidingWindowDefs.h.

119  { return { &window }; }
auto icarus::trigger::dumpTriggerWindowDefs ( TriggerWindowDefs_t const &  windows) -> details::DumpTriggerWindowDefWrapper
inline

Helper for printing a TriggerWindowDefs_t into a stream.

Example:

TriggerWindowDefs_t windows; // ... filled with some content

Definition at line 130 of file SlidingWindowDefs.h.

131  { return { &windows }; }
template<typename OpDetInfo >
std::vector< icarus::trigger::TrackedOpticalTriggerGate< OpDetInfo > > icarus::trigger::FillTriggerGates ( std::vector< icarus::trigger::OpticalTriggerGateData_t > const &  gates,
art::Assns< icarus::trigger::OpticalTriggerGateData_t, OpDetInfo > const &  gateToWaveformInfo 
)

Creates a gate object out of trigger gate data products.

Template Parameters
OpDetInfotype of the associated waveforms
Parameters
gatescollection of data from all the gates
gateToWaveformInfoassociation between each gate and its waveforms
Returns
a STL vector of TrackedOpticalTriggerGate with copy of data from gates

Objects like icarus::trigger::TrackedOpticalTriggerGate include the gate level information plus the connections to the source objects (waveforms). This structure is complicate enoug that they are not saved directly into an art event. Rather, they are diced into pieces and the pieces are stored.

This function stitches the pieces and returns back an object like icarus::trigger::TrackedOpticalTriggerGate.

Example:

std::vector<icarus::trigger::TrackedOpticalTriggerGate<sbn::OpDetWaveformMeta>>
readTriggerGates(art::Event const& event, art::InputTag const& dataTag)
{
auto const& gates
= event.getProduct<std::vector<TriggerGateData_t>>(dataTag);
auto const& gateToWaveforms
= event.getProduct<art::Assns<TriggerGateData_t, sbn::OpDetWaveformMeta>>
(dataTag);
return icarus::trigger::FillTriggerGates<sbn::OpDetWaveformMeta>
(gates, gateToWaveforms);
} // readTriggerGates()

will read the information from dateTag data products in an art event and return a collection of icarus::trigger::TrackedOpticalTriggerGate objects, each one with a copy of the data of the original data product and a pointer to each of the associated waveform metadata. Note that this specific functionality is now wrapped into icarus::trigger::ReadTriggerGates().

Return value

The returned collection contains one element for each OpticalTriggerGateData_t object in gates, in the same order. Each of these elements is of type icarus::trigger::TrackedOpticalTriggerGate<OpDetInfo>, contains a copy of the data of the corresponding gate, and a list of optical waveform information pointers (OpDetInfo objects) it is associated to.

Requirements

The requirements bind the gates to their association to waveforms:

  • each gate must be associated to at least one waveform
  • the associations must be grouped so that all the association pairs pertaining a gate are contiguous
    • within each of these groups, which is made of at least one waveform, the waveforms must be ordered by increasing timestamp
    • the groups must be in the same order as their associated gates This constitutes the requirement of one-to-many sequential association with the addition that each element in gates must have at least one associated waveform.

Definition at line 560 of file TriggerDataUtils.h.

563  {
564 
565  std::vector<icarus::trigger::TrackedOpticalTriggerGate<OpDetInfo>>
566  allGates; // the output
567 
568  auto iGateToWaveform = gateToWaveformInfo.begin();
569  auto const gwend = gateToWaveformInfo.end();
570 
571  for (auto const& [ iGate, gate ]: util::enumerate(gates)) {
572 
574 
575  //
576  // find the relevant waveforms for this gate;
577  // match by index of the element in the data product collection
578  //
579  while (iGateToWaveform != gwend) {
580  if (iGateToWaveform->first.key() == iGate) break;
581  ++iGateToWaveform;
582  } // while
583 
584  while (iGateToWaveform != gwend) {
585  if (iGateToWaveform->first.key() != iGate) break;
586 
587  OpDetInfo const& wfInfo = *(iGateToWaveform->second);
588 
589  // add the associated information to the gate:
590  trackedGate.gate().addChannel(wfInfo.ChannelNumber());
591  trackedGate.tracking().add(&wfInfo);
592 
593  ++iGateToWaveform;
594  } // while
595 
596  allGates.push_back(std::move(trackedGate));
597 
598  } // for gates
599 
600  return allGates;
601 } // icarus::trigger::FillTriggerGates()
A wrapper to trigger gate objects tracking the input of operations.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
TriggerGate_t const & gate() const &
Returns the enclosed gate.
template<typename Gate >
decltype(auto) icarus::trigger::gateDataIn ( Gate &&  gate)

Returns the trigger data (a TriggerGateData) from the specofied gate.

template<typename Gate >
decltype(auto) icarus::trigger::gateIn ( Gate &&  gate)

Returns the trigger gate (a ReadoutTriggerGate) from the specified gate.

template<typename TrackingGateColl >
auto icarus::trigger::gatesIn ( TrackingGateColl &  trackingGates)

Returns a sequence of all the readout trigger gates contained in trackingGates.

Definition at line 312 of file TrackedTriggerGate.h.

312  {
313 
314  // C++20: this is definitely a template concept...
315 
316  // constantness is driven by the one of type `TrackedTriggerGate`;
317  // decltype(auto) return preserves referencehood
318  auto getGate = [](auto& gate) -> decltype(auto) { return gateIn(gate); };
319 
320 #if 0
321  // C++20: this is some
322  return trackingGates | std::ranges::view::transform(getGate);
323 #endif // 0
324 
325  return util::make_transformed_span(trackingGates, getGate);
326 
327 } // icarus::trigger::gatesIn()
static constexpr Sample_t transform(Sample_t sample)
auto make_transformed_span(BIter begin, EIter end, Op &&op)
Definition: span.h:294
decltype(auto) gateIn(Gate &&gate)
Returns the trigger gate (a ReadoutTriggerGate) from the specified gate.
ApplyBeamGateClass icarus::trigger::makeApplyBeamGate ( util::quantities::intervals::microseconds  duration,
util::quantities::intervals::microseconds  delay,
detinfo::DetectorClocksData const &  clockData,
std::string const &  logCategory = "ApplyBeamGateClass" 
)

Returns a new ApplyBeamGateClass object with the specified gate.

Parameters
durationthe desired duration of the gate
delaythe delay of gate start relative to the global beam gate time
clockDatathe current detector clocks service provider data
logCategorymessage category the returned object will use
Returns
a new ApplyBeamGateClass object with the specified parameters
ApplyBeamGateClass icarus::trigger::makeApplyBeamGate ( util::quantities::intervals::microseconds  duration,
detinfo::DetectorClocksData const &  clockData,
std::string const &  logCategory = "ApplyBeamGateClass" 
)

Returns a new ApplyBeamGateClass object with the specified gate.

Parameters
durationthe desired duration of the gate
clockDatathe current detector clocks service provider data
logCategorymessage category the returned object will use
Returns
a new ApplyBeamGateClass object with the specified parameters

The gate starts at the nominal beam gate time as reported by clockData.

Creates a BeamGateStruct object of specified duration and start.

Parameters
detTimingsobject used for time conversions
durationlength of the gate [s]
delay(default: 0_us) time the gate opens relative to beam gate opening [s]
Returns
a BeamGateStruct

This is for when I will regret to have coupled BeamGateStruct interface to detinfo::DetectorTimings.

Definition at line 181 of file BeamGateStruct.h.

186  {
187 
188  return { duration, delay, detTimings };
189 
190 } // icarus::trigger::makeBeamGateStruct()
fDetProps &fDetProps fDetProps &fDetProps detTimings
template<typename GateColl >
auto icarus::trigger::maxGates ( GateColl const &  gates)

Computes the gate with the maximum opening of gates from collection.

Template Parameters
GateColltype of collection of gates
Parameters
gatesthe collection of gates to sum
Returns
a new gate maximum of all the gates
See Also
maxGatesSequence()

For each tick, the maximum opening among all the gates in the collection is picked. The returned gate has the same type as the gates in the collection.

Definition at line 571 of file TriggerGateOperations.h.

572  { return maxGatesSequence(begin(gates), end(gates)); }
auto maxGatesSequence(BIter const begin, EIter const end)
Computes the gate with the maximum opening of a sequence of gates.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
template<typename AGate , typename BGate , typename... OTrigGates>
auto icarus::trigger::maxGates ( AGate  A,
BGate const &  B,
OTrigGates const &...  others 
)

Computes the gate with the maximum opening of the specified gates.

Template Parameters
AGatetype of the first gate; it determines the return type
BGatetype of the second gate
OGatestype of other gates
Parameters
Afirst gate
Bsecond gate
othersother gates
Returns
a new gate maximum of all the argument gates, of same type as A
See Also
maxGatesSequence()

For each tick, the maximum opening among all the specified gates is picked. The returned gate has the same type as the first gate.

Note
There must be at least two gates in the arguments.
template<typename BIter , typename EIter >
auto icarus::trigger::maxGatesSequence ( BIter const  begin,
EIter const  end 
)

Computes the gate with the maximum opening of a sequence of gates.

Template Parameters
BItertype of iterator to the gates to add
EItertype of iterator past-the-end of the sequence of gates to add
Parameters
beginiterator to the first gate to add
enditerator past-the-last gate to add
Returns
a new gate maximum of all the specified ones
See Also
maxGates()

For each tick, the maximum opening among all the gates in the sequence is picked. The returned gate has the same type as the first gate.

Definition at line 565 of file TriggerGateOperations.h.

566  { return OpGatesSequence(GateOps::Max, begin, end); }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
auto OpGatesSequence(Op op, BIter const begin, EIter const end)
Computes the result of an operation on all gates in the sequence.
template<typename GateColl >
auto icarus::trigger::minGates ( GateColl const &  gates)

Computes the gate with the minimum opening of gates from collection.

Template Parameters
GateColltype of collection of gates
Parameters
gatesthe collection of gates to sum
Returns
a new gate minimum of all the gates
See Also
minGatesSequence()

For each tick, the minimum opening among all the gates in the collection is picked. The returned gate has the same type as the gates in the collection.

Definition at line 591 of file TriggerGateOperations.h.

592  { return minGatesSequence(begin(gates), end(gates)); }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
auto minGatesSequence(BIter const begin, EIter const end)
Computes the gate with the minimum opening of a sequence of gates.
template<typename AGate , typename BGate , typename... OTrigGates>
auto icarus::trigger::minGates ( AGate  A,
BGate const &  B,
OTrigGates const &...  others 
)

Computes the gate with the minimum opening of the specified gates.

Template Parameters
AGatetype of the first gate; it determines the return type
BGatetype of the second gate
OGatestype of other gates
Parameters
Afirst gate
Bsecond gate
othersother gates
Returns
a new gate minimum of all the argument gates, of same type as A
See Also
minGatesSequence()

For each tick, the minimum opening among all the specified gates is picked. The returned gate has the same type as the first gate.

Note
There must be at least two gates in the arguments.
template<typename BIter , typename EIter >
auto icarus::trigger::minGatesSequence ( BIter const  begin,
EIter const  end 
)

Computes the gate with the minimum opening of a sequence of gates.

Template Parameters
BItertype of iterator to the gates to add
EItertype of iterator past-the-end of the sequence of gates to add
Parameters
beginiterator to the first gate to add
enditerator past-the-last gate to add
Returns
a new gate minimum of all the specified ones
See Also
minGates()

For each tick, the minimum opening among all the gates in the sequence is picked. The returned gate has the same type as the first gate.

Definition at line 585 of file TriggerGateOperations.h.

586  { return OpGatesSequence(GateOps::Min, begin, end); }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
auto OpGatesSequence(Op op, BIter const begin, EIter const end)
Computes the result of an operation on all gates in the sequence.
template<typename GateColl >
auto icarus::trigger::mulGates ( GateColl const &  gates)

Multiplies all the gates in a collection.

Template Parameters
GateColltype of collection of gates
Parameters
gatesthe collection of gates to multiply
Returns
a new gate product of all the gates
See Also
mulGatesSequence()

All gates from the first on are summed. The returned gate has the same type as the gates in the collection.

Definition at line 551 of file TriggerGateOperations.h.

552  { return mulGatesSequence(begin(gates), end(gates)); }
auto mulGatesSequence(BIter const begin, EIter const end)
Multiplies a sequence of gates.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
template<typename AGate , typename BGate , typename... OTrigGates>
auto icarus::trigger::mulGates ( AGate  A,
BGate const &  B,
OTrigGates const &...  others 
)

Multiplies all the specified gates.

Template Parameters
AGatetype of the first gate to sum; it determines the return type
BGatetype of the second gate to sum
OGatestype of other gates to sum
Parameters
Afirst gate to be multiplied
Bsecond gate to be multiplied
othersother gates to be multiplied
Returns
a new gate product of all the argument gates, of the same type as A
See Also
mulGatesSequence()

All arguments are combined in the product of the gates. The product of two gates is at each tick the product of the level of opening of the two gates at that tick. The returned gate has the same type as the first gate.

Note
There must be at least two gates in the arguments.
template<typename BIter , typename EIter >
auto icarus::trigger::mulGatesSequence ( BIter const  begin,
EIter const  end 
)

Multiplies a sequence of gates.

Template Parameters
BItertype of iterator to the gates to add
EItertype of iterator past-the-end of the sequence of gates to add
Parameters
beginiterator to the first gate to add
enditerator past-the-last gate to add
Returns
a new gate product of all the specified ones
See Also
mulGates()

All gates from the first on are multiplied. The returned gate has the same type as the first gate.

Definition at line 545 of file TriggerGateOperations.h.

546  { return OpGatesSequence(GateOps::Mul, begin, end); }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
auto OpGatesSequence(Op op, BIter const begin, EIter const end)
Computes the result of an operation on all gates in the sequence.
std::ostream & icarus::trigger::operator<< ( std::ostream &  out,
WindowChannelMap const &  wi 
)

Definition at line 53 of file WindowChannelMap.cxx.

54  { wi.dump(out); return out; }
std::ostream & icarus::trigger::operator<< ( std::ostream &  out,
OpticalTriggerGate const &  gate 
)

Definition at line 238 of file OpticalTriggerGate.cxx.

239 {
240  out << gate.gateLevels();
241  return out;
242 } // icarus::trigger::operator<< (icarus::trigger::OpticalTriggerGate)
template<typename Gate , typename TrackedType >
std::ostream & icarus::trigger::operator<< ( std::ostream &  out,
TrackedTriggerGate< Gate, TrackedType > const &  gate 
)

Definition at line 290 of file TrackedTriggerGate.h.

291  { return out << gateIn(gate); }
decltype(auto) gateIn(Gate &&gate)
Returns the trigger gate (a ReadoutTriggerGate) from the specified gate.
template<typename Tick , typename TickInterval , typename ChannelIDType >
std::ostream& icarus::trigger::operator<< ( std::ostream &  ,
ReadoutTriggerGate< Tick, TickInterval, ChannelIDType > const &   
)
std::ostream & icarus::trigger::operator<< ( std::ostream &  out,
icarus::trigger::ApplyBeamGateClass const &  gate 
)

Definition at line 184 of file ApplyBeamGate.h.

185 {
186  out << gate.gate() << " (simulation time: " << gate.asSimulationTime()
187  << ")";
188  return out;
189 } // icarus::trigger::operator<< (icarus::trigger::ApplyBeamGateClass const&)
template<typename TK , typename TI >
std::ostream& icarus::trigger::operator<< ( std::ostream &  ,
TriggerGateData< TK, TI > const &   
)
template<typename TK , typename TI >
std::ostream& icarus::trigger::operator<< ( std::ostream &  ,
typename TriggerGateData< TK, TI >::Status const &   
)
template<typename Time >
std::ostream& icarus::trigger::operator<< ( std::ostream &  out,
icarus::trigger::BeamGateStruct::TimeRange< Time > const &  range 
)

Definition at line 167 of file BeamGateStruct.h.

171  {
172  out << range.start() << " -- " << range.end()
173  << " (duration: " << range.duration() << ")";
174  return out;
175  } // operator<< (icarus::trigger::BeamGateStruct::TimeRange<>)
std::ostream & icarus::trigger::operator<< ( std::ostream &  out,
dumpRecipe const &  dr 
)

Definition at line 615 of file FixBeamGateInfo_module.cc.

616 {
617  using namespace util::quantities::time_literals;
618 
619  auto printChangeRecipe = [&out, &indent=dr.indent]
620  (std::string const& name, auto const& recipe)
621  {
622  if (!recipe || recipe->empty()) return;
623  out << "\n" << indent << "- " << name << ":";
624  if (recipe->setValue) out << " set to " << (*recipe->setValue);
625  if (recipe->addValue) {
626  if (*recipe->addValue < 0_ns) out << " remove " << (-*recipe->addValue);
627  else out << " add " << (*recipe->addValue);
628  } // if adding
629  }; // printChangeRecipe()
630 
631  // selection
632  if (dr.recipe.empty()) {
633  out << "(no action)";
634  }
635  else {
636  out << dr.firstIndent;
637  if (dr.recipe.selectGates.empty()) out << "(always)";
638  else {
639  out << "(only on gates of type:";
640  for (sim::BeamType_t const gate: dr.recipe.selectGates.beamTypes) {
641  // to query BeamTypeSelector we need its own strong index type as key...
642  out << " " << FixBeamGateInfo::Config::BeamTypeSelector
643  .get(static_cast<FixBeamGateInfo::Config::BeamType_t>(gate)).name();
644  }
645  out << ")";
646  }
647 
648  printChangeRecipe("start", dr.recipe.start);
649  printChangeRecipe("width", dr.recipe.width);
650  }
651 
652  return out;
653 } // icarus::trigger::operator<<(dumpRecipe)
then echo fcl name
BeamType_t
Defines category of beams to be stored in sim::BeamGateInfo.
Definition: BeamTypes.h:9
template<typename Op , typename GateColl >
auto icarus::trigger::OpGateColl ( Op  op,
GateColl const &  gates 
)

Computes the result of an operation on all gates from collection.

Template Parameters
Optype of binary operation AGate (Op)(AGate, BGate)
GateColltype of collection of gates
Parameters
opthe binary operation to apply (copied)
gatesthe collection of gates to sum
Returns
a new gate result of op on all the gates
See Also
OpGates(), OpGatesSequence()

This is the sequential application of op to all gates via OpGates(), according to their order in the collection. The returned gate has the same type as the gates in the collection.

Definition at line 491 of file TriggerGateOperations.h.

492  { return OpGatesSequence(std::move(op), begin(gates), end(gates)); }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
auto OpGatesSequence(Op op, BIter const begin, EIter const end)
Computes the result of an operation on all gates in the sequence.
template<typename Op , typename AGate , typename BGate , typename... OGates>
AGate icarus::trigger::OpGates ( Op  op,
AGate  A,
BGate const &  B,
OGates const &...  others 
)

Applies an operation to two gates.

Template Parameters
Optype of binary operation AGate (Op)(AGate, BGate)
AGatetype of the first gate; it determines the return type
BGatetype of the second gate
OGatestype of other gates
Parameters
opthe binary operation to apply (copied)
Afirst gate
Bsecond gate
othersother gates
Returns
a new gate of same type as A, result of the operation.
See Also
OpGatesSequence(), OpGateColl()

For each tick, the operation op is performed between A, B and the others, and the result is stored into the return value. The order of operation is the same as in the arguments: ((A op B) op others...). The returned gate has the same type as the first gate (A).

Standard operations are provided in namespace GateOps.

A specific action is performed if the gates are "tracking" (i.e. instances of TrackedTriggerGate), in which case tracking will also be propagated so that the result includes all the tracked objects of all the operands.

Note
There must be at least two gates in the arguments.

Definition at line 468 of file TriggerGateOperations.h.

469 {
470 
471  if constexpr(sizeof...(others) == 0U) { // two operands: end of recursion
472 
473  if constexpr(isTrackedTriggerGate_v<AGate>) {
474  if constexpr(isTrackedTriggerGate_v<BGate>) {
475  A.tracking().add(B.tracking());
476  }
477  A.gate() = op(std::move(A.gate()), gateIn(B));
478  return A;
479  } // if tracking
480  else return op(std::move(A), B);
481  }
482  else {
483  return OpGates(op, OpGates(op, std::move(A), B), others...);
484  }
485 
486 } // icarus::trigger::OpGates()
AGate OpGates(Op op, AGate A, BGate const &B, OGates const &...others)
Applies an operation to two gates.
float A
Definition: dedx.py:137
decltype(auto) gateIn(Gate &&gate)
Returns the trigger gate (a ReadoutTriggerGate) from the specified gate.
template<typename Op , typename BIter , typename EIter >
auto icarus::trigger::OpGatesSequence ( Op  op,
BIter const  begin,
EIter const  end 
)

Computes the result of an operation on all gates in the sequence.

Template Parameters
Optype of binary operation AGate (Op)(AGate, BGate)
BItertype of iterator to the gates to add
EItertype of iterator past-the-end of the sequence of gates to add
Parameters
opthe binary operation to apply (copied)
beginiterator to the first gate to add
enditerator past-the-last gate to add
Returns
a new gate result of op on all the gates
See Also
OpGates(), OpGateColl()

This is the sequential application of op to all gates from begin to end via OpGates(), following their order in the collection. The returned gate has the same type as the one pointed by the begin iterator (BIter::value_type for standard iterators).

Definition at line 497 of file TriggerGateOperations.h.

498 {
499 
500  using Gate_t = typename std::iterator_traits<BIter>::value_type;
501 
502  // if `gates` is empty return a default-constructed gate
503  if (begin == end) return Gate_t{};
504 
505  BIter iGate = begin;
506  Gate_t resGate = *iGate;
507  while (++iGate != end)
508  resGate = OpGates(std::move(op), std::move(resGate), *iGate);
509 
510  return resGate;
511 
512 } // icarus::trigger::OpGatesSequence()
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
AGate OpGates(Op op, AGate A, BGate const &B, OGates const &...others)
Applies an operation to two gates.
void icarus::trigger::printTriggerWindowChannels ( std::ostream &  out,
TriggerWindowChannels_t const &  window 
)

Prints the composition of the optical detector window inline.

Definition at line 26 of file SlidingWindowDefs.cxx.

27 {
28  /*
29  * Format:
30  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31  * std::cout << "Window ";
32  * printTriggerWindowChannels(std::cout, window);
33  * std::cout << " defined." << std::endl;
34  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35  * may yield:
36  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37  * Window 6 channels ( 1, 2, 3, 4, 5, 6 ) defined.
38  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39  */
40  out << window.size() << " channels";
41  if (!window.empty())
42  out << " (" << icarus::makeIntegerRanges(window) << ")";
43 
44 } // icarus::trigger::printTriggerWindowChannels()
IntegerRanges< typename Coll::value_type, CheckGrowing > makeIntegerRanges(Coll const &coll)
void icarus::trigger::printTriggerWindowDefs ( std::ostream &  out,
TriggerWindowDefs_t const &  windows 
)

Prints the composition of all windows in long format.

Definition at line 49 of file SlidingWindowDefs.cxx.

50 {
51  /*
52  * Format:
53  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54  * std::cout << "Blah blah blah >";
55  * printTriggerWindowDefs(std::cout, windows);
56  * std::cout << "And blah blah." << std::endl;
57  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58  * may yield:
59  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60  * Blah blah blah >3 windows:
61  * #0: 6 channels ( 1, 2, 3, 4, 5, 6 )
62  * #1: 6 channels ( 4, 5, 6, 7, 8, 9 )
63  * #2: 6 channels ( 7, 8, 9, 10, 11, 12 )
64  * And blah blah.
65  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66  */
67  out << windows.size() << " windows:";
68  for (auto const& [ iWindow, window ]: util::enumerate(windows)) {
69  out << "\n #" << iWindow << ": ";
70  printTriggerWindowChannels(out, window);
71  } // for
72 
73 } // icarus::trigger::printTriggerWindowDefs()
void printTriggerWindowChannels(std::ostream &out, TriggerWindowChannels_t const &window)
Prints the composition of the optical detector window inline.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
template<typename OpDetInfo = sbn::OpDetWaveformMeta, typename Event >
std::vector< icarus::trigger::TrackedOpticalTriggerGate< OpDetInfo > > icarus::trigger::ReadTriggerGates ( Event const &  event,
art::InputTag const &  dataTag 
)

Assembles and returns trigger gates from serialized data.

Template Parameters
OpDetInfotype of object associated to the gates
Eventtype of object to read the needed information from
Parameters
eventobject to read all the needed information from
dataTagtag of the data to read from the event
Returns
a collection of "tracking" trigger gates
Exceptions
cet::exceptionwrapping any cet::exception thrown internally (typically a data product not found)
See Also
icarus::trigger::TriggerGateReader, icarus::trigger::FillTriggerGates()

This function returns "tracking" trigger gates from data read from the data read from event. It is a one-shot replacement for TriggerGateReader to be used when data to be consumed needn't or can't be declared, or when that declaration is performed separately.

Definition at line 652 of file TriggerDataUtils.h.

653 {
654  return TriggerGateReader<OpDetInfo>{ dataTag }.read(event);
655 } // icarus::trigger::TriggerSimulationOnGates::ReadTriggerGates()
template<typename GateColl >
auto icarus::trigger::sumGates ( GateColl const &  gates)

Sums all the gates in a collection.

Template Parameters
GateColltype of collection of gates
Parameters
gatesthe collection of gates to sum
Returns
a new gate sum of all the gates
See Also
sumGatesSequence()

All gates from the first on are summed. The returned gate has the same type as the gates in the collection.

Definition at line 531 of file TriggerGateOperations.h.

532  { return sumGatesSequence(begin(gates), end(gates)); }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
auto sumGatesSequence(BIter const begin, EIter const end)
Sums a sequence of gates.
template<typename AGate , typename BGate , typename... OTrigGates>
auto icarus::trigger::sumGates ( AGate  A,
BGate const &  B,
OTrigGates const &...  others 
)

Sums all the specified gates.

Template Parameters
AGatetype of the first gate to sum; it determines the return type
BGatetype of the second gate to sum
OGatestype of other gates to sum
Parameters
Afirst gate to be summed
Bsecond gate to be summed
othersother gates to be summed
Returns
a new gate sum of all the argument gates, of the same type as A
See Also
sumGatesSequence()

All arguments are combined in the sum of the gates. The returned gate has the same type as the first gate.

Note
There must be at least two gates in the arguments.
template<typename BIter , typename EIter >
auto icarus::trigger::sumGatesSequence ( BIter const  begin,
EIter const  end 
)

Sums a sequence of gates.

Template Parameters
BItertype of iterator to the gates to add
EItertype of iterator past-the-end of the sequence of gates to add
Parameters
beginiterator to the first gate to add
enditerator past-the-last gate to add
Returns
a new gate sum of all the specified ones
See Also
sumGates()

All gates from the first on are summed. The returned gate has the same type as the first gate.

Definition at line 525 of file TriggerGateOperations.h.

526  { return OpGatesSequence(GateOps::Sum, begin, end); }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
auto OpGatesSequence(Op op, BIter const begin, EIter const end)
Computes the result of an operation on all gates in the sequence.
icarus::trigger::MultiChannelOpticalTriggerGate icarus::trigger::sumTriggerGates ( std::vector< SingleChannelOpticalTriggerGate > const &  gates)

Definition at line 26 of file MultiChannelOpticalTriggerGate.cxx.

27 {
29  for (auto const& gate: gates) {
30  sum.Sum(gate);
31  } // for
32  return sum;
33 } // icarus::trigger::sumTriggerGates()
OpticalTriggerGate & Sum(OpticalTriggerGate const &other)
Combines with a gate, keeping the sum of openings of the two.
Logical multi-level gate associated to one or more channels.
std::string icarus::trigger::to_string ( WindowPattern const &  pattern)
inline

Definition at line 115 of file WindowPattern.h.

116  { return pattern.tag(); }
template<typename Gates >
std::vector< icarus::trigger::OpticalTriggerGateData_t > icarus::trigger::transformIntoOpticalTriggerGate ( Gates &&  gates)

Returns the trigger gates in serializable format.

Template Parameters
Gatestype of the source of trigger gate data
Parameters
gatesthe data to be reformatted (data will be stolen!)
Returns
gate data product

This function transfers the data from the original structured gates into a data collection suitable for serialization with art, but not including the association of each gate with all its contributing waveforms. It must be stressed that this causes information loss, because the trigger gates will not be associated any more to the contributing waveforms.

The return value is a collection of trigger gate data (icarus::trigger::OpticalTriggerGateData_t), with data stolen from gates.

The trigger gates are processed in the same order as they are in gates.

After the function returns, gates will have been depleted of all the gate data; any tracking information will be still associated to each gate, whose gate data will be in an invalid state anyway, only good for destruction.

The object gates is a iterable collection of gate objects: types derived from icarus::trigger::ReadoutTriggerGate and from TrackedOpticalTriggerGate are supported.

In the following example, we start with trigger gates already serialized in a art event. The serialization splits a trigger gate object in two components: the gate levels, and the associated waveforms. In the first part of the example we recover the information from the event and we assemble it into the standard trigger gate objects (of type icarus::trigger::TrackedOpticalTriggerGate<sbn::OpDetWaveformMeta>). After some unspecified and optional processing, gates are disassembled to be saved into the event: this is achieved by a call to transformIntoOpticalTriggerGate() which produces the trigger gate data and their associations to the waveforms. In the last part, these components are both stored into the event.

//
// somehow get/build a collection of trigger gates;
// here we use `FillTriggerGates()` to read existing data from the event
//
std::vector<icarus::trigger::TrackedOpticalTriggerGate<>> gates
// ...
//
// use the created vector and associations (e.g. put them into art event)
//
event.put(std::make_unique<std::vector<icarus::trigger::OpticalTriggerGateData_t>>

Also note that in the omitted processing part the trigger gates might have been combined into a different type of gates instead. To serialize that collection, the exact same procedure would be used. Note that in this example the association to the source waveform metadata is not serialised (and presumably lost). Another version of transformIntoOpticalTriggerGate() also provides support for the association to waveform sources.

Definition at line 495 of file TriggerDataUtils.h.

495  {
496 
497  using TriggerGateData_t = icarus::trigger::OpticalTriggerGateData_t;
498 
499  std::vector<TriggerGateData_t> gateData;
500 
501  for (TriggerGateData_t& gate: icarus::trigger::gatesIn(gates))
502  gateData.push_back(std::move(gate));
503 
504  return gateData;
505 
506 } // icarus::trigger::transformIntoOpticalTriggerGate(Gates)
auto gatesIn(TrackingGateColl &trackingGates)
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
template<typename OpDetInfo = sbn::OpDetWaveformMeta>
std::tuple< std::vector< icarus::trigger::OpticalTriggerGateData_t >, art::Assns< icarus::trigger::OpticalTriggerGateData_t, OpDetInfo > > icarus::trigger::transformIntoOpticalTriggerGate ( std::vector< icarus::trigger::TrackedOpticalTriggerGate< OpDetInfo >> &&  gates,
art::PtrMaker< icarus::trigger::OpticalTriggerGateData_t > const &  makeGatePtr,
util::DataProductPointerMap_t< OpDetInfo > const &  opDetInfoPtrs 
)

Returns the trigger gates in serializable format.

Template Parameters
OpDetInfotype of the associated waveforms
Parameters
gatesthe data to be reformatted (data will be stolen!)
makeGatePtrart pointer maker for the gate data
opDetInfoPtrsmap of art pointers to optical waveform information
Returns
a pair: gate data product and associations to OpDetInfo

This function transfers the data from the original structured gates into a data collection suitable for serialization with art, including the association of each gate with all its contributing waveforms.

The return value is a tuple of two elements:

  • 0: collection of trigger gate data (icarus::trigger::OpticalTriggerGateData_t), with data stolen from gates;
  • 1: association between trigger gate data and their optical waveform information, as reported by opDetInfoPtrs.

The trigger gates are processed in the same order as they are in gates, and the associations to the waveform information are set gate by gate, in the same order as they are reported by the tracking information of the input gate.

After the function returns, gates will have been depleted of all the data and left in an unspecified state only good for destruction.

The object gates is a sequence of icarus::trigger::TrackedOpticalTriggerGate objects, each of them containing a trigger gate object (icarus::trigger::OpticalTriggerGateData_t) and a list of tracked sources in the form of OpDetInfo objects.

In the following example, we start with trigger gates already serialized in a art event. The serialization splits a trigger gate object in two components: the gate levels, and the associated waveform information. In the first part of the example we recover the information from the event and we assemble it into the standard trigger gate objects (of type icarus::trigger::OpticalTriggerGateData_t). After some unspecified and optional processing, gates are disassembled to be saved into the event: this is achieved by a call to transformIntoOpticalTriggerGate() which produces the trigger gate data and their associations to the waveform information. In the last part, these components are both stored into the event.

//
// somehow get/build a collection of trigger gates;
// here we use `FillTriggerGates()` to read existing data from the event
//
std::vector<icarus::trigger::TrackedOpticalTriggerGate<sbn::OpDetWaveformMeta>> gates
= icarus::trigger::FillTriggerGates<sbn::OpDetWaveformMeta>
(
event.getProduct<std::vector<OpticalTriggerGateData_t>>("orig"),
event.getProduct<art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>("orig")
);
// ...
//
// optical waveform information to pointer map is required to create
// associations between the trigger gates and their waveforms
//
auto const& opDetInfoPtrs = util::mapDataProductPointers
(event, event.getValidHandle<std::vector<raw::OpDetWaveformMeta>>("opdaq"));
// transform the data; after this line, `gates` is not usable any more
(std::move(gates), makeGatePtr, opDetInfoPtrs);
//
// use the created vector and associations (e.g. put them into art event)
//
event.put(
std::make_unique<std::vector<OpticalTriggerGateData_t>>
(std::move(std::get<0U>(thresholdData)))
);
event.put(
std::make_unique<art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformInfo>>
(std::move(std::get<1U>(thresholdData)))
);

In this example the most convenient waveform information is used, sbn::OpDetWaveformMeta; the same syntax would hold for using the more traditional, but encumbering, raw::OpDetWaveform.

Definition at line 515 of file TriggerDataUtils.h.

519  {
520  using TriggerGateData_t = icarus::trigger::OpticalTriggerGateData_t;
521 
522  // note that we rely on the fact that `gates` still contains trigger gates,
523  // and those trigger gates still know about the associated waveforms;
524  // attempting to access their levels, though, would be an error
525  // (if really needed, we can still find them in `gateData`)
526  art::Assns<TriggerGateData_t, OpDetInfo> gateToWaveforms;
527 
528  for (auto const& [ iGate, gate ]: util::enumerate(gates)) {
529 
530  if (!gate.tracking().hasTracked()) continue;
531 
532  //
533  // produce the associations
534  //
535 
536  // pointer to the gate data we have just added:
537  art::Ptr<TriggerGateData_t> const& gatePtr = makeGatePtr(iGate);
538  for (OpDetInfo const* waveform: gate.tracking().getTracked()) {
539 
540  gateToWaveforms.addSingle(gatePtr, opDetInfoPtrs.at(waveform));
541 
542  } // for all waveform info
543 
544  } // for all gates
545 
546  //
547  // create objects for the data products
548  //
549  std::vector<TriggerGateData_t> gateData
551 
552  return { std::move(gateData), std::move(gateToWaveforms) };
553 
554 } // icarus::trigger::transformIntoOpticalTriggerGate()
auto gatesIn(TrackingGateColl &trackingGates)
std::vector< icarus::trigger::OpticalTriggerGateData_t > transformIntoOpticalTriggerGate(Gates &&gates)
Returns the trigger gates in serializable format.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.

Variable Documentation

template<typename Gate >
constexpr bool icarus::trigger::isReadoutTriggerGate_v = isReadoutTriggerGate<Gate>::value

Flag: true if Gate type derives from a ReadoutTriggerGate instance.

Definition at line 78 of file ReadoutTriggerGate.h.

template<typename T >
constexpr bool icarus::trigger::isTrackedTriggerGate_v = isTrackedTriggerGate<T>::value

Whether T is some form of TrackedTriggerGate`.

Definition at line 37 of file TrackedTriggerGate.h.

constexpr std::size_t icarus::trigger::kBNB = sbn::bits::value<triggerSource>(triggerSource::BNB)
static

Definition at line 367 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kCalibration = sbn::bits::value<triggerSource>(triggerSource::Calib)
static

Definition at line 371 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kEast = sbn::bits::value<triggerLocation>(triggerLocation::CryoEast)
static

Definition at line 363 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kNTriggerLocation = sbn::bits::value<triggerLocation>(triggerLocation::NBits)
static

Definition at line 365 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kNTriggerSource = sbn::bits::value<triggerSource>(triggerSource::NBits)
static

Definition at line 372 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kNuMI = sbn::bits::value<triggerSource>(triggerSource::NuMI)
static

Definition at line 368 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kOffBeamBNB = sbn::bits::value<triggerSource>(triggerSource::OffbeamBNB)
static

Definition at line 369 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kOffBeamNuMI = sbn::bits::value<triggerSource>(triggerSource::OffbeamNuMI)
static

Definition at line 370 of file BeamBits.h.

constexpr std::size_t icarus::trigger::kWest = sbn::bits::value<triggerLocation>(triggerLocation::CryoWest)
static

Definition at line 364 of file BeamBits.h.