All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WindowPattern.cxx
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Trigger/Algorithms/WindowPattern.cxx
3  * @brief Defines a (sliding) window trigger pattern (implementation file).
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date March 21, 2021
6  * @see icaruscode/PMT/Trigger/Algorithms/WindowPattern.h
7  */
8 
9 // library header
11 
12 
13 //------------------------------------------------------------------------------
15 
16  /*
17  * If the main window requirement is no larger than half the requested sum
18  * (rounded up) then the requirement is not relevant, although in the special
19  * cases where `S` is odd and `M` is its half rounded up (e.g. `M3S5`), the
20  * main window requirement may be used to decide to which side of the TPC
21  * the trigger should be assigned.
22  */
23 
24  unsigned int const maxIrrelevant
26 
27  return minInMainWindow > maxIrrelevant;
28 
29 } // icarus::trigger::WindowPattern::isMainRequirementRelevant()
30 
31 
32 //------------------------------------------------------------------------------
34 
35  return minSumInOppositeWindows > (minInMainWindow + minInOppositeWindow);
36 
37 } // icarus::trigger::WindowPattern::isSumRequirementRelevant()
38 
39 
40 //------------------------------------------------------------------------------
42  using namespace std::string_literals;
43 
44  std::string s;
45 
46  // `M` is added last, because it may be needed even if irrelevant
47  if (minInOppositeWindow > 0U)
48  s += "O"s + std::to_string(minInOppositeWindow);
49 
50  if (isSumRequirementRelevant())
51  s += "S"s + std::to_string(minSumInOppositeWindows);
52 
53  if ((minInDownstreamWindow > 0U) || requireDownstreamWindow) {
54  s += "D"s + std::to_string(minInDownstreamWindow);
55  if (requireDownstreamWindow) s+= "req"s;
56  } // if downstream
57 
58  if ((minInUpstreamWindow > 0U) || requireUpstreamWindow) {
59  s += "U"s + std::to_string(minInUpstreamWindow);
60  if (requireUpstreamWindow) s+= "req"s;
61  } // if upstream
62 
63  if (isMainRequirementRelevant() || s.empty())
64  s = "M"s + std::to_string(minInMainWindow) + s;
65 
66  return s;
67 } // icarus::trigger::WindowPattern::description()
68 
69 
70 //------------------------------------------------------------------------------
72  using namespace std::string_literals;
73 
74  bool const useMain = isMainRequirementRelevant();
75  bool const useSum = isSumRequirementRelevant();
76 
77  std::string s = "required:";
78 
79  if (useMain || !useSum)
80  s += " "s + std::to_string(minInMainWindow);
81  else
82  s += " "s + std::to_string(minSumInOppositeWindows) + " (main+opposite)"s;
83 
84  if (minInOppositeWindow > 0U)
85  s += " + "s + std::to_string(minInOppositeWindow) + " (opposite)"s;
86 
87  if (useMain && useSum)
88  s += " (and "s + std::to_string(minSumInOppositeWindows) + " main+opposite)"s;
89 
90  if ((minInDownstreamWindow > 0U) || requireDownstreamWindow) {
91  if (minInDownstreamWindow)
92  s += " + "s + std::to_string(minInDownstreamWindow);
93  s += " (downstream"s;
94  if (requireDownstreamWindow) s+= ", mandatory)"s;
95  s += ")"s;
96  } // if downstream
97 
98  if ((minInUpstreamWindow > 0U) || requireUpstreamWindow) {
99  if (minInUpstreamWindow) s += " + "s + std::to_string(minInUpstreamWindow);
100  s += " (upstream"s;
101  if (requireUpstreamWindow) s+= ", mandatory)"s;
102  s += ")"s;
103  } // if upstream
104 
105  return s;
106 } // icarus::trigger::WindowPattern::description()
107 
108 
109 //------------------------------------------------------------------------------
Defines a (sliding) window trigger pattern.
std::string tag() const
Returns a tag summarizing the pattern.
std::string to_string(WindowPattern const &pattern)
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
std::string description() const
Returns a description of the pattern.