RawMicroSliceHeaderV0.h
Go to the documentation of this file.
1 #ifndef RAWMICROSLICEHEADERV0_H
2 #define RAWMICROSLICEHEADERV0_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 RawMicroSliceHeader
17 #define CURRENT_CLASS_VERSION 0
18 #define CURRENT_FIELDS_SUB_NAMESPACE rawmuhdr
19 #include "DAQDataFormats/DataFormatLast.inc"
20 
21 /// CAUTION!!!!!
22 /// It is assumes that MicroSlice header always has a size of 1 for all versions
23 
24 namespace daqdataformats {
25  static const uint32_t RAWMICROSLICEHEADER_SIZE = 1;
26 
27  namespace VERSION_NAMESPACE {
29 
30 
32  MASK_DataPresent = 0x80000000,///< DP bit
33  MASK_MonteCarloFlag = 0x40000000,///< SIM bit. True if it's simuleted data
34  MASK_Extra = 0x3FC00000,///< Extra bits (used for debugging purposes by Rick K)
35  MASK_Version = 0x003E0000,///< Microslice header version
36  MASK_Timeout = 0x00010000,///< Microslice Timeout bit
37  MASK_ByteCount = 0x0000FFFF ///< Leading Byte count
38  };
40  WORD_DataPresent = 0,///< DP bit
41  WORD_MonteCarloFlag = 0,///< SIM bit. True if it's simuleted data
42  WORD_Extra = 0,///< Extra bits (used for debugging purposes by Rick K)
43  WORD_Version = 0,///< Microslice header version
44  WORD_Timeout = 0,///< Microslice Timeout bit
45  WORD_ByteCount = 0 ///< Leading Byte count
46  };
47 
48  DEFINE_SHIFT_FROM_MASK(DataPresent);
49  DEFINE_SHIFT_FROM_MASK(MonteCarloFlag);
51  DEFINE_SHIFT_FROM_MASK(Version);
53  DEFINE_SHIFT_FROM_MASK(ByteCount);
54  } // end of namespace CURRENT_FIELDS_SUB_NAMESPACE
55 
56 
57  class RawMicroSliceHeader: public PREVIOUS_VERSION_CLASS_NAME {
58 
59  public:
62  ~RawMicroSliceHeader(); ///< Destructor
63 
64  void init ();
65  void initSoft(); ///< initing without setting the version field
67  void print (std::ostream& os=std::cout) const;
68  uint32_t sizeofdata () const { return RAWMICROSLICEHEADER_SIZE;}
69  using PREVIOUS_VERSION_CLASS_NAME::readData;
70  void* readData(const void* pointer){return RawDAQData::readDataGeneral(pointer);}
71 
72  /// CAUTION!!!!!
73  /// It is assume that these methods will
74  /// be the same for all versions of MicroSlice Header
75  IMPLEMENT_GET_AND_SET_BOOL(DataPresent);
76  IMPLEMENT_GET_AND_SET_BOOL(MonteCarloFlag);
78  IMPLEMENT_GET (Version , uint32_t);
79  IMPLEMENT_GET_AND_SET (ByteCount, uint32_t);
80  bool addByteCount(const uint32_t);
81  bool resetByteCount();
82  uint32_t getMicroSliceSize() const;
83  virtual bool setVersion(const version_t);
84 
85  protected:
86  /// These methods are different for different
87  /// versions of the MicroSlice header
88  IMPLEMENT_FIRST_GET_AND_SET(Extra , uint32_t);
89  INIT_FIRST_GET_AND_SET (Status, uint32_t);
90 
91  };// end of RawMicroSliceHeader
92 }} // END NAMESPCE
93 
94 #endif /* RAWMICROSLICEHEADERV0_H */
#define IMPLEMENT_GET_AND_SET_BOOL(FUNC)
Definition: Macros.h:123
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
#define VERSION_NAMESPACE
#define IMPLEMENT_GET_AND_SET(FUNC, UNITS)
Definition: Macros.h:120
#define IMPLEMENT_FIRST_GET_AND_SET(FUNC, UNITS)
Definition: Macros.h:171
#define INIT_FIRST_GET_AND_SET(FUNC, UNITS)
Definition: Macros.h:245
bool print
OStream cout
Definition: OStream.cxx:6
int32_t version_t
Definition: RawDAQData.h:72
#define CURRENT_FIELDS_SUB_NAMESPACE
#define IMPLEMENT_GET(FUNC, UNITS)
Definition: Macros.h:101
Class to hold the data from the FEBs in correct formats.
static const uint32_t RAWMICROSLICEHEADER_SIZE