PAASS
Software suite to Acquire and Analyze Data from Pixie16
unittest-XiaListModeDataDecoder.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 
20 static const XiaListModeDataMask mask(R30474, 250);
21 using namespace unittest_encoded_data::R30474_250;
22 
23 //Test the error handling in the class
24 TEST_FIXTURE(XiaListModeDataDecoder, TestBufferLengthChecks) {
25  //Check that we throw a length error when the buffer length is zero
26  CHECK_THROW(DecodeBuffer(&empty_buffer[0], mask), length_error);
27  //Check that we return an empty vector when we have an empty module
28  CHECK_EQUAL(empty_buffer[1],
29  DecodeBuffer(&empty_module_buffer[0], mask).size());
30 }
33 TEST_FIXTURE(XiaListModeDataDecoder, TestHeaderDecoding) {
34  //Check that we get an empty vector when the header has an impossible size.
35  CHECK_EQUAL((unsigned int)0,
36  DecodeBuffer(&header_w_bad_headerlen[0], mask).size());
37 
38  //Check that we can decode a simple 4-word header.
39  XiaData result_data = *(DecodeBuffer(&header[0], mask).front());
40 
41  CHECK_EQUAL(slotId, result_data.GetSlotNumber());
42  CHECK_EQUAL(channelNumber, result_data.GetChannelNumber());
43  CHECK_EQUAL(energy, result_data.GetEnergy());
44  CHECK_EQUAL(ts_high, result_data.GetEventTimeHigh());
45  CHECK_EQUAL(ts_low, result_data.GetEventTimeLow());
46  CHECK_EQUAL(ts, result_data.GetTime());
47 }
48 
49 //Test if we can decode a trace properly
50 TEST_FIXTURE(XiaListModeDataDecoder, TestTraceDecoding) {
51  //Testing that we return an empty event list.
52  CHECK_EQUAL((unsigned int)0,
53  DecodeBuffer(&header_w_bad_eventlen[0], mask).size());
54 
55  XiaData result = *(DecodeBuffer(&header_N_trace[0], mask).front());
56  CHECK_ARRAY_EQUAL(unittest_trace_variables::trace, result.GetTrace(),
58 }
59 
60 //Test if we can decode the qdc properly
62  XiaData result = *(DecodeBuffer(&header_N_qdc[0], mask).front());
63  CHECK_ARRAY_EQUAL(qdc, result.GetQdc(), qdc.size());
64 }
65 
66 //Test that we can get the right timestamp if we involve the CFD.
67 TEST_FIXTURE(XiaListModeDataDecoder, TestCfdTimeCalculation) {
68  XiaData result = *(DecodeBuffer(&header_N_Cfd[0], mask).front());
69  CHECK_EQUAL(cfd_fractional_time, result.GetCfdFractionalTime());
70  CHECK_CLOSE(ts_w_cfd, result.GetTime(), 1e-5);
71 }
72 
73 
74 int main(int argv, char *argc[]) {
75  return (UnitTest::RunAllTests());
76 }
std::vector< unsigned int > GetQdc() const
Definition: XiaData.hpp:152
static const double ts
static const double ts_w_cfd
static const XiaListModeDataMask mask(R30474, 250)
static const unsigned int ts_low
unsigned int GetEventTimeHigh() const
Definition: XiaData.hpp:119
unsigned int header_w_bad_eventlen[6]
A header where the event length doesn&#39;t match what it should be.
STL namespace.
TEST_FIXTURE(XiaListModeDataDecoder, TestBufferLengthChecks)
static const std::vector< unsigned int > trace
unsigned int GetCfdFractionalTime() const
Definition: XiaData.hpp:110
static const unsigned int channelNumber
unsigned int GetChannelNumber() const
Definition: XiaData.hpp:113
unsigned int empty_module_buffer[2]
double GetTime() const
Method that will return the time for the channel. The actual time is a 48-bit number. We multiply 2^32 by the eventTimeHigh_ so that we account for the missing upper 16 bits of the number. The cfdTime_ contains all of the fractional time information, and so we divide by 2^16 here. Verify that this method works properly for all of the different module types and firmwares. It doesn&#39;t and this value simply needs to be set explicitly by the Decoder.
Definition: XiaData.hpp:107
static const std::vector< unsigned int > qdc
Class to decode Xia List mode Data.
unsigned int GetSlotNumber() const
Definition: XiaData.hpp:146
Header containing namespaced enumerations that are useful to different parts of the software...
This header provides sample data that can be used by Unit Tests to ensure proper functionality.
static const unsigned int slotId
unsigned int empty_buffer[2]
unsigned int GetEventTimeLow() const
Definition: XiaData.hpp:122
int main(int argv, char *argc[])
A pixie16 channel event.
Definition: XiaData.hpp:19
double GetEnergy() const
Definition: XiaData.hpp:96
static const unsigned int cfd_fractional_time
Class that handles decoding list mode data from XIA Pixie-16 modules.
static const unsigned int ts_high
std::vector< unsigned int > GetTrace() const
Definition: XiaData.hpp:155
unsigned int header_w_bad_headerlen[6]
A header with a header length 20 instead of the true header length 4.
static const unsigned int energy