RawNanoSliceHeaderV0.h
Go to the documentation of this file.
1 #ifndef RAWNANOSLICEHEADERV0_H
2 #define RAWNANOSLICEHEADERV0_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 RawNanoSliceHeader
17 #define CURRENT_CLASS_VERSION 0
18 #define CURRENT_FIELDS_SUB_NAMESPACE nanosliceheader
19 #include "DAQDataFormats/DataFormatLast.inc"
20 
21 namespace daqdataformats {
22 
23  //! Data structure for holding the unpacked FEB nanoslice header information
24  //! Data structure for holding all the nanoslice data of interest
25  typedef struct {
26  //uint32_t PAD3;
28  //uint32_t PAD5;
29  uint32_t PixelAddress;
30  uint32_t FEBStatus;
31  uint32_t FEBLinkID;
32  uint32_t Version;
33 
34  bool DebugMode;
36  bool LinkStatus;
38 
39 
40  namespace VERSION_NAMESPACE {
42 
43  static const uint32_t RAWNANOSLICEHEADER_SIZE = 1; ///< NanoSliceHeader size in words
44  static const uint32_t PAD3_DEFAULT_VALUE = 1; ///< Default value for Pad3
45 
47  MASK_LinkStatus = 0x00000001, //! Link Status (1 bit)
48  MASK_DataPresent = 0x00000002, //! Denis Perevalov Present/Absent flag (1 bit)
49  MASK_DebugMode = 0x00000004, //! Debug Mode (1 bit)
50  MASK_FEBId = 0x000001F8, //! FEB ID (6 bit)
51  MASK_FEBStatus = 0x0000FE00, //! FEB Status (7 bit)
52  MASK_PixelAddr = 0x001F0000, //! Pixel Address (5 bit)
53  MASK_Version = 0x03E00000, //! version number (5 bit)
54  MASK_Sequence = 0x1C000000, //! Sequence number (3 bit)
55  MASK_Pad3 = 0xE0000000, //! Pad3 (3 bit)
56  MASK_DAQEnabled = 0x00000200, //! DAQ Enabled Status Bit (1 bit)
57  MASK_BufferEmpty = 0x00000400, //! APD Data Buffer Empty (1 bit)
58  MASK_BufferFull = 0x00000800, //! APD Data Buffer Full (1 bit)
59  MASK_CommError = 0x00001000, //! FEB Communications Error (1 bit)
60  MASK_PacketError = 0x00002000, //! FEB Packet Error (1 bit)
61  MASK_OverflowError= 0x00004000, //! FEB Data Buff Overflow Error (1 bit)
62  MASK_ADCError = 0x00008000, //! FEB ADC Error (1 bit)
63  };// end of NanoSliceHeaderMASKS
64 
66  WORD_LinkStatus = 0, //! Link Status (1 bit)
67  WORD_DataPresent = 0, //! Denis Perevalov Present/Absent flag (1 bit)
68  WORD_DebugMode = 0, //! Debug Mode (1 bit)
69  WORD_FEBId = 0, //! FEB ID (6 bit)
70  WORD_FEBStatus = 0, //! FEB Status (7 bit)
71  WORD_PixelAddr = 0, //! Pixel Address (5 bit)
72  WORD_Version = 0, //! version number (5 bit)
73  WORD_Sequence = 0, //! Sequence number (3 bit)
74  WORD_Pad3 = 0, //! Pad3 (3 bit)
75  WORD_DAQEnabled = 0, //! DAQ Enabled Status Bit (1 bit)
76  WORD_BufferEmpty = 0, //! APD Data Buffer Empty (1 bit)
77  WORD_BufferFull = 0, //! APD Data Buffer Full (1 bit)
78  WORD_CommError = 0, //! FEB Communications Error (1 bit)
79  WORD_PacketError = 0, //! FEB Packet Error (1 bit)
80  WORD_OverflowError= 0, //! FEB Data Buff Overflow Error (1 bit)
81  WORD_ADCError = 0, //! FEB ADC Error (1 bit)
82  };// end of NanoSliceHeaderWORD
83 
84  DEFINE_SHIFT_FROM_MASK( LinkStatus );
85  DEFINE_SHIFT_FROM_MASK( DataPresent );
86  DEFINE_SHIFT_FROM_MASK( DebugMode );
87  DEFINE_SHIFT_FROM_MASK( FEBId );
88  DEFINE_SHIFT_FROM_MASK( FEBStatus );
89  DEFINE_SHIFT_FROM_MASK( PixelAddr );
90  DEFINE_SHIFT_FROM_MASK( Version );
91  DEFINE_SHIFT_FROM_MASK( Sequence );
92  DEFINE_SHIFT_FROM_MASK( Pad3 );
93  DEFINE_SHIFT_FROM_MASK( DAQEnabled );
94  DEFINE_SHIFT_FROM_MASK( BufferEmpty );
95  DEFINE_SHIFT_FROM_MASK( BufferFull );
96  DEFINE_SHIFT_FROM_MASK( CommError );
97  DEFINE_SHIFT_FROM_MASK( PacketError );
98  DEFINE_SHIFT_FROM_MASK( OverflowError);
99  DEFINE_SHIFT_FROM_MASK( ADCError );
100 
101  }// end of nanosliceheader namespace
102 
103  class RawNanoSliceHeader : public PREVIOUS_VERSION_CLASS_NAME {
104 
105  public:
106  RawNanoSliceHeader (const version_t); ///< The default constructor
108  ~RawNanoSliceHeader(); ///< Destructor
109 
110  bool advanceSequence();
111  void init ();
113  void print (std::ostream& os=std::cout) const;
115  using PREVIOUS_VERSION_CLASS_NAME::readData;
116  void* readData (const void* pointer){return RawDAQData::readDataGeneral(pointer);};
117 
118 
119  /// CAUTION!!!!!
120  /// It is assume that these methods will
121  /// be the same for all versions of NanoSlice Header
122  IMPLEMENT_GET_AND_SET_BOOL(DataPresent);
123  IMPLEMENT_GET_AND_SET_BOOL(LinkStatus);
124  IMPLEMENT_GET_AND_SET_BOOL(DebugMode);
125  IMPLEMENT_GET_AND_SET_BOOL(DAQEnabled);
126  IMPLEMENT_GET_AND_SET_BOOL(BufferEmpty);
127  IMPLEMENT_GET_AND_SET_BOOL(BufferFull);
128  IMPLEMENT_GET_AND_SET_BOOL(CommError);
129  IMPLEMENT_GET_AND_SET_BOOL(PacketError);
130  IMPLEMENT_GET_AND_SET_BOOL(OverflowError);
131  IMPLEMENT_GET_AND_SET_BOOL(ADCError);
132  IMPLEMENT_GET (Version , uint32_t);
133  IMPLEMENT_GET_AND_SET (FEBId, uint32_t);
134  IMPLEMENT_GET_AND_SET (FEBStatus, uint32_t);
135  IMPLEMENT_GET_AND_SET (PixelAddr, uint32_t);
136  IMPLEMENT_GET_AND_SET (Sequence, uint32_t);
137  IMPLEMENT_GET_AND_SET (Pad3, uint32_t);
138  protected:
139  IMPLEMENT_SET (Version , uint32_t);
140  /*
141  IMPLEMENT_FIRST_GET_AND_SET(FEBId , uint32_t);
142  IMPLEMENT_FIRST_GET_AND_SET(FEBStatus, uint32_t);
143  IMPLEMENT_FIRST_GET_AND_SET(PixelAddr, uint32_t);
144  IMPLEMENT_FIRST_GET_AND_SET(Sequence , uint32_t);
145  IMPLEMENT_FIRST_GET_AND_SET(Version , uint32_t);
146  IMPLEMENT_FIRST_GET_AND_SET(Pad3 , uint32_t);
147  IMPLEMENT_FIRST_GET_AND_SET_BOOL(DataPresent);
148  IMPLEMENT_FIRST_GET_AND_SET_BOOL(LinkStatus);
149  IMPLEMENT_FIRST_GET_AND_SET_BOOL(DebugMode);
150  IMPLEMENT_FIRST_GET_AND_SET_BOOL(DAQEnabled);
151  IMPLEMENT_FIRST_GET_AND_SET_BOOL(BufferEmpty);
152  IMPLEMENT_FIRST_GET_AND_SET_BOOL(BufferFull);
153  IMPLEMENT_FIRST_GET_AND_SET_BOOL(CommError);
154  IMPLEMENT_FIRST_GET_AND_SET_BOOL(PacketError);
155  IMPLEMENT_FIRST_GET_AND_SET_BOOL(OverflowError);
156  IMPLEMENT_FIRST_GET_AND_SET_BOOL(ADCError);
157  */
158 
159  INIT_FIRST(initWithData , , void, const NanoSliceHeader&);
160  INIT_FIRST(setParameters, , bool, const NanoSliceHeader&);
161 
162  };// end of RawNanoSliceHeader
163 }} // END NAMESPCE
164 
165 
166 #endif /* RAWNANOSLICEHEADERV0_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 INIT_FIRST(FUNC, CONSTNESS, OUTPUT_UNITS,...)
Definition: Macros.h:239
#define IMPLEMENT_SET(FUNC, UNITS)
Definition: Macros.h:102
Data structure for holding all the nanoslice data of interest.
bool print
static const uint32_t PAD3_DEFAULT_VALUE
Default value for Pad3.
OStream cout
Definition: OStream.cxx:6
int32_t version_t
Definition: RawDAQData.h:72
static const uint32_t RAWNANOSLICEHEADER_SIZE
NanoSliceHeader size in words.
#define IMPLEMENT_GET(FUNC, UNITS)
Definition: Macros.h:101
Class to hold the data from the FEBs in correct formats.
#define CURRENT_FIELDS_SUB_NAMESPACE