RawMilliSliceHeader.h
Go to the documentation of this file.
1 #ifndef RAWMILLISLICEHEADER_H
2 #define RAWMILLISLICEHEADER_H
3 #include "DAQDataFormats/RawDAQData.h"
4 #include "DAQDataFormats/BitFields.h"
5 #include "DAQDataFormats/Macros.h"
6 
7 #include "DAQDataFormats/DataFormatFirst.inc"
8 #define CURRENT_CLASS RawMilliSliceHeader
9 #define CURRENT_FIELDS_SUB_NAMESPACE rawmillihdr
10 
11 namespace daqdataformats {
12 
13 
15 
16  static const uint32_t MILLISLICEHEADER_SIZE = 9;
17  static const uint32_t MILLISLICEHEADER_SIZE_PLUS_ONE = MILLISLICEHEADER_SIZE + 1;
18 
19  enum Mode_t{
22  };
23 
24  // MilliSlice header delimiter. [0] value in the header, [1] value in the tail
25  static const uint32_t Marker_value[2] = {0x00007777, 0x00007778};
26 
27 
29  MASK_Marker = 0xFFFF0000, ///< Marker Mask (16 bits)
30  MASK_Version = 0x00000FFF, ///< Version Mask (12 bits)
31  MASK_SliceSize = 0xFFFFFFFF, ///< MilliSlice Size Mask (32 bits)
32  MASK_Partition = 0xFC000000, ///< Partition ( 6 bits)
33  MASK_DestBuffID = 0x03FF0000, ///< Dest Buffer ID Mask (10 bits)
34  MASK_DiblockId = 0x000000FF, // Diblock ID
35  MASK_DCMId = 0x00001F00, // DCM ID
36  MASK_DetId = 0x0000E000, // Detector ID
37  MASK_GlobalDCMID = 0x0000FFFF, // Global ID
38  MASK_MilliSliceSEQ = 0xFFFFFFFF, ///< Slice Seq Mask (32 bits)
39  MASK_TimeStartLow = 0xFFFFFFFF, ///< Start Time Low Mask (32 bits)
40  MASK_TimeStartHigh = 0x00FFFFFF, ///< Start Time High Mask (24 bits)
41  MASK_TimeLength = 0x03FFFFFF, ///< MilliSlice Time Length Mask (26 bits)
42  MASK_Complete = 0x04000000, ///< Completetess bit Mask
43  MASK_Mode = 0x08000000, ///< DCM Mode Mask
44  MASK_ConnectionInitialization = 0x10000000, ///< Initialization Connection bit Mask
45  MASK_CloseConnection = 0x20000000, ///< Close Connection bit
46  MASK_CorruptData = 0x40000000, ///< Corrupt data bit
47  MASK_MissingData = 0x80000000, ///< Missing data bit
48  MASK_MicrosliceNumber = 0x003FFFFF, ///< Number of MicroSlices Mask (22 bits)
49  MASK_FrameSEQ = 0xFFC00000, ///< Frame Seq Mask (10 bits)
50  MASK_MilliSliceIndexNumber = 0x0000FFFF, ///< The number of MilliSlice index entries (16 bits)
51  MASK_MicroSliceTimeLength_usec= 0x0FFF0000, ///< The conf'd time length of MicroSlices, in usec. (12 bits)
52  MASK_MonteCarloFlag = 0x20000000, ///< SIM flag (1 bit)
53  MASK_CRCCalculationUsed = 0x40000000, ///< Is CRC calculation used? (1 bit)
54  MASK_MilliSliceIndexUsed = 0x80000000, ///< Do we EVER produce the MilliSlice index? (1 bit)
55  };
56 
57 
64  WORD_DiblockId = 2, // Diblock ID
65  WORD_DCMId = 2, // DCM ID
66  WORD_DetId = 2, // Detector ID
67  WORD_GlobalDCMID = 2, // Global ID
73  WORD_Mode = 6,
85  };
86 
87  DEFINE_SHIFT_FROM_MASK(Marker);
88  DEFINE_SHIFT_FROM_MASK(Version);
89  DEFINE_SHIFT_FROM_MASK(SliceSize);
90  DEFINE_SHIFT_FROM_MASK(Partition);
91  DEFINE_SHIFT_FROM_MASK(DestBuffID);
92  DEFINE_SHIFT_FROM_MASK(DiblockId);
95  DEFINE_SHIFT_FROM_MASK(GlobalDCMID);
96  DEFINE_SHIFT_FROM_MASK(MilliSliceSEQ);
97  DEFINE_SHIFT_FROM_MASK(TimeStartLow);
98  DEFINE_SHIFT_FROM_MASK(TimeStartHigh);
99  DEFINE_SHIFT_FROM_MASK(TimeLength);
100  DEFINE_SHIFT_FROM_MASK(Complete);
102  DEFINE_SHIFT_FROM_MASK(ConnectionInitialization);
103  DEFINE_SHIFT_FROM_MASK(CloseConnection);
104  DEFINE_SHIFT_FROM_MASK(CorruptData);
105  DEFINE_SHIFT_FROM_MASK(MissingData);
106  DEFINE_SHIFT_FROM_MASK(MicrosliceNumber);
107  DEFINE_SHIFT_FROM_MASK(FrameSEQ);
108  DEFINE_SHIFT_FROM_MASK(MilliSliceIndexNumber);
109  DEFINE_SHIFT_FROM_MASK(MicroSliceTimeLength_usec);
110  DEFINE_SHIFT_FROM_MASK(MonteCarloFlag);
111  DEFINE_SHIFT_FROM_MASK(CRCCalculationUsed);
112  DEFINE_SHIFT_FROM_MASK(MilliSliceIndexUsed);
113 
114  }// end of namespace rawmillihdr
115 
116 
117 
119 
120  public:
121 
122  // Constructors
123  RawMilliSliceHeader(); //! The default constructor
124  RawMilliSliceHeader(const RawMilliSliceHeader& copy_in); //! Deep copy constructor
125  RawMilliSliceHeader(const void* millisliceheader_buffer); //! Shallow copy constructor
126  /// Destructor
128 
129  void init ();
130  uint32_t sizeofdata () const { return rawmillihdr::MILLISLICEHEADER_SIZE; }
131 
132  uint64_t getTimeStart() const;
133  rawmillihdr::Mode_t getMode() const;
134  bool setTimeStart(const uint64_t);
135  bool setMode(const rawmillihdr::Mode_t);
136  bool addSliceSize(const uint32_t);
137 
138  bool advanceMicrosliceNumber();
139  bool advanceFrameSEQ();
140  bool resetFrameSEQ();
141  bool advanceMilliSliceSEQ();
142 
143  IMPLEMENT_GET_NOVERSION (Version, uint32_t);
144  IMPLEMENT_SET_NOVERSION_PROTECTED(Version, uint32_t);
145 
146  IMPLEMENT_GET_AND_SET_NOVERSION(Marker, uint32_t);
147  IMPLEMENT_GET_AND_SET_NOVERSION(DestBuffID, uint32_t);
148  IMPLEMENT_GET_AND_SET_NOVERSION(Partition, uint32_t);
149  IMPLEMENT_GET_AND_SET_NOVERSION(DiblockId, uint32_t);
150  IMPLEMENT_GET_AND_SET_NOVERSION(DCMId, uint32_t);
152  IMPLEMENT_GET_AND_SET_NOVERSION(GlobalDCMID, uint32_t);
153  IMPLEMENT_GET_AND_SET_NOVERSION(TimeStartLow, uint32_t);
154  IMPLEMENT_GET_AND_SET_NOVERSION(TimeStartHigh, uint32_t);
155  IMPLEMENT_GET_AND_SET_NOVERSION(TimeLength, uint32_t);
156  IMPLEMENT_GET_AND_SET_NOVERSION(MilliSliceSEQ, uint32_t);
157  IMPLEMENT_GET_AND_SET_NOVERSION(FrameSEQ, uint32_t);
158  IMPLEMENT_GET_AND_SET_NOVERSION(SliceSize, uint32_t);
159  IMPLEMENT_GET_AND_SET_NOVERSION(MicrosliceNumber, uint32_t);
160  IMPLEMENT_GET_AND_SET_NOVERSION(MilliSliceIndexNumber, uint32_t);
161  IMPLEMENT_GET_AND_SET_NOVERSION(MicroSliceTimeLength_usec, uint32_t);
162  IMPLEMENT_GET_AND_SET_NOVERSION(MonteCarloFlag, bool);
163 
165  IMPLEMENT_IS_AND_SET_NOVERSION(ConnectionInitialization);
166  IMPLEMENT_IS_AND_SET_NOVERSION(CloseConnection);
167  IMPLEMENT_IS_AND_SET_NOVERSION(CorruptData);
168  IMPLEMENT_IS_AND_SET_NOVERSION(MissingData);
169  IMPLEMENT_IS_AND_SET_NOVERSION(CRCCalculationUsed);
170  IMPLEMENT_IS_AND_SET_NOVERSION(MilliSliceIndexUsed);
171 
172  using RawDAQData::readData;// unhide the reset of the readData methods
173  void* readData(const void* buffer){return readDataGeneral(buffer);}
174 
175  private:
176 
177  // These have to have a different name from readData and print.
178  // Otherwise, we can't bind them to their respactive DELEGATEs.
179  void* readDataFromBuffer(const void* buffer){return readDataGeneral(buffer);}
180  void printStandard (std::ostream& os=std::cout) const;
181 
182  version_t figureOutTheVersion(const void*) const {return 0;}
183  bool setFunctionPointers() {return true;}
184  };
185 
186 
187 } // END NAMESPCE daqdataformats
188 #endif /* RAWMILLISLICEHEADER_H */
The conf&#39;d time length of MicroSlices, in usec. (12 bits)
void * readDataFromBuffer(const void *buffer)
#define IMPLEMENT_GET_NOVERSION(FUNC, UNITS)
Definition: Macros.h:107
void * readData(const void *buffer)
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
version_t figureOutTheVersion(const void *) const
#define IMPLEMENT_SET_NOVERSION_PROTECTED(FUNC, UNITS)
Definition: Macros.h:114
OStream cout
Definition: OStream.cxx:6
void * readData(const void *buffer)
Shallow copy constructor.
Definition: RawDAQData.cpp:181
double Mode(TH1D *hist)
Definition: DedxComp.C:173
int32_t version_t
Definition: RawDAQData.h:72
#define CURRENT_FIELDS_SUB_NAMESPACE
#define IMPLEMENT_IS_AND_SET_NOVERSION(FUNC)
Definition: Macros.h:136
Class to hold the data from the FEBs in correct formats.
#define IMPLEMENT_GET_AND_SET_NOVERSION(FUNC, UNITS)
Definition: Macros.h:130