All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SlidingWindowDefs.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefs.h
3  * @brief Definition for PMT sliding windows.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date January 26, 2021
6  * @see icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefs.cxx
7  */
8 
9 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_SLIDINGWINDOWDEFS_H
10 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_SLIDINGWINDOWDEFS_H
11 
12 
13 // LArSoft libraries
14 #include "lardataobj/RawData/OpDetWaveform.h" // raw::Channel_t
15 
16 // C/C++ standard libraries
17 #include <iosfwd> // std::ostream
18 #include <vector>
19 
20 
21 // -----------------------------------------------------------------------------
22 namespace icarus::trigger {
23 
24  // --- BEGIN -- Optical detector windows -------------------------------------
25  /**
26  * @name Optical detector windows
27  *
28  * An optical detector window is just a group of optical detectors.
29  * For trigger, these windows comprise contiguous optical detectors, and may
30  * overlap for better coverage.
31  *
32  * The algorithm `SlidingWindowDefinitionAlg` allows the creation of "sliding"
33  * windows. The information on a single window is encoded in a standard
34  * container (`TriggerWindowChannels_t`), with a unique channel number
35  * representing each detector in the window in no particular order.
36  *
37  * Definitions ("aliases") are here provided for convenience, together with
38  * a couple of functions to print the content of a window or a set of windows.
39  */
40  /// @{
41 
42  /// Type of optical detector channel list in a window.
43  using TriggerWindowChannels_t = std::vector<raw::Channel_t>;
44 
45  /// Definition of all windows.
46  using TriggerWindowDefs_t = std::vector<TriggerWindowChannels_t>;
47 
48  // --- BEGIN -- Optical detector window dumping on stream --------------------
49 
50  /// Prints the composition of the optical detector `window` inline.
52  (std::ostream& out, TriggerWindowChannels_t const& window);
53 
54  /// Prints the composition of all `windows` in long format.
56  (std::ostream& out, TriggerWindowDefs_t const& windows);
57 
58 
59  // ---------------------------------------------------------------------------
60  namespace details {
61 
66 
67  std::ostream& operator<<
68  (std::ostream& out, DumpTriggerWindowChannelWrapper window);
69 
70  std::ostream& operator<<
71  (std::ostream& out, DumpTriggerWindowDefWrapper windows);
72 
73  } // namespace details
74  // ---------------------------------------------------------------------------
75 
76 
77  /**
78  * Helper for printing a `TriggerWindowChannels_t` into a stream.
79  *
80  * Example:
81  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
82  * TriggerWindowChannels_t window; // ... filled with some channels
83  * std::cout << "Window: " << icarus::trigger::dumpTriggerWindowChannels(window);
84  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85  */
88 
89  /**
90  * Helper for printing a TriggerWindowDefs_t into a stream.
91  *
92  * Example:
93  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
94  * TriggerWindowDefs_t windows; // ... filled with some content
95  * std::cout << "Windows: " << icarus::trigger::dumpTriggerWindowDefs(windows);
96  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97  */
98  auto dumpTriggerWindowDefs(TriggerWindowDefs_t const& windows)
100 
101  /// @}
102  // --- END ---- Optical detector windows -------------------------------------
103 
104 } // namespace icarus::trigger
105 
106 
107 // -----------------------------------------------------------------------------
108 // --- inline implementation
109 // -----------------------------------------------------------------------------
110 inline std::ostream& icarus::trigger::details::operator<<
111  (std::ostream& out, DumpTriggerWindowChannelWrapper window)
112  { printTriggerWindowChannels(out, *(window.window)); return out; }
113 
114 
115 // -----------------------------------------------------------------------------
117  (TriggerWindowChannels_t const& window)
119  { return { &window }; }
120 
121 
122 // -----------------------------------------------------------------------------
123 inline std::ostream& icarus::trigger::details::operator<<
124  (std::ostream& out, DumpTriggerWindowDefWrapper windows)
125  { printTriggerWindowDefs(out, *(windows.windows)); return out; }
126 
127 
128 // -----------------------------------------------------------------------------
131  { return { &windows }; }
132 
133 
134 // -----------------------------------------------------------------------------
135 
136 
137 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_SLIDINGWINDOWDEFS_H
void printTriggerWindowDefs(std::ostream &out, TriggerWindowDefs_t const &windows)
Prints the composition of all windows in long format.
void printTriggerWindowChannels(std::ostream &out, TriggerWindowChannels_t const &window)
Prints the composition of the optical detector window inline.
std::vector< raw::Channel_t > TriggerWindowChannels_t
Type of optical detector channel list in a window.
auto dumpTriggerWindowChannels(TriggerWindowChannels_t const &window) -> details::DumpTriggerWindowChannelWrapper
auto dumpTriggerWindowDefs(TriggerWindowDefs_t const &windows) -> details::DumpTriggerWindowDefWrapper
std::vector< TriggerWindowChannels_t > TriggerWindowDefs_t
Definition of all windows.