All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WindowPatternConfig.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/WindowPatternConfig.h
3  * @brief FHiCL configuration structure for `icarus::trigger::WindowPattern`.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date March 21, 2021
6  * @see icaruscode/PMT/Trigger/Algorithms/WindowPattern.cxx
7  */
8 
9 #ifndef ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWPATTERNCONFIG_H
10 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWPATTERNCONFIG_H
11 
12 
13 // framework libraries
14 #include "fhiclcpp/types/TableAs.h"
15 #include "fhiclcpp/types/Sequence.h"
16 #include "fhiclcpp/types/Atom.h"
17 
18 
19 // -----------------------------------------------------------------------------
20 namespace icarus::trigger::ns::fhicl {
21 
22  struct WindowPatternConfig;
23 
24  /**
25  * @brief Function for conversion `WindowPatternConfig` -> `WindowPattern`.
26  *
27  * The conversion is implicitly applied by `fhicl::TableAs<>`.
28  */
29  icarus::trigger::WindowPattern convert(WindowPatternConfig const& config);
30 
31  //----------------------------------------------------------------------------
32  /// Configuration element for a trigger window.
33  using WindowPatternTable =
34  ::fhicl::TableAs<icarus::trigger::WindowPattern, WindowPatternConfig>;
35 
36  /// Configuration element for any number of trigger windows.
37  using WindowPatternSequence = ::fhicl::Sequence<
38  ::fhicl::TableAs<icarus::trigger::WindowPattern, WindowPatternConfig>
39  >;
40 
41 } // namespace icarus::trigger
42 
43 
44 //------------------------------------------------------------------------------
45 /**
46  * @brief Configuration for a trigger window (`icarus::trigger::WindowPattern`).
47  * @see `icarus::trigger::WindowPattern` and `convert()`
48  *
49  * This FHiCL configuration class defines a trigger window, filling a
50  * `icarus::trigger::WindowPattern` object (or a sequence).
51  *
52  * The configuration describes the minimum requirement for the main window and
53  * each of the neighboring windows, and whether their existence is required.
54  * All parameters except for the requirement on the main window are optional,
55  * and if omitted (and assigned the default values) will be always satisfied.
56  *
57  * Example of usage:
58  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
59  * #include "icaruscode/PMT/Trigger/Algorithms/WindowPatternConfig.h"
60  * #include "icaruscode/PMT/Trigger/Algorithms/WindowPattern.h"
61  *
62  * class MyModule: public art::EDAnalyzer {
63  *
64  * icarus::trigger::WindowPattern const fOnePattern;
65  * icarus::trigger::WindowPatterns_t const fManyPatterns;
66  *
67  * public:
68  * struct Config {
69  *
70  * icarus::trigger::ns::fhicl::WindowPatternTable OneWindow {
71  * fhicl::Name("OneWindow"),
72  * fhicl::Comment("a single window configuration")
73  * };
74  *
75  * icarus::trigger::ns::fhicl::WindowPatternSequence ManyWindows {
76  * fhicl::Name("ManyWindows"),
77  * fhicl::Comment("many trigger window configurations [default: none]"),
78  * icarus::trigger::WindowPatterns_t{}
79  * };
80  *
81  * }; // struct Config
82  * using Parameters = art::EDAnalyzer::Table<Config>;
83  *
84  * MyModule(Parameters const& config);
85  *
86  * // ...
87  * }; // class MyModule
88  *
89  *
90  * MyModule::MyModule(Parameters const& config)
91  * : art::EDAnalyzer(config)
92  * , fOnePattern(config().OneWindow())
93  * , fManyPatterns(config().ManyWindows())
94  * {
95  * // ...
96  * }
97  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98  * will support a configuration block like:
99  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100  * physics.analyzers.mymodule: {
101  * module_type: MyModule
102  * OneWindow: {
103  * inMainWindow: 1
104  * inOppositeWindow: 1
105  * }
106  * ManyWindows: [
107  * {
108  * # M3D1
109  * inMainWindow: 3
110  * inDownstreamWindow: 1
111  * },
112  * {
113  * # M3D1req
114  * inMainWindow: 3
115  * inDownstreamWindow: 1
116  * requireDownstreamWindow: true
117  * },
118  * {
119  * # M5D2
120  * inMainWindow: 5
121  * inDownstreamWindow: 2
122  * },
123  * {
124  * # M5D2req
125  * inMainWindow: 5
126  * inDownstreamWindow: 2
127  * requireDownstreamWindow: true
128  * },
129  * {
130  * # M1S8
131  * inMainWindow: 4
132  * sumOfOppositeWindows: 8
133  * }
134  * ]
135  * }
136  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137  */
138 struct icarus::trigger::ns::fhicl::WindowPatternConfig {
139 
140  using Name = ::fhicl::Name;
141  using Comment = ::fhicl::Comment;
142  template <typename T> using Atom = ::fhicl::Atom<T>;
143 
144  Atom<unsigned int> inMainWindow {
145  Name("inMainWindow"),
146  Comment("minimum fired primitives in the main sliding window")
147  };
148  Atom<unsigned int> inUpstreamWindow {
149  Name("inUpstreamWindow"),
150  Comment(
151  "minimum fired primitives in the sliding window upstream of main one"
152  ),
153  0U // default
154  };
155  Atom<unsigned int> inDownstreamWindow {
156  Name("inDownstreamWindow"),
157  Comment(
158  "minimum fired primitives in the sliding window downstream of main one"
159  ),
160  0U // default
161  };
162  Atom<unsigned int> inOppositeWindow {
163  Name("inOppositeWindow"),
164  Comment(
165  "minimum fired primitives in the sliding window opposite of main one"
166  ),
167  0U // default
168  };
169  Atom<unsigned int> sumOfOppositeWindows {
170  Name("sumOfOppositeWindows"),
171  Comment(
172  "minimum fired primitives in the main plus opposite window"
173  ),
174  0U // default
175  };
176 
177  Atom<bool> requireUpstreamWindow {
178  Name("requireUpstreamWindow"),
179  Comment("an upstream window must be present (no border main window)"),
180  false
181  };
182  Atom<bool> requireDownstreamWindow {
183  Name("requireDownstreamWindow"),
184  Comment("a downstream window must be present (no border main window)"),
185  false
186  };
187 
188 }; // icarus::trigger::ns::fhicl::WindowPatternConfig
189 
190 
191 // -----------------------------------------------------------------------------
192 // --- Inline implementation
193 // -----------------------------------------------------------------------------
194 namespace icarus::trigger::ns::fhicl {
195 
196  icarus::trigger::WindowPattern convert(WindowPatternConfig const& config) {
197  return {
198  config.inMainWindow(), // minInMainWindow
199  config.inUpstreamWindow(), // minInUpstreamWindow
200  config.inDownstreamWindow(), // minInDownstreamWindow
201  config.inOppositeWindow(), // minInOppositeWindow
202  config.sumOfOppositeWindows(), // minSumInOppositeWindows
203  config.requireUpstreamWindow(), // requireUpstreamWindow
204  config.requireDownstreamWindow() // requireDownstreamWindow
205  };
206  } // icarus::trigger::ns::fhicl::convert()
207 
208 } // namespace icarus::trigger::ns::fhicl
209 
210 
211 // -----------------------------------------------------------------------------
212 
213 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWPATTERNCONFIG_H
::fhicl::Sequence< ::fhicl::TableAs< icarus::trigger::WindowPattern, WindowPatternConfig > > WindowPatternSequence
Configuration element for any number of trigger windows.
icarus::trigger::WindowPattern convert(WindowPatternConfig const &config)
Function for conversion WindowPatternConfig -&gt; WindowPattern.
Specification of the requirement of sliding window firing pattern.
Definition: WindowPattern.h:51
BEGIN_PROLOG vertical distance to the surface Name
::fhicl::TableAs< icarus::trigger::WindowPattern, WindowPatternConfig > WindowPatternTable
Configuration element for a trigger window.
bool requireUpstreamWindow
Whether a window location with no upstream window should be discarded.
Definition: WindowPattern.h:63