All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
TrackedTriggerGate_test.cc File Reference

Unit test for some utilities in TrackedTriggerGate.h More...

#include "icaruscode/PMT/Trigger/Utilities/TrackedOpticalTriggerGate.h"
#include "icaruscode/IcarusObj/OpDetWaveformMeta.h"
#include "lardataalg/DetectorInfo/DetectorTimingTypes.h"
#include "larcorealg/CoreUtils/DebugUtils.h"
#include <boost/test/unit_test.hpp>
#include <utility>
#include <type_traits>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( TrackedTriggerGate_test )
 

Functions

void static_tests ()
 
void TrackedTriggerGate_test ()
 
 BOOST_AUTO_TEST_CASE (TrackedTriggerGate_testcase)
 

Detailed Description

Unit test for some utilities in TrackedTriggerGate.h

Date
January 13, 2022
Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
See Also
icaruscode/PMT/Trigger/Utilities/TrackedTriggerGate.h

Largely incomplete.

Definition in file TrackedTriggerGate_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( TrackedTriggerGate_test )

Definition at line 21 of file TrackedTriggerGate_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( TrackedTriggerGate_testcase  )

Definition at line 243 of file TrackedTriggerGate_test.cc.

243  {
244 
245  static_tests();
246 
248 
249 } // BOOST_AUTO_TEST_CASE(TrackedTriggerGate_testcase)
void TrackedTriggerGate_test()
void static_tests()
void static_tests ( )

Definition at line 33 of file TrackedTriggerGate_test.cc.

33  {
34 
36 
39  GateData_t gateData;
40 
41  //
42  // gateIn()
43  //
44  static_assert(std::is_same_v<
45  decltype(gateIn(trackedGate)),
47  >);
48  static_assert(std::is_same_v<
49  decltype(gateIn(std::as_const(trackedGate))),
51  >);
52  static_assert(std::is_same_v<
53  decltype(gateIn(std::move(trackedGate))),
55  >);
56 
57  static_assert(std::is_same_v<
58  decltype(gateIn(gate)),
60  >);
61  static_assert(std::is_same_v<
62  decltype(gateIn(std::as_const(gate))),
64  >);
65  static_assert(std::is_same_v<
66  decltype(gateIn(std::move(gate))),
68  >);
69 
70  //
71  // gateDataIn()
72  //
73  static_assert(std::is_same_v<
74  decltype(gateDataIn(trackedGate)),
75  GateData_t&
76  >);
77  static_assert(std::is_same_v<
78  decltype(gateDataIn(std::as_const(trackedGate))),
79  GateData_t const&
80  >);
81  static_assert(std::is_same_v<
82  decltype(gateDataIn(std::move(trackedGate))),
83  GateData_t&&
84  >);
85  static_assert(std::is_same_v<
86  decltype(gateDataIn(gate)),
87  GateData_t&
88  >);
89  static_assert(std::is_same_v<
90  decltype(gateDataIn(std::as_const(gate))),
91  GateData_t const&
92  >);
93  static_assert(std::is_same_v<
94  decltype(gateDataIn(std::move(gate))),
95  GateData_t&&
96  >);
97 
98  static_assert(std::is_same_v<
99  decltype(gateDataIn(gateData)),
100  GateData_t&
101  >);
102  static_assert(std::is_same_v<
103  decltype(gateDataIn(std::as_const(gateData))),
104  GateData_t const&
105  >);
106  static_assert(std::is_same_v<
107  decltype(gateDataIn(std::move(gateData))),
108  GateData_t&&
109  >);
110 
111  //
112  // ok, now some non-static tests just for safety
113  //
114  BOOST_TEST(gateIn(trackedGate) == trackedGate.gate());
115  BOOST_TEST(gateIn(gate) == gate);
116  BOOST_TEST(gateDataIn(trackedGate) == trackedGate.gate().gateLevels());
117  BOOST_TEST(gateDataIn(gate) == gate.gateLevels());
118  BOOST_TEST(gateDataIn(gateData) == gateData);
119 
120 } // static_tests()
Base_t GateData_t
Type for gate data access.
A wrapper to trigger gate objects tracking the input of operations.
GateData_t const & gateLevels() const
Access to the underlying gate level data.
Logical multi-level gate associated to one or more readout channels.
TriggerGate_t const & gate() const &
Returns the enclosed gate.
decltype(auto) gateDataIn(Gate &&gate)
Returns the trigger data (a TriggerGateData) from the specofied gate.
decltype(auto) gateIn(Gate &&gate)
Returns the trigger gate (a ReadoutTriggerGate) from the specified gate.
void TrackedTriggerGate_test ( )

