RawTriggerHeaderV0.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawTriggerHeaderV0.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 RawTriggerHeader
14 #define CURRENT_CLASS_VERSION 0
15 #define CURRENT_FIELDS_SUB_NAMESPACE triggerheader
16 #include "DAQDataFormats/DataFormatLast.inc"
17 
18 namespace daqdataformats{
19 namespace VERSION_NAMESPACE{
20 
21 //------------------------Constructors------------------------------------------
23  PREVIOUS_VERSION_CLASS_NAME(version)
24  ,ZEROOUT_GET_AND_SET(Delimiter )
25  ,ZEROOUT_GET_AND_SET(Version )
26  ,ZEROOUT_GET_AND_SET(HWFlag )
27  ,ZEROOUT_GET_AND_SET(Source )
28  ,ZEROOUT_GET_AND_SET(SourceID )
29  ,ZEROOUT_GET_AND_SET(SourceSubID )
30  ,ZEROOUT_GET_AND_SET(TriggerNumberLow )
31  ,ZEROOUT_GET_AND_SET(TriggerNumberHigh )
32  ,ZEROOUT_GET_AND_SET(MasterTriggerNumberLow )
33  ,ZEROOUT_GET_AND_SET(MasterTriggerNumberHigh)
34  ,ZEROOUT_GET_AND_SET(MasterTriggerNumber)
35  ,ZEROOUT_GET_AND_SET(TriggerNumber)
36 {}
37 
38 //------------------------------------------------------------------------------
40  PREVIOUS_VERSION_CLASS_NAME(copyin)
41  ,DEEPCOPY_GET_AND_SET(Delimiter )
42  ,DEEPCOPY_GET_AND_SET(Version )
43  ,DEEPCOPY_GET_AND_SET(HWFlag )
44  ,DEEPCOPY_GET_AND_SET(Source )
45  ,DEEPCOPY_GET_AND_SET(SourceID )
46  ,DEEPCOPY_GET_AND_SET(SourceSubID )
47  ,DEEPCOPY_GET_AND_SET(TriggerNumberLow )
48  ,DEEPCOPY_GET_AND_SET(TriggerNumberHigh )
49  ,DEEPCOPY_GET_AND_SET(MasterTriggerNumberLow )
50  ,DEEPCOPY_GET_AND_SET(MasterTriggerNumberHigh)
51  ,DEEPCOPY_GET_AND_SET(MasterTriggerNumber)
52  ,DEEPCOPY_GET_AND_SET(TriggerNumber)
53 {}
54 
55 //------------------------------------------------------------------------------
57 //------------------------------------------------------------------------------
58 // General Initialization
60  EXECUTE_FUNCTION(setVersion)(_version);
62 }
63 
64 //------------------------------------------------------------------------------
65 // get Method for a full (64bit) wide trigger number (40bits in use)
66 uint64_t RawTriggerHeader::getTriggerNumber() const {
67  return getUint64_t(EXECUTE_FUNCTION(getTriggerNumberLow)(), EXECUTE_FUNCTION(getTriggerNumberHigh)());
68 }
69 
70 //------------------------------------------------------------------------------
71 // get Method for a full (64bit) wide trigger number (40bits in use)
72 uint64_t RawTriggerHeader::getMasterTriggerNumber() const {
73  return getUint64_t(EXECUTE_FUNCTION(getMasterTriggerNumberLow)(), EXECUTE_FUNCTION(getMasterTriggerNumberHigh)());
74 }
75 
76 //------------------------------------------------------------------------------
77 // set Method for Trigger Number High
78 bool RawTriggerHeader::setTriggerNumber(const uint64_t trig) {
79  uint32_t low, high;
80  getLoAndHi(trig, low, high);
81 
82  EXECUTE_FUNCTION(setTriggerNumberHigh)(high);
83  RETURN_FUNCTION(setTriggerNumberLow)(low);
84 }
85 
86 //------------------------------------------------------------------------------
87 // set Method for Trigger Number High
88 bool RawTriggerHeader::setMasterTriggerNumber(const uint64_t trig){
89  uint32_t low, high;
90  getLoAndHi(trig, low, high);
91 
92  EXECUTE_FUNCTION(setMasterTriggerNumberHigh)(high);
93  RETURN_FUNCTION(setMasterTriggerNumberLow)(low);
94 }
95 
96 //------------------------------------------------------------------------------
97 void RawTriggerHeader::print(std::ostream& os) const {
98 
99  os<<"++++ Trigger Header ++++\n";
100  os<<boost::format("Trigger Delimiter:\t0x%04x\n")%EXECUTE_FUNCTION(getDelimiter)();
101  os<<boost::format("Trigger Version:\t%u\n")%EXECUTE_FUNCTION(getVersion)();
102  os<<boost::format("Hardware Flag:\t\t%u\n")%EXECUTE_FUNCTION(getHWFlag)();
103  os<<boost::format("Trigger Source:\t\t%u\n")%EXECUTE_FUNCTION(getSource)();
104  os<<boost::format("Trigger Source ID:\t%u\n")%EXECUTE_FUNCTION(getSourceID)();
105  os<<boost::format("Trigger Source Sub ID:\t%u\n")%EXECUTE_FUNCTION(getSourceSubID)();
106  os<<boost::format("Trigger Number Low:\t%u\n")%EXECUTE_FUNCTION(getTriggerNumberLow)();
107  os<<boost::format("Trigger Number High:\t%u\n")%EXECUTE_FUNCTION(getTriggerNumberHigh)();
108  os<<boost::format("Master Trig Num Low:\t%u\n")%EXECUTE_FUNCTION(getMasterTriggerNumberLow)();
109  os<<boost::format("Master Trig Num High:\t%u\n")%EXECUTE_FUNCTION(getMasterTriggerNumberHigh)();
110  PRINT_ON_DEBUG("Buffer is set to "<<_Buffer);
111 }
112 
113 }}// end of namespaces
#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
RawTriggerHeader(const version_t)
The default constructor.
Class to hold the data from the global trigger header in the correct format.
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
void print(std::ostream &os=std::cout) const
const XML_Char * version
Definition: expat.h:187
int32_t version_t
Definition: RawDAQData.h:72
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
Class to hold the data from the FEBs in correct formats.