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

Produces plots about trigger simulation and trigger efficiency. More...

Inheritance diagram for icarus::trigger::MajorityTriggerEfficiencyPlots:
icarus::trigger::TriggerEfficiencyPlotsBase

Classes

struct  Config
 

Public Types

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

Public Member Functions

 MajorityTriggerEfficiencyPlots (Parameters const &config)
 
 MajorityTriggerEfficiencyPlots (MajorityTriggerEfficiencyPlots const &)=delete
 
 MajorityTriggerEfficiencyPlots (MajorityTriggerEfficiencyPlots &&)=delete
 
MajorityTriggerEfficiencyPlotsoperator= (MajorityTriggerEfficiencyPlots const &)=delete
 
MajorityTriggerEfficiencyPlotsoperator= (MajorityTriggerEfficiencyPlots &&)=delete
 
virtual void beginJob () override
 Initializes the plots. More...
 
virtual void analyze (art::Event const &event) override
 Fills the plots. Also extracts the information to fill them with. More...
 
virtual void endJob () override
 Prints end-of-job summaries. More...
 

Private Types

using WorkingTriggerGate_t = InputTriggerGate_t
 Type of gate data used for internal processing. More...
 
- Private Types inherited from icarus::trigger::TriggerEfficiencyPlotsBase
using microseconds = util::quantities::intervals::microseconds
 
using nanoseconds = util::quantities::intervals::nanoseconds
 
using EventInfo_t = details::EventInfo_t
 
using PMTInfo_t = details::PMTInfo_t
 
using TriggerInfo_t = details::TriggerInfo_t
 
using PlotSandbox = icarus::trigger::PlotSandbox
 Import type. More...
 
using PlotSandboxRefs_t = std::vector< std::reference_wrapper< PlotSandbox const >>
 List of references to plot sandboxes. More...
 
using PlotCategories_t = std::vector< PlotCategory >
 
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...
 
using TriggerGatesPerCryostat_t = std::vector< TriggerGates_t >
 Type of lists of gates, one list per cryostat (outer index: cryostat no). More...
 
using ChannelID_t = InputTriggerGate_t::TriggerGate_t::ChannelID_t
 Type representing the unique identifier of a optical detector channel. More...
 

Private Member Functions

virtual void initializePlotSet (PlotSandbox &plots, std::vector< SettingsInfo_t > const &settings) const override
 Initializes full set of plots for (ADC threshold + category). More...
 
virtual void simulateAndPlot (std::size_t const thresholdIndex, TriggerGatesPerCryostat_t const &gates, EventInfo_t const &eventInfo, detinfo::DetectorClocksData const &clockData, PlotSandboxRefs_t const &selectedPlots) override
 Simulates all trigger minimum requirements plots the results. More...
 
void plotResponses (std::size_t iThr, std::string const &threshold, PlotSandboxRefs_t const &plotSets, EventInfo_t const &eventInfo, detinfo::DetectorClocksData const &clockData, std::vector< WorkingTriggerGate_t > const &combinedCounts, std::vector< ChannelID_t > const &channelList)
 Completes the event trigger simulation and fills the plots. More...
 
std::vector< WorkingTriggerGate_tcombineTriggerPrimitives (TriggerGatesPerCryostat_t const &cryoGates, std::string const &threshold) const
 Computes the trigger response from primitives with the given threshold. More...
 
MajorityTriggerEfficiencyPlots
const & 
helper () const
 Access to the helper. More...
 
MajorityTriggerEfficiencyPlotshelper ()
 
- Private Member Functions inherited from icarus::trigger::TriggerEfficiencyPlotsBase
 TriggerEfficiencyPlotsBase (Config const &config, art::ConsumesCollector &consumer)
 Constructor; requires a configuration and module's consumesCollector(). More...
 
void process (art::Event const &event)
 Fills the plots. Also extracts the information to fill them with. More...
 
void printSummary () const
 Prints end-of-job summaries. More...
 
std::string const & logCategory () const
 Returns the name of the log category. More...
 
TTree * eventTree ()
 Returns a pointer to the tree where event information is written. More...
 
bool useGen () const
 Returns whether we are using and filling generator information. More...
 
bool useEDep () const
 Returns whether we are using and filling energy deposition information. More...
 
std::size_t nADCthresholds () const
 Returns the number of configured PMT thresholds. More...
 
auto ADCthresholds () const
 Returns a iterable sequence of all configured PMT thresholds. More...
 
std::string const & ADCthresholdTag (std::size_t iThr) const
 
geo::GeometryCore const & geometry () const
 Returns the detector geometry service provider. More...
 
