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

Simulates a "majority" trigger. More...

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

Classes

struct  Config
 

Public Types

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

Public Member Functions

 MajorityTriggerSimulation (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::TrackedOpticalTriggerGate< sbn::OpDetWaveformMeta >
 Type of trigger gate extracted from the input event. More...
 
using TriggerGates_t = std::vector< InputTriggerGate_t >
 A list of trigger gates from input. More...
 

Private Member Functions

void initializePlots ()
 Initializes the full set of plots (all ADC thresholds). More...
 
TriggerInfo_t produceForThreshold (art::Event &event, detinfo::DetectorTimings const &detTimings, ApplyBeamGateClass const &beamGate, std::size_t const iThr, icarus::trigger::ADCCounts_t const thr)
 Performs the simulation for the specified ADC threshold. More...
 
TriggerInfo_t simulate (ApplyBeamGateClass const &clockData, TriggerGates_t const &gates) const
 Performs the simulation of the configured trigger on gates input. More...
 
TriggerInfo_t simulateCryostat (ApplyBeamGateClass const &beamGate, std::size_t iCryo, TriggerGates_t const &gates) const
 Simulates the trigger response within a single cryostat. More...
 
raw::Trigger triggerInfoToTriggerData (detinfo::DetectorTimings const &detTimings, unsigned int triggerNumber, TriggerInfo_t const &info) const
 Converts the trigger information into a raw::Trigger object. More...
 
void plotTriggerResponse (std::size_t iThr, TriggerInfo_t const &triggerInfo) const
 Fills the plots for threshold index iThr with trigger information. More...
 
void printSummary () const
 Prints the summary of fired triggers on screen. More...
 
icarus::trigger::ApplyBeamGateClass makeMyBeamGate (art::Event const *event=nullptr) const
 Shortcut to create an ApplyBeamGate with the current configuration. More...
 
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
 

Private Attributes

std::map
< icarus::trigger::ADCCounts_t,
art::InputTag > 
fADCthresholds
 ADC thresholds to read, and the input tag connected to their data. More...
 
unsigned int const fMinimumPrimitives
 Minimum number of trigger primitives for a trigger to happen. More...
 
microseconds fBeamGateDuration
 Duration of the gate during with global optical triggers are accepted. More...
 
nanoseconds fTriggerTimeResolution
 Trigger resolution in time. More...
 
std::uint32_t fBeamBits
 Bits for the beam gate being simulated. More...
 
std::string const fLogCategory
 Message facility stream category for output. More...
 
geo::GeometryCore const & fGeom
 
art::TFileDirectory fOutputDir
 ROOT directory where all the plots are written. More...
 
MajorityTriggerCombiner const fCombiner
 Algorithm to combine primitives. More...
 
GeometryChannelSplitter fChannelSplitter
 Algorithm to sort trigger gates by cryostat or TPC. More...
 
icarus::trigger::PlotSandbox fPlots
 All plots in one practical sandbox. More...
 
std::vector< std::atomic
< unsigned int > > 
fTriggerCount
 
std::atomic< unsigned int > fTotalEvents { 0U }
 Count of fired triggers. More...
 
icarus::ns::util::ThreadSafeChangeMonitor
< icarus::trigger::ApplyBeamGateClass
fGateChangeCheck
 Functor returning whether a gate has changed. More...
 

Detailed Description

Simulates a "majority" trigger.

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.

This module simulates a trigger requesting a minimum number of single trigger requests in the event, and saves the result as raw::Trigger data products. While only one trigger definition is used, inputs with different thresholds may be specified to have the different responses.

Configuration

An example job configuration is provided as simulatemajoritytriggers_icarus.fcl.

Output data products

Trigger logic algorithm

This section describes the trigger logic algorithm used in icarus::trigger::MajorityTriggerSimulation and its assumptions.

The algorithm keeps the trigger primitives from the different cryostats separate for the most time. Within each cryostat, all trigger primitives are treated equally, whether they originate from one or from two channels (or 10 or 30), and wherever their channels are in the cryostat. The trigger primitives in each cryostat are combined in a multi-level gate by adding them, so that the level of the resulting gate matches at any time how many trigger primitives are on at that time. Finally, the maximum number of trigger primitives open in any of the cryostats at each time is the level to be compared to the trigger requirements.

This multi-level gate is set in coincidence with the beam gate by multiplying the multi-level and the beam gates. The beam gate opens at a time configured in DetectorClocks service provider (detinfo::DetectorClocks::BeamGateTime()) and has a duration configured in this module (BeamGateDuration).

At this point, the trigger gate is a multi-level gate suppressed everywhere except than during the beam gate. The trigger requirement is simply how many trigger primitives must be open at the same time in a single cryostat for the trigger to fire. The requirement is set in the configuration (MinimumPrimitives). To determine whether a trigger with the given minimum number of primitives open at the same time has fired, the gate combined as described above is scanned to find the first tick where the level of the gate reaches or passes this minimum required number. If such tick exists, the trigger is considered to have fired, and at that time.

While there is a parameter describing the time resolution of the trigger (TriggerTimeResolution), this is currently only used for aesthetic purposes to choose the binning of some plots: the resolution is not superimposed to the gates (yet).

Output plots

Plots are directly stored in the producer folder of the TFileService ROOT output file.

Summary plots are generated:

The plots marked "per threshold" have a "threshold" axis where each bin corresponds to the threshold specified in the Thresholds configuration parameter. Note that the numerical value of the axis on that bin does not match the threshold value.

Definition at line 342 of file MajorityTriggerSimulation_module.cc.

Member Typedef Documentation

Type of trigger gate extracted from the input event.

Definition at line 434 of file MajorityTriggerSimulation_module.cc.

Definition at line 349 of file MajorityTriggerSimulation_module.cc.

Definition at line 350 of file MajorityTriggerSimulation_module.cc.

Definition at line 398 of file MajorityTriggerSimulation_module.cc.

A list of trigger gates from input.

Definition at line 437 of file MajorityTriggerSimulation_module.cc.

Type alias.

Definition at line 430 of file MajorityTriggerSimulation_module.cc.

Constructor & Destructor Documentation

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

Definition at line 605 of file MajorityTriggerSimulation_module.cc.

606  : art::EDProducer (config)
607  // configuration
608  , fMinimumPrimitives (config().MinimumPrimitives())
609  , fBeamGateDuration (config().BeamGateDuration())
610  , fTriggerTimeResolution(config().TriggerTimeResolution())
611  , fBeamBits (config().BeamBits())
612  , fLogCategory (config().LogCategory())
613  // services
614  , fGeom (*lar::providerFrom<geo::Geometry>())
615  , fOutputDir (*art::ServiceHandle<art::TFileService>())
616  // internal and cached
619  , fPlots(
620  fOutputDir, "", "minimum primitives: " + std::to_string(fMinimumPrimitives)
621  )
622 {
623 
624  //
625  // more complex parameter parsing
626  //
627  std::string const discrModuleLabel = config().TriggerGatesTag();
628  for (raw::ADC_Count_t threshold: config().Thresholds()) {
630  = art::InputTag{ discrModuleLabel, util::to_string(threshold) };
631  }
632 
633  // initialization of a vector of atomic is not as trivial as it sounds...
634  fTriggerCount = std::vector<std::atomic<unsigned int>>(fADCthresholds.size());
635  std::fill(fTriggerCount.begin(), fTriggerCount.end(), 0U);
636 
637 
638  //
639  // input data declaration
640  //
641  using icarus::trigger::OpticalTriggerGateData_t; // for convenience
642 
643  // trigger primitives
644  for (art::InputTag const& inputDataTag: util::const_values(fADCthresholds)) {
645  consumes<std::vector<OpticalTriggerGateData_t>>(inputDataTag);
646  consumes<art::Assns<OpticalTriggerGateData_t, raw::OpDetWaveform>>
647  (inputDataTag);
648  } // for
649 
650  //
651  // output data declaration
652  //
653  for (art::InputTag const& inputDataTag: util::const_values(fADCthresholds))
654  produces<std::vector<raw::Trigger>>(inputDataTag.instance());
655 
656 
657  mf::LogInfo(fLogCategory)
658  << "Requirement of minimum " << fMinimumPrimitives << " primitives.";
659 
660 
661 } // icarus::trigger::MajorityTriggerSimulation::MajorityTriggerSimulation()
BEGIN_PROLOG BeamGateDuration pmtthr physics producers trigtilewindowORS Thresholds
std::vector< std::atomic< unsigned int > > fTriggerCount
std::string const fLogCategory
Message facility stream category for output.
art::TFileDirectory fOutputDir
ROOT directory where all the plots are written.
std::map< icarus::trigger::ADCCounts_t, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
decltype(auto) const_values(Coll &&coll)
Range-for loop helper iterating across the constant values of the specified collection.
unsigned int const fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
A value measured in the specified unit.
Definition: quantities.h:566
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
std::uint32_t fBeamBits
Bits for the beam gate being simulated.
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
GeometryChannelSplitter fChannelSplitter
Algorithm to sort trigger gates by cryostat or TPC.
std::string to_string(WindowPattern const &pattern)
microseconds fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
MajorityTriggerCombiner const fCombiner
Algorithm to combine primitives.
nanoseconds fTriggerTimeResolution
Trigger resolution in time.
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.

Member Function Documentation

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

Initializes the plots.

Definition at line 665 of file MajorityTriggerSimulation_module.cc.

665  {
666 
667  initializePlots();
668 
669 } // icarus::trigger::MajorityTriggerSimulation::beginJob()
void initializePlots()
Initializes the full set of plots (all ADC thresholds).
void icarus::trigger::MajorityTriggerSimulation::endJob ( )
overridevirtual

Prints end-of-job summaries.

Definition at line 707 of file MajorityTriggerSimulation_module.cc.

707  {
708 
709  printSummary();
710 
711 } // icarus::trigger::MajorityTriggerSimulation::endJob()
void printSummary() const
Prints the summary of fired triggers on screen.
void icarus::trigger::MajorityTriggerSimulation::initializePlots ( )
private

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

Definition at line 715 of file MajorityTriggerSimulation_module.cc.

715  {
716 
717  //
718  // overview plots with different settings
719  //
720 
721  std::vector<std::string> thresholdLabels;
722  thresholdLabels.reserve(size(fADCthresholds));
723  for (art::InputTag const& inputDataTag: util::const_values(fADCthresholds))
724  thresholdLabels.push_back(inputDataTag.instance());
725 
726  auto const beamGate = makeMyBeamGate();
727  fGateChangeCheck(beamGate);
728  mf::LogInfo(fLogCategory)
729  << "Beam gate for plots: " << beamGate.asSimulationTime()
730  << " (simulation time), " << beamGate.tickRange()
731  << " (optical ticks)"
732  ;
733 
734  //
735  // Triggering efficiency vs. ADC threshold.
736  //
737  auto* NTriggers = fPlots.make<TH1F>(
738  "NTriggers",
739  "Number of triggering events"
740  ";PMT discrimination threshold [ ADC counts ]"
741  ";events",
742  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
743  );
744  util::ROOT::applyAxisLabels(NTriggers->GetXaxis(), thresholdLabels);
745 
746  auto* Eff = fPlots.make<TEfficiency>(
747  "Eff",
748  "Efficiency of triggering"
749  ";PMT discrimination threshold [ ADC counts ]"
750  ";trigger efficiency",
751  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
752  );
753  // people are said to have earned hell for things like this;
754  // but TEfficiency really does not expose the interface to assign labels to
755  // its axes, which supposedly could be done had we chosen to create it by
756  // histograms instead of directly as recommended.
758  (const_cast<TH1*>(Eff->GetTotalHistogram())->GetXaxis(), thresholdLabels);
759 
760  detinfo::timescales::optical_time_ticks const triggerResolutionTicks{
762  };
763 
764  auto const& beamGateTicks = beamGate.tickRange();
765  auto* TrigTime = fPlots.make<TH2F>(
766  "TriggerTick",
767  "Trigger time tick"
768  ";optical time tick [ /" + util::to_string(triggerResolutionTicks) + " ]"
769  ";PMT discrimination threshold [ ADC counts ]"
770  ";events",
771  static_cast<int>(std::ceil(beamGate.lengthTicks()/triggerResolutionTicks)),
772  beamGateTicks.start().value(),
774  (beamGateTicks.start() + beamGate.lengthTicks(), triggerResolutionTicks)
775  .value(),
776  thresholdLabels.size(), 0.0, double(thresholdLabels.size())
777  );
778  util::ROOT::applyAxisLabels(TrigTime->GetYaxis(), thresholdLabels);
779 
780 
781 } // icarus::trigger::MajorityTriggerSimulation::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
std::string const fLogCategory
Message facility stream category for output.
constexpr T roundup(T const value, U const quantum, T const offset=T{})
Returns the value, rounded up.
Definition: rounding.h:112
std::map< icarus::trigger::ADCCounts_t, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
decltype(auto) const_values(Coll &&coll)
Range-for loop helper iterating across the constant values of the specified collection.
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
icarus::trigger::ApplyBeamGateClass makeMyBeamGate(art::Event const *event=nullptr) const
Shortcut to create an ApplyBeamGate with the current configuration.
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
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.
icarus::ns::util::ThreadSafeChangeMonitor< icarus::trigger::ApplyBeamGateClass > fGateChangeCheck
Functor returning whether a gate has changed.
temporary value
nanoseconds fTriggerTimeResolution
Trigger resolution in time.
detinfo::DetectorTimings makeDetTimings(art::Event const *event)
Returns a detinfo::DetectorTimings from DetectorClocksService.
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.
icarus::trigger::ApplyBeamGateClass icarus::trigger::MajorityTriggerSimulation::makeMyBeamGate ( art::Event const *  event = nullptr) const
inlineprivate

Shortcut to create an ApplyBeamGate with the current configuration.

Definition at line 584 of file MajorityTriggerSimulation_module.cc.

585  {
586  return makeApplyBeamGate(
590  );
591  }
std::string const fLogCategory
Message facility stream category for output.
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 fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
detinfo::DetectorClocksData makeDetClockData(art::Event const *event)
Returns a detinfo::DetectorClocksData from DetectorClocksService.
icarus::trigger::ApplyBeamGateClass icarus::trigger::MajorityTriggerSimulation::makeMyBeamGate ( art::Event const &  event) const
inlineprivate

Definition at line 593 of file MajorityTriggerSimulation_module.cc.

593 { return makeMyBeamGate(&event); }
icarus::trigger::ApplyBeamGateClass makeMyBeamGate(art::Event const *event=nullptr) const
Shortcut to create an ApplyBeamGate with the current configuration.
void icarus::trigger::MajorityTriggerSimulation::plotTriggerResponse ( std::size_t  iThr,
TriggerInfo_t const &  triggerInfo 
) const
private

Fills the plots for threshold index iThr with trigger information.

Definition at line 887 of file MajorityTriggerSimulation_module.cc.

888 {
889 
890  fPlots.demand<TEfficiency>("Eff").Fill(triggerInfo.fired(), iThr);
891 
892  if (triggerInfo.fired()) {
893  fPlots.demand<TH1>("NTriggers").Fill(iThr);
894  fPlots.demand<TH2>("TriggerTick").Fill(triggerInfo.atTick().value(), iThr);
895  }
896 
897 } // icarus::trigger::MajorityTriggerSimulation::plotTriggerResponse()
Obj & demand(std::string const &name) const
Fetches an object with the specified name to be modified.
Definition: PlotSandbox.h:667
icarus::trigger::PlotSandbox fPlots
All plots in one practical sandbox.
void icarus::trigger::MajorityTriggerSimulation::printSummary ( ) const
private

Prints the summary of fired triggers on screen.

Definition at line 901 of file MajorityTriggerSimulation_module.cc.

901  {
902 
903  //
904  // summary from our internal counters
905  //
906  mf::LogInfo log(fLogCategory);
907  log
908  << "Summary of triggers requiring " << fMinimumPrimitives
909  << "+ primitives for " << fTriggerCount.size() << " ADC thresholds:"
910  ;
911  for (auto const& [ count, thr ]
912  : util::zip(fTriggerCount, util::get_elements<0U>(fADCthresholds)))
913  {
914  log << "\n ADC threshold " << thr
915  << ": " << count << " events triggered";
916  if (fTotalEvents > 0U)
917  log << " (" << (double(count) / fTotalEvents * 100.0) << "%)";
918  } // for
919 
920 } // icarus::trigger::MajorityTriggerSimulation::printSummary()
std::vector< std::atomic< unsigned int > > fTriggerCount
std::string const fLogCategory
Message facility stream category for output.
std::map< icarus::trigger::ADCCounts_t, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
unsigned int const fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
std::atomic< unsigned int > fTotalEvents
Count of fired triggers.
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)
void icarus::trigger::MajorityTriggerSimulation::produce ( art::Event &  event)
overridevirtual

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

Definition at line 673 of file MajorityTriggerSimulation_module.cc.

673  {
674 
675  mf::LogDebug log(fLogCategory);
676  log << "Event " << event.id() << ":";
677 
678  auto const clockData
679  = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
680  detinfo::DetectorTimings const detTimings{clockData};
681  auto const beamGate = makeMyBeamGate(event);
682 
683  if (auto oldGate = fGateChangeCheck(beamGate); oldGate) {
684  mf::LogWarning(fLogCategory)
685  << "Beam gate has changed from " << *oldGate << " to " << beamGate << "!";
686  }
687 
688 
689  for (auto const [ iThr, thr ]
690  : util::enumerate(util::get_elements<0U>(fADCthresholds))
691  ) {
692 
693  TriggerInfo_t const triggerInfo = produceForThreshold(event, detTimings, beamGate, iThr, thr);
694 
695  log << "\n * threshold " << thr << ": ";
696  if (triggerInfo) log << "trigger at " << triggerInfo.atTick();
697  else log << "not triggered";
698 
699  } // for
700 
701  ++fTotalEvents;
702 
703 } // icarus::trigger::MajorityTriggerSimulation::produce()
std::string const fLogCategory
Message facility stream category for output.
std::map< icarus::trigger::ADCCounts_t, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
icarus::trigger::ApplyBeamGateClass makeMyBeamGate(art::Event const *event=nullptr) 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
icarus::ns::util::ThreadSafeChangeMonitor< icarus::trigger::ApplyBeamGateClass > fGateChangeCheck
Functor returning whether a gate has changed.
std::atomic< unsigned int > fTotalEvents
Count of fired triggers.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
fDetProps &fDetProps fDetProps &fDetProps detTimings
TriggerInfo_t produceForThreshold(art::Event &event, detinfo::DetectorTimings const &detTimings, ApplyBeamGateClass const &beamGate, std::size_t const iThr, icarus::trigger::ADCCounts_t const thr)
Performs the simulation for the specified ADC threshold.
auto icarus::trigger::MajorityTriggerSimulation::produceForThreshold ( art::Event &  event,
detinfo::DetectorTimings const &  detTimings,
ApplyBeamGateClass const &  beamGate,
std::size_t const  iThr,
icarus::trigger::ADCCounts_t const  thr 
)
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
a simple copy of 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 785 of file MajorityTriggerSimulation_module.cc.

790  {
791 
792  //
793  // get the input
794  //
795  art::InputTag const dataTag = fADCthresholds.at(thr);
796  auto const& gates = icarus::trigger::ReadTriggerGates(event, dataTag);
797 
798  //
799  // simulate the trigger response
800  //
801  TriggerInfo_t const triggerInfo = simulate(beamGate, gates);
802  if (triggerInfo) ++fTriggerCount[iThr]; // keep the unique count
803 
804  //
805  // fill the plots
806  //
807  plotTriggerResponse(iThr, triggerInfo);
808 
809  //
810  // create and store the data product
811  //
812  auto triggers = std::make_unique<std::vector<raw::Trigger>>();
813  if (triggerInfo.fired()) {
814  triggers->push_back
815  (triggerInfoToTriggerData(detTimings, fTriggerCount[iThr], triggerInfo));
816  } // if
817  event.put(std::move(triggers), dataTag.instance());
818 
819  return triggerInfo;
820 
821 } // icarus::trigger::MajorityTriggerSimulation::produceForThreshold()
std::vector< std::atomic< unsigned int > > fTriggerCount
TriggerInfo_t simulate(ApplyBeamGateClass const &clockData, TriggerGates_t const &gates) const
Performs the simulation of the configured trigger on gates input.
std::map< icarus::trigger::ADCCounts_t, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
raw::Trigger triggerInfoToTriggerData(detinfo::DetectorTimings const &detTimings, unsigned int triggerNumber, TriggerInfo_t const &info) const
Converts the trigger information into a raw::Trigger object.
void plotTriggerResponse(std::size_t iThr, TriggerInfo_t const &triggerInfo) const
Fills the plots for threshold index iThr with trigger information.
fDetProps &fDetProps fDetProps &fDetProps detTimings
std::vector< icarus::trigger::TrackedOpticalTriggerGate< OpDetInfo > > ReadTriggerGates(Event const &event, art::InputTag const &dataTag)
Assembles and returns trigger gates from serialized data.
auto icarus::trigger::MajorityTriggerSimulation::simulate ( ApplyBeamGateClass const &  clockData,
TriggerGates_t const &  gates 
) const
private

Performs the simulation of the configured trigger on gates input.

Parameters
gatesthe input to the trigger simulation
Returns
the outcome and details of the trigger simulation

The simulation is performed using the input single trigger requests (or trigger primitives) from the gates collection.

The gates are split by cryostat, and the simulation is performed independently on each cryostat (simulateCryostat()). Finally, the cryostat triggers are combined (OR) into the final trigger decision, bearing as time the earliest one.

Definition at line 826 of file MajorityTriggerSimulation_module.cc.

828 {
829 
830  /*
831  * 1. split the input by cryostat
832  * 2. simulate the cryostat trigger
833  * 3. combine the responses (earliest wins)
834  */
835 
836  // to use the splitter we need a *copy* of the gates
837  auto const& cryoGates = fChannelSplitter.byCryostat(TriggerGates_t{ gates });
838 
839  TriggerInfo_t triggerInfo; // not fired by default
840  for (auto const& [ iCryo, gatesInCryo ]: util::enumerate(cryoGates)) {
841 
842  triggerInfo.addAndReplaceIfEarlier
843  (simulateCryostat(beamGate, iCryo, gatesInCryo));
844 
845  } // for gates in cryostat
846 
847  triggerInfo.sortOpenings();
848 
849  return triggerInfo;
850 
851 } // icarus::trigger::MajorityTriggerSimulation::simulate()
bool addAndReplaceIfEarlier(TriggerInfo_t const &other)
If other has fired, and at an earlier tick, set a new main().
TriggerInfo_t simulateCryostat(ApplyBeamGateClass const &beamGate, std::size_t iCryo, TriggerGates_t const &gates) const
Simulates the trigger response within a single cryostat.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::vector< std::vector< GateObj > > byCryostat(std::vector< GateObj > &&gates) const
Splits the gates by cryostat.
GeometryChannelSplitter fChannelSplitter
Algorithm to sort trigger gates by cryostat or TPC.
std::vector< InputTriggerGate_t > TriggerGates_t
A list of trigger gates from input.
auto icarus::trigger::MajorityTriggerSimulation::simulateCryostat ( ApplyBeamGateClass const &  beamGate,
std::size_t  iCryo,
TriggerGates_t const &  gates 
) const
private

Simulates the trigger response within a single cryostat.

Parameters
beamGatethe beam gate to be applied
iCryoindex of the cryostat being processed
gatesthe trigger primitives to be considered
Returns
the outcome and details of the trigger simulation

The simulation computes the count of trigger gates open at any time, sets it in coincidence with the beam gate, and fires a trigger if within that gate the count of open gates is equal or larger than the threshold configured (MinimumPrimitives). The time is the earliest one when that requirement is met.

Definition at line 855 of file MajorityTriggerSimulation_module.cc.

860 {
862 
863  /*
864  * 1. combine the trigger primitives
865  * 2. apply the beam gate on the combination
866  * 3. compute the trigger response
867  */
868 
869  auto const combinedCount = beamGate.apply(fCombiner.combine(gates));
870 
871  TriggerInfo_t triggerInfo;
873  { combinedCount, fMinimumPrimitives };
874  extractOpeningInfo.setLocation(iCryo);
875  while (extractOpeningInfo) {
876  auto info = extractOpeningInfo();
877  if (info) triggerInfo.add(info.value());
878  } // while
879 
880  return triggerInfo;
881 
882 } // icarus::trigger::MajorityTriggerSimulation::simulateCryostat()
unsigned int const fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
GateObj combine(std::vector< GateObj > const &gates) const
Combines all the gates (by cryostat) in a single majority gate.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
MajorityTriggerCombiner const fCombiner
Algorithm to combine primitives.
Helper to extract OpeningInfo_t from a trigger gate.
Definition: TriggerInfo_t.h:30
raw::Trigger icarus::trigger::MajorityTriggerSimulation::triggerInfoToTriggerData ( detinfo::DetectorTimings const &  detTimings,
unsigned int  triggerNumber,
TriggerInfo_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 926 of file MajorityTriggerSimulation_module.cc.

928 {
929  assert(info.fired());
930 
931  return {
932  triggerNumber, // counter
933  double(detTimings.toElectronicsTime(info.atTick())), // trigger time
934  double(detTimings.BeamGateTime()), // beam gate in electronics time scale
935  fBeamBits // bits
936  };
937 
938 } // icarus::trigger::MajorityTriggerSimulation::triggerInfoToTriggerData()
std::uint32_t fBeamBits
Bits for the beam gate being simulated.
fDetProps &fDetProps fDetProps &fDetProps detTimings

Member Data Documentation

std::map<icarus::trigger::ADCCounts_t, art::InputTag> icarus::trigger::MajorityTriggerSimulation::fADCthresholds
private

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

Definition at line 443 of file MajorityTriggerSimulation_module.cc.

std::uint32_t icarus::trigger::MajorityTriggerSimulation::fBeamBits
private

Bits for the beam gate being simulated.

Definition at line 453 of file MajorityTriggerSimulation_module.cc.

microseconds icarus::trigger::MajorityTriggerSimulation::fBeamGateDuration
private

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

Definition at line 449 of file MajorityTriggerSimulation_module.cc.

GeometryChannelSplitter icarus::trigger::MajorityTriggerSimulation::fChannelSplitter
private

Algorithm to sort trigger gates by cryostat or TPC.

Definition at line 475 of file MajorityTriggerSimulation_module.cc.

MajorityTriggerCombiner const icarus::trigger::MajorityTriggerSimulation::fCombiner
private

Algorithm to combine primitives.

Definition at line 472 of file MajorityTriggerSimulation_module.cc.

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

Functor returning whether a gate has changed.

Definition at line 488 of file MajorityTriggerSimulation_module.cc.

geo::GeometryCore const& icarus::trigger::MajorityTriggerSimulation::fGeom
private

Definition at line 462 of file MajorityTriggerSimulation_module.cc.

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

Message facility stream category for output.

Definition at line 456 of file MajorityTriggerSimulation_module.cc.

unsigned int const icarus::trigger::MajorityTriggerSimulation::fMinimumPrimitives
private

Minimum number of trigger primitives for a trigger to happen.

Definition at line 446 of file MajorityTriggerSimulation_module.cc.

art::TFileDirectory icarus::trigger::MajorityTriggerSimulation::fOutputDir
private

ROOT directory where all the plots are written.

Definition at line 465 of file MajorityTriggerSimulation_module.cc.

icarus::trigger::PlotSandbox icarus::trigger::MajorityTriggerSimulation::fPlots
private

All plots in one practical sandbox.

Count of fired triggers, per threshold.

Definition at line 478 of file MajorityTriggerSimulation_module.cc.

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

Count of fired triggers.

Definition at line 482 of file MajorityTriggerSimulation_module.cc.

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

Definition at line 481 of file MajorityTriggerSimulation_module.cc.

nanoseconds icarus::trigger::MajorityTriggerSimulation::fTriggerTimeResolution
private

Trigger resolution in time.

Definition at line 451 of file MajorityTriggerSimulation_module.cc.


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