RawSummaryDCMDataPointV0.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawSummaryDCMDataPointV0.h"
2 #include "DAQDataFormats/BitFields.h"
3 #include <boost/format.hpp>
4 
5 /// It is requred to
6 /// 1. include DAQDataFormats/DataFormatFirst.inc
7 /// 2. define CURRENT_CLASS
8 /// 3. define CURRENT_CLASS_VERSION for version of the class
9 /// OR define LAST_CLASS_VERSION for the main structure of the class
10 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
11 /// 5. include DAQDataFormats/DataFormatLast.inc
12 /// before the declaration of the DataFormat version class in the header.
13 #include "DAQDataFormats/DataFormatFirst.inc"
14 #define CURRENT_CLASS RawSummaryDCMDataPoint
15 #define CURRENT_CLASS_VERSION 0
16 #define CURRENT_FIELDS_SUB_NAMESPACE summarydcmdatapoint
17 #include "DAQDataFormats/DataFormatLast.inc"
18 
19 //#define PRINT_ON_DEBUG(x) std::cout<<x<<"\n";
20 
21 namespace daqdataformats{
22 
23 namespace VERSION_NAMESPACE{
24  //------------------------Constructors------------------------------------------
26  PREVIOUS_VERSION_CLASS_NAME(version)
27  ,ZEROOUT_GET_AND_SET(Version)
29  ,ZEROOUT_GET_AND_SET(DCMID)
30  ,ZEROOUT_GET_AND_SET(TimeStampLow)
31  ,ZEROOUT_GET_AND_SET(TimeStampHigh)
32 {}
33 
34 //------------------------------------------------------------------------------
36  PREVIOUS_VERSION_CLASS_NAME(copyin)
37  ,DEEPCOPY_GET_AND_SET(Version)
39  ,DEEPCOPY_GET_AND_SET(DCMID)
40  ,DEEPCOPY_GET_AND_SET(TimeStampLow)
41  ,DEEPCOPY_GET_AND_SET(TimeStampHigh)
42 {
43 }
44 //------------------------Destructor--------------------------------------------
46 
47 //------------------------------------------------------------------------------
48 // Default Initialization of Data members
50  EXECUTE_FUNCTION(setVersion)(_version);
51 }
52 
53 //------------------------------------------------------------------------------
54 // get Method for 64 bit time stamp
55 uint64_t RawSummaryDCMDataPoint::getTimeStamp() const {
56  return getUint64_t(EXECUTE_FUNCTION(getTimeStampLow)(), EXECUTE_FUNCTION(getTimeStampHigh)());
57 }
58 
59 //------------------------------------------------------------------------------
60 // set Method for 64bit time stamp
61 bool RawSummaryDCMDataPoint::setTimeStamp(const uint64_t timestamp) {
62  uint32_t low, high;
63  getLoAndHi(timestamp, low, high);
64 
65  EXECUTE_FUNCTION(setTimeStampHigh)(high);
66  RETURN_FUNCTION(setTimeStampLow)(low);
67 }
68 
69 //------------------------------------------------------------------------------
70 // Printing the NanoSlice
71 void RawSummaryDCMDataPoint::print(std::ostream& os) const {
72 
73  os<<boost::format("SummaryDCMDataPoint: Verion=%u Type=%u DCMID=%u TimeStampLow=%u TimeStampHigh=%u ")
74  %EXECUTE_FUNCTION(getVersion)()
75  %EXECUTE_FUNCTION(getDataType)()
76  %EXECUTE_FUNCTION(getDCMID)()
77  %EXECUTE_FUNCTION(getTimeStampLow)()
78  %EXECUTE_FUNCTION(getTimeStampHigh)();
79 
80  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
81 
82  os<<"Data size = "<<size_of_data<<"\n";
83 
84 
85  os<<"\nRAW(hex):";
86  for(uint32_t i = 0; i < size_of_data; ++i){
87  printWord(i,false, os);
88  os<<" ";
89  }
90 
91  os<<"\nRAW(binary):";
92  for(uint32_t i = 0; i < size_of_data; ++i){
93  if(i > 0)os<<" ";
94  printWord(i,true, os);
95  os<<std::endl;
96  }
97 }
98 
99 
100 }}// end of namespaces
101 
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
#define DEEPCOPY_GET_AND_SET(FUNC)
Definition: FunctionBind.h:44
#define VERSION_NAMESPACE
#define ZEROOUT_GET_AND_SET(FUNC)
Definition: FunctionBind.h:56
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
const XML_Char * version
Definition: expat.h:187
int32_t version_t
Definition: RawDAQData.h:72
Class to hold the data from the FEBs in correct formats.