nanoseconds triggerTimeResolution () const
 Returns the resolution of trigger timing clock [ns]. More...
 
virtual void initializePlots (PlotCategories_t categories, std::vector< SettingsInfo_t > const &settings)
 Initializes all the plot sets, one per PMT threshold. More...
 
void initializePlots (std::vector< SettingsInfo_t > const &settings)
 Initializes sets of default plots, one per PMT threshold. More...
 
virtual void initializeEfficiencyPerTriggerPlots (PlotSandbox &plots) const
 Initializes set of plots per complete trigger definition into plots. More...
 
virtual void initializeEventPlots (PlotSandbox &plots) const
 Initializes a single, trigger-independent plot set into plots. More...
 
virtual void initializePMTplots (PlotSandbox &plots) const
 
virtual bool shouldPlotEvent (EventInfo_t const &eventInfo) const
 
virtual void fillEventPlots (EventInfo_t const &eventInfo, PlotSandbox const &plots) const
 Fills the plots (initializeEventPlots()) with info from eventInfo. More...
 
virtual void fillPMTplots (PMTInfo_t const &PMTinfo, PlotSandbox const &plots) const
 Fill the plots (initializePMTplots()) with info from PMTinfo. More...
 
virtual void fillEfficiencyPlots (EventInfo_t const &eventInfo, TriggerInfo_t const &triggerInfo, PlotSandbox const &plots) const
 
virtual void fillAllEfficiencyPlots (EventInfo_t const &eventInfo, PMTInfo_t const &PMTinfo, TriggerInfo_t const &triggerInfo, PlotSandbox const &plots) const
 
void deleteEmptyPlots ()
 Deletes plots with no entries, and directories which became empty. More...
 
std::size_t createCountersForPattern (std::string const &patternName)
 Creates counters for all the thresholds of the specified trigger. More...
 
GatePack_t makeGatePack (art::Event const *event=nullptr) const
 Creates a GatePack_t from the specified event. More...
 
void registerTriggerResult (std::size_t threshold, std::size_t pattern, bool fired)
 Registers the outcome of the specified trigger. More...
 
void registerTriggerResult (std::size_t threshold, std::size_t pattern, TriggerInfo_t const &triggerInfo)
 
icarus::trigger::ApplyBeamGateClass makeMyBeamGate (detinfo::DetectorClocksData const &clockData) 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 Attributes

std::vector< unsigned int > fMinimumPrimitives
 Minimum number of trigger primitives for a trigger to happen. More...
 
std::unique_ptr< ResponseTreefResponseTree
 Handler of ROOT tree output. More...
 

Additional Inherited Members

- Static Private Member Functions inherited from icarus::trigger::TriggerEfficiencyPlotsBase
static std::vector< ChannelID_textractActiveChannels (TriggerGatesPerCryostat_t const &cryoGates)
 Returns all channels contributing to the trigger gates. More...
 
- Static Private Attributes inherited from icarus::trigger::TriggerEfficiencyPlotsBase
static PlotCategories_t const DefaultPlotCategories
 List of event categories. More...
 

Detailed Description

Produces plots about trigger simulation and trigger efficiency.

This module is an implementation of TriggerEfficiencyPlotsBase for a trigger defined as a minimum number of trigger primitives beyond threshold.

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 the pairing with AND or OR of two optical detector channels discriminated against a certain ADC count threshold.

Trigger logic algorithm

This section describes the trigger logic algorithm used in icarus::trigger::MajorityTriggerEfficiencyPlots 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 algorithm handles multiple trigger primitive requirements. Each requirement is simply how many trigger primitives must be open at the same time in a single cryostat for the trigger to fire. The values of these requirements are set in the configuration (MinimumPrimitives). To determine whether a trigger with a given requirement, i.e. with a required minimum number of trigger 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.

As a consequence, there are for each event as many different trigger responses as how many different requirements are configured in MinimumPrimitives, times how many ADC thresholds are provided in input, configured in Thresholds.

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).

The combination algorithm is implemented in combineTriggerPrimitives() while the requirement evaluation and plotting are implemented in plotResponses().

The set of plots and their organization are described in the documentation of icarus::trigger::TriggerEfficiencyPlotsBase. In the following documentation only the additions are described.

Output plots

A generic "setting" of icarus::trigger::TriggerEfficiencyPlotsBase is in this module represented by the single trigger primitive requirement N (configuration parameter: MinimumPrimitives). The folders and plots will identify each requirement with the tag ReqN (e.g. Req5 when requesting at least 5 trigger primitives for an event trigger).

There are a few plots that are produced by this module in addition to the ones in TriggerEfficiencyPlotsBase.

There are different "types" of plots. Some do not depend on triggering at all, like the deposited energy distribution. Others cross different trigger definitions, like the trigger efficiency as function of trigger requirement. Others still assume a single trigger definition: this is the case of trigger efficiency plots versus energy. Finally, there are plots that depend on a specific trigger definition and outcome: this is the case of all the plots including only triggering or non-triggering events.

A list of additional plots follows for each plot type. All the plots are always relative to a specific optical detector channel threshold (ADC) and a broad event category.

Plots independent of the triggers (selection plots)

Only the standard plots from TriggerEfficiencyPlotsBase are produced in this category.

Plots including different trigger requirements

In addition to the plots from TriggerEfficiencyPlotsBase, the following plots are also produced:

Plots depending on a specific trigger definition

Only the standard plots from TriggerEfficiencyPlotsBase are produced in this category.

Plots depending on a specific trigger definition and response

Only the standard plots from TriggerEfficiencyPlotsBase are produced in this category.

Configuration parameters

In addition to all the configuration parameters from TriggerEfficiencyPlotsBase, the following one is also present:

An example job configuration is provided as maketriggerplots_icarus.fcl.

Technical description of the module

This module class is derived from icarus::trigger::TriggerEfficiencyPlotsBase, which provides a backbone to perform the simulation of triggers and plotting of their efficiency.

There is not any superior design involved in this separation, but just the desire to share most code possible between different modules which simulate different trigger patterns and as a consequence might have specific plots to fill.

This module redefines:

It does not redefine initializeEfficiencyPerTriggerPlots() nor initializeEventPlots() because there are no additional plots of the types these functions deal with.

The event categories are from the default list (DefaultPlotCategories) too.

Definition at line 278 of file MajorityTriggerEfficiencyPlots_module.cc.

Member Typedef Documentation

Definition at line 298 of file MajorityTriggerEfficiencyPlots_module.cc.

Type of gate data used for internal processing.

Definition at line 331 of file MajorityTriggerEfficiencyPlots_module.cc.

Constructor & Destructor Documentation

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

Definition at line 506 of file MajorityTriggerEfficiencyPlots_module.cc.

507  : art::EDAnalyzer (config)
509  // configuration
510  , fMinimumPrimitives(config().MinimumPrimitives())
511 {
512  std::sort(fMinimumPrimitives.begin(), fMinimumPrimitives.end());
513 
514  //
515  // more complex parameter parsing
516  //
517  if (helper().eventTree()) {
518 
519  fResponseTree = std::make_unique<ResponseTree>
521 
522  } // if make tree
523 
524  if (fMinimumPrimitives.empty()) {
525  throw art::Exception(art::errors::Configuration)
526  << "At least one 'MinimumPrimitives' requirement... required.";
527  }
528 
529  std::size_t iPattern [[maybe_unused]] = 0U; // NOTE: incremented only in DEBUG
530  for (auto const& req: fMinimumPrimitives) {
531  std::size_t const index [[maybe_unused]]
533  assert(index == iPattern++);
534  } // for requirements
535 
536  {
537  mf::LogInfo log(helper().logCategory());
538  log
539  << "Requirement of minimum trigger primitives ("
540  << fMinimumPrimitives.size() << "):";
541  for (auto const& req: fMinimumPrimitives) log << " " << req;
542  log << ".";
543  }
544 
545 } // icarus::trigger::MajorityTriggerEfficiencyPlots::MajorityTriggerEfficiencyPlots()
TriggerEfficiencyPlotsBase(Config const &config, art::ConsumesCollector &consumer)
Constructor; requires a configuration and module&#39;s consumesCollector().
std::vector< unsigned int > fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
std::string const & logCategory() const
Returns the name of the log category.
TTree * eventTree()
Returns a pointer to the tree where event information is written.
std::unique_ptr< ResponseTree > fResponseTree
Handler of ROOT tree output.
auto ADCthresholds() const
Returns a iterable sequence of all configured PMT thresholds.
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.
std::size_t createCountersForPattern(std::string const &patternName)
Creates counters for all the thresholds of the specified trigger.
std::string to_string(WindowPattern const &pattern)
fDetProps &fDetProps fDetProps &fDetProps consumesCollector())
icarus::trigger::MajorityTriggerEfficiencyPlots::MajorityTriggerEfficiencyPlots ( MajorityTriggerEfficiencyPlots const &  )
delete
icarus::trigger::MajorityTriggerEfficiencyPlots::MajorityTriggerEfficiencyPlots ( MajorityTriggerEfficiencyPlots &&  )
delete

Member Function Documentation

void icarus::trigger::MajorityTriggerEfficiencyPlots::analyze ( art::Event const &  event)
overridevirtual

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

Definition at line 574 of file MajorityTriggerEfficiencyPlots_module.cc.

575 {
576 
577  // hook helper and framework;
578  // actual action is in the (overridden) virtual function `plotResponses()`
579  // and `fillXxxPlots()`.
580  helper().process(event);
581 
582 } // icarus::trigger::MajorityTriggerEfficiencyPlots::analyze()
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.
void process(art::Event const &event)
Fills the plots. Also extracts the information to fill them with.
void icarus::trigger::MajorityTriggerEfficiencyPlots::beginJob ( )
overridevirtual

Initializes the plots.

Definition at line 549 of file MajorityTriggerEfficiencyPlots_module.cc.

549  {
550 
551  // hook helper and framework;
552  // actual action is in the (overridden) virtual functions `initializeXxx()`.
553 
554  // NOTE this action can't happen in constructor because relies on polymorphism
555  std::vector<SettingsInfo_t> settings;
556  for (auto [ iReq, minCount ]: util::enumerate(fMinimumPrimitives)) {
557  std::string const minCountStr { std::to_string(minCount) };
558  settings.emplace_back(
559  iReq, // index
560  "Req" + minCountStr, // tag
561  minCountStr + " channels required" // description
562  );
563  } // for
564 
565  // we use the default plot categories defined in
566  // `TriggerEfficiencyPlotsBase::DefaultPlotCategories`
567  helper().initializePlots(settings);
568 
569 } // icarus::trigger::MajorityTriggerEfficiencyPlots::beginJob()
std::vector< unsigned int > fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.
std::string to_string(WindowPattern const &pattern)
virtual void initializePlots(PlotCategories_t categories, std::vector< SettingsInfo_t > const &settings)
Initializes all the plot sets, one per PMT threshold.
auto icarus::trigger::MajorityTriggerEfficiencyPlots::combineTriggerPrimitives ( TriggerGatesPerCryostat_t const &  cryoGates,
std::string const &  threshold 
) const
private

Computes the trigger response from primitives with the given threshold.

Parameters
cryoGatescollections of trigger primitives, one coll. per cryostat
thresholdPMT threshold of the primitives (for printing purposes)
Returns
a list of combined trigger primitives, one combination per cryostat

The input trigger primitives are already grouped by cryostat. For each cryostat, the primitives are combined and one combination is returned. The combination is just the "total" of the primitives opened at each tick.

The event trigger is not finalized here, and the cryostat trigger primitives are all returned.

Definition at line 902 of file MajorityTriggerEfficiencyPlots_module.cc.

905  {
906 
907  //
908  // simple count
909  //
910  std::vector<WorkingTriggerGate_t> cryoCombinedGate;
911  cryoCombinedGate.reserve(cryoGates.size());
912 
913  for (auto const& [ iCryo, gates ]: util::enumerate(cryoGates)) {
914  geo::CryostatID const cryoID(iCryo);
915 
916  mf::LogTrace(helper().logCategory())
917  << "Simulating trigger response with ADC threshold " << threshold
918  << " for " << cryoID << " (" << gates.size() << " primitives)";
919 
920  cryoCombinedGate.push_back(icarus::trigger::sumGates(gates));
921  } // for
922 
923  //
924  // largest number of trigger primitives at any time, per cryostat
925  //
926  return cryoCombinedGate;
927 
928 } // icarus::trigger::MajorityTriggerEfficiencyPlots::combineTriggerPrimitives()
std::string const & logCategory() const
Returns the name of the log category.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
auto sumGates(GateColl const &gates)
Sums all the gates in a collection.
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void icarus::trigger::MajorityTriggerEfficiencyPlots::endJob ( )
overridevirtual

Prints end-of-job summaries.

Definition at line 586 of file MajorityTriggerEfficiencyPlots_module.cc.

586  {
587 
588  // hook helper and framework
589  helper().printSummary();
590 
591 } // icarus::trigger::MajorityTriggerEfficiencyPlots::endJob()
void printSummary() const
Prints end-of-job summaries.
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.
MajorityTriggerEfficiencyPlots const& icarus::trigger::MajorityTriggerEfficiencyPlots::helper ( ) const
inlineprivate

Access to the helper.

Definition at line 351 of file MajorityTriggerEfficiencyPlots_module.cc.

351 { return *this; }
MajorityTriggerEfficiencyPlots& icarus::trigger::MajorityTriggerEfficiencyPlots::helper ( )
inlineprivate

Definition at line 352 of file MajorityTriggerEfficiencyPlots_module.cc.

352 { return *this; }
void icarus::trigger::MajorityTriggerEfficiencyPlots::initializePlotSet ( PlotSandbox plots,
std::vector< SettingsInfo_t > const &  settings 
) const
overrideprivatevirtual

Initializes full set of plots for (ADC threshold + category).

This customization of TriggerEfficiencyPlotsBase::initializePlotSet() adds some trigger-definition specific plots and some overview plots across different trigger definitions.

Reimplemented from icarus::trigger::TriggerEfficiencyPlotsBase.

Definition at line 596 of file MajorityTriggerEfficiencyPlots_module.cc.

597 {
598 
599  //
600  // Selection-related plots
601  //
602 
603  // (inherited)
604  helper().TriggerEfficiencyPlotsBase::initializePlotSet(plots, settings);
605 
606  //
607  // overview plots with different settings
608  //
609 
610  // a variable binning for the required number of trigger primitives
611  auto [ minimumPrimBinning, minimumPrimBinningLabels ]
613  assert(minimumPrimBinning.size() == minimumPrimBinningLabels.size() + 1U);
614 
615  {
616  mf::LogTrace log(helper().logCategory());
617  log << "MajorityTriggerEfficiencyPlots (plots '"
618  << plots.name() << "') variable binning including the "
619  << fMinimumPrimitives.size() << " points {";
620  for (auto value: fMinimumPrimitives) log << " " << value;
621  log << " } => " << minimumPrimBinningLabels.size() << " bins: ";
622  for (auto const& [ value, label ]
623  : util::zip<1U>(minimumPrimBinning, minimumPrimBinningLabels))
624  {
625  log << " " << value << " (\"" << label << "\") =>";
626  } // for
627  log << " " << minimumPrimBinning.back();
628  } // debug output block
629 
630  //
631  // Triggering efficiency vs. requirements.
632  //
633 
634  auto const [ detTimings, beamGate, preSpillWindow ] = makeGatePack();
635 
636  detinfo::timescales::optical_time_ticks const triggerResolutionTicks
637  { detTimings.toOpticalTicks(helper().triggerTimeResolution()) };
638 
639  auto const& beamGateOpt = beamGate.asOptTickRange();
640 
641  auto* TrigTime = plots.make<TH2F>(
642  "TriggerTick",
643  "Trigger time tick"
644  ";minimum requested number of trigger primitives"
645  ";optical time tick [ /" + util::to_string(triggerResolutionTicks) + " ]",
646  minimumPrimBinning.size() - 1U, minimumPrimBinning.data(),
647 // fMinimumPrimitives.back(), 0, fMinimumPrimitives.back() + 1
648  beamGateOpt.duration() / triggerResolutionTicks,
649  beamGateOpt.first.value(), beamGateOpt.second.value()
650  );
651 
652  util::ROOT::applyAxisLabels(TrigTime->GetXaxis(), minimumPrimBinningLabels);
653 
654  auto* Eff = plots.make<TEfficiency>(
655  "Eff",
656  "Efficiency of triggering"
657  ";minimum requested number of trigger primitives"
658  ";trigger efficiency",
659  minimumPrimBinning.size() - 1U, minimumPrimBinning.data()
660 // fMinimumPrimitives.back(), 0, fMinimumPrimitives.back() + 1
661  );
662 
663  // people are said to have earned hell for things like this;
664  // but TEfficiency really does not expose the interface to assign labels to
665  // its axes, which supposedly could be done had we chosen to create it by
666  // histograms instead of directly as recommended.
668  const_cast<TH1*>(Eff->GetTotalHistogram())->GetXaxis(),
669  minimumPrimBinningLabels
670  );
671 
672  //
673  // plots independent of the trigger primitive requirements
674  //
675  plots.make<TH1F>(
676  "NPrimitives",
677  "Number of trigger primitives (\"channels firing at once\")"
678  ";maximum trigger primitives at the same time on a single cryostat"
679  ";events",
680  192, 0.0, 192.0 // large number, zoom in presentations!
681  );
682 
683 } // icarus::trigger::MajorityTriggerEfficiencyPlots::initializePlotSet()
std::vector< unsigned int > fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
std::pair< std::vector< double >, std::vector< std::string > > makeVariableBinningAndLabels(Coll const &centralPoints)
Returns a variable size binning for the points.
std::string const & logCategory() const
Returns the name of the log category.
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
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
nanoseconds triggerTimeResolution() const
Returns the resolution of trigger timing clock [ns].
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
std::vector< PlotDef > plots
Definition: demo.h:54
GatePack_t makeGatePack(art::Event const *event=nullptr) const
Creates a GatePack_t from the specified event.
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.
temporary value
fDetProps &fDetProps fDetProps &fDetProps detTimings
MajorityTriggerEfficiencyPlots& icarus::trigger::MajorityTriggerEfficiencyPlots::operator= ( MajorityTriggerEfficiencyPlots const &  )
delete
MajorityTriggerEfficiencyPlots& icarus::trigger::MajorityTriggerEfficiencyPlots::operator= ( MajorityTriggerEfficiencyPlots &&  )
delete
void icarus::trigger::MajorityTriggerEfficiencyPlots::plotResponses ( std::size_t  iThr,
std::string const &  threshold,
PlotSandboxRefs_t const &  plotSets,
EventInfo_t const &  eventInfo,
detinfo::DetectorClocksData const &  clockData,
std::vector< WorkingTriggerGate_t > const &  combinedCounts,
std::vector< ChannelID_t > const &  channelList 
)
private

Completes the event trigger simulation and fills the plots.

Parameters
iThrindex of PMT threshold (used in tree output)
thresholdPMT threshold in ADC counts (for printing)
plotSetsset of plot boxes to fill (from initializePlotSet())
eventInfoevent information for plotting
combinedCountscombined trigger primitives, per cryostat

For each of the trigger requirements (MinimumPrimitives), this method:

  1. applies the requirement to the combinedCounts trigger primitive
  2. computes the event triggers (including the main one)
  3. fills all plots in all the plot sets for this requirement accordingly

The input combined trigger primitives contain the maximum number of trigger primitives active at each optical clock tick, one entry for each cryostat. It is assumed that the beam gate has already been "applied" so that outside it no trigger primitive is considered open.

A trigger with requirement of minimum trigger primitives N is fired if this combined primitive reaches or passes N, i.e. if there are at least N open trigger primitives at any time. The time of the trigger is taken as the first tick at which the requirement is met.

Extra plots are an overview of the trigger efficiency for different requirements, per threshold, the distribution of the trigger time for different requirements, and maximum number of open primitive in a cryostat, per event.

Note that there is no information about which cryostat is meeting the trigger requirement.

Definition at line 716 of file MajorityTriggerEfficiencyPlots_module.cc.

724  {
725 
726  /*
727  * This function plots according to the configured minimum number of trigger
728  * primitives: for each requirement of minimum number of primitives, the
729  * earliest time where that requirement is met is found, and that is
730  * considered as the trigger time.
731  *
732  * The following quantities are drawn per ADC threshold and per plot category:
733  *
734  * * per minimum number of primitives:
735  * * trigger efficiency (i.e. whether there was _any time_ a number of
736  * primitives fulfilling the requirement)
737  * * trigger time in ticks (distribution as 2D histogram)
738  * * maximum number of trigger primitives present at any time
739  * * deposited energy during beam spill
740  *
741  */
742  using namespace std::string_literals;
743 
744  using ClockTick_t = WorkingTriggerGate_t::TriggerGate_t::ClockTick_t;
745  using OpeningCount_t = WorkingTriggerGate_t::TriggerGate_t::OpeningCount_t;
746 
747  using PrimitiveCount_t = std::pair<ClockTick_t, OpeningCount_t>;
748 
749  PrimitiveCount_t maxPrimitives { ClockTick_t{ 0 } /* dummy */, 0U };
750  for (auto const& [ iCryo, combinedCount ]
751  : util::enumerate(gatesIn(combinedCounts)))
752  {
753  auto const maxPrimitiveTime { combinedCount.findMaxOpen() };
754  PrimitiveCount_t const maxPrimitivesInCryo
755  { maxPrimitiveTime, combinedCount.openingCount(maxPrimitiveTime) };
756  if (maxPrimitivesInCryo.second > maxPrimitives.second)
757  maxPrimitives = maxPrimitivesInCryo;
758 
759  mf::LogTrace log { helper().logCategory() };
760  log << "Max primitive count in " << threshold << " for C:" << iCryo << ": "
761  << maxPrimitivesInCryo.second;
762  if (maxPrimitivesInCryo.second > 0) {
763  log << " at tick " << maxPrimitivesInCryo.first << " ("
765  (detinfo::DetectorTimings::optical_tick{ maxPrimitivesInCryo.first })
766  << ")"
767  ;
768  } // if
769  } // for
770 
771  PMTInfo_t const PMTinfo { threshold, channelList };
772 
773  /*
774  * Fill all the histograms for all the minimum primitive requirements
775  * (filling the information whether or not the trigger fired),
776  * for all the qualifying categories.
777  * Note that in this type of plots each event appears in all bins
778  * (may be with "fired" or "not fired" on each bin)
779  */
780 
781  // PrimitiveCount_t lastMinCount { WorkingTriggerGate_t::MinTick, 0 };
782 
783  bool fired = true; // the final trigger response (changes with requirement)
784 
785  for (auto [ iReq, minCount ]: util::enumerate(fMinimumPrimitives)) {
786 
787  TriggerInfo_t triggerInfo;
788  if (fired) { // this is still the previous requirement
789  for (auto const& [ iCryo, cryoGate ]: util::enumerate(combinedCounts)) {
790 
792  { gateIn(cryoGate), minCount };
793  extractOpeningInfo.setLocation(iCryo);
794  while (extractOpeningInfo) {
795  auto info = extractOpeningInfo();
796  if (info) triggerInfo.add(info.value());
797  } // while
798  } // for all cryostats
799  triggerInfo.sortOpenings(); // sort in time
800  fired = triggerInfo.fired();
801  } // if previous fired
802 
803  if (fired) {
804  mf::LogTrace log(helper().logCategory());
805  log
806  << " => fired (>" << minCount << ") at " << triggerInfo.atTick()
807  << " (level " << triggerInfo.level() << ") from"
808  ;
809  if (triggerInfo.hasLocation()) log << " C:" << triggerInfo.location();
810  else log << " unknown location";
811  log << ", " << triggerInfo.nTriggers() << " triggers total:";
812  for (auto const& [iTrigger, info ]: util::enumerate(triggerInfo.all())) {
813  log << " [" << iTrigger << "] at " << info.tick;
814  if (info.hasLocation()) log << " of C:" << info.locationID;
815  else log << " [unknown location]";
816  log << " (level=" << info.level << ")";
817  } // for
818 
819  } // if fired
820  else {
821  mf::LogTrace(helper().logCategory())
822  << " => not fired (>" << minCount << ")";
823  }
824 
825  // at this point we know we have minCount or more trigger primitives,
826  // and the time of this one is in lastMinCount.first (just in case)
827 
828  if (fResponseTree) fResponseTree->assignResponse(iThr, iReq, fired);
829 
830  registerTriggerResult(iThr, iReq, fired);
831 
832  std::string const minCountStr { "Req" + std::to_string(minCount) };
833 
834  // go through all the plot categories this event qualifies for
835  // (for example: charged currents, muon neutrinos, ...)
836  for (icarus::trigger::PlotSandbox const& plotSet: plotSets) {
837 
838  //
839  // overview plots from different thresholds
840  //
841 
842  HistGetter const get { plotSet };
843 
844  // simple efficiency
845  get.Eff("Eff"s).Fill(fired, minCount);
846 
847  // trigger time (if any)
848  if (fired) {
849  get.Hist2D("TriggerTick"s).Fill(minCount, triggerInfo.atTick().value());
850  }
851 
852  //
853  // plots depending on the trigger response
854  // (but not caring of the trigger definition details)
855  //
856 
857  // efficiency plots
858  // (including event plots in the triggered or non-triggered category)
860  (eventInfo, PMTinfo, triggerInfo, plotSet.demandSandbox(minCountStr));
861 
862  //
863  // add here further trigger-specific plots
864  //
865 
866  } // for all qualifying plot categories
867 
868  } // for all requirements
869 
870  /*
871  * Now fill the plots independent of the trigger response:
872  * the same value is plotted in all plot sets.
873  * (again for all pertinent event categories, e.g. charged currents, etc.)
874  */
875  for (PlotSandbox const& plotSet: plotSets) {
876 
877  //
878  // general plots, independent of trigger definition details
879  //
880  fillEventPlots(eventInfo, plotSet);
881 
882  //
883  // general plots, independent of trigger definition but dependent on
884  // threshold
885  //
886  fillPMTplots(PMTinfo, plotSet);
887 
888  //
889  // trigger-definition specific plots
890  //
891  HistGetter const get(plotSet);
892 
893  // number of primitives
894  get.Hist("NPrimitives"s).Fill(maxPrimitives.second);
895 
896  } // for
897 
898 } // icarus::trigger::MajorityTriggerEfficiencyPlots::plotResponses()
std::vector< unsigned int > fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
virtual void fillEventPlots(EventInfo_t const &eventInfo, PlotSandbox const &plots) const
Fills the plots (initializeEventPlots()) with info from eventInfo.
std::string const & logCategory() const
Returns the name of the log category.
auto gatesIn(TrackingGateColl &trackingGates)
virtual void fillAllEfficiencyPlots(EventInfo_t const &eventInfo, PMTInfo_t const &PMTinfo, TriggerInfo_t const &triggerInfo, PlotSandbox const &plots) const
std::unique_ptr< ResponseTree > fResponseTree
Handler of ROOT tree output.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
electronics_time toElectronicsTime(FromTime time) const
Converts a time point into electronics time scale.
virtual void fillPMTplots(PMTInfo_t const &PMTinfo, PlotSandbox const &plots) const
Fill the plots (initializePMTplots()) with info from PMTinfo.
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.
std::string to_string(WindowPattern const &pattern)
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
A class exposing an upgraded interface of detinfo::DetectorClocksData.
void registerTriggerResult(std::size_t threshold, std::size_t pattern, bool fired)
Registers the outcome of the specified trigger.
icarus::trigger::PlotSandbox PlotSandbox
Import type.
detinfo::timescales::optical_tick optical_tick
Helper to extract OpeningInfo_t from a trigger gate.
Definition: TriggerInfo_t.h:30
A helper to manage ROOT objects with consistent naming.
Definition: PlotSandbox.h:95
decltype(auto) gateIn(Gate &&gate)
Returns the trigger gate (a ReadoutTriggerGate) from the specified gate.
void icarus::trigger::MajorityTriggerEfficiencyPlots::simulateAndPlot ( std::size_t const  thresholdIndex,
TriggerGatesPerCryostat_t const &  gates,
EventInfo_t const &  eventInfo,
detinfo::DetectorClocksData const &  clockData,
PlotSandboxRefs_t const &  selectedPlots 
)
overrideprivatevirtual

Simulates all trigger minimum requirements plots the results.

Parameters
thresholdIndexthe index of the PMT threshold of input primitives
gatesthe trigger primitives used to simulate the trigger response
eventInfogeneral information about the event being simulated
selectedPlotslist of boxes containing plots to be filled

This method is expected to perform the following steps for each trigger primitive requirement in MinimumPrimitives:

  1. combine the trigger primitives: combineTriggerPrimitives();
  2. apply the beam gate: applyBeamGate() on the combined primitives;
  3. generate the trigger response: in plotResponses();
  4. fill all plots: also in in plotResponses().

Details are in the documentation of the relevant methods.

This method is invoked once per PMT threshold.

Implements icarus::trigger::TriggerEfficiencyPlotsBase.

Definition at line 687 of file MajorityTriggerEfficiencyPlots_module.cc.

693  {
694 
695  auto const threshold = helper().ADCthresholdTag(thresholdIndex);
696 
697  auto const& beamGate = helper().makeMyBeamGate(clockData);
698 
699  /*
700  * 1. combine trigger primitives per cryostat (`combineTriggerPrimitives()`)
701  * 2. apply the beam gate on the combination (`applyBeamGate()`)
702  * 3. and compute the trigger response (`plotResponses()`)
703  * 4. fill plots with the result (also `plotResponses()`)
704  */
706  thresholdIndex, threshold, selectedPlots, eventInfo,
707  clockData,
708  beamGate.applyToAll(combineTriggerPrimitives(gates, threshold)),
710  );
711 
712 } // icarus::trigger::MajorityTriggerEfficiencyPlots::simulateAndPlot()
std::string const & ADCthresholdTag(std::size_t iThr) const
std::vector< WorkingTriggerGate_t > combineTriggerPrimitives(TriggerGatesPerCryostat_t const &cryoGates, std::string const &threshold) const
Computes the trigger response from primitives with the given threshold.
icarus::trigger::ApplyBeamGateClass makeMyBeamGate(detinfo::DetectorClocksData const &clockData) const
Shortcut to create an ApplyBeamGate with the current configuration.
void plotResponses(std::size_t iThr, std::string const &threshold, PlotSandboxRefs_t const &plotSets, EventInfo_t const &eventInfo, detinfo::DetectorClocksData const &clockData, std::vector< WorkingTriggerGate_t > const &combinedCounts, std::vector< ChannelID_t > const &channelList)
Completes the event trigger simulation and fills the plots.
static std::vector< ChannelID_t > extractActiveChannels(TriggerGatesPerCryostat_t const &cryoGates)
Returns all channels contributing to the trigger gates.
MajorityTriggerEfficiencyPlots const & helper() const
Access to the helper.

Member Data Documentation

std::vector<unsigned int> icarus::trigger::MajorityTriggerEfficiencyPlots::fMinimumPrimitives
private

Minimum number of trigger primitives for a trigger to happen.

Definition at line 337 of file MajorityTriggerEfficiencyPlots_module.cc.

std::unique_ptr<ResponseTree> icarus::trigger::MajorityTriggerEfficiencyPlots::fResponseTree
private

Handler of ROOT tree output.

Definition at line 344 of file MajorityTriggerEfficiencyPlots_module.cc.


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