33 #include "art/Framework/Core/EDAnalyzer.h"
34 #include "art/Framework/Core/ModuleMacros.h"
35 #include "art/Framework/Principal/Event.h"
36 #include "canvas/Utilities/Exception.h"
37 #include "messagefacility/MessageLogger/MessageLogger.h"
38 #include "fhiclcpp/types/TableAs.h"
39 #include "fhiclcpp/types/Table.h"
40 #include "fhiclcpp/types/Sequence.h"
53 #include <type_traits>
62 template <
typename DestColl,
typename SrcColl>
63 DestColl& appendCollection(DestColl& dest, SrcColl&& src);
106 template <
typename Thresholds,
typename Settings>
108 (TTree&
tree,
Thresholds const& thresholds, Settings
const& settings);
111 void assignResponse(std::size_t iThr, std::size_t iSettings,
bool resp);
120 namespace icarus::trigger {
class SlidingWindowTriggerEfficiencyPlots; }
333 :
public art::EDAnalyzer
347 Comment(
"sliding window pattern requirements")
369 virtual void analyze(art::Event
const& event)
override;
372 virtual void endJob()
override;
449 std::size_t
const thresholdIndex,
472 std::size_t iThr, std::string
const& threshold,
502 template <
typename DestColl,
typename SrcColl>
503 DestColl& appendCollection(DestColl& dest, SrcColl&& src) {
505 dest.end(), std::move_iterator(src.begin()), std::move_iterator(src.end())
515 template <
typename Thresholds,
typename Settings>
517 (TTree& tree,
Thresholds const& thresholds, Settings
const& settings)
520 , RespTxxSxx{ std::make_unique<bool[]>(
indices.size()) }
527 std::string
const branchName
531 (branchName.c_str(), &(RespTxxSxx[
indices(iThr, iSetting)]));
542 (std::size_t iThr, std::size_t iSettings,
bool resp)
553 : art::EDAnalyzer (config)
556 , fPatterns(config().Patterns())
560 helper().logCategory() +
"_WindowMapManager"
564 if (fPatterns.empty()) {
565 throw art::Exception(art::errors::Configuration)
566 <<
"At least one 'MinimumPrimitives' requirement... required.";
569 std::size_t iPattern [[maybe_unused]] = 0U;
570 for (
auto const&
pattern: fPatterns) {
571 std::size_t
const index [[maybe_unused]]
572 = createCountersForPattern(
pattern.tag());
573 assert(index == iPattern++);
580 if (helper().eventTree()) {
582 fResponseTree = std::make_unique<ResponseTree>
583 (*(helper().eventTree()), helper().ADCthresholds(), fPatterns);
588 mf::LogInfo log(helper().logCategory());
591 <<
"Requirement of sliding window patterns ("
592 << fPatterns.size() <<
"):";
593 for (
auto const&
pattern: fPatterns)
608 std::vector<SettingsInfo_t> settings;
610 settings.emplace_back(
626 (art::Event
const& event)
632 helper().process(event);
640 helper().deleteEmptyPlots();
643 helper().printSummary();
658 helper().TriggerEfficiencyPlotsBase::initializePlotSet(plots, settings);
664 std::vector<std::string> patternLabels;
666 fPatterns.cbegin(), fPatterns.cend(), back_inserter(patternLabels),
673 auto const [
detTimings, beamGate, preSpillWindow ] = makeGatePack();
675 { detTimings.toOpticalTicks(helper().triggerTimeResolution()) };
677 auto const& beamGateOpt = beamGate.asOptTickRange();
679 auto* TrigTime = plots.
make<TH2F>(
683 ";optical time tick [ /" +
util::to_string(triggerResolutionTicks) +
" ]",
684 fPatterns.size(), 0.0, double(fPatterns.size()),
685 beamGateOpt.duration() / triggerResolutionTicks,
686 beamGateOpt.first.value(), beamGateOpt.second.value()
691 auto* Triggers = plots.
make<TH1F>(
696 fPatterns.size(), 0.0, double(fPatterns.size())
701 auto* Eff = plots.
make<TEfficiency>(
703 "Efficiency of triggering"
705 ";trigger efficiency",
706 fPatterns.size(), 0.0, double(fPatterns.size())
716 (const_cast<TH1*>(Eff->GetTotalHistogram())->GetXaxis(), patternLabels);
718 (const_cast<TH1*>(Eff->GetPassedHistogram())->GetXaxis(), patternLabels);
725 std::size_t
const thresholdIndex,
732 auto const threshold = helper().ADCthresholdTag(thresholdIndex);
748 if (fWindowMapMan(gates)) initializePatternAlgorithms();
751 auto const& beamGate = helper().makeMyBeamGate(clockData);
758 for (
auto const& cryoGates: gates)
759 appendCollection(inBeamGates, beamGate.applyToAll(cryoGates));
763 mf::LogTrace log(helper().logCategory());
764 log <<
"Input for threshold " << threshold <<
": " << inBeamGates.size()
765 <<
" primitives. After beam gate:";
766 unsigned int nOpen = 0U;
769 auto const maxTick = gate.findMaxOpen();
770 if (maxTick == gate.MinTick)
continue;
772 log <<
"\n window #" << iWindow <<
": maximum "
773 << gate.openingCount(maxTick) <<
" at tick " << maxTick;
775 if (!nOpen) log <<
" nothing.";
781 { threshold, helper().extractActiveChannels(gates) };
788 auto& patternAlg = fPatternAlgs[iPattern];
791 = patternAlg.simulateResponse(inBeamGates);
793 registerTriggerResult(thresholdIndex, iPattern, triggerInfo.
info);
796 thresholdIndex, threshold,
799 eventInfo, PMTinfo, triggerInfo
807 fillAllEventPlots(selectedPlots, eventInfo);
812 fillAllPMTplots(selectedPlots, PMTinfo);
822 fPatternAlgs.clear();
823 for (
auto const&
pattern: fPatterns)
824 fPatternAlgs.emplace_back(*fWindowMapMan,
pattern, helper().logCategory());
842 fillEventPlots(eventInfo, plotSet);
865 fillPMTplots(PMTinfo, plotSet);
873 std::size_t iThr, std::string
const& threshold,
881 using namespace std::string_literals;
883 bool const fired = triggerInfo.
info.
fired();
885 if (fResponseTree) fResponseTree->assignResponse(iThr, iPattern, fired);
888 std::string
const patternTag { pattern.
tag() };
901 get.
Eff(
"Eff"s).Fill(fired, iPattern);
904 if (fired)
get.Hist(
"Triggers"s).Fill(iPattern);
908 get.Hist2D(
"TriggerTick"s).Fill
909 (iPattern, triggerInfo.
info.
atTick().value());
919 helper().fillAllEfficiencyPlots
920 (eventInfo, PMTinfo, triggerInfo.
info, plotSet.demandSandbox(patternTag));
BEGIN_PROLOG BeamGateDuration pmtthr physics producers trigtilewindowORS Thresholds
bool fired() const
Returns whether the trigger fired.
Obj * make(std::string const &name, std::string const &title, Args &&...args)
Creates a new ROOT object with the specified name and title.
Helper class to produce plots about trigger simulation and trigger efficiency.
Assembles the topology of trigger windows.
Class to extract and verify a window topology from trigger gates.
icarus::trigger::ns::fhicl::WindowPatternSequence Patterns
SlidingWindowTriggerEfficiencyPlots(Parameters const &config)
virtual void analyze(art::Event const &event) override
Fills the plots. Also extracts the information to fill them with.
::fhicl::Sequence< ::fhicl::TableAs< icarus::trigger::WindowPattern, WindowPatternConfig > > WindowPatternSequence
Configuration element for any number of trigger windows.
Definition of util::enumerate().
void plotResponse(std::size_t iThr, std::string const &threshold, std::size_t iPattern, WindowPattern const &pattern, PlotSandboxRefs_t const &plotSets, EventInfo_t const &eventInfo, PMTInfo_t const &PMTinfo, WindowTriggerInfo_t const &triggerInfo) const
Fills plots with the specified trigger response.
Class managing the serialization of trigger responses in a simple ROOT tree.
ResponseTree(TTree &tree, Thresholds const &thresholds, Requirements const &minReqs)
Constructor: accommodates that many thresholds and requirements.
void assignResponse(std::size_t iThr, std::size_t iReq, bool resp)
Assigns the response for the specified trigger.
auto gatesIn(TrackingGateColl &trackingGates)
void initializePatternAlgorithms()
std::size_t size(FixedBins< T, C > const &) noexcept
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).
TEfficiency & Eff(std::string const &name) const
details::PMTInfo_t PMTInfo_t
TensorIndices class to flatten multi-dimension indices into linear.
Produces plots about trigger simulation and trigger efficiency.
Helper data structure to store transient trigger result.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
virtual void endJob() override
Prints end-of-job summaries.
Specification of the requirement of sliding window firing pattern.
std::vector< icarus::trigger::SlidingWindowPatternAlg > fPatternAlgs
All algorithm instances, one per pattern.
icarus::trigger::WindowPatterns_t WindowPatterns_t
List of configured patterns.
Access the description of detector geometry.
Information about the event.
void fillAllEventPlots(PlotSandboxRefs_t const &plotSets, EventInfo_t const &eventInfo) const
Fills all event plots with data from eventInfo as in fillEventPlots().
Converts a tensor element specification into a linear index.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
icarus::trigger::WindowTopologyManager fWindowMapMan
Mapping of each sliding window with location and topological information.
Defines a (sliding) window trigger pattern.
WindowPatterns_t const fPatterns
Configured sliding window requirement patterns.
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
Utilities to extend the interface of geometry vectors.
A bunch of diverse utilities and futilities related to ROOT.
geo::GeometryCore const & geometry() const
Returns the detector geometry service provider.
std::vector< PlotDef > plots
Utilities for the conversion of trigger gate data formats.
BEGIN_PROLOG vertical distance to the surface Name
Helper data structure to store PMT activity information in the event.
Test of util::counter and support utilities.
Simple class holding a tree.
FHiCL configuration structure for icarus::trigger::WindowPattern.
Base class for _art_modules plotting trigger efficiencies.
util::MatrixIndices indices
std::unique_ptr< bool[]> RespTxxSxx
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.
SlidingWindowTriggerEfficiencyPlots const & helper() const
Access to the helper.
TriggerInfo_t info
Standard trigger information.
A wrapper to trigger gate objects tracking the contributions.
optical_tick atTick() const
Returns the time of the trigger (undefined if !fired()).
std::string tag() const
Returns a tag summarizing the pattern.
Contains all timing reference information for the detector.
then echo File list $list not found else cat $list while read file do echo $file sed s
art::EDAnalyzer::Table< Config > Parameters
virtual void beginJob() override
Initializes the plots.
Data types for detinfo::DetectorTimings.
Functions pulling in STL customization if available.
icarus::trigger::SlidingWindowPatternAlg::AllTriggerInfo_t WindowTriggerInfo_t
Data structure to communicate internally a trigger response.
Selected information about the event.
std::vector< std::reference_wrapper< PlotSandbox const >> PlotSandboxRefs_t
List of references to plot sandboxes.
virtual void initializePlots(PlotCategories_t categories, std::vector< SettingsInfo_t > const &settings)
Initializes all the plot sets, one per PMT threshold.
std::vector< TriggerGates_t > TriggerGatesPerCryostat_t
Type of lists of gates, one list per cryostat (outer index: cryostat no).
std::vector< WindowPattern > WindowPatterns_t
A list of window patterns.
void fillAllPMTplots(PlotSandboxRefs_t const &plotSets, PMTInfo_t const &PMTinfo) const
Fills all PMY plots with data from PMTinfo as in fillPMTplots().
Complete information from this algorithm, standard + non-standard (extra).
std::unique_ptr< ResponseTree > fResponseTree
Handler of ROOT tree output.
Applies sliding window trigger patterns.
virtual void initializePlotSet(PlotSandbox &plots, std::vector< SettingsInfo_t > const &settings) const override
Initializes full set of plots for (ADC threshold + category).
Provides sortBy() class of utilities.
A helper to manage ROOT objects in a art::TFileDirectory.
std::vector< InputTriggerGate_t > TriggerGates_t
A list of trigger gates from input.
A helper to manage ROOT objects with consistent naming.
SlidingWindowTriggerEfficiencyPlots & helper()