All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WindowChannelMap.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/WindowChannelMap.h
3  * @brief Data structure enclosing information for trigger sliding windows.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date January 29, 2021
6  * @see icaruscode/PMT/Trigger/Algorithms/WindowChannelMap.cxx
7  *
8  * Linkage to the implementation file is required when using `dump()` methods.
9  */
10 
11 
12 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWCHANNELMAP_H
13 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWCHANNELMAP_H
14 
15 
16 // LArSoft libraries
17 #include "lardataobj/RawData/OpDetWaveform.h" // raw::Channel_t
18 #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t
19 #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo::CryostatID
20 
21 // C/C++ standard libraries
22 #include <iosfwd> // std::ostream
23 #include <vector>
24 #include <string>
25 #include <utility> // std::move()
26 #include <limits> // std::numeric_limits<>
27 #include <cstddef> // std::size_t
28 
29 
30 //------------------------------------------------------------------------------
31 namespace icarus::trigger {
32  class WindowChannelMap;
33  std::ostream& operator<< (std::ostream& , WindowChannelMap const&);
34 } // namespace icarus::trigger
35 
36 /**
37  * @brief Information about composition and topology of trigger sliding windows.
38  *
39  * This class collects optical detector windows defined as a collection of
40  * channels, supposedly contiguous in space.
41  * A rudimentary topology is described with each window having upstream,
42  * downstream windows (with respect to the nominal beam direction) and a
43  * single opposite window.
44  *
45  * The class exposes a minimal collection interface and is therefore iterable.
46  * Windows are identified by an index that matches their position in the
47  * collection.
48  *
49  * This is just a data structure, and algorithms building the composition and
50  * topology of the windows are not part of it.
51  */
53 
54  public:
55 
56  using WindowIndex_t = std::size_t; ///< Type of window index
57 
58  /// Special index denoting an invalid window.
60  = std::numeric_limits<WindowIndex_t>::max();
61 
62  /// Geometric location and composition of the window.
64 
65  geo::Point_t center; ///< Center of the window.
66 
67  geo::CryostatID cryoid; ///< Which cryostat the channels are in.
68 
69  /// Optical detector channels covered by this window.
70  std::vector<raw::Channel_t> channels;
71 
72  /// Returns whether the window is in a single, known cryostat.
73  bool hasCryostat() const { return cryoid.isValid; }
74 
75  }; // struct WindowComposition_t
76 
77  /// Information of the identity and neighbourhood of a window.
79 
80  WindowIndex_t index; ///< Index of the window this information is about.
81 
82  /// Index of the window opposite to this one.
84 
85  /// Index of the window upstream of this one.
87 
88  /// Index of the window downstream of this one.
90 
91  /// Returns whether the main window has another upstream of it.
92  bool hasUpstreamWindow() const { return isValidWindow(upstream); }
93 
94  /// Returns whether the main window has another downstream of it.
95  bool hasDownstreamWindow() const { return isValidWindow(downstream); }
96 
97  /// Returns whether the main window has another downstream of it.
98  bool hasOppositeWindow() const { return isValidWindow(opposite); }
99 
100  }; // struct WindowTopology_t
101 
102  /// Information of a single window.
104 
106 
108 
109  /// Prints the information content (single line).
110  void dump(std::ostream& out, std::string const& indent = "") const;
111 
112  }; // struct WindowInfo_t
113 
114 
115  /// Construction: moves the `windows` information into the map.
116  explicit WindowChannelMap(std::vector<WindowInfo_t>&& windows)
117  : fWindows(std::move(windows)) {}
118 
119  // --- BEGIN Access to window information ------------------------------------
120  /// @name Access to window information.
121  /// @{
122 
123  /// Number of sliding windows.
124  std::size_t nWindows() const { return fWindows.size(); }
125 
126  /// Returns whether a window with the specified index is present.
127  bool hasWindow(WindowIndex_t index) const { return index < nWindows(); }
128 
129  /// Returns the information for the window with specified `index` (unchecked).
130  WindowInfo_t const& info(WindowIndex_t index) const { return fWindows[index]; }
131 
132  /// @}
133  // --- END Access to window information --------------------------------------
134 
135  // @{
136  /// Prints the content of the full mapping.
137  void dump(
138  std::ostream& out, std::string const& indent, std::string const& firstIndent
139  ) const;
140  void dump(std::ostream& out, std::string const& indent = "") const
141  { dump(out, indent, indent); }
142  // @}
143 
144 
145 
146  /// @name Iterable standard interface
147  /// @{
149  using reference_type = WindowInfo_t const&;
150  using pointer_type = WindowInfo_t const*;
151 
152  std::size_t size() const { return nWindows(); }
153  bool empty() const { return fWindows.empty(); }
154  auto begin() const { return fWindows.begin(); }
155  auto end() const { return fWindows.end(); }
156  auto cbegin() const { return begin(); }
157  auto cend() const { return end(); }
158  /// @}
159 
160 
161  /// Returns whether the specified index is not the invalid window index.
162  static bool isValidWindow(WindowIndex_t index)
163  { return index != InvalidWindowIndex; }
164 
165 
166  private:
167  std::vector<WindowInfo_t> fWindows; /// Information for each window.
168 
169 }; // icarus::trigger::WindowChannelMap
170 
171 
172 //------------------------------------------------------------------------------
173 
174 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWCHANNELMAP_H
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
WindowIndex_t upstream
Index of the window upstream of this one.
bool hasCryostat() const
Returns whether the window is in a single, known cryostat.
bool hasUpstreamWindow() const
Returns whether the main window has another upstream of it.
bool hasDownstreamWindow() const
Returns whether the main window has another downstream of it.
WindowIndex_t downstream
Index of the window downstream of this one.
std::ostream & operator<<(std::ostream &out, icarus::trigger::ApplyBeamGateClass const &gate)
static const WindowIndex_t InvalidWindowIndex
Special index denoting an invalid window.
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:211
bool hasWindow(WindowIndex_t index) const
Returns whether a window with the specified index is present.
bool hasOppositeWindow() const
Returns whether the main window has another downstream of it.
std::size_t nWindows() const
Number of sliding windows.
Information about composition and topology of trigger sliding windows.
Geometric location and composition of the window.
std::size_t WindowIndex_t
Type of window index.
Information of the identity and neighbourhood of a window.
Definitions of geometry vector data types.
WindowChannelMap(std::vector< WindowInfo_t > &&windows)
Construction: moves the windows information into the map.
void dump(std::ostream &out, std::string const &indent="") const
Definition of data types for geometry description.
geo::CryostatID cryoid
Which cryostat the channels are in.
static bool isValidWindow(WindowIndex_t index)
Returns whether the specified index is not the invalid window index.
std::vector< raw::Channel_t > channels
Optical detector channels covered by this window.
std::vector< WindowInfo_t > fWindows
WindowIndex_t opposite
Index of the window opposite to this one.
WindowIndex_t index
Index of the window this information is about.
void dump(std::ostream &out, std::string const &indent, std::string const &firstIndent) const
Prints the content of the full mapping.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
void dump(std::ostream &out, std::string const &indent="") const
Prints the information content (single line).
WindowInfo_t const & info(WindowIndex_t index) const
Returns the information for the window with specified index (unchecked).
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190