All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WaveformOperations_test.cc
Go to the documentation of this file.
1 /**
2  * @file WaveformOperations_test.cc
3  * @brief Unit test for waveform operations.
4  * @date June 27, 2019
5  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
6  * @see `icarusalg/Utilities/WaveformOperations.h`
7  */
8 
9 // Boost libraries
10 #define BOOST_TEST_MODULE WaveformOperationsTest
11 #include <boost/test/unit_test.hpp>
12 
13 // ICARUS libraries
15 
16 
17 //------------------------------------------------------------------------------
19 
20  using Sample_t = signed short int;
21 
23 
24  // negative polarity waveform with baseline +8000
25  constexpr NegOp op(+8000);
26 
27  //
28  // "absolute" operations
29  //
30 
31  static_assert(NegOp::distance(+8000, +7000) == +1000);
32  static_assert(NegOp::distance(+8000, +9000) == -1000);
33 
34  static_assert(NegOp::shiftBy(+8000, +1000) == +7000);
35  static_assert(NegOp::shiftBy(+8000, -1000) == +9000);
36 
37  static_assert(NegOp::subtractBaseline(+7000, +8000) == +1000);
38  static_assert(NegOp::subtractBaseline(+9000, +8000) == -1000);
39 
40  //
41  // comparisons
42  //
43 
44  static_assert( (NegOp::lessThan (+8000, +7000)));
45  static_assert(!(NegOp::lessThan (+8000, +8000)));
46  static_assert(!(NegOp::lessThan (+8000, +9000)));
47  static_assert(!(NegOp::greaterThan (+8000, +7000)));
48  static_assert(!(NegOp::greaterThan (+8000, +8000)));
49  static_assert( (NegOp::greaterThan (+8000, +9000)));
50  static_assert(!(NegOp::noLessThan (+8000, +7000)));
51  static_assert( (NegOp::noLessThan (+8000, +8000)));
52  static_assert( (NegOp::noLessThan (+8000, +9000)));
53  static_assert( (NegOp::noGreaterThan(+8000, +7000)));
54  static_assert( (NegOp::noGreaterThan(+8000, +8000)));
55  static_assert(!(NegOp::noGreaterThan(+8000, +9000)));
56 
57  //
58  // operations relative to the baseline
59  //
60 
61  static_assert(op.shiftFromBaseline(+1000) == +7000);
62  static_assert(op.shiftFromBaseline(-1000) == +9000);
63 
64  static_assert(op.subtractBaseline(+7000) == +1000);
65  static_assert(op.subtractBaseline(+9000) == -1000);
66 
67 
68 } // void NegativePolarityTest()
69 
70 
71 //------------------------------------------------------------------------------
73 
74  using Sample_t = signed short int;
75 
77 
78  // negative polarity waveform with baseline +8000
79  constexpr PosOp op(+8000);
80 
81  //
82  // "absolute" operations
83  //
84 
85  static_assert(PosOp::distance(+8000, +9000) == +1000);
86  static_assert(PosOp::distance(+8000, +7000) == -1000);
87 
88  static_assert(PosOp::shiftBy(+8000, +1000) == +9000);
89  static_assert(PosOp::shiftBy(+8000, -1000) == +7000);
90 
91  static_assert(PosOp::subtractBaseline(+9000, +8000) == +1000);
92  static_assert(PosOp::subtractBaseline(+7000, +8000) == -1000);
93 
94  //
95  // comparisons
96  //
97 
98  static_assert(!(PosOp::lessThan (+8000, +7000)));
99  static_assert(!(PosOp::lessThan (+8000, +8000)));
100  static_assert( (PosOp::lessThan (+8000, +9000)));
101  static_assert( (PosOp::greaterThan (+8000, +7000)));
102  static_assert(!(PosOp::greaterThan (+8000, +8000)));
103  static_assert(!(PosOp::greaterThan (+8000, +9000)));
104  static_assert( (PosOp::noLessThan (+8000, +7000)));
105  static_assert( (PosOp::noLessThan (+8000, +8000)));
106  static_assert(!(PosOp::noLessThan (+8000, +9000)));
107  static_assert(!(PosOp::noGreaterThan(+8000, +7000)));
108  static_assert( (PosOp::noGreaterThan(+8000, +8000)));
109  static_assert( (PosOp::noGreaterThan(+8000, +9000)));
110 
111  //
112  // operations relative to the baseline
113  //
114 
115  static_assert(op.shiftFromBaseline(+1000) == +9000);
116  static_assert(op.shiftFromBaseline(-1000) == +7000);
117 
118  static_assert(op.subtractBaseline(+9000) == +1000);
119  static_assert(op.subtractBaseline(+7000) == -1000);
120 
121 
122 } // void PositivePolarityTest()
123 
124 
125 //------------------------------------------------------------------------------
126 //--- The tests
127 //---
128 BOOST_AUTO_TEST_CASE( AllTests ) {
129 
132 
133 } // BOOST_AUTO_TEST_CASE( AllTests )
134 
BOOST_AUTO_TEST_CASE(AllTests)
void NegativePolarityTest()
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
Operations< Sample,-1 > NegativePolarityOperations
Waveform operations for negative polarity waveforms.
Operations on waveform samples.
static constexpr bool noGreaterThan(Sample_t a, Sample_t b)
bool greaterThan(CluLen c1, CluLen c2)
void PositivePolarityTest()
bool lessThan(CluLen c1, CluLen c2)
Operations< Sample,+1 > PositivePolarityOperations
Waveform operations for positive polarity waveforms.