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

Simulates a sliding window trigger. More...

Inheritance diagram for icarus::trigger::SlidingWindowTriggerSimulation:
lar::UncopiableAndUnmovableClass

Classes

struct  Config
 
struct  ThresholdPlotInfo_t
 All information needed to generate plots for a specific threshold. More...
 

Public Types

using microseconds = util::quantities::intervals::microseconds
 
using nanoseconds = util::quantities::intervals::nanoseconds
 
using Parameters = art::EDProducer::Table< Config >
 

Public Member Functions

 SlidingWindowTriggerSimulation (Parameters const &config)
 
virtual void beginJob () override
 Initializes the plots. More...
 
virtual void produce (art::Event &event) override
 Runs the simulation and saves the results into the art event. More...
 
virtual void endJob () override
 Prints end-of-job summaries. More...
 

Private Types

using TriggerInfo_t = details::TriggerInfo_t
 Type alias. More...
 
using InputTriggerGate_t = icarus::trigger::SlidingWindowPatternAlg::InputTriggerGate_t
 Type of trigger gate extracted from the input event. More...
 
using TriggerGates_t = icarus::trigger::SlidingWindowPatternAlg::TriggerGates_t
 List of trigger gates. More...
 
using WindowTriggerInfo_t = icarus::trigger::SlidingWindowPatternAlg::AllTriggerInfo_t
 Data structure to communicate internally a trigger response. More...
 
using BinnedContent_t = icarus::ns::util::FixedBins< double >
 Content for future histograms, binned. More...
 

Private Member Functions

void initializePlots ()
 Initializes the full set of plots (all ADC thresholds). More...
 
void finalizePlots ()
 Creates summary plots from proto-histogram data. More...
 
void makeThresholdPlots (std::string const &threshold, icarus::trigger::PlotSandbox &plots, ThresholdPlotInfo_t const &plotInfo)
 
void makeEventPlots ()
 Creates in the main sandbox all event-wide plots. More...
 
void plotEvent (art::Event const &event, detinfo::DetectorTimings const &detTimings)
 Fills event-wide plots. More...
 
void plotTriggerResponse (std::size_t iThr, std::string const &thrTag, WindowTriggerInfo_t const &triggerInfo, detinfo::DetectorTimings const &detTimings)
 Fills the plots for threshold index iThr with trigger information. More...
 
WindowTriggerInfo_t produceForThreshold (art::Event &event, detinfo::DetectorTimings const &detTimings, ApplyBeamGateClass const &beamGate, std::size_t const iThr, std::string const &thrTag)
 Performs the simulation for the specified ADC threshold. More...
 
raw::Trigger triggerInfoToTriggerData (detinfo::DetectorTimings const &detTimings, unsigned int triggerNumber, WindowTriggerInfo_t const &info) const
 Converts the trigger information into a raw::Trigger object. More...
 
void printSummary () const
 Prints the summary of fired triggers on screen. More...
 
TH1 * makeHistogramFromBinnedContent (icarus::trigger::PlotSandbox &plots, std::string const &name, std::string const &title, BinnedContent_t const &binnedContent) const
 Creates and returns a 1D histogram filled with binnedContent. More...
 
icarus::trigger::ApplyBeamGateClass makeMyBeamGate (detinfo::DetectorClocksData data) const
 Shortcut to create an ApplyBeamGate with the current configuration. More...
 
icarus::trigger::ApplyBeamGateClass makeMyBeamGate (art::Event const *event=nullptr) const
 
icarus::trigger::ApplyBeamGateClass makeMyBeamGate (art::Event const &event) const
 
- Private Member Functions inherited from lar::UncopiableClass
 UncopiableClass ()=default
 Default constructor. More...
 
 ~UncopiableClass ()=default
 Default destructor. More...
 
 UncopiableClass (UncopiableClass const &)=delete
 Deleted copy and move constructors and assignments. More...
 
 UncopiableClass (UncopiableClass &&)=default
 
UncopiableClassoperator= (UncopiableClass const &)=delete
 
UncopiableClassoperator= (UncopiableClass &&)=default
 
- Private Member Functions inherited from lar::UnmovableClass
 UnmovableClass ()=default
 Default constructor. More...
 
 ~UnmovableClass ()=default
 Default destructor. More...
 
 UnmovableClass (UnmovableClass const &)=default
 Default copy constructor and assignment. More...
 
UnmovableClassoperator= (UnmovableClass const &)=default
 
 UnmovableClass (UnmovableClass &&)=delete
 Deleted move constructor and assignment. More...
 
UnmovableClassoperator= (UnmovableClass &&)=delete
 

Static Private Member Functions

static TriggerGates_t readTriggerGates (art::Event const &event, art::InputTag const &dataTag)
 
static double eventTimestampInSeconds (art::Timestamp const &time)
 Returns the time of the event in seconds from The Epoch. More...
 
static double eventTimestampInSeconds (art::Event const &event)
 

Private Attributes

std::map< std::string,
art::InputTag > 
fADCthresholds
 Name of ADC thresholds to read, and the input tag connected to their data. More...
 
WindowPattern const fPattern
 Configured sliding window requirement pattern. More...
 
microseconds fBeamGateDuration
 Duration of the gate during with global optical triggers are accepted. More...
 
microseconds fBeamGateStart
 Start of the beam gate with respect to BeamGate(). More...
 
std::uint32_t fBeamBits
 Bits for the beam gate being simulated. More...
 
nanoseconds fTriggerTimeResolution
 Trigger resolution in time. More...
 
double fEventTimeBinning
 Trigger time plot binning [s]. More...
 
std::string const fLogCategory
 Message facility stream category for output. More...
 
art::TFileDirectory fOutputDir
 ROOT directory where all the plots are written. More...
 
std::vector< std::string > fOutputInstances
 Output data product instance names (same order as fADCthresholds). More...
 
icarus::trigger::WindowTopologyManager fWindowMapMan
 Mapping of each sliding window with location and topological information. More...
 
std::optional
< icarus::trigger::SlidingWindowPatternAlg
fPatternAlg
 Pattern algorithm. More...
 
icarus::trigger::PlotSandbox fPlots
 All plots in one practical sandbox. More...
 
ThresholdPlotInfo_t fEventPlotInfo
 Proto-histogram information in a convenient packet; event-wide. More...
 
std::vector< ThresholdPlotInfo_tfThresholdPlots
 Proto-histogram information in a not-so-practical array; per threshold. More...
 
std::vector< std::atomic
< unsigned int > > 
fTriggerCount
 
std::atomic< unsigned int > fTotalEvents { 0U }
 Count of opened gates. More...
 
icarus::ns::util::ThreadSafeChangeMonitor
< icarus::trigger::ApplyBeamGateClass
fGateChangeCheck
 Functor returning whether a gate has changed. More...
 

Detailed Description

Simulates a sliding window trigger.

This module produces raw::Trigger objects each representing the outcome of some trigger logic applied to a discriminated input ("trigger primitives").

A trigger primitive is a two-level function of time which describes when that primitive is on and when it is off. Trigger primitives are given as input to this module and their origin may vary, but the standard source in ICARUS is single trigger request (LVDS).

This module applies a sliding window pattern to the input: the pattern consists of a requirement on the main window and optional additional requirements on the neighbouring windows. This module rebases the configured pattern on each of the available windows, evaluates the requirement of the pattern in that configuration, and decides whether those requirements are met. The general trigger is considered passed if any of the rebased patterns satisfies the requirement at any time, and no special treatment is performed in case multiple windows fulfil them, except that the trigger time is driven by the earliest of the satisfied patterns.

A single trigger pattern is configured for each instance of the module, while multiple input sets (e.g. with different discrimination thresholds) can be processed on the same pattern by the same module instance. Conversely, testing a different pattern requires the instantiation of a new module.

Configuration

An example job configuration is provided as simulate_sliding_window_trigger_icarus.fcl.

Output data products

Trigger logic algorithm

This section describes the trigger logic algorithm used in icarus::trigger::SlidingWindowTriggerSimulation and its assumptions. Nevertheless, more up-to-date information can be found in SlidingWindowTrigger module (for the combination of the LVDS signals into window-wide gates) and in icarus::trigger::SlidingWindowPatternAlg, which applies the configured pattern logic to the input.

The module receives as input a multi-level trigger gate for each of the windows to be considered. On the first input (i.e. the first event), that input is parsed to learn the windows and their relative position from the input trigger gates. This topology will be used to apply the configured patterns. On the following events, their input is checked to confirm the compatibility of the composition of its windows with the one from that first event (both aspects are handled by an icarus::trigger::WindowTopologyManager object).

All multi-level gates are set in coincidence with the beam gate by multiplying the multi-level and the beam gates. Because of this, trigger gates are suppressed everywhere except than during the beam gate. The beam gate opens at a time configured in DetectorClocks service provider (detinfo::DetectorClocks::BeamGateTime()), optionally offset (BeamGateStart), and has a duration configured in this module (BeamGateDuration).

The algorithm handles independently multiple trigger patterns. On each input, each configured pattern is applied based on the window topology. Each pattern describes a minimum level of the trigger gate in the window, that usually means the number of LVDS signals in coincidence at any given time ("majority"). A pattern may have requirements on the neighbouring windows in addition to the main one. The pattern is satisfied if all involved windows pass their specific requirements at the same time (coincidence between windows). Each pattern is applied in turn to each of the windows (which is the "main" window). The neighborhood described in the pattern is applied with respect to that main window. The trigger fires if one or more of the windows satisfy the pattern, and the trigger time is the one of the earliest satisfied pattern (more precisely, the earliest tick when the coincidence required by that pattern is satisfied).* All windows in the detector are considered independently, but the supported patterns may only include components in the same cryostat. Therefore, triggers are effectively on a single cryostat. An object of class icarus::trigger::SlidingWindowPatternAlg applies this logic: see its documentation for the most up-to-date details.

Eventually, for each event there are as many different trigger responses as how many different patterns are configured (Patterns configuration parameter), times how many ADC thresholds are provided in input, configured in Thresholds.

Technical aspects of the module

This module does not build the trigger gates of the sliding windows, but rather it takes them as input (see e.g. SlidingWindowTrigger module). Window topology (size of the windows and their relations) is stored in icarus::trigger::WindowChannelMap objects, and its construction is delegated to icarus::trigger::WindowTopologyAlg (under the hood of the WindowTopologyManager class) which learns it from the actual trigger gate input rather than on explicit configuration. Pattern definitions and configuration are defined in icarus::trigger::WindowPattern and icarus::trigger::ns::fhicl::WindowPatternConfig respectively. Trigger simulation is delegated to icarus::trigger::SlidingWindowPatternAlg.

Definition at line 253 of file SlidingWindowTriggerSimulation_module.cc.

Member Typedef Documentation

Content for future histograms, binned.

Definition at line 368 of file SlidingWindowTriggerSimulation_module.cc.

Type of trigger gate extracted from the input event.

Definition at line 357 of file SlidingWindowTriggerSimulation_module.cc.

Definition at line 260 of file SlidingWindowTriggerSimulation_module.cc.

Definition at line 261 of file SlidingWindowTriggerSimulation_module.cc.

Definition at line 327 of file SlidingWindowTriggerSimulation_module.cc.

List of trigger gates.

Definition at line 361 of file SlidingWindowTriggerSimulation_module.cc.

Type alias.

Definition at line 353 of file SlidingWindowTriggerSimulation_module.cc.

Data structure to communicate internally a trigger response.

Definition at line 365 of file SlidingWindowTriggerSimulation_module.cc.

Constructor & Destructor Documentation

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

Definition at line 565 of file SlidingWindowTriggerSimulation_module.cc.