Definition at line 126 of file TrackedTriggerGate_test.cc.

126  {
127 
128  /*
129  * This test is a copy from TriggerGateData unit test.
130  * It's basically a placeholder, since the real tests are the static ones.
131  */
132 
134  icarus::trigger::OpticalTriggerGateData_t& gate = trackedGate.gate();
135 
136  BOOST_CHECK((gate.alwaysClosed()));
137 
138  /*
139  * ^ 12 34
140  * 4 | === 20 ===
141  * 3 | -4 4 10 == === 26
142  * 2 | === 2 === == 15 === === 40
143  * 1 | == 7=== 17 23=== 29== 37 ===
144  * 0-*=======---=|=---,----,----,----,----,----,===-,-===,--===============
145  * -10 -5 0 5 10 20 30 40 50
146  */
147 
148  gate.openBetween(-4, -1, 2); // -> 2
149  gate.openAt ( 2); // -> 1
150  gate.openAt ( 4); // -> 2
151  gate.closeAt( 7); // -> 1
152  gate.openAt (10); // -> 2
153  gate.openAt (12, 2); // -> 4
154  gate.closeAt(15); // -> 3
155  gate.closeAt(17); // -> 2
156  gate.openAt (20); // -> 3
157  gate.closeAt(23, 2); // -> 1
158  gate.openAt (26); // -> 2
159  gate.closeAt(29); // -> 1
160  gate.closeAt(31); // -> 0
161  gate.openAt (34, 4); // -> 4
162  gate.closeAt(37, 4); // -> 0
163  gate.openAt (40); // -> 1
164  gate.closeAt(43); // -> 0
165 
166  BOOST_CHECK((!gate.alwaysClosed()));
167  BOOST_TEST((gate.openingCount(-9) == 0));
168  BOOST_TEST((gate.openingCount(-8) == 0));
169  BOOST_TEST((gate.openingCount(-7) == 0));
170  BOOST_TEST((gate.openingCount(-6) == 0));
171  BOOST_TEST((gate.openingCount(-5) == 0));
172  BOOST_TEST((gate.openingCount(-4) == 2));
173  BOOST_TEST((gate.openingCount(-3) == 2));
174  BOOST_TEST((gate.openingCount(-2) == 2));
175  BOOST_TEST((gate.openingCount(-1) == 0));
176  BOOST_TEST((gate.openingCount( 0) == 0));
177  BOOST_TEST((gate.openingCount( 1) == 0));
178  BOOST_TEST((gate.openingCount( 2) == 1));
179  BOOST_TEST((gate.openingCount( 3) == 1));
180  BOOST_TEST((gate.openingCount( 4) == 2));
181  BOOST_TEST((gate.openingCount( 5) == 2));
182  BOOST_TEST((gate.openingCount( 6) == 2));
183  BOOST_TEST((gate.openingCount( 7) == 1));
184  BOOST_TEST((gate.openingCount( 8) == 1));
185  BOOST_TEST((gate.openingCount( 9) == 1));
186  BOOST_TEST((gate.openingCount(10) == 2));
187  BOOST_TEST((gate.openingCount(11) == 2));
188  BOOST_TEST((gate.openingCount(12) == 4));
189  BOOST_TEST((gate.openingCount(13) == 4));
190  BOOST_TEST((gate.openingCount(14) == 4));
191  BOOST_TEST((gate.openingCount(15) == 3));
192  BOOST_TEST((gate.openingCount(16) == 3));
193  BOOST_TEST((gate.openingCount(17) == 2));
194  BOOST_TEST((gate.openingCount(18) == 2));
195  BOOST_TEST((gate.openingCount(19) == 2));
196  BOOST_TEST((gate.openingCount(20) == 3));
197  BOOST_TEST((gate.openingCount(21) == 3));
198  BOOST_TEST((gate.openingCount(22) == 3));
199  BOOST_TEST((gate.openingCount(23) == 1));
200  BOOST_TEST((gate.openingCount(24) == 1));
201  BOOST_TEST((gate.openingCount(25) == 1));
202  BOOST_TEST((gate.openingCount(26) == 2));
203  BOOST_TEST((gate.openingCount(27) == 2));
204  BOOST_TEST((gate.openingCount(28) == 2));
205  BOOST_TEST((gate.openingCount(29) == 1));
206  BOOST_TEST((gate.openingCount(30) == 1));
207  BOOST_TEST((gate.openingCount(31) == 0));
208  BOOST_TEST((gate.openingCount(32) == 0));
209  BOOST_TEST((gate.openingCount(33) == 0));
210  BOOST_TEST((gate.openingCount(34) == 4));
211  BOOST_TEST((gate.openingCount(35) == 4));
212  BOOST_TEST((gate.openingCount(36) == 4));
213  BOOST_TEST((gate.openingCount(37) == 0));
214  BOOST_TEST((gate.openingCount(38) == 0));
215  BOOST_TEST((gate.openingCount(39) == 0));
216  BOOST_TEST((gate.openingCount(40) == 1));
217  BOOST_TEST((gate.openingCount(41) == 1));
218  BOOST_TEST((gate.openingCount(42) == 1));
219  BOOST_TEST((gate.openingCount(43) == 0));
220  BOOST_TEST((gate.openingCount(44) == 0));
221  BOOST_TEST((gate.openingCount(45) == 0));
222  BOOST_TEST((gate.openingCount(46) == 0));
223  BOOST_TEST((gate.openingCount(47) == 0));
224  BOOST_TEST((gate.openingCount(48) == 0));
225  BOOST_TEST((gate.openingCount(49) == 0));
226 
227  BOOST_TEST((gate.findMaxOpen( ) == 12));
228  BOOST_TEST((gate.findMaxOpen(12) == 12));
229  BOOST_TEST((gate.findMaxOpen(13) == 13));
230  BOOST_TEST((gate.findMaxOpen(14) == 14));
231  BOOST_TEST((gate.findMaxOpen(15) == 34));
232 
233  auto [ lower2031, upper2031 ] = gate.openingRange(20, 30);
234  BOOST_TEST((lower2031 == 1));
235  BOOST_TEST((upper2031 == 4));
236 
237 } // TrackedTriggerGate_test()
A wrapper to trigger gate objects tracking the input of operations.
void closeAt(ClockTick_t tick, OpeningDiff_t count)
Close this gate at the specified time (decrease the opening by count).
void openBetween(ClockTick_t start, ClockTick_t end, OpeningDiff_t count=1)
Open this gate at specified start tick, and close it at end tick.
Logical multi-level gate associated to one or more readout channels.
OpeningCount_t openingCount(ClockTick_t tick) const
Returns the opening count of the gate at the specified tick.
void openAt(ClockTick_t tick, OpeningDiff_t count)
Open this gate at the specified time (increase the opening by count).
TriggerGate_t const & gate() const &
Returns the enclosed gate.
ClockTick_t findMaxOpen(ClockTick_t start=MinTick, ClockTick_t end=MaxTick) const
Returns the tick at which the gate has the maximum opening.
bool alwaysClosed() const
Returns whether this gate never opened.
std::pair< OpeningCount_t, OpeningCount_t > openingRange(ClockTick_t start, ClockTick_t end) const
Returns the range of trigger opening values in the specified range.