RawEventHeaderV0.h
Go to the documentation of this file.
1 #ifndef RAWEVENTHEADERV0_H
2 #define RAWEVENTHEADERV0_H
3 #include "DAQDataFormats/RawDAQData.h"
4 #include "DAQDataFormats/Macros.h"
5 #include "DAQDataFormats/BitFields.h"
6 
7 /// It is requred to
8 /// 1. include DAQDataFormats/DataFormatFirst.inc
9 /// 2. define CURRENT_CLASS
10 /// 3. define CURRENT_CLASS_VERSION for version of the class
11 /// OR define LAST_CLASS_VERSION for the main structure of the class
12 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
13 /// 5. include DAQDataFormats/DataFormatLast.inc
14 /// before the declaration of the DataFormat version class in the header.
15 #include "DAQDataFormats/DataFormatFirst.inc"
16 #define CURRENT_CLASS RawEventHeader
17 #define CURRENT_CLASS_VERSION 0
18 #define CURRENT_FIELDS_SUB_NAMESPACE raweventhdr
19 #include "DAQDataFormats/DataFormatLast.inc"
20 
21 namespace daqdataformats {
22 
24  /// Event header delimiter
25  static const uint32_t Marker_value[2] = {0xE929, 0xE929};
26  }
27 
28 namespace VERSION_NAMESPACE {
30 
32 
33  const uint32_t RAWEVENTHEADER_SIZE = 8;
34 
36  MASK_MarkerRight = 0x0000FFFF, //! Marker Mask left (16 bits)
37  MASK_MarkerLeft = 0xFFFF0000, //! Marker Mask right (16 bits)
38  MASK_EventSize = 0xFFFFFFFF, //! Size of the event in words (8 bits)
39  MASK_Version = 0x00000FFF, //! Version Mask (12 bits)
40  MASK_DataLoggerID = 0xFFFF0000, //! DataLogger ID (16 bits)
41  MASK_RunNumber = 0x00FFFFFF, //! Run number (24 bits)
42  MASK_RunType = 0xFF000000, //! Run type (8 bits)
43  MASK_ConfigIDX = 0x0000FFFF, //! Detector configuration identifier (16 bits)
44  MASK_Partition = 0x00FF0000, //! Data logger partition (8 bits)
45  MASK_Subrun = 0x3F000000, //! SubRun number (6 bits)
46  MASK_EventNumberLo = 0xFFFFFFFF, //! Universal event number lower 0-31 bits
47  MASK_EventNumberHi = 0x000000FF, //! Universal event number upper 32-39 bits
48  MASK_EventType = 0xFF000000, //! Size of the event in words (8 bits)
49  MASK_DataBlockNumber = 0x0000FFFF, //! Number of event size (16 bits)
50  MASK_EventIncomplete = 0x20000000, //! Event incomplete flag (1 bit)
51  MASK_MonteCarloFlag = 0x40000000, //! SIM flag (1 bit)
52  MASK_CRCCalculationUsed = 0x80000000 //! Is CRC calculation used? (1 bit)
53  };
54 
59  WORD_Version = 2,
61  WORD_RunNumber = 3,
62  WORD_RunType = 3,
64  WORD_Partition = 4,
65  WORD_Subrun = 4,
70  WORD_EventIncomplete = 7, //! Event incomplete flag (1 bit)
73  };
74 
75  DEFINE_SHIFT_FROM_MASK(MarkerRight );
76  DEFINE_SHIFT_FROM_MASK(MarkerLeft );
77  DEFINE_SHIFT_FROM_MASK(EventSize );
78  DEFINE_SHIFT_FROM_MASK(Version );
79  DEFINE_SHIFT_FROM_MASK(DataLoggerID );
80  DEFINE_SHIFT_FROM_MASK(RunNumber );
82  DEFINE_SHIFT_FROM_MASK(ConfigIDX );
83  DEFINE_SHIFT_FROM_MASK(Partition );
84  DEFINE_SHIFT_FROM_MASK(Subrun );
85  DEFINE_SHIFT_FROM_MASK(EventNumberLo );
86  DEFINE_SHIFT_FROM_MASK(EventNumberHi );
87  DEFINE_SHIFT_FROM_MASK(EventType );
88  DEFINE_SHIFT_FROM_MASK(DataBlockNumber );
89  DEFINE_SHIFT_FROM_MASK(EventIncomplete );
90  DEFINE_SHIFT_FROM_MASK(MonteCarloFlag );
91  DEFINE_SHIFT_FROM_MASK(CRCCalculationUsed );
92 
93 
94  }// end of namespace raweventhdr
95 
96  class RawEventHeader: public PREVIOUS_VERSION_CLASS_NAME {
97  public:
98  RawEventHeader (const version_t); ///< The default constructor
100  ~RawEventHeader(); ///< Destructor
101 
102  void init ();
104  void print (std::ostream& os=std::cout) const;
106  using RawDAQData::readData;
107  void* readData(const void* pointer){return RawDAQData::readDataGeneral(pointer);};
108 
109  // Fields that are defined in later versions, but are not allowed in this version
110  bool setTriggerFilled(const uint32_t) {return GENERATE_FUNCTION_IS_NOT_ALLOWED;}
111  bool setTailFilled (const uint32_t) {return GENERATE_FUNCTION_IS_NOT_ALLOWED;}
113  uint32_t getTailFilled () const {GENERATE_FUNCTION_IS_NOT_ALLOWED; return 0;}
114 
115  protected:
116 
117  IMPLEMENT_FIRST_GET_AND_SET(MarkerLeft , uint32_t);
118  IMPLEMENT_FIRST_GET_AND_SET(MarkerRight , uint32_t);
119  IMPLEMENT_FIRST_GET_AND_SET(Version , uint32_t);
120  IMPLEMENT_FIRST_GET_AND_SET(DataLoggerID , uint32_t);
121  IMPLEMENT_FIRST_GET_AND_SET(RunNumber , uint32_t);
123  IMPLEMENT_FIRST_GET_AND_SET(ConfigIDX , uint32_t);
124  IMPLEMENT_FIRST_GET_AND_SET(Partition , uint32_t);
125  IMPLEMENT_FIRST_GET_AND_SET(Subrun , uint32_t);
126  IMPLEMENT_FIRST_GET_AND_SET(EventNumberLo , uint32_t);
127  IMPLEMENT_FIRST_GET_AND_SET(EventNumberHi , uint32_t);
128  IMPLEMENT_FIRST_GET_AND_SET(EventType , uint32_t);
129  IMPLEMENT_FIRST_GET_AND_SET(EventSize , uint32_t);
130  IMPLEMENT_FIRST_GET_AND_SET(DataBlockNumber , uint32_t);
131  IMPLEMENT_FIRST_GET_AND_SET_BOOL(MonteCarloFlag);
132  IMPLEMENT_FIRST_IS_AND_SET (CRCCalculationUsed);
133  IMPLEMENT_FIRST_IS_AND_SET (EventIncomplete);
134 
135  INIT_FIRST(addEventSize , ,bool , const uint32_t);
136  INIT_FIRST(advanceEventNumber , ,bool, );
137  INIT_FIRST(advanceDataBlockNumber, ,bool, );
138 
139  INIT_FIRST(getEventNumber , const, uint64_t, );
140  INIT_FIRST(setEventNumber , , bool , const uint64_t);
141 
142  /// Returns tail version corresponding to the Event(EventHeader) version
143  INIT_FIRST(getTailVersion , const, version_t, );
144 
145  };
146 
147 
148 }} // END NAMESPCE daqdataformats
149 #endif /* RAWEVENTHEADERV0_H */
#define CURRENT_FIELDS_SUB_NAMESPACE
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
#define IMPLEMENT_FIRST_IS_AND_SET(FUNC)
Definition: Macros.h:177
#define GENERATE_FUNCTION_IS_NOT_ALLOWED
calling functionIsNotAllowed
Definition: RawDAQData.h:21
#define VERSION_NAMESPACE
#define INIT_FIRST(FUNC, CONSTNESS, OUTPUT_UNITS,...)
Definition: Macros.h:239
#define IMPLEMENT_FIRST_GET_AND_SET(FUNC, UNITS)
Definition: Macros.h:171
Partition identifier that Run Control and Data Logger belong to (8 bits)
bool print
Partition identifier that Run Control and Data Logger belong to (8 bits)
version_t getTailVersion(const version_t event_version)
Function to get the tail version from Event version.
Definition: RawEvent.h:25
OStream cout
Definition: OStream.cxx:6
void * readData(const void *buffer)
Shallow copy constructor.
Definition: RawDAQData.cpp:181
int32_t version_t
Definition: RawDAQData.h:72
Class to hold the data from the FEBs in correct formats.
#define IMPLEMENT_FIRST_GET_AND_SET_BOOL(FUNC)
Definition: Macros.h:174