566  : art::EDProducer (config)
567  // configuration
568  , fPattern (config().Pattern())
569  , fBeamGateDuration (config().BeamGateDuration())
570  , fBeamGateStart (config().BeamGateStart())
571  , fBeamBits (config().BeamBits())
572  , fTriggerTimeResolution(config().TriggerTimeResolution())
573  , fEventTimeBinning (config().EventTimeBinning())
574  , fLogCategory (config().LogCategory())
575  // services
576  , fOutputDir (*art::ServiceHandle<art::TFileService>())
577  // internal and cached
578  , fWindowMapMan
579  { *lar::providerFrom<geo::Geometry>(), fLogCategory + "_WindowMapManager" }
580  , fPlots(
581  fOutputDir, "", "requirement: " + fPattern.description()
582  )
583  , fEventPlotInfo{
584  BinnedContent_t{ fEventTimeBinning } // eventTimes
585  , BinnedContent_t{ // HWtrigTimeVsBeam
587  <detinfo::timescales::trigger_time::interval_t>().value()
588  }
589  , BinnedContent_t{ // triggerTimesVsHWtrig
591  <detinfo::timescales::trigger_time::interval_t>().value()
592  }
593  , BinnedContent_t{ // triggerTimesVsBeam
595  <detinfo::timescales::trigger_time::interval_t>().value()
596  }
597  }
598 {
599 
600  //
601  // more complex parameter parsing
602  //
603  std::string const& discrModuleLabel = config().TriggerGatesTag();
604  for (std::string const& threshold: config().Thresholds())
605  fADCthresholds[threshold] = art::InputTag{ discrModuleLabel, threshold };
606 
607  // initialization of a vector of atomic is not as trivial as it sounds...
608  fTriggerCount = std::vector<std::atomic<unsigned int>>(fADCthresholds.size());
609  std::fill(fTriggerCount.begin(), fTriggerCount.end(), 0U);
610 
611  //
612  // input data declaration
613  //
614  using icarus::trigger::OpticalTriggerGateData_t; // for convenience
615 
616  // trigger primitives
617  for (art::InputTag const& inputDataTag: util::const_values(fADCthresholds)) {
618  consumes<std::vector<OpticalTriggerGateData_t>>(inputDataTag);
619  consumes<art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>
620  (inputDataTag);
621  } // for
622 
623  //
624  // output data declaration
625  //
626  // keepThresholdName is true if we write instance name in output data products
627  bool const keepThresholdName
628  = config().KeepThresholdName().value_or(config().Thresholds().size() > 1);
629  if (!keepThresholdName && (config().Thresholds().size() > 1)) {
630  throw art::Exception(art::errors::Configuration)
631  << config().KeepThresholdName.name()
632  << " can be set to `true` only when a single threshold is specified ("
633  << config().Thresholds.name() << " has " << config().Thresholds().size()
634  << ")";
635  }
636 
637  for (auto const& inputDataTag: util::const_values(fADCthresholds)) {
638  std::string const outputInstance
639  = keepThresholdName? inputDataTag.instance(): "";
640  produces<std::vector<raw::Trigger>>(outputInstance);
641  fOutputInstances.push_back(outputInstance);
642  }
643 
644  {
645  mf::LogInfo log(fLogCategory);
646  log << "\nConfigured " << fADCthresholds.size() << " thresholds (ADC):";
647  for (auto const& [ thresholdTag, dataTag ]: fADCthresholds)
648  log << "\n * " << thresholdTag << " (from '" << dataTag.encode() << "')";
649 
650  } // local block
651 
652 
653 } // icarus::trigger::SlidingWindowTriggerSimulation::SlidingWindowTriggerSimulation()
BEGIN_PROLOG BeamGateDuration pmtthr physics producers trigtilewindowORS Thresholds
icarus::trigger::WindowTopologyManager fWindowMapMan
Mapping of each sliding window with location and topological information.
std::uint32_t fBeamBits
Bits for the beam gate being simulated.
icarus::ns::util::FixedBins< double > BinnedContent_t
Content for future histograms, binned.
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
Name of ADC thresholds to read, and the input tag connected to their data.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
art::TFileDirectory fOutputDir
ROOT directory where all the plots are written.
constexpr IV convertInto() const
Convert this interval into the specified one.
Definition: intervals.h:389
microseconds fBeamGateStart
Start of the beam gate with respect to BeamGate().
WindowPattern const fPattern
Configured sliding window requirement pattern.
microseconds fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
std::string const fLogCategory
Message facility stream category for output.
std::vector< std::string > fOutputInstances
Output data product instance names (same order as fADCthresholds).
temporary value
BEGIN_PROLOG triggeremu_data_config_icarus settings sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds Pattern
std::string description() const
Returns a description of the pattern.
ThresholdPlotInfo_t fEventPlotInfo
Proto-histogram information in a convenient packet; event-wide.

Member Function Documentation

void icarus::trigger::SlidingWindowTriggerSimulation::beginJob ( )
overridevirtual

Initializes the plots.

Definition at line 657 of file SlidingWindowTriggerSimulation_module.cc.

657  {
658 
659  initializePlots();
660 
661 } // icarus::trigger::SlidingWindowTriggerSimulation::beginJob()
void initializePlots()
Initializes the full set of plots (all ADC thresholds).
void icarus::trigger::SlidingWindowTriggerSimulation::endJob ( )
overridevirtual

Prints end-of-job summaries.

Definition at line 703 of file SlidingWindowTriggerSimulation_module.cc.

703  {
704 
705  finalizePlots();
706 
707  printSummary();
708 
709 } // icarus::trigger::SlidingWindowTriggerSimulation::endJob()
void printSummary() const
Prints the summary of fired triggers on screen.
void finalizePlots()
Creates summary plots from proto-histogram data.
double icarus::trigger::SlidingWindowTriggerSimulation::eventTimestampInSeconds ( art::Timestamp const &  time)
staticprivate

Returns the time of the event in seconds from The Epoch.

Definition at line 1171 of file SlidingWindowTriggerSimulation_module.cc.

1172 {
1173  // high value: seconds from the Epoch (Jan 1, 1970 UTC?);
1174  // low value: nanoseconds after that the start of that second
1175  return static_cast<double>(time.timeHigh())
1176  + static_cast<double>(time.timeHigh()) * 1e-9;
1177 } // icarus::trigger::SlidingWindowTriggerSimulation::eventTimestampInSeconds()
do i e
double icarus::trigger::SlidingWindowTriggerSimulation::eventTimestampInSeconds ( art::Event const &  event)
staticprivate

Definition at line 1182 of file SlidingWindowTriggerSimulation_module.cc.

1183  { return eventTimestampInSeconds(event.time()); }
static double eventTimestampInSeconds(art::Timestamp const &time)
Returns the time of the event in seconds from The Epoch.
void icarus::trigger::SlidingWindowTriggerSimulation::finalizePlots ( )
private

Creates summary plots from proto-histogram data.

Definition at line 857 of file SlidingWindowTriggerSimulation_module.cc.

857  {
858 
859  for (auto const& [ thr, info ]
860  : util::zip(util::get_elements<0U>(fADCthresholds), fThresholdPlots))
861  {
863  makeThresholdPlots(thr, plots, info);
864  if (plots.empty()) fPlots.deleteSubSandbox(plots.name());
865  } // for thresholds
866 
867  makeEventPlots();
868 
869 } // icarus::trigger::SlidingWindowTriggerSimulation::finalizePlots()
void makeThresholdPlots(std::string const &threshold, icarus::trigger::PlotSandbox &plots, ThresholdPlotInfo_t const &plotInfo)
std::map< std::string, art::InputTag > fADCthresholds
Name of ADC thresholds to read, and the input tag connected to their data.
void makeEventPlots()
Creates in the main sandbox all event-wide plots.
std::string const & name() const
Returns the sandbox name.
Definition: PlotSandbox.h:196
bool deleteSubSandbox(std::string const &name)
Deletes the subbox with the specified name and its directory.
std::vector< ThresholdPlotInfo_t > fThresholdPlots
Proto-histogram information in a not-so-practical array; per threshold.
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.
bool empty() const
Returns if the sandbox is empty (neither it nor subboxes hold objects).
std::vector< PlotDef > plots
Definition: demo.h:54
static auto & demandSandbox(SandboxType &sandbox, std::string const &name)
Helper function for demandSandbox() implementations.
Definition: PlotSandbox.h:750
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
A helper to manage ROOT objects with consistent naming.
Definition: PlotSandbox.h:95
void icarus::trigger::SlidingWindowTriggerSimulation::initializePlots ( )
private

Initializes the full set of plots (all ADC thresholds).

