PAASS
Software suite to Acquire and Analyze Data from Pixie16
unittest-XiaListModeDataEncoder.cpp
Go to the documentation of this file.
1 #include <stdexcept>
6 
7 #include <UnitTest++.h>
8 
9 #include "HelperEnumerations.hpp"
10 #include "UnitTestSampleData.hpp"
12 
13 using namespace std;
14 using namespace DataProcessing;
15 using namespace unittest_encoded_data;
16 using namespace unittest_decoded_data;
17 using namespace unittest_encoded_data::R30474_250;
18 
19 TEST_FIXTURE(XiaListModeDataEncoder, TestEncodingThrows) {
20  //Check that we throw a range error when we pass an empty XiaData class
21  CHECK_THROW(EncodeXiaData(XiaData(), R30474, 250), invalid_argument);
22 
23  //Check that we catch an invalid_argument when we pass a bogus firmware
24  CHECK_THROW(EncodeXiaData(XiaData(), UNKNOWN, 250), invalid_argument);
25 
26  //Check that we catch an invalid_argument when we pass a bogus frequency
27  CHECK_THROW(EncodeXiaData(XiaData(), R30474, 2500), invalid_argument);
28 }
29 
32 TEST_FIXTURE(XiaListModeDataEncoder, TestSimpleHeaderEncoding) {
33  XiaData data;
34  data.SetEnergy(energy);
35  data.SetSlotNumber(slotId);
37  data.SetCrateNumber(crateId);
38  data.SetEventTimeLow(ts_low);
40 
41  //Check that we can handle just a simple 4 word header
42  CHECK_ARRAY_EQUAL(header_vec, EncodeXiaData(data, R30474, 250),
43  header_vec.size());
44 
45  //Check that we can handle a header with a trace
47  CHECK_ARRAY_EQUAL(header_vec_w_trc, EncodeXiaData(data, R30474, 250),
48  header_vec_w_trc.size());
49 
50  //Check that we can handle a QDC
51  data.SetQdc(qdc);
52  data.SetTrace(vector<unsigned int>());
53  CHECK_ARRAY_EQUAL(header_vec_w_qdc, EncodeXiaData(data, R30474, 250),
54  header_vec_w_qdc.size());
55 
56  //Check that we can handle a QDC and a Trace
57  data.SetQdc(qdc);
59  CHECK_ARRAY_EQUAL(header_vec_w_qdc_n_trc, EncodeXiaData(data, R30474, 250),
60  header_vec_w_qdc_n_trc.size());
61 }
62 
63 int main(int argv, char *argc[]) {
64  return (UnitTest::RunAllTests());
65 }
std::vector< unsigned int > header_vec_w_qdc
void SetEventTimeLow(const unsigned int &a)
Sets the lower 32 bits of the event time.
Definition: XiaData.hpp:196
void SetCrateNumber(const unsigned int &a)
Sets the crate number.
Definition: XiaData.hpp:180
static const unsigned int ts_low
static const unsigned int crateId
void SetSlotNumber(const unsigned int &a)
Sets the slot number.
Definition: XiaData.hpp:220
STL namespace.
static const std::vector< unsigned int > trace
void SetChannelNumber(const unsigned int &a)
Sets the channel number.
Definition: XiaData.hpp:176
static const unsigned int channelNumber
std::vector< unsigned int > header_vec
std::vector< unsigned int > header_vec_w_qdc_n_trc
void SetTrace(const std::vector< unsigned int > &a)
Sets the trace recorded on board.
Definition: XiaData.hpp:228
static const std::vector< unsigned int > qdc
void SetQdc(const std::vector< unsigned int > &a)
Sets the QDCs that were calculated on-board.
Definition: XiaData.hpp:212
Header containing namespaced enumerations that are useful to different parts of the software...
void SetEnergy(const double &a)
Sets the energy calculated on-board.
Definition: XiaData.hpp:184
This header provides sample data that can be used by Unit Tests to ensure proper functionality.
static const unsigned int slotId
int main(int argv, char *argc[])
Class that handles encoding Pixie-16 list mode data from a XiaData class.
TEST_FIXTURE(XiaListModeDataEncoder, TestEncodingThrows)
std::vector< unsigned int > header_vec_w_trc
A pixie16 channel event.
Definition: XiaData.hpp:19
static const unsigned int ts_high
static const unsigned int energy
void SetEventTimeHigh(const unsigned int &a)
Sets the upper 16 bits of the event time.
Definition: XiaData.hpp:192