All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
icarus::trigger::SlidingWindowTrigger Class Reference

Combines trigger channels (V1730 LVDS gates) into sliding windows. More...

Inheritance diagram for icarus::trigger::SlidingWindowTrigger:

Classes

struct  Config
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 

Public Member Functions

 SlidingWindowTrigger (Parameters const &config)
 
 SlidingWindowTrigger (SlidingWindowTrigger const &)=delete
 
 SlidingWindowTrigger (SlidingWindowTrigger &&)=delete
 
SlidingWindowTriggeroperator= (SlidingWindowTrigger const &)=delete
 
SlidingWindowTriggeroperator= (SlidingWindowTrigger &&)=delete
 
virtual void produce (art::Event &event) override
 Fills the plots. Also extracts the information to fill them with. More...
 

Private Types

using WindowDefs_t = icarus::trigger::TriggerWindowDefs_t
 Definition of all windows. More...
 
using TriggerGateData_t = icarus::trigger::OpticalTriggerGate::GateData_t
 
using TrackedTriggerGate_t = icarus::trigger::TrackedOpticalTriggerGate< sbn::OpDetWaveformMeta >
 Reconstituted trigger gate type internally used. More...
 

Private Member Functions

unsigned int nDisabledWindows () const noexcept
 Returns the number of disabled windows. More...
 
void produceThreshold (art::Event &event, icarus::trigger::OpDetWaveformMetaDataProductMap_t &waveformMap, std::string const &threshold, art::InputTag const &dataTag) const
 Performs the combination for data with a specified threshold. More...
 
std::vector
< icarus::trigger::TrackedOpticalTriggerGate
< sbn::OpDetWaveformMeta > > 
ReadTriggerGates (art::Event const &event, art::InputTag const &dataTag, icarus::trigger::OpDetWaveformMetaDataProductMap_t &waveformMap) const
 Reads a set of input gates from the event and updates waveformMap. More...
 
WindowDefs_t defineWindows () const
 Defines the channels falling in each window. More...
 

Static Private Member Functions

static std::vector< std::size_t > makeEnabledWindowIndices (std::size_t nWindows, fhicl::OptionalSequence< std::size_t > const &enabled, fhicl::OptionalSequence< std::size_t > const &disabled)
 Returns a list of enabled window indices. More...
 
static void UpdateWaveformMap (icarus::trigger::OpDetWaveformMetaDataProductMap_t &map, art::Assns< TriggerGateData_t, sbn::OpDetWaveformMeta > const &assns)
 Adds the waveforms in the specified association to the waveform map. More...
 

Private Attributes

std::map< std::string,
art::InputTag > 
fADCthresholds
 ADC thresholds to read, and the input tag connected to their data. More...
 
unsigned int const fWindowSize
 Sliding window size in number of channels. More...
 
unsigned int const fWindowStride
 Sliding window base offset. More...
 
WindowDefs_t const fWindowChannels
 Channel content of each window. More...
 
std::vector< std::size_t > const fEnabledWindows
 List of windows to be included. More...
 
bool fProduceWaveformAssns
 Whether to produce gate/waveform associations. More...
 
std::string const fLogCategory
 Message facility stream category for output. More...
 
icarus::trigger::SlidingWindowCombinerAlg
const 
fCombiner
 Combining algorithm. More...
 

Detailed Description

Combines trigger channels (V1730 LVDS gates) into sliding windows.

This module combines the input discriminated waveforms into a set of new multi-level discriminated gates according to the geometric criterion of a sliding window.

The combination is a sum of all the discriminated waveforms within the window. Different optical detector planes are treated independently and separately. It is expected that the input is from V1730 LVDS gates (see icarus::trigger::LVDSgates module) which combine (usually) two optical detector channels each.

Sliding window configuration

The size of the window is specified in terms on number of optical detector channels per window and of stride. The windows are allowed to overlap, but they have all the same number of channels. If the parameters yield an invalid configuration, the module will throw an exception.

The definition of a valid window configuration is quite restrictive. Optical detector channels are grouped by the TPC width coordinate (z) into "towers". In ICARUS, a tower is made of either two or three channels, depending on the position in z. A window can't split a tower, but rather has to include whole towers. In addition, the input discriminated waveforms may include information from multiple channels (that is the common case if the input is LVDS gates). A window can't cover only part of the channels of any input, but rather must extend wide enough so that all the channels in the included gates are covered. Channels may be exempted by marking them as "missing". Finally, all the channels which are not "missing" must be covered by at least one window.

For the sliding window configuration to be valid, all the windows starting with an offset multiple of the stride must be valid.

For the standard pairing of LVDS gates in ICARUS, this translates into the only allowed window sizes are by 10 and 15 channels or their multiples, with a stride also in multiples of 10 or 15 respectively. For example, the following configurations are all valid:

Input data products

Requirements

The algorithms require that in each set all optical channels are covered.

Output data products

If window selection is requested (with EnableOnlyWindows or DisableWindows configuration parameters), only the selected windows will have an output entry. While each trigger data object comes with all the channels it covers, there is no explicit information of the index of the surviving windows.

Note
At the moment, associations between input and output gates is not produced. art::Assns would not support it, requiring distinct types for the associated objects.

Configuration parameters

A terse description of the parameters is printed by running lar --print-description SlidingWindowTrigger.

Note: when using EnableOnlyWindows or DisableWindows it may be useful to check the output of the module (at construction) to verify that the selected indices match the intended windows.

Definition at line 213 of file SlidingWindowTrigger_module.cc.

Member Typedef Documentation

Definition at line 280 of file SlidingWindowTrigger_module.cc.

Reconstituted trigger gate type internally used.

Definition at line 313 of file SlidingWindowTrigger_module.cc.

Definition at line 309 of file SlidingWindowTrigger_module.cc.

Definition of all windows.

Definition at line 307 of file SlidingWindowTrigger_module.cc.

Constructor & Destructor Documentation

icarus::trigger::SlidingWindowTrigger::SlidingWindowTrigger ( Parameters const &  config)
explicit

Definition at line 403 of file SlidingWindowTrigger_module.cc.

404  : art::EDProducer(config)
405  // configuration
406  , fWindowSize(config().WindowSize())
407  , fWindowStride
408  (util::fhicl::getOptionalValue(config().Stride).value_or(fWindowSize))
411  fWindowChannels.size(),
412  config().EnableOnlyWindows, config().DisableWindows
413  ))
414  , fProduceWaveformAssns(config().ProduceWaveformAssns())
415  , fLogCategory(config().LogCategory())
416  // demand full PMT coverage only if no window was disabled:
417  , fCombiner(
419  config().MissingChannels(),
420  nDisabledWindows() == 0U
421  )
422 {
423  //
424  // more complex parameter parsing
425  //
426  std::string const discrModuleLabel = config().TriggerGatesTag();
427  for (std::string const& threshold: config().Thresholds())
428  fADCthresholds[threshold] = art::InputTag{ discrModuleLabel, threshold };
429 
430  //
431  // configuration report (short)
432  //
433  {
434  mf::LogInfo log(fLogCategory);
435  log << "Trigger configuration: " << fWindowChannels.size() << " windows";
436  if (fEnabledWindows.size() < fWindowChannels.size())
437  log << " (only " << fEnabledWindows.size() << " enabled)";
438  log << ":";
439  for (auto const& [ iWindow, window ]: util::enumerate(fWindowChannels)) {
440  log << "\n #" << iWindow << ": "
442  if (std::find(fEnabledWindows.begin(), fEnabledWindows.end(), iWindow)
443  == fEnabledWindows.end())
444  {
445  log << " (disabled)";
446  }
447  } // for
448 
449  log << "\nConfigured " << fADCthresholds.size() << " thresholds (ADC):";
450  for (auto const& [ threshold, dataTag ]: fADCthresholds)
451  log << "\n * " << threshold << " (from '" << dataTag.encode() << "')";
452  } // local block
453 
454 
455  using icarus::trigger::OpticalTriggerGateData_t; // for convenience
456 
457  //
458  // input data declaration
459  //
460  for (art::InputTag const& inputDataTag: util::const_values(fADCthresholds)) {
461  consumes<std::vector<OpticalTriggerGateData_t>>(inputDataTag);
462  consumes<art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>
463  (inputDataTag);
464  } // for
465 
466 
467  //
468  // output data declaration
469  //
470  for (art::InputTag const& inputDataTag: util::const_values(fADCthresholds)) {
471  produces<std::vector<OpticalTriggerGateData_t>>(inputDataTag.instance());
472  produces<art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>
473  (inputDataTag.instance());
474  if (fProduceWaveformAssns) {
475  produces<art::Assns<OpticalTriggerGateData_t, raw::OpDetWaveform>>
476  (inputDataTag.instance());
477  }
478  } // for
479 
480 
481 } // icarus::trigger::SlidingWindowTrigger::SlidingWindowTrigger()
BEGIN_PROLOG BeamGateDuration pmtthr physics producers trigtilewindowORS Thresholds
std::vector< std::size_t > const fEnabledWindows
List of windows to be included.
WindowDefs_t const fWindowChannels
Channel content of each window.
std::optional< typename Optional::value_type > getOptionalValue(Optional const &parameter)
Returns the value of an optional parameter as std::optional.
Definition: FHiCLutils.h:188
bool fProduceWaveformAssns
Whether to produce gate/waveform associations.
decltype(auto) const_values(Coll &&coll)
Range-for loop helper iterating across the constant values of the specified collection.
std::map< std::string, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
unsigned int nDisabledWindows() const noexcept
Returns the number of disabled windows.
unsigned int const fWindowStride
Sliding window base offset.
auto dumpTriggerWindowChannels(TriggerWindowChannels_t const &window) -> details::DumpTriggerWindowChannelWrapper
unsigned int const fWindowSize
Sliding window size in number of channels.
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
std::string const fLogCategory
Message facility stream category for output.
BEGIN_PROLOG triggeremu_data_config_icarus settings sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds WindowSize
physics filters filter
size_t Stride(bool allow_default)
icarus::trigger::SlidingWindowCombinerAlg const fCombiner
Combining algorithm.
static std::vector< std::size_t > makeEnabledWindowIndices(std::size_t nWindows, fhicl::OptionalSequence< std::size_t > const &enabled, fhicl::OptionalSequence< std::size_t > const &disabled)
Returns a list of enabled window indices.
WindowDefs_t defineWindows() const
Defines the channels falling in each window.
icarus::trigger::SlidingWindowTrigger::SlidingWindowTrigger ( SlidingWindowTrigger const &  )
delete
icarus::trigger::SlidingWindowTrigger::SlidingWindowTrigger ( SlidingWindowTrigger &&  )
delete

