All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WindowPattern.h
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/WindowPattern.h
3  * @brief Defines a (sliding) window trigger pattern.
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_WINDOWPATTERN_H
10 #define ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWPATTERN_H
11 
12 
13 // C/C++ standard libraries
14 #include <vector>
15 #include <string>
16 #include <limits>
17 
18 
19 // -----------------------------------------------------------------------------
20 namespace icarus::trigger {
21 
22  struct WindowPattern;
23 
24  /// A list of window patterns.
25  using WindowPatterns_t = std::vector<WindowPattern>;
26 
27  //----------------------------------------------------------------------------
28  std::string to_string(WindowPattern const& pattern);
29 
30  //----------------------------------------------------------------------------
31 
32 } // namespace icarus::trigger
33 
34 
35 //------------------------------------------------------------------------------
36 /**
37  * @brief Specification of the requirement of sliding window firing pattern.
38  *
39  * This structure contains the requirements of a trigger on a ("main") window.
40  * The main window is supposed to have neighbors upstream and downstream of it
41  * (the "stream" being the neutrino beam's), and a single window opposite to it.
42  * The requirements are a minimum activity (as a count of LVDS signals open at
43  * the same time) for each of the windows. A minimum requirement of `0` is
44  * considered to be always satisfied (even if effectively the window it refers
45  * to does not exist).
46  *
47  * Special requirements are whether it is mandatory for the window to have a
48  * upstream and/or downstream window (the presence of an opposite window is
49  * assumed to always be optional).
50  */
52 
53  /// @name Minimum required number of open trigger primitives per window.
54  /// @{
55  unsigned int minInMainWindow = 0U;
56  unsigned int minInUpstreamWindow = 0U;
57  unsigned int minInDownstreamWindow = 0U;
58  unsigned int minInOppositeWindow = 0U;
59  unsigned int minSumInOppositeWindows = 0U;
60  /// @}
61 
62  /// Whether a window location with no upstream window should be discarded.
63  bool requireUpstreamWindow = false;
64 
65  /// Whether a window location with no downstream window should be discarded.
67 
68  /// Returns whether the main requirement (`M`) contributes to specification.
69  /// This is not the case when `S` is specified that is twice `M` or when its
70  /// value is `0`.
71  bool isMainRequirementRelevant() const;
72 
73  /// Returns whether the sum requirement (`S`) contributes to specification.
74  /// This is not the case when `S` is not larger than the sum of `M` and `O`.
75  bool isSumRequirementRelevant() const;
76 
77 
78  /**
79  * @brief Returns a tag summarizing the pattern.
80  *
81  * The tag encodes the requirements on the main window (_R(M)_), its
82  * opposite window (_R(O)_), their minimum sum (_R(S)_) and downstream
83  * (_R(D)_) and upstream (_R(U)_) windows.
84  * A requirement _R(X)_ is in the format `X##[req]`, where `X` is the tag
85  * letter of the requirement, `##` is the requirement level for that window,
86  * and the optional `req` tag means that if for a main window this window
87  * does not exist, that main window is not considered (e.g. the downstream
88  * window of a main window which is the most downstream in the detector).
89  *
90  * For example, `M5O2D2reqU1` requires 5 openings in the main window (`M5`),
91  * 2 in the window opposite to the main one (`O2`) and also 2 on the window
92  * downstream of the main one (`D2req`) and also 1 on the window
93  * upstream of the main one (`U1`); in addition, if the main window
94  * has no downstream window (i.e. it's at the "far end" of the detector),
95  * the downstream requirement is never satisfied and the trigger is
96  * considered to never fire. Instead, if there is no upstream window (i.e.
97  * the main window is in the "near end" of the detector) the upstream window
98  * requirement is considered to be satisfied (or ignored).
99  *
100  * Redundant requirements are omitted (except for `M0` if not superseded by a
101  * sum requirement).
102  */
103  std::string tag() const;
104 
105  /// Returns a description of the pattern.
106  std::string description() const;
107 
108 
109 }; // icarus::triggerWindowPattern
110 
111 
112 //------------------------------------------------------------------------------
113 //--- Inline definitions
114 //------------------------------------------------------------------------------
116  { return pattern.tag(); }
117 
118 
119 // -----------------------------------------------------------------------------
120 
121 #endif // ICARUSCODE_PMT_TRIGGER_ALGORITHMS_WINDOWPATTERN_H
Specification of the requirement of sliding window firing pattern.
Definition: WindowPattern.h:51
bool requireDownstreamWindow
Whether a window location with no downstream window should be discarded.
Definition: WindowPattern.h:66
std::string tag() const
Returns a tag summarizing the pattern.
std::string to_string(WindowPattern const &pattern)
bool requireUpstreamWindow
Whether a window location with no upstream window should be discarded.
Definition: WindowPattern.h:63
std::vector< WindowPattern > WindowPatterns_t
A list of window patterns.
Definition: WindowPattern.h:25
std::string description() const
Returns a description of the pattern.