Definition at line 713 of file SlidingWindowTriggerSimulation_module.cc.

713  {
714 
715  //
716  // overview plots with different settings
717  //
718 
719  std::vector<std::string> thresholdLabels;
720  thresholdLabels.reserve(size(fADCthresholds));
721  for (std::string thr: util::get_elements<0U>(fADCthresholds))
722  thresholdLabels.push_back(std::move(thr));
723 
724  auto const beamGate = makeMyBeamGate();
725  fGateChangeCheck(beamGate);
726  mf::LogInfo(fLogCategory)
727  << "Beam gate for plots: " << beamGate.asSimulationTime()
728  << " (simulation time), " << beamGate.tickRange()
729  << " (optical ticks)"
730  ;
731 
732  //
733  // Triggering efficiency vs. ADC threshold.
734  //
735  auto* NTriggers = fPlots.make<TH1F>(
736  "NTriggers",
737  "Number of triggering events"
738  ";PMT discrimination threshold [ ADC counts ]"
739  ";events",
740  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
741  );
742  util::ROOT::applyAxisLabels(NTriggers->GetXaxis(), thresholdLabels);
743 
744  auto* Eff = fPlots.make<TEfficiency>(
745  "Eff",
746  "Triggering pass fraction"
747  ";PMT discrimination threshold [ ADC counts ]"
748  ";trigger pass fraction",
749  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
750  );
751  // people are said to have earned hell for things like this;
752  // but TEfficiency really does not expose the interface to assign labels to
753  // its axes, which supposedly could be done had we chosen to create it by
754  // histograms instead of directly as recommended.
756  (const_cast<TH1*>(Eff->GetTotalHistogram())->GetXaxis(), thresholdLabels);
757 
758  detinfo::timescales::optical_time_ticks const triggerResolutionTicks{
760  };
761 
762  auto const& beamGateTicks = beamGate.tickRange();
763  auto* TrigTime = fPlots.make<TH2F>(
764  "TriggerTick",
765  "Trigger time tick"
766  ";optical time tick [ /" + util::to_string(triggerResolutionTicks) + " ]"
767  ";PMT discrimination threshold [ ADC counts ]"
768  ";events",
769  static_cast<int>(std::ceil(beamGate.lengthTicks()/triggerResolutionTicks)),
770  beamGateTicks.start().value(),
772  (beamGateTicks.start() + beamGate.lengthTicks(), triggerResolutionTicks)
773  .value(),
774  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
775  );
776  util::ROOT::applyAxisLabels(TrigTime->GetYaxis(), thresholdLabels);
777 
778 
779  // we allow some fixed margin in the plot, just in case:
780  constexpr microseconds beamPlotPadding { 4_us };
781 
783 
784  // hardware trigger may happen at any place within the beam gate,
785  // and in this plot range I want to include the full beam gate;
786  // so I take a beam gate worth of time before the trigger time,
787  // and as much after it; since this plot is relative to the hardware trigger,
788  // the hardware trigger time itself is 0
789  icarus::ns::util::BinningSpecs const HWtrigBinning = alignBinningTo(
791  (- beamGate.length() - beamPlotPadding).value(),
792  (beamGate.length() + beamPlotPadding).value(),
793  fTriggerTimeResolution.convertInto<trigger_time::interval_t>().value()
794  },
795  0.0
796  );
797  fPlots.make<TH2F>(
798  "TriggerTimeVsHWTrig",
799  "Time of the trigger"
800  ";trigger time (relative to hardware trigger) [ #mus ]"
801  ";PMT discrimination threshold [ ADC counts ]"
802  ";triggers",
803  HWtrigBinning.nBins(), HWtrigBinning.lower(), HWtrigBinning.upper(),
804  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
805  );
806 
807  icarus::ns::util::BinningSpecs const beamGateBinning = alignBinningTo(
809  (-beamPlotPadding).value(),
810  (beamGate.length() + beamPlotPadding).value(),
811  fTriggerTimeResolution.convertInto<trigger_time::interval_t>().value()
812  },
813  0.0
814  );
815  fPlots.make<TH2F>(
816  "TriggerTimeVsBeamGate",
817  "Time of the trigger"
818  ";trigger time (relative to beam gate opening) [ #mus ]"
819  ";PMT discrimination threshold [ ADC counts ]"
820  ";triggers",
821  beamGateBinning.nBins(), beamGateBinning.lower(), beamGateBinning.upper(),
822  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
823  );
824 
825  //
826  // per-threshold plots; should this initialization be set into its own method?
827  //
828  for (auto const& [ thr, info ]
829  : util::zip(util::get_elements<0U>(fADCthresholds), fThresholdPlots))
830  {
832  = fPlots.addSubSandbox("Thr" + thr, "Threshold: " + thr);
833 
834  plots.make<TGraph>(
835  "TriggerTimeVsHWTrigVsBeam",
836  "Time of the trigger: emulated vs. hardware"
837  ";hardware trigger time (relative to beam gate opening) [ #mus ]"
838  ";emulated trigger time (relative to beam gate opening) [ #mus ]"
839  );
840 
841  } // for thresholds
842 
843  fThresholdPlots.resize(
845  {
846  BinnedContent_t{ fEventTimeBinning }, // eventTimes
847  BinnedContent_t{ HWtrigBinning.binWidth() }, // HWtrigTimeVsBeam
848  BinnedContent_t{ HWtrigBinning.binWidth() }, // triggerTimesVsHWtrig
849  BinnedContent_t{ beamGateBinning.binWidth() } // triggerTimesVsBeam
850  }
851  );
852 
853 } // icarus::trigger::SlidingWindowTriggerSimulation::initializePlots()
Obj * make(std::string const &name, std::string const &title, Args &&...args)
Creates a new ROOT object with the specified name and title.
Definition: PlotSandbox.h:701
constexpr T roundup(T const value, U const quantum, T const offset=T{})
Returns the value, rounded up.
Definition: rounding.h:112
icarus::ns::util::FixedBins< double > BinnedContent_t
Content for future histograms, binned.
std::map< std::string, art::InputTag > fADCthresholds
Name of ADC thresholds to read, and the input tag connected to their data.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
void applyAxisLabels(TAxis *pAxis, std::vector< std::string > const &labels, int first=1)
Sets all the labels starting with the bin first (1 by default).
Definition: ROOTutils.h:175
double lower() const
Returns the value of the lower end of the first bin.
Definition: BinningSpecs.h:187
icarus::trigger::ApplyBeamGateClass makeMyBeamGate(detinfo::DetectorClocksData data) const
Shortcut to create an ApplyBeamGate with the current configuration.
std::vector< ThresholdPlotInfo_t > fThresholdPlots
Proto-histogram information in a not-so-practical array; per threshold.
BinningSpecs alignBinningTo(BinningSpecs const &binning, double boundary, bool extendCoverage=true)
Returns a binning shifted to align with the specified boundary.
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
Data structure holding binning information.
Definition: BinningSpecs.h:170
double binWidth() const
Returns the width of the bins (all bins have the same width).
Definition: BinningSpecs.h:199
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.
Ticks toOpticalTicks(time_interval time) const
Returns the optical ticks corresponding to a time interval.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
std::vector< PlotDef > plots
Definition: demo.h:54
constexpr IV convertInto() const
Convert this interval into the specified one.
Definition: intervals.h:389
double upper() const
Returns the value of the upper end of the last bin.
Definition: BinningSpecs.h:190
std::string const fLogCategory
Message facility stream category for output.
SandboxType & addSubSandbox(std::string const &name, std::string const &desc, Args &&...args)
Creates a new sandbox contained in this one.
Definition: PlotSandbox.h:723
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
temporary value
unsigned long nBins() const
Returns the number of bins.
Definition: BinningSpecs.h:196
icarus::ns::util::ThreadSafeChangeMonitor< icarus::trigger::ApplyBeamGateClass > fGateChangeCheck
Functor returning whether a gate has changed.
detinfo::DetectorTimings makeDetTimings(art::Event const *event)
Returns a detinfo::DetectorTimings from DetectorClocksService.
A helper to manage ROOT objects with consistent naming.
Definition: PlotSandbox.h:95
void icarus::trigger::SlidingWindowTriggerSimulation::makeEventPlots ( )
private