Member Function Documentation

auto icarus::trigger::SlidingWindowTrigger::defineWindows ( ) const
private

Defines the channels falling in each window.

Definition at line 499 of file SlidingWindowTrigger_module.cc.

501 {
502  // delegated to `SlidingWindowDefinitionAlg`
503 
505  *(lar::providerFrom<geo::Geometry>()),
506  "SlidingWindowTrigger/SlidingWindowDefinitionAlg"
507  };
508 
509  return algo.makeWindows(fWindowSize, fWindowStride);
510 
511 } // icarus::trigger::SlidingWindowTrigger::defineWindows()
unsigned int const fWindowStride
Sliding window base offset.
unsigned int const fWindowSize
Sliding window size in number of channels.
Groups optical detector channels into windows based on position.
WindowDefs_t makeWindows(unsigned int windowSize, unsigned int windowStride) const
Performs the calculation and returns the sliding window composition.
auto icarus::trigger::SlidingWindowTrigger::makeEnabledWindowIndices ( std::size_t  nWindows,
fhicl::OptionalSequence< std::size_t > const &  enabled,
fhicl::OptionalSequence< std::size_t > const &  disabled 
)
staticprivate

Returns a list of enabled window indices.

Definition at line 588 of file SlidingWindowTrigger_module.cc.

592  {
593 
594  std::vector<std::size_t> selection; // indices of the enabled windows
595 
596  // add all enabled windows (or all if no enabled list is specified)
597  if (!enabled(selection)) {
598  selection.resize(nWindows);
599  std::iota(selection.begin(), selection.end(), 0U);
600  }
601 
602  // remove all disabled windows (if any)
603  std::vector<std::size_t> removeWindows;
604  disabled(removeWindows);
605  auto const find = [&selection](std::size_t index)
606  { return std::find(selection.begin(), selection.end(), index); };
607  for (std::size_t const index: removeWindows) {
608  if (auto const it = find(index); it != selection.end()) selection.erase(it);
609  } // for
610 
611  return selection;
612 } // icarus::trigger::SlidingWindowTrigger::makeEnabledWindowIndices()
unsigned int icarus::trigger::SlidingWindowTrigger::nDisabledWindows ( ) const
inlineprivatenoexcept

Returns the number of disabled windows.

Definition at line 342 of file SlidingWindowTrigger_module.cc.

