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

Assembles and returns trigger gates from serialized data. More...

#include <TriggerDataUtils.h>

Public Types

using OpDetWaveformMeta_t = OpDetInfo
 Type of associated information. More...
 
using TriggerGates_t = icarus::trigger::TrackedOpticalTriggerGate< OpDetWaveformMeta_t >
 Type of data objects returned. More...
 

Public Member Functions

 TriggerGateReader (art::InputTag dataTag)
 Constructor: configure to read the data with the specified tag. More...
 
template<typename ConsumesCollector >
void declareConsumes (ConsumesCollector &collector) const
 Declares to the collector the data products that are going to be read. More...
 
art::InputTag const & inputTag () const
 Returns the input tag the data is read from. More...
 
template<typename Event >
std::vector
< icarus::trigger::TrackedOpticalTriggerGate
< OpDetInfo > > 
read (Event const &event) const
 
template<typename Event >
std::vector< TriggerGates_tread (Event const &event) const
 Reads the configured data product from the specified event. More...
 
template<typename Event >
std::vector< TriggerGates_toperator() (Event const &event) const
 

Private Attributes

art::InputTag fDataTag
 Data tag of the data products being read. More...
 

Detailed Description

template<typename OpDetInfo = sbn::OpDetWaveformMeta>
class icarus::trigger::TriggerGateReader< OpDetInfo >

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::FillTriggerGates()

This class manages reading from a data source trigger gates (vector of icarus::trigger::OpticalTriggerGateData_t elements) and their associations to a tracking information (OpDetInfo: sbn::OpDetWaveformMeta by default, but it may also be e.g. raw::OpDetWaveform).

All this information is merged into the "tracking" trigger gates, which wrap _ a copy_ of the trigger gates and a reference to the tracked information (by simple C pointer).

This class is a framework interface to FillTriggerGates(); interaction with the data source and the framework is driven by the Event object in the read() method, which is expected to expose an interface similar to _art_'sart::Event<tt>, and in particular: *Event::getProduct<T>(art::InputTag)to read and return directly a reference to the persistent, framework-owned data products of typeT`.

In addition, this class provides a shortcut to declare the consumed data products, again in a art-like interface. A full usage example in a module includes:

  1. a reader data member in the module class reading the data:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} icarus::trigger::TriggerGateReader<> const fGateReader; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  2. construction in the module constructor initializer list from a configured input tag representing the data to be read:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} , fGateReader{ config().TriggerGateTag() } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  3. also in the module constructor body, declaration of what is going to be read: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} fGateReader.declareConsumes(consumesCollector()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. actual reading in a context where the current event is known: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} std::vector<icarus::trigger::TrackedOpticalTriggerGate<sbn::OpDetWaveformMeta>> gates = fGateReader(event); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In a context where the consume declaration is not relevant/desired, the first three steps can be omitted and the reading can happen with a temporary TriggerGateReader object; or the shortcut function icarus::trigger::ReadTriggerGates() can be used instead:

std::vector<icarus::trigger::TrackedOpticalTriggerGate<sbn::OpDetWaveformMeta>>
gates = icarus::trigger::ReadTriggerGates<sbn::OpDetWaveformMeta>(event, dataTag);

is equivalent to the last step above. Note that it is still possible to use temporaries also for the consume declaration: for example, a program using icarus::trigger::ReadTriggerGates() may in the proper place (e.g. a module constructor) call explicitly the consume declaration:

is equivalent to the three steps above. The only advantage of the approach in multiple steps of the first example is that consistency of declaration and use is guaranteed by construction.

Definition at line 298 of file TriggerDataUtils.h.

Member Typedef Documentation

template<typename OpDetInfo = sbn::OpDetWaveformMeta>
using icarus::trigger::TriggerGateReader< OpDetInfo >::OpDetWaveformMeta_t = OpDetInfo

Type of associated information.

Definition at line 459 of file TriggerDataUtils.h.