Creates in the main sandbox all event-wide plots.

Definition at line 926 of file SlidingWindowTriggerSimulation_module.cc.

926  {
927 
928  BinnedContent_t const* content;
929 
930  content = &(fEventPlotInfo.eventTimes);
932  "EventTime",
933  "Time of the events"
934  ";time"
935  ";events [ / " + std::to_string(content->binWidth())
936  + "\" ]",
937  *content
938  );
939 
940  content = &(fEventPlotInfo.HWtrigTimeVsBeam);
942  "HWTrigVsBeam",
943  "Time of the hardware trigger"
944  ";trigger time (relative to beam gate) [ #mus ]"
945  ";events [ / " + std::to_string(content->binWidth())
946  + " #mus ]",
947  *content
948  );
949 
950 } // icarus::trigger::SlidingWindowTriggerSimulation::makeEventPlots()
TH1 * makeHistogramFromBinnedContent(icarus::trigger::PlotSandbox &plots, std::string const &name, std::string const &title, BinnedContent_t const &binnedContent) const
Creates and returns a 1D histogram filled with binnedContent.
icarus::ns::util::FixedBins< double > BinnedContent_t
Content for future histograms, binned.
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.
std::string to_string(WindowPattern const &pattern)
ThresholdPlotInfo_t fEventPlotInfo
Proto-histogram information in a convenient packet; event-wide.
TH1 * icarus::trigger::SlidingWindowTriggerSimulation::makeHistogramFromBinnedContent ( icarus::trigger::PlotSandbox plots,
std::string const &  name,
std::string const &  title,
BinnedContent_t const &  binnedContent 
) const
private

Creates and returns a 1D histogram filled with binnedContent.

Definition at line 1145 of file SlidingWindowTriggerSimulation_module.cc.

1149  {
1150 
1151  if (binnedContent.empty()) return nullptr;
1152 
1153  TH1* hist = plots.make<TH1F>(
1154  name, title,
1155  binnedContent.nBins(), binnedContent.min(), binnedContent.max()
1156  );
1157 
1158  // directly transfer the content bin by bin
1159  unsigned int total = 0U;
1160  for (auto [ iBin, count ]: util::enumerate(binnedContent)) {
1161  hist->SetBinContent(iBin + 1, count);
1162  total += count;
1163  }
1164  hist->SetEntries(static_cast<double>(total));
1165  return hist;
1166 } // icarus::trigger::SlidingWindowTriggerSimulation::makeHistogramFromBinnedContent
Obj * make(std::string const &name, std::string const &title, Args &&...args)
Creates a new ROOT object with the specified name and title.
Definition: PlotSandbox.h:701
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
then echo fcl name
std::size_t count(Cont const &cont)
icarus::trigger::ApplyBeamGateClass icarus::trigger::SlidingWindowTriggerSimulation::makeMyBeamGate ( detinfo::DetectorClocksData  data) const
inlineprivate

Shortcut to create an ApplyBeamGate with the current configuration.

Definition at line 530 of file SlidingWindowTriggerSimulation_module.cc.

531  {
532  return makeApplyBeamGate(
534  std::move(data),
536  );
537  }
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.
microseconds fBeamGateStart
Start of the beam gate with respect to BeamGate().
microseconds fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
std::string const fLogCategory
Message facility stream category for output.
icarus::trigger::ApplyBeamGateClass icarus::trigger::SlidingWindowTriggerSimulation::makeMyBeamGate ( art::Event const *  event = nullptr) const
inlineprivate

Definition at line 539 of file SlidingWindowTriggerSimulation_module.cc.

icarus::trigger::ApplyBeamGateClass makeMyBeamGate(detinfo::DetectorClocksData data) const
Shortcut to create an ApplyBeamGate with the current configuration.
detinfo::DetectorClocksData makeDetClockData(art::Event const *event)
Returns a detinfo::DetectorClocksData from DetectorClocksService.
icarus::trigger::ApplyBeamGateClass icarus::trigger::SlidingWindowTriggerSimulation::makeMyBeamGate ( art::Event const &  event) const
inlineprivate

Definition at line 542 of file SlidingWindowTriggerSimulation_module.cc.

542 { return makeMyBeamGate(&event); }
icarus::trigger::ApplyBeamGateClass makeMyBeamGate(detinfo::DetectorClocksData data) const
Shortcut to create an ApplyBeamGate with the current configuration.
void icarus::trigger::SlidingWindowTriggerSimulation::makeThresholdPlots ( std::string const &  threshold,
icarus::trigger::PlotSandbox plots,
ThresholdPlotInfo_t const &  plotInfo 
)
private

Creates in plots sandbox all plots for threshold threshold from data in plotInfo.

Definition at line 873 of file SlidingWindowTriggerSimulation_module.cc.

877  {
878 
879  BinnedContent_t const* content;
880 
881  content = &(plotInfo.eventTimes);
883  "TriggerTime",
884  "Time of the triggered events"
885  ";time"
886  ";triggered events [ / " + std::to_string(content->binWidth())
887  + "\" ]",
888  *content
889  );
890 
891  content = &(plotInfo.HWtrigTimeVsBeam);
893  "HWTrigVsBeam",
894  "Time of the hardware trigger"
895  ";trigger time (relative to beam gate) [ #mus ]"
896  ";events [ / " + std::to_string(content->binWidth())
897  + " #mus ]",
898  *content
899  );
900 
901  content = &(plotInfo.triggerTimesVsHWtrig);
903  "TriggerTimeVsHWTrig",
904  "Time of the trigger"
905  ";trigger time (relative to hardware trigger) [ #mus ]"
906  ";triggers [ / " + std::to_string(content->binWidth())
907  + " #mus ]",
908  *content
909  );
910 
911  content = &(plotInfo.triggerTimesVsBeam);
913  "TriggerTimeVsBeamGate",
914  "Time of the trigger"
915  ";trigger time (relative to beam gate opening) [ #mus ]"
916  ";triggers [ / " + std::to_string(content->binWidth())
917  + " #mus ]",
918  *content
919  );
920 
921 } // icarus::trigger::SlidingWindowTriggerSimulation::makeThresholdPlots()
TH1 * makeHistogramFromBinnedContent(icarus::trigger::PlotSandbox &plots, std::string const &name, std::string const &title, BinnedContent_t const &binnedContent) const
Creates and returns a 1D histogram filled with binnedContent.
icarus::ns::util::FixedBins< double > BinnedContent_t
Content for future histograms, binned.
std::string to_string(WindowPattern const &pattern)
void icarus::trigger::SlidingWindowTriggerSimulation::plotEvent ( art::Event const &  event,
detinfo::DetectorTimings const &  detTimings 
)
private

Fills event-wide plots.

Definition at line 1007 of file SlidingWindowTriggerSimulation_module.cc.

1008 {
1009 
1010  detinfo::timescales::trigger_time const beamGateTime
1011  { detTimings.toTriggerTime(detTimings.BeamGateTime()) };
1012 
1014  fEventPlotInfo.HWtrigTimeVsBeam.add(-beamGateTime.value());
1015 
1016 } // icarus::trigger::SlidingWindowTriggerSimulation::plotEvent()
BinIndex_t add(Data_t value)
Increases by a unit the count at the bin including value.
Definition: FixedBins.h:338
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
fDetProps &fDetProps fDetProps &fDetProps detTimings
static double eventTimestampInSeconds(art::Timestamp const &time)
Returns the time of the event in seconds from The Epoch.
ThresholdPlotInfo_t fEventPlotInfo
Proto-histogram information in a convenient packet; event-wide.
void icarus::trigger::SlidingWindowTriggerSimulation::plotTriggerResponse ( std::size_t  iThr,
std::string const &  thrTag,
WindowTriggerInfo_t const &  triggerInfo,
detinfo::DetectorTimings const &  detTimings 
)
private

Fills the plots for threshold index iThr with trigger information.

Definition at line 1020 of file SlidingWindowTriggerSimulation_module.cc.

1024  {
1025 
1026  bool const fired = triggerInfo.info.fired();
1027 
1028  fPlots.demand<TEfficiency>("Eff").Fill(fired, iThr);
1029 
1030  if (fired) {
1031  using namespace detinfo::timescales;
1032 
1033  // time of the beam gate in hardware trigger time scale
1034  trigger_time const beamGateTime
1035  { detTimings.toTriggerTime(detTimings.BeamGateTime()) };
1036 
1037  optical_tick const thisTriggerTick { triggerInfo.info.atTick() };
1038  trigger_time const thisTriggerTimeVsHWtrig
1039  { detTimings.toTriggerTime(thisTriggerTick) };
1040  time_interval const thisTriggerTimeVsBeamGate
1041  { thisTriggerTimeVsHWtrig - beamGateTime };
1042 
1043  mf::LogTrace(fLogCategory)
1044  << "Trigger " << fPattern.tag() << " at tick " << thisTriggerTick
1045  << " (" << thisTriggerTimeVsHWtrig << " vs. HW trigger, "
1046  << thisTriggerTimeVsBeamGate << " vs. beam gate)"
1047  ;
1048 
1049  fPlots.demand<TH1>("NTriggers").Fill(iThr);
1050  fPlots.demand<TH2>("TriggerTick").Fill(thisTriggerTick.value(), iThr);
1051  fPlots.demand<TH2>("TriggerTimeVsHWTrig").Fill
1052  (thisTriggerTimeVsHWtrig.value(), iThr);
1053  fPlots.demand<TH2>("TriggerTimeVsBeamGate").Fill
1054  (thisTriggerTimeVsBeamGate.value(), iThr);
1055 
1057 // plots.demand<TGraph>("TriggerTimeVsHWTrigVsBeam").AddPoint( // ROOT 6.24?
1058  TGraph& graph = plots.demand<TGraph>("TriggerTimeVsHWTrigVsBeam");
1059  graph.SetPoint(graph.GetN(),
1060  -beamGateTime.value(), thisTriggerTimeVsBeamGate.value()
1061  );
1062 
1063  ThresholdPlotInfo_t& plotInfo { fThresholdPlots[iThr] };
1064  plotInfo.HWtrigTimeVsBeam.add(-beamGateTime.value());
1065  plotInfo.triggerTimesVsHWtrig.add(thisTriggerTimeVsHWtrig.value());
1066  plotInfo.triggerTimesVsBeam.add(thisTriggerTimeVsBeamGate.value());
1067 
1068  }
1069 
1070 } // icarus::trigger::SlidingWindowTriggerSimulation::plotTriggerResponse()
std::vector< ThresholdPlotInfo_t > fThresholdPlots
Proto-histogram information in a not-so-practical array; per threshold.
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.
std::vector< PlotDef > plots
Definition: demo.h:54
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:114
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
std::string tag() const
Returns a tag summarizing the pattern.
WindowPattern const fPattern
Configured sliding window requirement pattern.
std::string const fLogCategory
Message facility stream category for output.
static auto & demandSandbox(SandboxType &sandbox, std::string const &name)
Helper function for demandSandbox() implementations.
Definition: PlotSandbox.h:750
Obj & demand(std::string const &name) const
Fetches an object with the specified name to be modified.
Definition: PlotSandbox.h:667
fDetProps &fDetProps fDetProps &fDetProps detTimings
A helper to manage ROOT objects with consistent naming.
Definition: PlotSandbox.h:95
void icarus::trigger::SlidingWindowTriggerSimulation::printSummary ( ) const
private

Prints the summary of fired triggers on screen.

Definition at line 1074 of file SlidingWindowTriggerSimulation_module.cc.

1074  {
1075 
1076  //
1077  // summary from our internal counters
1078  //
1079  mf::LogInfo log(fLogCategory);
1080  log
1081  << "Summary of triggers for " << fTriggerCount.size()
1082  << " thresholds (ADC) with pattern: " << fPattern.description()
1083  ;
1084  for (auto const& [ count, thr ]
1085  : util::zip(fTriggerCount, util::get_elements<0U>(fADCthresholds)))
1086  {
1087  log << "\n threshold " << thr
1088  << ": " << count;
1089  if (fTotalEvents > 0U) {
1090  log << "/" << fTotalEvents
1091  << " (" << (double(count) / fTotalEvents * 100.0) << "%)";
1092  }
1093  else log << " events triggered";
1094  } // for
1095 
1096 } // icarus::trigger::SlidingWindowTriggerSimulation::printSummary()
std::map< std::string, art::InputTag > fADCthresholds
Name of ADC thresholds to read, and the input tag connected to their data.
std::atomic< unsigned int > fTotalEvents
Count of opened gates.
WindowPattern const fPattern
Configured sliding window requirement pattern.
std::string const fLogCategory
Message facility stream category for output.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
std::size_t count(Cont const &cont)
std::string description() const
Returns a description of the pattern.
void icarus::trigger::SlidingWindowTriggerSimulation::produce ( art::Event &  event)
overridevirtual

Runs the simulation and saves the results into the art event.

Definition at line 665 of file SlidingWindowTriggerSimulation_module.cc.

666 {
667 
668  detinfo::DetectorClocksData const clockData
669  = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
670  detinfo::DetectorTimings const detTimings{clockData};
671  auto const beamGate = makeMyBeamGate(clockData);
672 
673  if (auto oldGate = fGateChangeCheck(beamGate); oldGate) {
674  MF_LOG_DEBUG(fLogCategory)
675  << "Beam gate has changed from " << *oldGate << " to " << beamGate;
676  }
677 
678 
679  mf::LogDebug log(fLogCategory); // this will print at the end of produce()
680  log << "Event " << event.id() << ":";
681 
682  for (auto const& [ iThr, thrTag ]
683  : util::enumerate(util::get_elements<0U>(fADCthresholds))
684  ) {
685 
686  WindowTriggerInfo_t const triggerInfo
687  = produceForThreshold(event, detTimings, beamGate, iThr, thrTag);
688 
689  log << "\n * threshold " << thrTag << ": ";
690  if (triggerInfo) log << "trigger at " << triggerInfo.info.atTick();
691  else log << "not triggered";
692 
693  } // for
694 
695  plotEvent(event, detTimings);
696 
697  ++fTotalEvents;
698 
699 } // icarus::trigger::SlidingWindowTriggerSimulation::produce()
void plotEvent(art::Event const &event, detinfo::DetectorTimings const &detTimings)
Fills event-wide plots.
std::map< std::string, art::InputTag > fADCthresholds
Name of ADC thresholds to read, and the input tag connected to their data.
icarus::trigger::ApplyBeamGateClass makeMyBeamGate(detinfo::DetectorClocksData data) const
Shortcut to create an ApplyBeamGate with the current configuration.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::atomic< unsigned int > fTotalEvents
Count of opened gates.
icarus::trigger::SlidingWindowPatternAlg::AllTriggerInfo_t WindowTriggerInfo_t
Data structure to communicate internally a trigger response.
Contains all timing reference information for the detector.
WindowTriggerInfo_t produceForThreshold(art::Event &event, detinfo::DetectorTimings const &detTimings, ApplyBeamGateClass const &beamGate, std::size_t const iThr, std::string const &thrTag)
Performs the simulation for the specified ADC threshold.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
std::string const fLogCategory
Message facility stream category for output.
fDetProps &fDetProps fDetProps &fDetProps detTimings
icarus::ns::util::ThreadSafeChangeMonitor< icarus::trigger::ApplyBeamGateClass > fGateChangeCheck
Functor returning whether a gate has changed.
auto icarus::trigger::SlidingWindowTriggerSimulation::produceForThreshold ( art::Event &  event,
detinfo::DetectorTimings const &  detTimings,
ApplyBeamGateClass const &  beamGate,
std::size_t const  iThr,
std::string const &  thrTag 
)
private

Performs the simulation for the specified ADC threshold.

Parameters
eventart event to read data from and put results into
iThrindex of the threshold in the configuration
thrvalue of the threshold (ADC counts)
Returns
the trigger response information

For the given threshold, the simulation of the configured trigger is performed. The input data is read from the event (the source tag is from the module configuration), simulation is performed, auxiliary plots are drawn and a raw::Trigger collection is stored into the event.

The stored collection contains either one or zero raw::Trigger elements.

The simulation itself is performed by the simulate() method.

Definition at line 954 of file SlidingWindowTriggerSimulation_module.cc.

959  {
960 
961  auto& plotInfo = fThresholdPlots[iThr];
962 
963  //
964  // get the input
965  //
966  art::InputTag const& dataTag = fADCthresholds.at(thrTag);
967  auto const& gates = readTriggerGates(event, dataTag);
968 
969 
970  // extract or verify the topology of the trigger windows
971  if (fWindowMapMan(gates))
973  assert(fPatternAlg);
974 
975  //
976  // simulate the trigger response
977  //
978  WindowTriggerInfo_t const triggerInfo
979  = fPatternAlg->simulateResponse(beamGate.applyToAll(gates));
980  if (triggerInfo) {
981  ++fTriggerCount[iThr]; // keep the unique count
982  plotInfo.eventTimes.add(eventTimestampInSeconds(event));
983  }
984 
985  //
986  // fill the plots
987  //
988  plotTriggerResponse(iThr, thrTag, triggerInfo, detTimings);
989 
990  //
991  // create and store the data product
992  //
993  auto triggers = std::make_unique<std::vector<raw::Trigger>>();
994  if (triggerInfo.info.fired()) {
995  triggers->push_back
996  (triggerInfoToTriggerData(detTimings, fTriggerCount[iThr], triggerInfo));
997  } // if
998  event.put(std::move(triggers), fOutputInstances[iThr]);
999 
1000  return triggerInfo;
1001 
1002 } // icarus::trigger::SlidingWindowTriggerSimulation::produceForThreshold()
icarus::trigger::WindowTopologyManager fWindowMapMan
Mapping of each sliding window with location and topological information.
std::map< std::string, art::InputTag > fADCthresholds
Name of ADC thresholds to read, and the input tag connected to their data.
static TriggerGates_t readTriggerGates(art::Event const &event, art::InputTag const &dataTag)
std::vector< ThresholdPlotInfo_t > fThresholdPlots
Proto-histogram information in a not-so-practical array; per threshold.
void plotTriggerResponse(std::size_t iThr, std::string const &thrTag, WindowTriggerInfo_t const &triggerInfo, detinfo::DetectorTimings const &detTimings)
Fills the plots for threshold index iThr with trigger information.
raw::Trigger triggerInfoToTriggerData(detinfo::DetectorTimings const &detTimings, unsigned int triggerNumber, WindowTriggerInfo_t const &info) const
Converts the trigger information into a raw::Trigger object.
icarus::trigger::SlidingWindowPatternAlg::AllTriggerInfo_t WindowTriggerInfo_t
Data structure to communicate internally a trigger response.
WindowPattern const fPattern
Configured sliding window requirement pattern.
std::string const fLogCategory
Message facility stream category for output.
std::vector< std::string > fOutputInstances
Output data product instance names (same order as fADCthresholds).
fDetProps &fDetProps fDetProps &fDetProps detTimings
std::optional< icarus::trigger::SlidingWindowPatternAlg > fPatternAlg
Pattern algorithm.
static double eventTimestampInSeconds(art::Timestamp const &time)
Returns the time of the event in seconds from The Epoch.
auto icarus::trigger::SlidingWindowTriggerSimulation::readTriggerGates ( art::Event const &  event,
art::InputTag const &  dataTag 
)
staticprivate