343  { return fWindowChannels.size() - fEnabledWindows.size(); }
std::vector< std::size_t > const fEnabledWindows
List of windows to be included.
WindowDefs_t const fWindowChannels
Channel content of each window.
SlidingWindowTrigger& icarus::trigger::SlidingWindowTrigger::operator= ( SlidingWindowTrigger const &  )
delete
SlidingWindowTrigger& icarus::trigger::SlidingWindowTrigger::operator= ( SlidingWindowTrigger &&  )
delete
void icarus::trigger::SlidingWindowTrigger::produce ( art::Event &  event)
overridevirtual

Fills the plots. Also extracts the information to fill them with.

Definition at line 485 of file SlidingWindowTrigger_module.cc.

485  {
486 
488 
489  for (auto const& [ thresholdStr, dataTag ]: fADCthresholds) {
490 
491  produceThreshold(event, waveformMap, thresholdStr, dataTag);
492 
493  } // for all thresholds
494 
495 } // icarus::trigger::SlidingWindowTrigger::produce()
std::map< std::string, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
void produceThreshold(art::Event &event, icarus::trigger::OpDetWaveformMetaDataProductMap_t &waveformMap, std::string const &threshold, art::InputTag const &dataTag) const
Performs the combination for data with a specified threshold.
util::DataProductPointerMap_t< sbn::OpDetWaveformMeta > OpDetWaveformMetaDataProductMap_t
Map util::DataProductPointerMap_t for sbn::OpDetWaveformMeta objects.
void icarus::trigger::SlidingWindowTrigger::produceThreshold ( art::Event &  event,
icarus::trigger::OpDetWaveformMetaDataProductMap_t waveformMap,
std::string const &  threshold,
art::InputTag const &  dataTag 
) const
private

Performs the combination for data with a specified threshold.

Definition at line 515 of file SlidingWindowTrigger_module.cc.

520  {
521 
522  mf::LogDebug(fLogCategory)
523  << "Processing threshold " << threshold
524  << " from '" << dataTag.encode() << "'"
525  ;
526 
527  using icarus::trigger::OpticalTriggerGateData_t; // for convenience
530 
531  std::vector<TrackedTriggerGate_t> const& gates
532  = ReadTriggerGates(event, dataTag, waveformMap);
533 
534  std::vector<TrackedTriggerGate_t> combinedGates = fCombiner.combine(gates);
535 
536  // transform the data; after this line, `gates` is not usable any more
537  art::PtrMaker<OpticalTriggerGateData_t> const makeGatePtr
538  (event, dataTag.instance());
539  auto [ outputGates, outputAssns ]
541  (std::move(combinedGates), makeGatePtr, waveformMap);
542 
543  {
544  mf::LogTrace log { fLogCategory };
545  log
546  << "Threshold " << threshold << " ('" << dataTag.encode() << "'): "
547  << gates.size() << " input channels, "
548  << outputGates.size() << " output channels (+"
549  << outputAssns.size() << " associations to waveforms) into '"
550  << moduleDescription().moduleLabel() << ":" << dataTag.instance() << "'"
551  ;
552  for (auto const& [ iGate, gate ]: util::enumerate(outputGates)) {
553  log << "\n [#" << iGate << "] " << compactdump(gate);
554  } // for
555  } // local scope
556 
557  if (fProduceWaveformAssns) {
558 
559  // produce one gate-waveform association for each gate-metadata one;
560  // do it now while the gate/metadata association is still locally available
561  icarus::trigger::OpDetWaveformMetaMatcher waveformMetaMatcher{ event };
562  art::Assns<OpticalTriggerGateData_t, raw::OpDetWaveform> outputWaveAssns;
563  for (auto const [ gatePtr, metaPtr ]: outputAssns)
564  outputWaveAssns.addSingle(gatePtr, waveformMetaMatcher(metaPtr));
565 
566  event.put(
567  std::make_unique<art::Assns<OpticalTriggerGateData_t, raw::OpDetWaveform>>
568  (std::move(outputWaveAssns)),
569  dataTag.instance()
570  );
571  } // if fProduceWaveformAssns
572 
573  event.put(
574  std::make_unique<std::vector<OpticalTriggerGateData_t>>
575  (std::move(outputGates)),
576  dataTag.instance()
577  );
578  event.put(
579  std::make_unique<art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>
580  (std::move(outputAssns)),
581  dataTag.instance()
582  );
583 
584 } // icarus::trigger::SlidingWindowTrigger::produceThreshold()
icarus::trigger::TrackedOpticalTriggerGate< sbn::OpDetWaveformMeta > TrackedTriggerGate_t
Reconstituted trigger gate type internally used.
bool fProduceWaveformAssns
Whether to produce gate/waveform associations.
A wrapper to trigger gate objects tracking the input of operations.
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
Object to facilitate the discovery of the raw::OpDetWaveform a sbn::OpDetWaveformMeta objects comes f...
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
std::string const fLogCategory
Message facility stream category for output.
std::vector< icarus::trigger::TrackedOpticalTriggerGate< sbn::OpDetWaveformMeta > > ReadTriggerGates(art::Event const &event, art::InputTag const &dataTag, icarus::trigger::OpDetWaveformMetaDataProductMap_t &waveformMap) const
Reads a set of input gates from the event and updates waveformMap.
std::vector< TrackedTriggerGate_t > combine(std::vector< TrackedTriggerGate_t > const &gates) const
Combines the gates according to the configured grouping.
icarus::trigger::SlidingWindowCombinerAlg const fCombiner
Combining algorithm.
auto compactdump(ReadoutTriggerGate< Tick, TickInterval, ChannelIDType > const &gate) -> details::CompactFormatter< ReadoutTriggerGate< Tick, TickInterval, ChannelIDType >>
Manipulator-like function for compact format of trigger gates.
auto icarus::trigger::SlidingWindowTrigger::ReadTriggerGates ( art::Event const &  event,
art::InputTag const &  dataTag,
icarus::trigger::OpDetWaveformMetaDataProductMap_t waveformMap 
) const
private

