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::DiscriminatePMTwaveformsByChannel Class Reference

Produces discriminated optical waveforms. More...

Inheritance diagram for icarus::trigger::DiscriminatePMTwaveformsByChannel:

Classes

struct  ADCvalueSetting_t
 Information on the current setting of a threshold. More...
 
struct  ChannelConfig
 
struct  ChannelInfo_t
 Collection of settings for one channel. More...
 
struct  Config
 

Public Types

using TriggerGateData_t = icarus::trigger::OpticalTriggerGate::GateData_t
 The type of data produced for a single channel. More...
 
using Parameters = art::EDProducer::Table< Config >
 

Public Member Functions

 DiscriminatePMTwaveformsByChannel (Parameters const &config)
 
virtual void beginRun (art::Run &run) override
 
virtual void produce (art::Event &event) override
 Creates the data products. More...
 

Private Types

enum  Source_t {
  Source_t::Default, Source_t::List, Source_t::Unset, Source_t::Run,
  Source_t::Event, Source_t::PMTconfig, Source_t::ChannelSpec
}
 
using ADCCounts_t = icarus::trigger::ADCCounts_t
 

Private Member Functions

void refreshCurrentThresholds ()
 Updates fCurrentThresholds with the current status of the object. More...
 
void refreshCurrentBaselines ()
 Updates fCurrentBaselines with the current status of the object. More...
 
template<typename Logger = mf::LogInfo>
void printCurrentThresholdsAndBaselines () const
 Prints the current thresholds to the message logger. More...
 

Static Private Member Functions

static unsigned int getNOpDetChannels (fhicl::OptionalAtom< unsigned int > const &param)
 Creates a collection with one gate per channel and no gaps. More...
 
static std::vector< ChannelInfo_treadChannelInfoSpecs (std::vector< ChannelInfo_t > const &config)
 

Private Attributes

art::InputTag const fOpDetWaveformTag
 Input optical waveform tag. More...
 
std::optional< art::InputTag >
const 
fBaselineTag
 
std::optional< float > const fBaseline
 A constant baseline level. More...
 
unsigned int const fNOpDetChannels
 Number of optical detector channels. More...
 
std::optional
< raw::ADC_Count_t > const 
fDefaultThreshold
 Default threshold. More...
 
std::vector< raw::ADC_Count_t >
const 
fThresholdList
 The thresholds configured by a sequence parameter. More...
 
std::optional< art::InputTag >
const 
fThresholdsFromPMTconfig
 Tag of PMTconfiguration data product to read thresholds from. More...
 
std::vector< ChannelInfo_t > const fChannelInfos
 A map of thresholds: channel ID -> relative threshold value [ADC]. More...
 
std::string const fOutputInstanceName
 Instance name for output. More...
 
bool const fSavePMTcoverage
 Whether to save also sbn::OpDetWaveformMeta. More...
 
std::string const fLogCategory
 Category name for the console output stream. More...
 
std::optional
< sbn::PMTconfiguration
fPMTconfig
 PMT readout configuration for the current run. More...
 
std::vector
< icarus::WaveformBaseline
fBaselinesRun
 Current baseline list from run (one per channel). More...
 
std::vector< ADCvalueSetting_tfCurrentThresholds
 A map of current thresholds: channel ID -> relative threshold value [ADC]. More...
 
std::vector< ADCvalueSetting_tfCurrentBaselines
 A map of current baselines: channel ID -> baseline [ADC]. More...
 
std::unique_ptr
< icarus::trigger::TriggerGateBuilder
fTriggerGateBuilder
 Algorithms to simulate trigger gates out of optical channel output. More...
 

Detailed Description

Produces discriminated optical waveforms.

This module produces a "discriminated waveform" for each optical detector channel and for a single set of discrimination thresholds. The thresholds are specified one per channel.

Output data products

The output data products can be assigned an instance name (OutputInstanceName configuration parameter) if desired. They are:

Input data products

Service requirements

The following services are required:

Configuration parameters

There are several (too many?) ways to specify the discrimination thresholds. In the end, all PMT channels must be assigned a threshold: if at any time, on any event, a channel is found whose threshold was not set, an exception is thrown. All threshold specifications are relative to the baseline. There are currently four levels of threshold setting:

  1. if NChannels (positive integer) and DefaultThreshold (integral number) are both specified, the first NChannels PMT channels are assigned the DefaultThreshold; note that they both need to be specified at the same time, and when they are, channels with ID equal or larger than NChannels are still not configured, i.e. they will not be assigned the DefaultThreshold and if encountered an exception will be thrown;
  2. ThresholdList (list of integers) will define a threshold for each channel starting with ID 0 on; thresholds already set with the previous step will be overridden;
  3. ThresholdsFromPMTconfig (input tag) points to a data product with a PMT configuration (sbn::PMTconfiguration) which contains information on each channel, including the thresholds; thresholds are set for each channel from the value returned by sbn::V1730channelConfiguration::relativeThreshold() for that channel; only channel configuration entries that have a offline channel ID (sbn::V1730channelConfiguration::hasChannelID()) are configured in this way; thresholds already set with the previous steps will be overridden; when using this parameter, NChannels is also mandatory and channels with ID greater or equal than NChannels will trigger an exception.
  4. Thresholds (list of tables): in each entry, a threshold is specified for a single channel; the format of the entry is:
    • Channel (integral, mandatory): channel number;
    • Threshold (integral, mandatory): the threshold for that channel.
    Thresholds already set with the previous steps will be overridden.

All these are optional (but if the configuration has none, not much can be done since there will be no channel configured).

A terse description of the remaining parameters follows.

Definition at line 188 of file DiscriminatePMTwaveformsByChannel_module.cc.

Member Typedef Documentation

Definition at line 331 of file DiscriminatePMTwaveformsByChannel_module.cc.

Definition at line 307 of file DiscriminatePMTwaveformsByChannel_module.cc.

The type of data produced for a single channel.

Definition at line 194 of file DiscriminatePMTwaveformsByChannel_module.cc.

Member Enumeration Documentation

Enumerator
Default 
List 
Unset 
Run 
Event 
PMTconfig 
ChannelSpec 

Definition at line 379 of file DiscriminatePMTwaveformsByChannel_module.cc.

380  { Default, List, Unset, Run, Event, PMTconfig, ChannelSpec };
process_name PMTconfig
constexpr BitMask< Storage > Unset(Flag_t< Storage > flag)
Returns a bit mask which unsets the specified flag.

Constructor & Destructor Documentation

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

Definition at line 477 of file DiscriminatePMTwaveformsByChannel_module.cc.

478  : art::EDProducer(config)
479  // configuration
480  , fOpDetWaveformTag(config().OpticalWaveforms())
481  , fBaselineTag(util::fhicl::getOptionalValue(config().Baselines))
482  , fBaseline(util::fhicl::getOptionalValue(config().Baseline))
484  , fDefaultThreshold(util::fhicl::getOptionalValue(config().DefaultThreshold))
485  , fThresholdList(config().ThresholdList())
487  (util::fhicl::getOptionalValue(config().ThresholdsFromPMTconfig))
489  , fOutputInstanceName(config().OutputInstanceName())
490  , fSavePMTcoverage(config().SavePMTcoverage())
491  , fLogCategory(config().OutputCategory())
493  (
494  art::make_tool<icarus::trigger::TriggerGateBuilder>
495  (config().TriggerGateBuilder_.get<fhicl::ParameterSet>())
496  )
497 {
498 
499  if (config().DefaultThreshold.hasValue()
500  || config().ThresholdsFromPMTconfig.hasValue()
501  ) {
502  if (!config().NChannels.hasValue()) {
503  throw art::Exception(art::errors::Configuration)
504  << "Configuration parameter `" << config().NChannels.name()
505  << "` not specified: it is mandatory when either `"
506  << config().DefaultThreshold.name() << "` or `"
507  << config().ThresholdsFromPMTconfig.name() << "` are specified.\n";
508  }
509  }
510 
511  //
512  // optional configuration parameters
513  //
514  if (bool(fBaseline) + bool(fBaselineTag) != 1)
515  {
516  throw art::Exception(art::errors::Configuration)
517  << "Exactly one among options `" << config().Baselines.name() << "` ("
518  << (fBaselineTag? ("'" + fBaselineTag->encode() + "'"): "not set")
519  << ") and `" << config().Baseline.name() << "` ("
520  << (fBaseline? ("'" + std::to_string(*fBaseline) + "'"): "not set")
521  << ") must be specified.\n";
522  }
523 
524 
528 
529  //
530  // declaration of input
531  //
532  consumes<std::vector<raw::OpDetWaveform>>(fOpDetWaveformTag);
533 
535  consumes<sbn::PMTconfiguration, art::InRun>(*fThresholdsFromPMTconfig);
536 
537 
538  //
539  // declaration of output
540  //
541 
542  produces<std::vector<TriggerGateData_t>>(fOutputInstanceName);
543  produces<art::Assns<TriggerGateData_t, raw::OpDetWaveform>>
545  if (fSavePMTcoverage) {
546  produces<std::vector<sbn::OpDetWaveformMeta>>(fOutputInstanceName);
547  produces<art::Assns<raw::OpDetWaveform, sbn::OpDetWaveformMeta>>
549  produces<art::Assns<sbn::OpDetWaveformMeta, TriggerGateData_t>>
551  }
552 
553 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::DiscriminatePMTwaveformsByChannel()
BEGIN_PROLOG BeamGateDuration pmtthr physics producers trigtilewindowORS Thresholds
unsigned int const fNOpDetChannels
Number of optical detector channels.
std::optional< typename Optional::value_type > getOptionalValue(Optional const &parameter)
Returns the value of an optional parameter as std::optional.
Definition: FHiCLutils.h:188
void refreshCurrentBaselines()
Updates fCurrentBaselines with the current status of the object.
void printCurrentThresholdsAndBaselines() const
Prints the current thresholds to the message logger.
std::optional< raw::ADC_Count_t > const fDefaultThreshold
Default threshold.
bool const fSavePMTcoverage
Whether to save also sbn::OpDetWaveformMeta.
std::unique_ptr< icarus::trigger::TriggerGateBuilder > fTriggerGateBuilder
Algorithms to simulate trigger gates out of optical channel output.
std::vector< raw::ADC_Count_t > const fThresholdList
The thresholds configured by a sequence parameter.
void refreshCurrentThresholds()
Updates fCurrentThresholds with the current status of the object.
std::vector< ChannelInfo_t > const fChannelInfos
A map of thresholds: channel ID -&gt; relative threshold value [ADC].
static std::vector< ChannelInfo_t > readChannelInfoSpecs(std::vector< ChannelInfo_t > const &config)
physics producers discrimopdaq OpticalWaveforms
std::string to_string(WindowPattern const &pattern)
static unsigned int getNOpDetChannels(fhicl::OptionalAtom< unsigned int > const &param)
Creates a collection with one gate per channel and no gaps.
std::string const fLogCategory
Category name for the console output stream.
std::optional< art::InputTag > const fThresholdsFromPMTconfig
Tag of PMTconfiguration data product to read thresholds from.
std::optional< float > const fBaseline
A constant baseline level.

Member Function Documentation

void icarus::trigger::DiscriminatePMTwaveformsByChannel::beginRun ( art::Run &  run)
overridevirtual

Prepares the plots to be filled. Prepares the plots to be filled.

Definition at line 558 of file DiscriminatePMTwaveformsByChannel_module.cc.

559 {
561  auto const& PMTconfig
562  = run.getProduct<sbn::PMTconfiguration>(fThresholdsFromPMTconfig.value());
563 
564  if (!fPMTconfig || (fPMTconfig != PMTconfig)) {
568  }
569  } // if thresholds from config
570 
571 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::beginRun()
void printCurrentThresholdsAndBaselines() const
Prints the current thresholds to the message logger.
std::optional< sbn::PMTconfiguration > fPMTconfig
PMT readout configuration for the current run.
process_name PMTconfig
void refreshCurrentThresholds()
Updates fCurrentThresholds with the current status of the object.
std::optional< art::InputTag > const fThresholdsFromPMTconfig
Tag of PMTconfiguration data product to read thresholds from.
Class containing configuration for PMT readout.
unsigned int icarus::trigger::DiscriminatePMTwaveformsByChannel::getNOpDetChannels ( fhicl::OptionalAtom< unsigned int > const &  param)
staticprivate

Creates a collection with one gate per channel and no gaps.

Parameters
gatesthe trigger gates to be put in the collection
Returns
a collection with with one gate per channel and no gaps

The returned collection includes one gate per channel, and at least fNOpDetChannels channels (more if there are channels with higher number than that). For each channel, a gate is set in the item of the collection with index the channel ID (i.e. the first gate in the collection will be the one for channel 0, the next the one for channel 1 and so on). It is assumed that there is only at most one gate per channel. The gates specified in the argument are moved to the proper item in the returned collection. The other gates are assigned the proper channel number but are closed gates and associated with no waveform.Fetches the optical detector count from geometry unless in param.

Definition at line 949 of file DiscriminatePMTwaveformsByChannel_module.cc.

950 {
951  unsigned int nChannels;
952  return
953  param(nChannels)? nChannels: lar::providerFrom<geo::Geometry>()->NOpDets();
954 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::getNOpDetChannels()
template<typename Logger >
void icarus::trigger::DiscriminatePMTwaveformsByChannel::printCurrentThresholdsAndBaselines ( ) const
private

Prints the current thresholds to the message logger.

Definition at line 893 of file DiscriminatePMTwaveformsByChannel_module.cc.

894 {
895  Logger log { fLogCategory };
896 
897  auto const printSourceTag = [&log](Source_t source)
898  {
899  switch (source) {
900  case Source_t::Default: log << "(default value)";
901  break;
902  case Source_t::List: log << "(from threshold list)";
903  break;
904  case Source_t::Unset: log << "not set";
905  break;
906  case Source_t::PMTconfig: log << "(from PMT readout configuration)";
907  break;
908  case Source_t::Run: log << "(from run information)";
909  break;
910  case Source_t::Event: log << "(from event information)";
911  break;
912  case Source_t::ChannelSpec: log << "(specified for this channel)";
913  break;
914  } // switch
915  };
916 
917  std::size_t const nChannels
918  = std::max(fCurrentThresholds.size(), fCurrentBaselines.size());
919  log << "discrimination settings for " << nChannels << " channels";
920  if ((fNOpDetChannels > 0U) && (fNOpDetChannels < nChannels))
921  log << " (but only the first " << fNOpDetChannels << " will be processed)";
922  log << ':';
923  for (std::size_t const channel: util::counter(nChannels)) {
924 
925  log << "\n channel " << channel
926  << ": threshold ";
927  if (channel < fCurrentThresholds.size()) {
928  auto const& thrInfo = fCurrentThresholds[channel];
929  if (thrInfo.source != Source_t::Unset) log << thrInfo.value << ' ';
930  printSourceTag(thrInfo.source);
931  }
932  else log << "n/a";
933 
934  log << "; baseline ";
935  if (channel < fCurrentBaselines.size()) {
936  auto const& blineInfo = fCurrentBaselines[channel];
937  if (blineInfo.source != Source_t::Unset) log << blineInfo.value << ' ';
938  printSourceTag(blineInfo.source);
939  }
940  else log << "n/a";
941 
942  } // for channel
943 
944 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::printCurrentThresholdsAndBaselines()
unsigned int const fNOpDetChannels
Number of optical detector channels.
do source
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
std::vector< ADCvalueSetting_t > fCurrentBaselines
A map of current baselines: channel ID -&gt; baseline [ADC].
std::string const fLogCategory
Category name for the console output stream.
std::vector< ADCvalueSetting_t > fCurrentThresholds
A map of current thresholds: channel ID -&gt; relative threshold value [ADC].
void icarus::trigger::DiscriminatePMTwaveformsByChannel::produce ( art::Event &  event)
overridevirtual

Creates the data products.

Definition at line 575 of file DiscriminatePMTwaveformsByChannel_module.cc.

575  {
576 
577  //
578  // set up the algorithm to create the trigger gates
579  //
581  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event)
582  };
583 
584  //
585  // fetch input
586  //
587  auto const& waveformHandle
588  = event.getValidHandle<std::vector<raw::OpDetWaveform>>(fOpDetWaveformTag);
589  auto const& waveforms = *waveformHandle;
590 
591  // map address of waveform to art pointer to that waveform
592  auto const& opDetWavePtrs
593  = util::mapDataProductPointers(event, waveformHandle);
594 
595  //
596  // retrieve the baseline information if provided event by event
597  //
598  std::vector<icarus::WaveformBaseline> baselines;
599  if (fBaselineTag) {
600  // read and assign from the data product; configured baselines are ignored
601 
602  baselines = event.getProduct<std::vector<icarus::WaveformBaseline>>
603  (fBaselineTag.value());
604 
605  } // if baselines from event
606  else {
607  // assign baselines from configuration
608  baselines.reserve(waveforms.size());
609  for (auto const& waveform: waveforms) {
610  auto const channelSlot
611  = static_cast<std::size_t>(waveform.ChannelNumber());
612  if (channelSlot >= fCurrentBaselines.size()) {
613  throw cet::exception("DiscriminatePMTwaveformsByChannel")
614  << "Waveforms on channel " << waveform.ChannelNumber()
615  << " have no baseline configured.\n";
616  }
617  baselines.emplace_back(fCurrentBaselines[channelSlot].value.value());
618  } // for all waveforms
619  } // if ... else
620 
621  {
622  mf::LogDebug log { fLogCategory };
623  log << "Discrimination of " << waveforms.size() << " PMT waveforms from '"
624  << fOpDetWaveformTag.encode() << "'";
625  if (fBaselineTag)
626  log << " with baselines from '" << fBaselineTag->encode() << "'";
627  }
628 
629 
630  // We use an algorithm designed for applying to all channels the same
631  // thresholds, and many of them. But here we have a different threshold per
632  // channel, and a single threshold in that.
633  // So we'll reconfigure the algorithm for each channel, and process only
634  // the waveforms (and all of them) on that channel
635  // (a possible alternative is to set all the thresholds that appear in any
636  // of the channels, and after processing pick the right one for each channel;
637  // this normally works well because the threshold values are actually very few
638  // (a nominal one, and a few exceptions) but it may not scale.
639 
640  // group the waveforms by channel; ignore the channels we'll not process:
641  // channel ID -> all input waveforms and baselines on that channel
642  std::vector<std::vector<icarus::trigger::WaveformWithBaseline>>
643  waveformInfoPerChannel(fNOpDetChannels);
644 
645  for (auto const& [ waveform, baseline ]: util::zip(waveforms, baselines)) {
646 
647  auto const channelSlot = static_cast<std::size_t>(waveform.ChannelNumber());
648  if (channelSlot >= waveformInfoPerChannel.size()) continue; // ignore
649 
650  waveformInfoPerChannel[channelSlot].emplace_back
651  (&waveform, &baseline);
652 
653  } // for all channels
654 
655  assert(fCurrentThresholds.size() >= fNOpDetChannels);
657  for (auto const& [ channelSlot, waveInfo ]:
658  util::enumerate(waveformInfoPerChannel)
659  ) {
660  auto const channel = static_cast<raw::Channel_t>(channelSlot);
661  if (waveInfo.empty()) {
662  // gate associated to channel, always closed
663  gates.emplace_back(icarus::trigger::OpticalTriggerGateData_t{ channel });
664  continue;
665  }
666 
667  // set the threshold
668  auto const& threshold = fCurrentThresholds[channelSlot];
669  if (threshold.isUnset()) {
670  throw cet::exception("DiscriminatePMTwaveformsByChannel")
671  << "No threshold set up for PMT channel #" << channel << ".\n";
672  }
673  fTriggerGateBuilder->resetup
674  (detTimings, { ADCCounts_t::castFrom(threshold.value) });
675  assert(fTriggerGateBuilder->nChannelThresholds() == 1U);
676  mf::LogTrace(fLogCategory)
677  << "Processing PMT channel #" << channel
678  << " (first waveform baseline: " << waveInfo.front().baseline()
679  << ") and threshold " << fTriggerGateBuilder->channelThresholds().front()
680  ;
681 
682  // if there are waveforms, run the algorithm;
683  // save the first collection, i.e. the first (and only) threshold;
684  // extract the trigger gates from TriggerGates object immediately,
685  // GateData_t is a collection of TrackedTriggerGate objects,
686  // one per channel; that is, only one entry in this case
688  = std::move(fTriggerGateBuilder->build(waveInfo).front()).gates();
689  assert(channelGates.size() == 1);
690  gates.push_back(std::move(channelGates.front()));
691 
692  } // for all channels
693 
694  { // nameless block
695  mf::LogTrace log(fLogCategory);
696  log << "Trigger gates:\n";
697  unsigned int nOpenGates = gates.size();
698  for (auto const& gate: gates) if (gate.gate().alwaysClosed()) --nOpenGates;
699  log << nOpenGates << "/" << gates.size() << " trigger gates";
700  if (nOpenGates) {
701  log << ":";
702  for (auto const& gate: gates) {
703  if (gate.gate().alwaysClosed()) continue;
704  log << "\n " << gate;
705  }
706  }
707  } // nameless block
708 
709  //
710  // prepare output
711  //
712  art::PtrMaker<TriggerGateData_t> const makeGatePtr
713  { event, fOutputInstanceName };
714 
715  //
716  // reformat the results for the threshold
717  //
719  (std::move(gates), makeGatePtr, opDetWavePtrs);
720 
721  if (fSavePMTcoverage) {
722 
723  art::PtrMaker<sbn::OpDetWaveformMeta> const makePMTinfoPtr
724  { event, fOutputInstanceName };
725 
726  // PMT info and associations to input waveforms
727  sbn::OpDetWaveformMetaMaker const makePMTinfo { detTimings };
728 
729  std::vector<sbn::OpDetWaveformMeta> PMTinfo;
730  art::Assns<raw::OpDetWaveform, sbn::OpDetWaveformMeta> WavePMTinfoAssns;
731  art::PtrMaker<raw::OpDetWaveform> const makeWavePtr
732  { event, waveformHandle.id() };
733 
734  for (auto const& [ iWaveform, waveform ]: util::enumerate(waveforms)) {
735 
736  PMTinfo.push_back(makePMTinfo(waveform));
737 
738  WavePMTinfoAssns.addSingle
739  (makeWavePtr(iWaveform), makePMTinfoPtr(iWaveform));
740 
741  } // for
742 
743  // replica of discriminated gate-waveform association replacing the latter
744  // with the PMT coverage with the same index as the waveform
745  art::Assns<sbn::OpDetWaveformMeta, TriggerGateData_t> PMTinfoGateAssns;
746  for (auto [ gatePtr, wavePtr ]: assns)
747  PMTinfoGateAssns.addSingle(makePMTinfoPtr(wavePtr.key()), gatePtr);
748 
749  event.put(
750  std::make_unique<std::vector<sbn::OpDetWaveformMeta>>(std::move(PMTinfo)),
752  );
753  event.put(
754  std::make_unique<art::Assns<raw::OpDetWaveform, sbn::OpDetWaveformMeta>>
755  (std::move(WavePMTinfoAssns)),
757  );
758  event.put(
759  std::make_unique<art::Assns<sbn::OpDetWaveformMeta, TriggerGateData_t>>
760  (std::move(PMTinfoGateAssns)),
762  );
763 
764  } // if save PMT coverage
765 
766  //
767  // move the reformatted data into the event
768  //
769  event.put(
770  std::make_unique<std::vector<TriggerGateData_t>>(std::move(data)),
772  );
773  event.put(
774  std::make_unique<art::Assns<TriggerGateData_t, raw::OpDetWaveform>>
775  (std::move(assns)),
777  );
778 
779 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::produce()
unsigned int const fNOpDetChannels
Number of optical detector channels.
std::vector< icarus::trigger::OpticalTriggerGateData_t > transformIntoOpticalTriggerGate(Gates &&gates)
Returns the trigger gates in serializable format.
static constexpr quantity_t castFrom(U value)
Returns a new quantity initialized with the specified value.
Definition: quantities.h:825
bool const fSavePMTcoverage
Whether to save also sbn::OpDetWaveformMeta.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
Logical multi-level gate associated to one or more readout channels.
BEGIN_PROLOG baseline
std::unique_ptr< icarus::trigger::TriggerGateBuilder > fTriggerGateBuilder
Algorithms to simulate trigger gates out of optical channel output.
Converter from raw::OpDetWaveform into sbn::OpDetWaveformMeta.
std::vector< ADCvalueSetting_t > fCurrentBaselines
A map of current baselines: channel ID -&gt; baseline [ADC].
A class exposing an upgraded interface of detinfo::DetectorClocksData.
DataProductPointerMap_t< ArtHandleData_t< Handle > > mapDataProductPointers(art::Event const &event, Handle const &handle)
Creates a map from address of data product element to art pointer to it.
std::string const fLogCategory
Category name for the console output stream.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
std::vector< ADCvalueSetting_t > fCurrentThresholds
A map of current thresholds: channel ID -&gt; relative threshold value [ADC].
temporary value
fDetProps &fDetProps fDetProps &fDetProps detTimings
auto icarus::trigger::DiscriminatePMTwaveformsByChannel::readChannelInfoSpecs ( std::vector< ChannelInfo_t > const &  config)
staticprivate

Definition at line 959 of file DiscriminatePMTwaveformsByChannel_module.cc.

960 {
961  std::vector<ChannelInfo_t> chMap = config;
962 
963  auto const compareByChannel
964  = [](ChannelInfo_t const& a, ChannelInfo_t const& b)
965  { return a.channel == b.channel; }
966  ;
967 
968  // sort and check for duplicates
969  std::sort(chMap.begin(), chMap.end());
970  auto iDup = std::unique(chMap.begin(), chMap.end(), compareByChannel);
971  if (iDup != chMap.end()) {
972  art::Exception e { art::errors::Configuration };
973  e << "Found " << std::distance(iDup, chMap.end())
974  << " duplicate channels in the configuration:";
975  while (iDup != chMap.end()) e << " " << (iDup++)->channel;
976  throw e;
977  } // if duplicates
978 
979  return chMap;
980 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::readChannelInfoSpecs()
process_name gaushit a
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
do i e
void icarus::trigger::DiscriminatePMTwaveformsByChannel::refreshCurrentBaselines ( )
private

Updates fCurrentBaselines with the current status of the object.

Definition at line 854 of file DiscriminatePMTwaveformsByChannel_module.cc.

855 {
856  //
857  // start from scratch
858  //
859  fCurrentBaselines.clear();
860 
861  //
862  // first set the default values for the first time
863  //
864  if ((fNOpDetChannels > 0U) && fBaseline.has_value()) {
865  fCurrentBaselines.resize(
867  ADCvalueSetting_t
869  );
870  } // if
871 
872  //
873  // override from channel list
874  //
875  for (auto const& chInfo: fChannelInfos) {
876  if (!chInfo.baseline.has_value()) continue;
877  auto const channelSlot = static_cast<std::size_t>(chInfo.channel);
878  if (fCurrentBaselines.size() <= channelSlot) // make room
879  fCurrentBaselines.resize(channelSlot + 1U);
880  fCurrentBaselines[channelSlot] = {
881  Source_t::ChannelSpec, ADCCounts_t::castFrom(chInfo.baseline.value())
882  };
883 
884  } // for
885 
886 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::refreshCurrentBaselines()
unsigned int const fNOpDetChannels
Number of optical detector channels.
static constexpr quantity_t castFrom(U value)
Returns a new quantity initialized with the specified value.
Definition: quantities.h:825
std::vector< ChannelInfo_t > const fChannelInfos
A map of thresholds: channel ID -&gt; relative threshold value [ADC].
std::vector< ADCvalueSetting_t > fCurrentBaselines
A map of current baselines: channel ID -&gt; baseline [ADC].
std::optional< float > const fBaseline
A constant baseline level.
void icarus::trigger::DiscriminatePMTwaveformsByChannel::refreshCurrentThresholds ( )
private

Updates fCurrentThresholds with the current status of the object.

Definition at line 784 of file DiscriminatePMTwaveformsByChannel_module.cc.

785 {
786  //
787  // start from scratch
788  //
789  fCurrentThresholds.clear();
790 
791  //
792  // first set the default values for the first time
793  //
794  if (fNOpDetChannels > 0U) {
795  fCurrentThresholds.resize(
797  fDefaultThreshold.has_value()
798  ? ADCvalueSetting_t
800  : ADCvalueSetting_t{ Source_t::Unset }
801  );
802  } // if
803 
804  //
805  // override from the list
806  //
807  if (fCurrentThresholds.size() < fThresholdList.size())
808  fCurrentThresholds.resize(fThresholdList.size());
809  for (auto [ iThr, thr ]: util::enumerate(fThresholdList))
811 
812  //
813  // override from PMT configuration
814  //
815  if (fPMTconfig) {
816  for (sbn::V1730Configuration const& boardConfig: fPMTconfig->boards) {
817  for (sbn::V1730channelConfiguration const& channelConfig
818  : boardConfig.channels
819  ) {
820  if (!channelConfig.hasChannelID()) continue;
821 
822  auto const channelSlot
823  = static_cast<std::size_t>(channelConfig.channelID);
824  if (fCurrentThresholds.size() <= channelSlot)
825  fCurrentThresholds.resize(channelSlot + 1U);
826 
827  fCurrentThresholds[channelSlot] = {
830  };
831 
832  } // for channel
833  } // for board
834  } // if we have PMT configuration
835 
836  //
837  // override from channel list
838  //
839  for (auto const& chInfo: fChannelInfos) {
840  if (!chInfo.threshold.has_value()) continue;
841  auto const channelSlot = static_cast<std::size_t>(chInfo.channel);
842  if (fCurrentThresholds.size() <= channelSlot) // make room
843  fCurrentThresholds.resize(channelSlot + 1U);
844  fCurrentThresholds[channelSlot] = {
845  Source_t::ChannelSpec, ADCCounts_t::castFrom(chInfo.threshold.value())
846  };
847 
848  } // for
849 
850 } // icarus::trigger::DiscriminatePMTwaveformsByChannel::refreshCurrentThresholds()
unsigned int const fNOpDetChannels
Number of optical detector channels.
static constexpr quantity_t castFrom(U value)
Returns a new quantity initialized with the specified value.
Definition: quantities.h:825
std::optional< raw::ADC_Count_t > const fDefaultThreshold
Default threshold.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::optional< sbn::PMTconfiguration > fPMTconfig
PMT readout configuration for the current run.
std::vector< raw::ADC_Count_t > const fThresholdList
The thresholds configured by a sequence parameter.
short signed int relativeThreshold() const
Threshold relative to the baseline (ticks).
std::vector< ChannelInfo_t > const fChannelInfos
A map of thresholds: channel ID -&gt; relative threshold value [ADC].
std::vector< ADCvalueSetting_t > fCurrentThresholds
A map of current thresholds: channel ID -&gt; relative threshold value [ADC].
raw::Channel_t channelID
Offline channel ID.
bool hasChannelID() const
Returns whether the channel ID is set.
std::vector< sbn::V1730channelConfiguration > channels
Configuration of each channel.
Class containing configuration for a V1730 channel.
Class containing configuration for a V1730 board.

Member Data Documentation

std::optional<float> const icarus::trigger::DiscriminatePMTwaveformsByChannel::fBaseline
private

A constant baseline level.

Definition at line 340 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::vector<icarus::WaveformBaseline> icarus::trigger::DiscriminatePMTwaveformsByChannel::fBaselinesRun
private

Current baseline list from run (one per channel).

Definition at line 377 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::optional<art::InputTag> const icarus::trigger::DiscriminatePMTwaveformsByChannel::fBaselineTag
private

Definition at line 338 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::vector<ChannelInfo_t> const icarus::trigger::DiscriminatePMTwaveformsByChannel::fChannelInfos
private

A map of thresholds: channel ID -> relative threshold value [ADC].

Definition at line 354 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::vector<ADCvalueSetting_t> icarus::trigger::DiscriminatePMTwaveformsByChannel::fCurrentBaselines
private

A map of current baselines: channel ID -> baseline [ADC].

Definition at line 393 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::vector<ADCvalueSetting_t> icarus::trigger::DiscriminatePMTwaveformsByChannel::fCurrentThresholds
private

A map of current thresholds: channel ID -> relative threshold value [ADC].

Definition at line 390 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::optional<raw::ADC_Count_t> const icarus::trigger::DiscriminatePMTwaveformsByChannel::fDefaultThreshold
private

Default threshold.

Definition at line 345 of file DiscriminatePMTwaveformsByChannel_module.cc.

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

Category name for the console output stream.

Definition at line 361 of file DiscriminatePMTwaveformsByChannel_module.cc.

unsigned int const icarus::trigger::DiscriminatePMTwaveformsByChannel::fNOpDetChannels
private

Number of optical detector channels.

Definition at line 342 of file DiscriminatePMTwaveformsByChannel_module.cc.

art::InputTag const icarus::trigger::DiscriminatePMTwaveformsByChannel::fOpDetWaveformTag
private

Input optical waveform tag.

Input waveform baseline tag.

Definition at line 335 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::string const icarus::trigger::DiscriminatePMTwaveformsByChannel::fOutputInstanceName
private

Instance name for output.

Definition at line 356 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::optional<sbn::PMTconfiguration> icarus::trigger::DiscriminatePMTwaveformsByChannel::fPMTconfig
private

PMT readout configuration for the current run.

Definition at line 374 of file DiscriminatePMTwaveformsByChannel_module.cc.

bool const icarus::trigger::DiscriminatePMTwaveformsByChannel::fSavePMTcoverage
private

Whether to save also sbn::OpDetWaveformMeta.

Definition at line 358 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::vector<raw::ADC_Count_t> const icarus::trigger::DiscriminatePMTwaveformsByChannel::fThresholdList
private

The thresholds configured by a sequence parameter.

Definition at line 348 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::optional<art::InputTag> const icarus::trigger::DiscriminatePMTwaveformsByChannel::fThresholdsFromPMTconfig
private

Tag of PMTconfiguration data product to read thresholds from.

Definition at line 351 of file DiscriminatePMTwaveformsByChannel_module.cc.

std::unique_ptr<icarus::trigger::TriggerGateBuilder> icarus::trigger::DiscriminatePMTwaveformsByChannel::fTriggerGateBuilder
private

Algorithms to simulate trigger gates out of optical channel output.

Definition at line 396 of file DiscriminatePMTwaveformsByChannel_module.cc.


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