All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SlidingWindowDefinitionAlg.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.h
3  * @brief Algorithm composing PMT sliding windows from geometry information.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date January 26, 2021
6  * @see icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefinitionAlg.cxx
7  */
8 
9 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_SLIDINGWINDOWDEFINITIONALG_H
10 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_SLIDINGWINDOWDEFINITIONALG_H
11 
12 // ICARUS libraries
14 
15 // LArSoft libraries
16 #include "lardataobj/RawData/OpDetWaveform.h" // raw::Channel_t
17 
18 // framework libraries
19 #include "cetlib_except/exception.h" // convenience
20 
21 // C/C++ standard libraries
22 #include <iosfwd> // std::ostream
23 #include <vector>
24 #include <string>
25 #include <utility> // std::move()
26 
27 
28 // -----------------------------------------------------------------------------
29 //
30 // forward declarations
31 //
32 namespace geo { class GeometryCore; }
33 
34 // -----------------------------------------------------------------------------
35 namespace icarus::trigger { class SlidingWindowDefinitionAlg; }
36 /**
37  * @brief Groups optical detector channels into windows based on position.
38  *
39  * This algorithm groups all the optical detectors in the specified detector
40  * geometry description into "sliding windows".
41  *
42  * Each optical detector "wall" (detectors at the same drift coordinate, that is
43  * on the same plane) is sliced in windows of a given size (`windowSize`, the
44  * number of optical detector channels within) starting one after the other at
45  * fixed intervals (`windowStride`).
46  *
47  * For example, a partition with window size 30 channels and stride also 30
48  * channels on a wall of 90 optical detector channels will create 3 windows
49  * with 30 channels each. A splitting with size 30 channels but stride only 15
50  * channels will create 5 windows of 30 channels each, which overlap (like in
51  * 0-29, 15-44, 30-59, 45-74 and 60-89).
52  *
53  * The windows are returned in the formats defined in
54  * `icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefs.h`, that is a list
55  * of windows, each being a list of optical detector channels.
56  *
57  *
58  * Algorithm details
59  * ------------------
60  *
61  * Optical detectors are split into "walls" and within each wall into "towers"
62  * (a wall being a set of optical detectors at the same drift coordinate, i.e.
63  * on a plane, and a tower being a set of detector in a wall which share the
64  * horizontal position but are piled in the vertical one, _y_).
65  * The task of separating the detectors in walls and towers is delegated to
66  * the algorithm `icarus::trigger::PMTverticalSlicingAlg`.
67  *
68  * Each wall is processed separately. The towers in the wall are sorted in the
69  * non-vertical direction (in ICARUS they will have a pattern of 2 channels,
70  * 3 channels, 3 channels, 2 channels, repeated 9 times), and the windows are
71  * created starting from one end. Towers are progressively added to the window
72  * until the window reaches the desided size (if it overshoots it, the window
73  * size is not compatible with the geometry and an exception is thrown).
74  * The process is repeated for each window, starting with the first tower,
75  * then the tower starting after `windowStride` optical detectors, then the
76  * tower starting after twice `windowStride` detectors, and so on, until a
77  * a window is reached that can't be completed because we ran out of towers.
78  * If there is no tower starting at the exact multiple of `windowStride`,
79  * the stride parameter is not compatible with the detector geometry, and an
80  * exception is thrown.
81  *
82  */
84 
85  // --- BEGIN Configuration variables -----------------------------------------
86 
87  /// Message facility stream category for output.
88  std::string const fLogCategory;
89 
90  // --- END Configuration variables -------------------------------------------
91 
92 
93  // --- BEGIN -- Setup --------------------------------------------------------
94 
95  geo::GeometryCore const& fGeom; ///< Geometry service provider.
96 
97  // --- END ---- Setup --------------------------------------------------------
98 
99  public:
100 
101  /// Type of optical detector channel list in a window.
103 
104  /// Definition of all windows.
106 
107 
108  /**
109  * @brief Constructor: complete algorithm setup.
110  * @param geom LArSoft geometry service provider
111  * @param logCategory tag to use for messages to message facility service
112  */
114  geo::GeometryCore const& geom,
115  std::string logCategory = "SlidingWindowDefinitionAlg"
116  );
117 
118 
119  // @{
120  /**
121  * @brief Performs the calculation and returns the sliding window composition.
122  * @param windowSize number of optical detectors in each window
123  * @param windowStride new window every `windowStride` optical detectors
124  */
126  (unsigned int windowSize, unsigned int windowStride) const;
127 
128  WindowDefs_t operator()
129  (unsigned int windowSize, unsigned int windowStride) const
130  { return makeWindows(windowSize, windowStride); }
131 
132  //@}
133 
134  // @{
135  /**
136  * @brief Performs the calculation and returns the sliding window composition.
137  * @param windowSize number of optical detectors in each window
138  *
139  * Windows are contiguous and not overlapping.
140  */
141  WindowDefs_t makeWindows(unsigned int windowSize) const
142  { return makeWindows(windowSize, windowSize); }
143 
144  WindowDefs_t operator() (unsigned int windowSize) const
145  { return makeWindows(windowSize); }
146 
147  //@}
148 
149 }; // icarus::trigger::SlidingWindowDefinitionAlg
150 
151 
152 
153 // -----------------------------------------------------------------------------
154 // --- inline implementation
155 // -----------------------------------------------------------------------------
157  geo::GeometryCore const& geom,
158  std::string logCategory /* = "SlidingWindowDefinitionAlg" */
159  )
160  : fLogCategory(std::move(logCategory))
161  , fGeom(geom)
162  {}
163 
164 
165 // -----------------------------------------------------------------------------
166 
167 
168 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_SLIDINGWINDOWDEFINITIONALG_H
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
std::vector< raw::Channel_t > TriggerWindowChannels_t
Type of optical detector channel list in a window.
icarus::trigger::TriggerWindowDefs_t WindowDefs_t
Definition of all windows.
fDetProps &fDetProps fDetProps &fDetProps fLogCategory
icarus::trigger::TriggerWindowChannels_t WindowChannels_t
Type of optical detector channel list in a window.
geo::GeometryCore const & fGeom
Geometry service provider.
Description of geometry of one entire detector.
Definition for PMT sliding windows.
WindowDefs_t operator()(unsigned int windowSize, unsigned int windowStride) const
std::string const fLogCategory
Message facility stream category for output.
Groups optical detector channels into windows based on position.
SlidingWindowDefinitionAlg(geo::GeometryCore const &geom, std::string logCategory="SlidingWindowDefinitionAlg")
Constructor: complete algorithm setup.
WindowDefs_t makeWindows(unsigned int windowSize) const
Performs the calculation and returns the sliding window composition.
std::vector< TriggerWindowChannels_t > TriggerWindowDefs_t
Definition of all windows.
WindowDefs_t makeWindows(unsigned int windowSize, unsigned int windowStride) const
Performs the calculation and returns the sliding window composition.