Reads a set of input gates from the event and updates waveformMap.

Definition at line 628 of file SlidingWindowTrigger_module.cc.

632  {
634 
635  auto const& assns =
636  event.getProduct<art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>
637  (dataTag);
638 
639  UpdateWaveformMap(waveformMap, assns);
640 
642  (event.getProduct<std::vector<OpticalTriggerGateData_t>>(dataTag), assns);
643 
644 } // icarus::trigger::SlidingWindowTrigger::ReadTriggerGates()
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
static void UpdateWaveformMap(icarus::trigger::OpDetWaveformMetaDataProductMap_t &map, art::Assns< TriggerGateData_t, sbn::OpDetWaveformMeta > const &assns)
Adds the waveforms in the specified association to the waveform map.
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.
void icarus::trigger::SlidingWindowTrigger::UpdateWaveformMap ( icarus::trigger::OpDetWaveformMetaDataProductMap_t map,
art::Assns< TriggerGateData_t, sbn::OpDetWaveformMeta > const &  assns 
)
staticprivate

Adds the waveforms in the specified association to the waveform map.

Definition at line 616 of file SlidingWindowTrigger_module.cc.

619  {
620 
621  for (art::Ptr<sbn::OpDetWaveformMeta> const& wave: util::get_elements<1U>(assns))
622  map.emplace(wave.get(), wave);
623 
624 } // icarus::trigger::SlidingWindowTrigger::UpdateWaveformMap()

Member Data Documentation

std::map<std::string, art::InputTag> icarus::trigger::SlidingWindowTrigger::fADCthresholds
private

ADC thresholds to read, and the input tag connected to their data.

Definition at line 318 of file SlidingWindowTrigger_module.cc.

icarus::trigger::SlidingWindowCombinerAlg const icarus::trigger::SlidingWindowTrigger::fCombiner
private

Combining algorithm.

Definition at line 338 of file SlidingWindowTrigger_module.cc.

std::vector<std::size_t> const icarus::trigger::SlidingWindowTrigger::fEnabledWindows
private

List of windows to be included.

Definition at line 327 of file SlidingWindowTrigger_module.cc.

std::string const icarus::trigger::SlidingWindowTrigger::fLogCategory
private

Message facility stream category for output.

Definition at line 333 of file SlidingWindowTrigger_module.cc.

bool icarus::trigger::SlidingWindowTrigger::fProduceWaveformAssns
private

Whether to produce gate/waveform associations.

Definition at line 330 of file SlidingWindowTrigger_module.cc.

WindowDefs_t const icarus::trigger::SlidingWindowTrigger::fWindowChannels
private

Channel content of each window.

Definition at line 324 of file SlidingWindowTrigger_module.cc.

unsigned int const icarus::trigger::SlidingWindowTrigger::fWindowSize
private

Sliding window size in number of channels.

Definition at line 320 of file SlidingWindowTrigger_module.cc.

unsigned int const icarus::trigger::SlidingWindowTrigger::fWindowStride
private

Sliding window base offset.

Definition at line 321 of file SlidingWindowTrigger_module.cc.


The documentation for this class was generated from the following file: