10 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWTOPOLOGYALG_H
11 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWTOPOLOGYALG_H
21 #include "cetlib_except/exception.h"
37 namespace icarus::trigger {
38 class WindowTopologyAlg;
39 class WindowTopologyVerification;
40 class WindowTopologyManager;
74 std::string
const&
logCategory =
"WindowTopologyAlg"
156 template <
typename... Args>
173 std::size_t firstWindowIndex = 0U
200 std::vector<WindowChannelMap::WindowInfo_t*>
const& windowList,
239 std::string
const&
logCategory =
"WindowTopologyVerification"
250 (std::string
const&
logCategory =
"WindowTopologyVerification");
308 template <
typename Gates>
359 std::string
const&
logCategory =
"WindowTopologyManager"
369 template <
typename Gates>
380 template <
typename Gates>
396 template <
typename Gates>
409 std::string
const& logCategory
411 : icarus::ns::util::mfLoggingClass(logCategory)
412 , fWindowMap(
std::move(topology))
418 std::string
const& logCategory
420 : icarus::ns::util::mfLoggingClass(logCategory)
426 {
return fWindowMap.has_value(); }
432 { fWindowMap = std::move(topology); }
438 {
return fWindowMap.value(); }
443 {
return fWindowMap.reset(); }
447 inline void icarus::trigger::WindowTopologyVerification::operator()
449 { verifyOrThrow(gates); }
453 inline void icarus::trigger::WindowTopologyVerification::operator()
455 { verifyOrThrow(gates); }
463 std::string
const& logCategory
465 : icarus::ns::util::mfLoggingClass(logCategory)
466 , fVerify{ logCategory }
474 {
return fVerify.getTopology(); }
480 {
return &(fVerify.getTopology()); }
488 template <
typename Gates>
490 (Gates
const& gates)
const
493 std::string
const errorMsg = verify(gates);
494 if (errorMsg.empty())
return;
497 throw cet::exception(
"WindowTopologyVerification")
498 <<
"Some channels from trigger gates do not match the previous window allocation:\n"
501 <<
"Window allocation: "
502 << fWindowMap.value()
511 template <
typename Gates>
515 if (fVerify.hasTopology()) {
516 return fVerify.verify(gates);
519 extractTopology(gates);
526 template <
typename Gates>
528 if (fVerify.hasTopology()) {
533 extractTopology(gates);
540 template <
typename Gates>
544 { *
fGeom, logCategory() +
"_Extractor" };
545 fVerify.setTopology(topoMaker.createFromGates(gates));
551 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWTOPOLOGYALG_H
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
icarus::trigger::WindowTopologyAlg::TriggerGatesPerCryostat_t TriggerGatesPerCryostat_t
Type of sets of trigger gates, grouped by cryostat.
icarus::trigger::WindowTopologyAlg::TriggerGates_t TriggerGates_t
Type of sets of trigger gates.
Class to extract and verify a window topology from trigger gates.
std::vector< InputTriggerGate_t > TriggerGates_t
A list of trigger gates from input.
static WindowChannelColl_t extractGateChannels(TriggerGates_t const &gates)
Extracts the channel ID from a collection of gates.
A wrapper to trigger gate objects tracking the input of operations.
Base class facilitating logging to message facility.
WindowChannelMap const * operator->() const
WindowChannelMap const & getTopology() const
icarus::trigger::TrackedOpticalTriggerGate< sbn::OpDetWaveformMeta > InputTriggerGate_t
Type of trigger gate extracted from the input event.
std::vector< TriggerGates_t > TriggerGatesPerCryostat_t
Type of lists of gates, one list per cryostat (outer index: cryostat no).
Information about composition and topology of trigger sliding windows.
icarus::trigger::WindowTopologyAlg::TriggerGatesPerCryostat_t TriggerGatesPerCryostat_t
Type of sets of trigger gates, grouped by cryostat.
icarus::trigger::WindowTopologyAlg::TriggerGates_t TriggerGates_t
Type of sets of trigger gates.
std::vector< WindowChannels_t > WindowChannelColl_t
All channels in many gates (one list per gate).
Geometry information for a single cryostat.
std::optional< icarus::trigger::WindowChannelMap > fWindowMap
The reference topology to check against.
Information of a single window.
Helper for logging classes.
void verifyOrThrow(Gates const &gates) const
Implementation of operator().
void clearTopology()
Forgets the current topology. Set a new one with setTopology().
geo::GeometryCore const *const fGeom
Geometry service provider.
WindowTopologyVerification(icarus::trigger::WindowChannelMap topology, std::string const &logCategory="WindowTopologyVerification")
Constructor.
WindowChannelMap const & operator*() const
WindowTopologyAlg(geo::GeometryCore const &geom, std::string const &logCategory="WindowTopologyAlg")
Constructor.
WindowChannelMap emplaceAndDumpMap(Args &&...args) const
bool operator()(Gates const &gates)
Extracts topology or verifies it against gates .
bool hasTopology() const
Returns whether a window topology is set (see setTopology()).
std::string verifyGate(std::size_t iWindow, InputTriggerGate_t const &gate) const
void extractTopology(Gates const &gates)
Helper: creates the topology from gates.
WindowChannelMap createFromGates(TriggerGatesPerCryostat_t const &gates) const
Returns the topology of the windows described by the gates.
Algorithm verifying the topology from trigger gates.
std::vector< raw::Channel_t > WindowChannels_t
All channels in a gate.
Description of geometry of one entire detector.
geo::GeometryCore const *const fGeom
Geometry service provider.
Data structure enclosing information for trigger sliding windows.
Algorithm to create trigger window topology information.
static WindowChannelMap::WindowInfo_t const * findClosestWindow(std::vector< WindowChannelMap::WindowInfo_t * > const &windowList, WindowChannelMap::WindowInfo_t const *targetWindow)
Returns the window in windowList closest to the targetWindow.
std::string verify(TriggerGatesPerCryostat_t const &gates) const
Verifies that gates match the topology current set up.
A simple alias for a most commonly used TrackedTriggerGate type.
static std::vector< WindowChannelMap::WindowInfo_t > createWindowsFromCryostat(WindowChannelColl_t const &windowChannels, geo::CryostatGeo const &cryo, geo::GeometryCore const &geom, std::size_t firstWindowIndex=0U)
Extracts topology information from a set of windows.
WindowChannelMap createFromCryostatGates(TriggerGates_t const &windowChannels, geo::CryostatGeo const &cryo) const
Returns the topology of the windows described by the gates.
std::string setOrVerify(Gates const &gates)
Extracts topology or verifies it against gates .
void operator()(TriggerGatesPerCryostat_t const &gates) const
Verifies that gates match the topology current set up.
void setTopology(icarus::trigger::WindowChannelMap topology)
Resets the topology to be verified against.
std::string logCategory() const
Returns the logging category string for this object.
WindowTopologyVerification fVerify
Verification algorithm; holds the current topology information.
WindowTopologyManager(geo::GeometryCore const &geom, std::string const &logCategory="WindowTopologyManager")
Constructor.
The data type to uniquely identify a cryostat.