MicroSliceUnitTest.cpp
Go to the documentation of this file.
1 /*
2  * File: MicroSliceUnitTest.cpp
3  * Author: denis
4  *
5  * Created on September 24, 2012, 10:18 AM
6  */
7 //#include "DAQDataFormats/../unittest/RawDAQDataUnitTest.h"
8 //#include "DAQDataFormats/../unittest/MicroSliceConstructor.h"
9 #include "RawDAQDataUnitTest.h"
10 #include "MicroSliceConstructor.h"
12 
13 namespace daqdataformats {
14 
18  CPPUNIT_TEST(loopedcheckDeepCopyConstructor);
20  CPPUNIT_TEST(testReadDataIntoSameVersion);
22 public:
25 
28  void loopedcheckDeepCopyConstructor();
30 
32 
34 
35 private:
37 };
38 
39 //------------------------------------------------------------------------------
43 {
44 }
45 
46 //------------------------------------------------------------------------------
48 
49 //------------------------------------------------------------------------------
51 
52  /// Checking just construction
53  {
55  ASSERT_CHECK_FIELD(MonteCarloFlag);
56  ASSERT_CHECK_FIELD(Time);
57  delete df;
58  }
59 
60  /// Now Checking filling MicroSlice with NanoSlices
61  rawnano::NanoSliceConstructor nano_constructor;
63  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<_mainDFConstructor->_currentNanoSliceVersion<<std::endl;
64 
66  microslice->setVersion(0);
67  _mainDFConstructor->setFieldToTestValue_Time(microslice);
68  _mainDFConstructor->setFieldToTestValue_MonteCarloFlag(microslice);
69  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<_mainDFConstructor->_currentNanoSliceVersion<<std::endl;
70 
71  RawNanoSlice* nano1 = (RawNanoSlice*)nano_constructor.getFilledDataFormat(_mainDFConstructor->_currentNanoSliceVersion);
72 
73  RawNanoSlice* nano2 = (RawNanoSlice*)nano_constructor.getFilledDataFormat(_mainDFConstructor->_currentNanoSliceVersion);
74 
76  nano2->setPulseHeight(nano2->getPulseHeight() + 1);
77  }
79  nano2->setValue1(nano2->getValue1() + 1);
80  }
81 
82  microslice->addNanoSlice(nano1->getBuffer());
83  microslice->addNanoSlice(nano2->getBuffer());
84 
85  CPPUNIT_ASSERT(compareDataFormats(microslice, microslice->getHeader() , FIRST_CONTAINS_SECOND));
86  CPPUNIT_ASSERT(compareDataFormats(microslice, microslice->getTimingMarker(), FIRST_CONTAINS_SECOND));
87  CPPUNIT_ASSERT(compareDataFormats(microslice, nano1 , FIRST_CONTAINS_SECOND));
88  CPPUNIT_ASSERT(compareDataFormats(microslice, nano2 , FIRST_CONTAINS_SECOND));
89 
90  CPPUNIT_ASSERT(microslice->getNumNanoSlices() == 2 );
91 
92  CPPUNIT_ASSERT(_mainDFConstructor->checkField_MonteCarloFlag(microslice) );
93  CPPUNIT_ASSERT(_mainDFConstructor->checkField_Time(microslice) );
94 
96 
97  delete nano1;
98  delete nano2;
99  delete microslice;
100  }
101 }
102 
103 //------------------------------------------------------------------------------
104 void MicroSliceUnitTest::loopedcheckDeepCopyConstructor(){
105 
106  rawnano::NanoSliceConstructor nano_constructor;
107 
109  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<_mainDFConstructor->_currentNanoSliceVersion<<std::endl;
111  }
112 
113 }
114 
115 //------------------------------------------------------------------------------
117 
118  rawnano::NanoSliceConstructor nano_constructor;
119 
121  LOG_DEBUG("UNITTEST")<< "From "<<__PRETTY_FUNCTION__<<". Checking Nano version "<<_mainDFConstructor->_currentNanoSliceVersion<<std::endl;
123  }
124 
125 }
126 
127 //CPPUNIT_TEST_SUITE_REGISTRATION(MicroSliceUnitTest);
129 CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats");
130 
131 }; // end of class
#define DEFINE_testReadDataIntoSameVersion
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
version_t getNanoSlicesVersion(const RawMicroSlice *) const
Gets the NanoSlices version in the MicroSlice.
bool setVersion(const version_t)
virtual DATAFORMAT_COMPARE_RESULTS compareDataFormats(const RawDAQData *, const RawDAQData *) const
Are the two data formats the same?
MicroSliceConstructor * _mainDFConstructor
#define DEFINE_checkShallowCopyConstructor(CLASS)
Standard function that checks Shallow Copy Constructor.
uint32_t getNumNanoSlices() const
Get current Hit Probability (for a microslice generation)
daqdataformats::RawDAQData * getEmptyDataFormat(const version_t) const
method to create an empty dataformat with a given version
virtual void checkShallowCopyConstructor()
Check Shallow Copy Constructors for all versions.
Base class for RawDAQData unittest.
DEFINE_checkDeepCopyConstructor(RawMicroSlice) DEFINE_checkShallowCopyConstructor(RawMicroSlice) void loopedcheckDeepCopyConstructor()
daqdataformats::RawTimingMarker * getTimingMarker() const
Get the MicroSlice Header.
CPPUNIT_TEST(basicFieldGetAndSetChecks)
DEFINE_testReadDataIntoSameVersion void basicFieldGetAndSetChecks()
Check all field gets and sets for all versions.
daqdataformats::RawMicroSliceHeader * getHeader() const
RawDAQDataConstructor * _dataFormatConstructor
Pointer to RawDAQDataConstructor.
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConfigurationBlockUnitTest,"DAQDataFormats")
Class to hold the MicroSlice data.
Definition: RawMicroSlice.h:48
virtual void checkDeepCopyConstructor()
Check Deep Copy Constructors for all versions.
#define ASSERT_CHECK_FIELD(FIELD_NAME)
Assert checking get/set of the the field is good.
void addNanoSlice(const void *nanoslice_buffer, const bool check_mc_flag=true)
CPPUNIT_TEST_SUITE(MicroSliceUnitTest)
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
Class to hold the data from the FEBs in correct formats.
CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQDataFormats")