PAASS
Software suite to Acquire and Analyze Data from Pixie16
unittest-XiaData.cpp
Go to the documentation of this file.
1 #include <vector>
6 
7 #include <cmath>
8 
9 #include <UnitTest++.h>
10 
11 #include "UnitTestSampleData.hpp"
12 #include "XiaData.hpp"
13 
14 using namespace std;
15 using namespace unittest_trace_variables;
16 using namespace unittest_decoded_data;
17 
19 
20 TEST_FIXTURE(XiaData, Test_GetBaseline) {
21  SetBaseline(baseline);
22  CHECK_EQUAL(baseline, GetBaseline());
23 }
24 
25 TEST_FIXTURE(XiaData, Test_GetId) {
26  SetSlotNumber(slotId);
27  SetChannelNumber(channelNumber);
28  SetCrateNumber(crateId);
29  CHECK_EQUAL(crateId * 208 + GetModuleNumber() * 16 +
30  channelNumber, GetId());
31 }
32 
33 TEST_FIXTURE(XiaData, Test_GetSetCfdForcedTrig) {
34  SetCfdForcedTriggerBit(cfd_forced_trigger);
35  CHECK(GetCfdForcedTriggerBit());
36 }
37 
38 TEST_FIXTURE(XiaData, Test_GetSetCfdFractionalTime) {
39  SetCfdFractionalTime(cfd_fractional_time);
40  CHECK_EQUAL(cfd_fractional_time, GetCfdFractionalTime());
41 }
42 
43 TEST_FIXTURE(XiaData, Test_GetSetCfdTriggerSourceBit) {
44  SetCfdTriggerSourceBit(cfd_source_trigger_bit);
45  CHECK(GetCfdTriggerSourceBit());
46 }
47 
48 TEST_FIXTURE(XiaData, Test_GetSetChannelNumber) {
49  SetChannelNumber(channelNumber);
50  CHECK_EQUAL(channelNumber, GetChannelNumber());
51 }
52 
53 TEST_FIXTURE(XiaData, Test_GetSetCrateNumber) {
54  SetCrateNumber(crateId);
55  CHECK_EQUAL(crateId, GetCrateNumber());
56 }
57 
58 TEST_FIXTURE(XiaData, Test_GetSetEnergy) {
59  SetEnergy(energy);
60  CHECK_EQUAL(energy, GetEnergy());
61 }
62 
63 TEST_FIXTURE(XiaData, Test_GetSetEnergySums) {
64  SetEnergySums(energy_sums);
65  CHECK_ARRAY_EQUAL(energy_sums, GetEnergySums(),
66  energy_sums.size());
67 }
68 
69 TEST_FIXTURE(XiaData, Test_GetSetEventTimeHigh) {
70  SetEventTimeHigh(ts_high);
71  CHECK_EQUAL(ts_high, GetEventTimeHigh());
72 }
73 
74 TEST_FIXTURE(XiaData, Test_GetSetEventTimeLow) {
75  SetEventTimeLow(ts_low);
76  CHECK_EQUAL(ts_low, GetEventTimeLow());
77 }
78 
79 TEST_FIXTURE(XiaData, Test_GetSetExternalTimeHigh) {
80  SetExternalTimeHigh(ex_ts_high);
81  CHECK_EQUAL(ex_ts_high, GetExternalTimeHigh());
82 }
83 
84 TEST_FIXTURE(XiaData, Test_GetSetExternalTimeLow) {
85  SetExternalTimeLow(ex_ts_low);
86  CHECK_EQUAL(ex_ts_low, GetExternalTimeLow());
87 }
88 
89 TEST_FIXTURE(XiaData, Test_GetSetPileup) {
90  SetPileup(pileup_bit);
91  CHECK(IsPileup());
92 }
93 
94 TEST_FIXTURE(XiaData, Test_GetSetQdc) {
95  SetQdc(qdc);
96  CHECK_ARRAY_EQUAL(qdc, GetQdc(), qdc.size());
97 }
98 
99 TEST_FIXTURE(XiaData, Test_GetSetSaturation) {
100  SetSaturation(trace_out_of_range);
101  CHECK(IsSaturated());
102 }
103 
104 TEST_FIXTURE(XiaData, Test_GetSetSlotNumber) {
105  SetSlotNumber(slotId);
106  CHECK_EQUAL(slotId, GetSlotNumber());
107 }
108 
109 TEST_FIXTURE(XiaData, Test_GetSetTrace) {
110  SetTrace(trace);
111  CHECK_ARRAY_EQUAL(trace, GetTrace(), trace.size());
112 }
113 
114 TEST_FIXTURE(XiaData, Test_GetSetVirtualChannel) {
115  SetVirtualChannel(virtual_channel);
116  CHECK(IsVirtualChannel());
117 }
118 
119 TEST_FIXTURE(XiaData, Test_GetTime) {
120  SetTime(ts);
121  CHECK_EQUAL(ts, GetTime());
122 }
123 
125 TEST(Test_CompareTime){
126  lhs.Clear(); rhs.Clear();
127 
128  lhs.SetTime(ts);
129  rhs.SetTime(ts+10);
130 
131  CHECK(lhs.CompareTime(&lhs, &rhs));
132 }
133 
134 //This will test that the ID for the rhs is greater than the lhs
135 TEST(Test_CompareId) {
136  lhs.Clear(); rhs.Clear();
138  lhs.SetSlotNumber(slotId);
139  lhs.SetCrateNumber(crateId);
140 
142  rhs.SetSlotNumber(slotId+2);
143  rhs.SetCrateNumber(crateId);
144 
145  CHECK(lhs.CompareId(&lhs, &rhs));
146 }
147 
148 TEST(Test_Equality) {
149  lhs.Clear(); rhs.Clear();
151  lhs.SetSlotNumber(slotId);
152  lhs.SetCrateNumber(crateId);
153  rhs = lhs;
154  CHECK(lhs == rhs);
155 }
156 
157 TEST(Test_LessThanOperator) {
158  lhs.Clear(); rhs.Clear();
159  lhs.SetTime(ts);
160  rhs = lhs;
161  rhs.SetTime(ts+10);
162  CHECK(lhs < rhs);
163 }
164 
165 int main(int argv, char *argc[]) {
166  return (UnitTest::RunAllTests());
167 }
168 
static bool CompareId(const XiaData *lhs, const XiaData *rhs)
A method that will compare the unique ID of two XiaData classes.
Definition: XiaData.hpp:73
static const bool pileup_bit
static const double ts
static const bool cfd_source_trigger_bit
static const unsigned int ex_ts_high
void SetCrateNumber(const unsigned int &a)
Sets the crate number.
Definition: XiaData.hpp:180
static const unsigned int ts_low
int main(int argv, char *argc[])
static const unsigned int crateId
void SetSlotNumber(const unsigned int &a)
Sets the slot number.
Definition: XiaData.hpp:220
void Clear()
Clear all variables and set them to some default values.
Definition: XiaData.cpp:11
STL namespace.
static const std::vector< unsigned int > trace
void SetChannelNumber(const unsigned int &a)
Sets the channel number.
Definition: XiaData.hpp:176
static bool CompareTime(const XiaData *lhs, const XiaData *rhs)
A method that will compare the times of two XiaData classes this method can be used in conjunction wi...
Definition: XiaData.hpp:64
static const unsigned int channelNumber
static const bool virtual_channel
XiaData lhs
static const std::vector< unsigned int > energy_sums
static const double baseline
static const bool cfd_forced_trigger
static const unsigned int ex_ts_low
static const std::vector< unsigned int > qdc
This header provides sample data that can be used by Unit Tests to ensure proper functionality.
static const bool trace_out_of_range
static const unsigned int slotId
A pixie16 channel event.
Definition: XiaData.hpp:19
static const unsigned int cfd_fractional_time
XiaData rhs
static const unsigned int ts_high
TEST_FIXTURE(XiaData, Test_GetBaseline)
void SetTime(const double &a)
Sets the calculated arrival time of the signal.
Definition: XiaData.hpp:224
static const unsigned int energy
TEST(Test_CompareTime)
This will test that the Time for the rhs is greater than the lhs.