Reads a set of input gates from the event

Returns
trigger gates, converted into InputTriggerGate_t

Definition at line 1119 of file SlidingWindowTriggerSimulation_module.cc.

1121 {
1122 
1123  using icarus::trigger::OpticalTriggerGateData_t; // for convenience
1124 
1125  // currently the associations are a waste of time memory...
1126  auto const& gates
1127  = event.getProduct<std::vector<OpticalTriggerGateData_t>>(dataTag);
1128  auto const& gateToWaveforms = event.getProduct
1129  <art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>(dataTag);
1130 
1131  try {
1132  return icarus::trigger::FillTriggerGates(gates, gateToWaveforms);
1133  }
1134  catch (cet::exception const& e) {
1135  throw cet::exception("SlidingWindowTriggerSimulation", "", e)
1136  << "Error encountered while reading data products from '"
1137  << dataTag.encode() << "'\n";
1138  }
1139 
1140 } // icarus::trigger::SlidingWindowTriggerSimulation::readTriggerGates()
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.
raw::Trigger icarus::trigger::SlidingWindowTriggerSimulation::triggerInfoToTriggerData ( detinfo::DetectorTimings const &  detTimings,
unsigned int  triggerNumber,
WindowTriggerInfo_t const &  info 
) const
private

Converts the trigger information into a raw::Trigger object.

Parameters
triggerNumberthe unique number to assign to this trigger
infothe information about the fired trigger
Returns
a raw::Trigger object with all the information encoded

The trigger described by info is encoded into a raw::Trigger object. The trigger must have fired.

Definition at line 1102 of file SlidingWindowTriggerSimulation_module.cc.

1104 {
1105  assert(info.info.fired());
1106 
1107  return {
1108  triggerNumber, // counter
1109  double(detTimings.toElectronicsTime(info.info.atTick())), // trigger time
1110  double(detTimings.BeamGateTime()), // beam gate in electronics time scale
1111  fBeamBits // bits
1112  };
1113 
1114 } // icarus::trigger::SlidingWindowTriggerSimulation::triggerInfoToTriggerData()
std::uint32_t fBeamBits
Bits for the beam gate being simulated.
fDetProps &fDetProps fDetProps &fDetProps detTimings

Member Data Documentation

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

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

Definition at line 382 of file SlidingWindowTriggerSimulation_module.cc.

std::uint32_t icarus::trigger::SlidingWindowTriggerSimulation::fBeamBits
private

Bits for the beam gate being simulated.

Definition at line 393 of file SlidingWindowTriggerSimulation_module.cc.

microseconds icarus::trigger::SlidingWindowTriggerSimulation::fBeamGateDuration
private

Duration of the gate during with global optical triggers are accepted.

Definition at line 388 of file SlidingWindowTriggerSimulation_module.cc.

microseconds icarus::trigger::SlidingWindowTriggerSimulation::fBeamGateStart
private

Start of the beam gate with respect to BeamGate().

Definition at line 391 of file SlidingWindowTriggerSimulation_module.cc.

ThresholdPlotInfo_t icarus::trigger::SlidingWindowTriggerSimulation::fEventPlotInfo
private

Proto-histogram information in a convenient packet; event-wide.

Definition at line 429 of file SlidingWindowTriggerSimulation_module.cc.

double icarus::trigger::SlidingWindowTriggerSimulation::fEventTimeBinning
private

Trigger time plot binning [s].

Definition at line 397 of file SlidingWindowTriggerSimulation_module.cc.

icarus::ns::util::ThreadSafeChangeMonitor<icarus::trigger::ApplyBeamGateClass> icarus::trigger::SlidingWindowTriggerSimulation::fGateChangeCheck
private

Functor returning whether a gate has changed.

Definition at line 441 of file SlidingWindowTriggerSimulation_module.cc.

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

Message facility stream category for output.

Definition at line 400 of file SlidingWindowTriggerSimulation_module.cc.

art::TFileDirectory icarus::trigger::SlidingWindowTriggerSimulation::fOutputDir
private

ROOT directory where all the plots are written.

Definition at line 408 of file SlidingWindowTriggerSimulation_module.cc.

std::vector<std::string> icarus::trigger::SlidingWindowTriggerSimulation::fOutputInstances
private

Output data product instance names (same order as fADCthresholds).

Definition at line 416 of file SlidingWindowTriggerSimulation_module.cc.

WindowPattern const icarus::trigger::SlidingWindowTriggerSimulation::fPattern
private

Configured sliding window requirement pattern.

Definition at line 385 of file SlidingWindowTriggerSimulation_module.cc.

std::optional<icarus::trigger::SlidingWindowPatternAlg> icarus::trigger::SlidingWindowTriggerSimulation::fPatternAlg
private

Pattern algorithm.

Definition at line 423 of file SlidingWindowTriggerSimulation_module.cc.

icarus::trigger::PlotSandbox icarus::trigger::SlidingWindowTriggerSimulation::fPlots
private

All plots in one practical sandbox.

Definition at line 426 of file SlidingWindowTriggerSimulation_module.cc.

std::vector<ThresholdPlotInfo_t> icarus::trigger::SlidingWindowTriggerSimulation::fThresholdPlots
private

Proto-histogram information in a not-so-practical array; per threshold.

Count of fired triggers, per threshold.

Definition at line 432 of file SlidingWindowTriggerSimulation_module.cc.

std::atomic<unsigned int> icarus::trigger::SlidingWindowTriggerSimulation::fTotalEvents { 0U }
private

Count of opened gates.

Definition at line 436 of file SlidingWindowTriggerSimulation_module.cc.

std::vector<std::atomic<unsigned int> > icarus::trigger::SlidingWindowTriggerSimulation::fTriggerCount
private

Definition at line 435 of file SlidingWindowTriggerSimulation_module.cc.

nanoseconds icarus::trigger::SlidingWindowTriggerSimulation::fTriggerTimeResolution
private

Trigger resolution in time.

Definition at line 395 of file SlidingWindowTriggerSimulation_module.cc.

icarus::trigger::WindowTopologyManager icarus::trigger::SlidingWindowTriggerSimulation::fWindowMapMan
mutableprivate

Mapping of each sliding window with location and topological information.

Definition at line 420 of file SlidingWindowTriggerSimulation_module.cc.


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