template<typename OpDetInfo = sbn::OpDetWaveformMeta>
using icarus::trigger::TriggerGateReader< OpDetInfo >::TriggerGates_t = icarus::trigger::TrackedOpticalTriggerGate<OpDetWaveformMeta_t>

Type of data objects returned.

Definition at line 463 of file TriggerDataUtils.h.

Constructor & Destructor Documentation

template<typename OpDetInfo = sbn::OpDetWaveformMeta>
icarus::trigger::TriggerGateReader< OpDetInfo >::TriggerGateReader ( art::InputTag  dataTag)
inline

Constructor: configure to read the data with the specified tag.

Definition at line 467 of file TriggerDataUtils.h.

467 : fDataTag(std::move(dataTag)) {}
art::InputTag fDataTag
Data tag of the data products being read.

Member Function Documentation

template<typename OpDetInfo >
template<typename ConsumesCollector >
void icarus::trigger::TriggerGateReader< OpDetInfo >::declareConsumes ( ConsumesCollector &  collector) const

Declares to the collector the data products that are going to be read.

Definition at line 610 of file TriggerDataUtils.h.

611 {
612 
613  using icarus::trigger::OpticalTriggerGateData_t; // for convenience
614 
615  collector.template consumes<std::vector<OpticalTriggerGateData_t>>(fDataTag);
616  collector.template consumes<art::Assns<OpticalTriggerGateData_t, OpDetInfo>>
617  (fDataTag);
618 
619 } // icarus::trigger::TriggerGateReader::declareConsumes()
art::InputTag fDataTag
Data tag of the data products being read.
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>
art::InputTag const& icarus::trigger::TriggerGateReader< OpDetInfo >::inputTag ( ) const
inline

Returns the input tag the data is read from.

Definition at line 474 of file TriggerDataUtils.h.

474 { return fDataTag; }
art::InputTag fDataTag
Data tag of the data products being read.
template<typename OpDetInfo = sbn::OpDetWaveformMeta>
template<typename Event >
std::vector<TriggerGates_t> icarus::trigger::TriggerGateReader< OpDetInfo >::operator() ( Event const &  event) const
inline

Definition at line 481 of file TriggerDataUtils.h.

482  { return read(event); }
std::vector< TriggerGates_t > read(Event const &event) const
Reads the configured data product from the specified event.
template<typename OpDetInfo = sbn::OpDetWaveformMeta>
template<typename Event >
std::vector<TriggerGates_t> icarus::trigger::TriggerGateReader< OpDetInfo >::read ( Event const &  event) const

Reads the configured data product from the specified event.

template<typename OpDetInfo = sbn::OpDetWaveformMeta>
template<typename Event >
std::vector<icarus::trigger::TrackedOpticalTriggerGate<OpDetInfo> > icarus::trigger::TriggerGateReader< OpDetInfo >::read ( Event const &  event) const

Definition at line 626 of file TriggerDataUtils.h.

626  {
627 
628  using icarus::trigger::OpticalTriggerGateData_t; // for convenience
629 
630  // currently the associations are a waste of time memory...
631  auto const& gates
632  = event.template getProduct<std::vector<OpticalTriggerGateData_t>>(fDataTag);
633  auto const& gateToWaveforms = event.template getProduct
634  <art::Assns<OpticalTriggerGateData_t, OpDetInfo>>(fDataTag);
635 
636  try {
637  return icarus::trigger::FillTriggerGates(gates, gateToWaveforms);
638  }
639  catch (cet::exception const& e) {
640  throw cet::exception("readTriggerGates", "", e)
641  << "readTriggerGates() encountered an error while reading data products from '"
642  << fDataTag.encode() << "'\n";
643  }
644 
645 } // icarus::trigger::TriggerGateReader::read()
art::InputTag fDataTag
Data tag of the data products being read.
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
do i e
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.

Member Data Documentation

template<typename OpDetInfo = sbn::OpDetWaveformMeta>
art::InputTag icarus::trigger::TriggerGateReader< OpDetInfo >::fDataTag
private

Data tag of the data products being read.

Definition at line 455 of file TriggerDataUtils.h.


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