RawEventHeaderV0.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawEventHeaderV0.h"
2 #include <boost/format.hpp>
3 
4 /// It is requred to
5 /// 1. include DAQDataFormats/DataFormatFirst.inc
6 /// 2. define CURRENT_CLASS
7 /// 3. define CURRENT_CLASS_VERSION for version of the class
8 /// OR define LAST_CLASS_VERSION for the main structure of the class
9 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
10 /// 5. include DAQDataFormats/DataFormatLast.inc
11 /// before the declaration of the DataFormat version class in the header.
12 #include "DAQDataFormats/DataFormatFirst.inc"
13 #define CURRENT_CLASS RawEventHeader
14 #define CURRENT_CLASS_VERSION 0
15 #define CURRENT_FIELDS_SUB_NAMESPACE raweventhdr
16 #include "DAQDataFormats/DataFormatLast.inc"
17 
18 namespace daqdataformats{
19 namespace VERSION_NAMESPACE{
20 
21 //------------------------------------------------------------------------------
22 // Default constructor
24  RawDAQData(version)
25  ,ZEROOUT_GET_AND_SET(MarkerLeft )
26  ,ZEROOUT_GET_AND_SET(MarkerRight )
27  ,ZEROOUT_GET_AND_SET(Version )
28  ,ZEROOUT_GET_AND_SET(DataLoggerID )
29  ,ZEROOUT_GET_AND_SET(RunNumber )
31  ,ZEROOUT_GET_AND_SET(ConfigIDX )
32  ,ZEROOUT_GET_AND_SET(Partition )
33  ,ZEROOUT_GET_AND_SET(Subrun )
34  ,ZEROOUT_GET_AND_SET(EventNumberLo )
35  ,ZEROOUT_GET_AND_SET(EventNumberHi )
36  ,ZEROOUT_GET_AND_SET(EventType )
37  ,ZEROOUT_GET_AND_SET(EventSize )
38  ,ZEROOUT_GET_AND_SET(DataBlockNumber )
39  ,ZEROOUT_GET_AND_SET(MonteCarloFlag)
40  ,ZEROOUT_IS_AND_SET (CRCCalculationUsed)
41  ,ZEROOUT_IS_AND_SET (EventIncomplete)
42  ,ZEROOUT_FUNCTION(addEventSize )
43  ,ZEROOUT_FUNCTION(advanceEventNumber )
44  ,ZEROOUT_FUNCTION(advanceDataBlockNumber)
45  ,ZEROOUT_GET_AND_SET(EventNumber)
46 { }
47 
48 //------------------------------------------------------------------------------
50  RawDAQData(copyin)
51  ,DEEPCOPY_GET_AND_SET(MarkerLeft )
52  ,DEEPCOPY_GET_AND_SET(MarkerRight )
53  ,DEEPCOPY_GET_AND_SET(Version )
54  ,DEEPCOPY_GET_AND_SET(DataLoggerID )
55  ,DEEPCOPY_GET_AND_SET(RunNumber )
57  ,DEEPCOPY_GET_AND_SET(ConfigIDX )
58  ,DEEPCOPY_GET_AND_SET(Partition )
59  ,DEEPCOPY_GET_AND_SET(Subrun )
60  ,DEEPCOPY_GET_AND_SET(EventNumberLo )
61  ,DEEPCOPY_GET_AND_SET(EventNumberHi )
62  ,DEEPCOPY_GET_AND_SET(EventType )
63  ,DEEPCOPY_GET_AND_SET(EventSize )
64  ,DEEPCOPY_GET_AND_SET(DataBlockNumber )
65  ,DEEPCOPY_GET_AND_SET(MonteCarloFlag)
66  ,DEEPCOPY_IS_AND_SET (CRCCalculationUsed)
67  ,DEEPCOPY_IS_AND_SET (EventIncomplete)
68  ,DEEPCOPY_FUNCTION(addEventSize )
69  ,DEEPCOPY_FUNCTION(advanceEventNumber )
70  ,DEEPCOPY_FUNCTION(advanceDataBlockNumber)
71  ,DEEPCOPY_GET_AND_SET(EventNumber)
72 { }
73 
74 //------------------------------------------------------------------------------
75 // Destructor
77 
78 //------------------------------------------------------------------------------
79 // Initialization of data members
81  setVersion (_version);
84  setEventSize(EXECUTE_FUNCTION(sizeofdata)());
85 }
86 
87 //------------------------------------------------------------------------------
88 uint64_t RawEventHeader::getEventNumber() const {
89  return getUint64_t(EXECUTE_FUNCTION(getEventNumberLo)(), EXECUTE_FUNCTION(getEventNumberHi)());
90 }
91 //------------------------------------------------------------------------------
92 bool RawEventHeader::setEventNumber (const uint64_t event) {
93  uint32_t low, high;
94  getLoAndHi(event, low, high);
95 
96  EXECUTE_FUNCTION(setEventNumberHi)(high);
97  RETURN_FUNCTION(setEventNumberLo)(low);
98 }
99 
100 //------------------------------------------------------------------------------
101 bool RawEventHeader::addEventSize (const uint32_t size) {RETURN_FUNCTION(setEventSize)(EXECUTE_FUNCTION(getEventSize)() + size);}
102 bool RawEventHeader::advanceDataBlockNumber() {RETURN_FUNCTION(setDataBlockNumber)(EXECUTE_FUNCTION(getDataBlockNumber)() + 1);}
103 bool RawEventHeader::advanceEventNumber() {RETURN_FUNCTION(setEventNumber)(EXECUTE_FUNCTION(getEventNumber)() + 1);}
104 
105 
106 //------------------------------------------------------------------------------
108 
109 //------------------------------------------------------------------------------
110 // Print the MilliSlice header information
111 void RawEventHeader::print(std::ostream& os) const{
112  os<<"\nRawEvent Header:";
113  os<<boost::format(" MarkerLeft=%u" ) % EXECUTE_FUNCTION(getMarkerLeft)(); //! MilliSlice header delimiter
114  os<<boost::format(" MarkerRight=%u" ) % EXECUTE_FUNCTION(getMarkerRight)(); //! MilliSlice header delimiter
115  os<<boost::format(" Version=%u" ) % EXECUTE_FUNCTION(getVersion)(); //! Version number for the MilliSlice event builder
116  os<<boost::format(" DataLoggerID=%u" ) % EXECUTE_FUNCTION(getDataLoggerID)();
117  os<<boost::format(" RunNumber=%u" ) % EXECUTE_FUNCTION(getRunNumber)();
118  os<<boost::format(" RunType=%u" ) % EXECUTE_FUNCTION(getRunType)();
119  os<<boost::format(" ConfigIDX=%u" ) % EXECUTE_FUNCTION(getConfigIDX)();
120  os<<boost::format(" Partition=%u" ) % EXECUTE_FUNCTION(getPartition)();
121  os<<boost::format(" Subrun=%u" ) % EXECUTE_FUNCTION(getSubrun)();
122  os<<boost::format(" EventNumberLo=%u" ) % EXECUTE_FUNCTION(getEventNumberLo)();
123  os<<boost::format(" EventNumberHi=%u" ) % EXECUTE_FUNCTION(getEventNumberHi)();
124  os<<boost::format(" EventType=%u" ) % EXECUTE_FUNCTION(getEventType)();
125  os<<boost::format(" EventSize=%u" ) % EXECUTE_FUNCTION(getEventSize)();
126  os<<boost::format(" DataBlockNumber=%u" ) % EXECUTE_FUNCTION(getDataBlockNumber)();
127  os<<boost::format(" isEventIncomplete=%u" ) % EXECUTE_FUNCTION(isEventIncomplete)();
128  os<<boost::format(" MonteCarloFlag=%u" ) % EXECUTE_FUNCTION(getMonteCarloFlag)();
129  os<<boost::format(" isCRCCalculationUsed=%u") % EXECUTE_FUNCTION(isCRCCalculationUsed)();
130 
131  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
132 
133  os<<"\nRAW:";
134  for(uint32_t i = 0; i < size_of_data; ++i){
135  os<<boost::format(" ");
136  printWord(i, false, os);
137  }
138 
139  os<<"\nRAW:";
140  for(uint32_t i = 0; i < size_of_data; ++i){
141  os<<boost::format("\n");
142  printWord(i, true, os);
143  }
144 
145 }
146 
147 
148 }}
#define ZEROOUT_FUNCTION(FUNC)
Definition: FunctionBind.h:52
#define DEEPCOPY_FUNCTION(FUNC)
Definition: FunctionBind.h:40
#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
RawEventHeader(const version_t)
The default constructor.
#define ZEROOUT_IS_AND_SET(FUNC)
Definition: FunctionBind.h:59
#define ZEROOUT_GET_AND_SET(FUNC)
Definition: FunctionBind.h:56
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
#define DEEPCOPY_IS_AND_SET(FUNC)
Definition: FunctionBind.h:47
version_t getTailVersion(const version_t event_version)
Function to get the tail version from Event version.
Definition: RawEvent.h:25
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.
void print(std::ostream &os=std::cout) const