RawMilliSliceHeader.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawMilliSliceHeader.h"
2 #include "DAQDataFormats/DataFormatException.h"
3 #include <boost/format.hpp>
4 
5 namespace daqdataformats{
6 
7 //------------------------------------------------------------
8 // Default constructor
10  RawDAQData(0
11  ,(init_t) &RawMilliSliceHeader::init
12  ,(sizeofdata_t) &RawMilliSliceHeader::sizeofdata
13  ,(setBufferSource_t) &RawDAQData::setBufferSource
14  ,(print_t) &RawMilliSliceHeader::printStandard
15  ,(readData_t) &RawMilliSliceHeader::readDataFromBuffer)
16 {
17  /// Perform general routines
19 }
20 
21 //------------------------------------------------------------------------------
23  RawDAQData(copy_in)
24 {
25  lastOperationsInDeepCopy(copy_in);
26 }
27 
28 //------------------------------------------------------------------------------
29 RawMilliSliceHeader::RawMilliSliceHeader(const void* millisliceheader_buffer):
30  RawDAQData(0
36 {
37  /// Use default Shallow copy constructor
38  copy(millisliceheader_buffer);
39 }
40 
41 //------------------------------------------------------------
42 // Destructor
44 
45 //------------------------------------------------------------
47 
48  /// Need to clear the MilliSlice Header every time on the init
49  clear();
50  /// Set version in the buffer
51  //setVersion(0);
52 
53  /// Set Pad3 in the buffer do the defalut value
54  setMarker(rawmillihdr::Marker_value[0]);
55 
56  setSliceSize(sizeofdata());
57 }
58 
60 
61 //------------------------------------------------------------------------------
63  return getUint64_t(getTimeStartLow(), getTimeStartHigh());
64  }
65 
66 //------------------------------------------------------------------------------
67 // Setters
69 
70  bool RawMilliSliceHeader::advanceFrameSEQ() { return setFrameSEQ(getFrameSEQ() + 1);}
71  bool RawMilliSliceHeader::resetFrameSEQ() { return setFrameSEQ(0); }
72  bool RawMilliSliceHeader::advanceMilliSliceSEQ() { return setMilliSliceSEQ(getMilliSliceSEQ() + 1);}
73  bool RawMilliSliceHeader::addSliceSize(uint32_t size) { return setSliceSize(getSliceSize() + size);}
74  bool RawMilliSliceHeader::advanceMicrosliceNumber() { return setMicrosliceNumber(getMicrosliceNumber() + 1);}
75 
76 //------------------------------------------------------------------------------
78  uint32_t lo, hi;
79  getLoAndHi(timestamp, lo, hi);
80 
81  setTimeStartLow(lo);
82  return setTimeStartHigh(hi);
83  }
84 
85 
86 //------------------------------------------------------------------------------
87 // Print the MilliSlice header information
88 void RawMilliSliceHeader::printStandard(std::ostream& os) const {
89 
90  os<<std::endl<<"MilliSlice Header:";
91  os<<boost::format(" Version=%u" )% getVersion(); //! Version number for the MilliSlice event builder
92  os<<boost::format(" Marker=0x%04x" )% getMarker(); //! MilliSlice header delimiter
93  os<<boost::format(" getDiblockId=%u" )% getDiblockId();
94  os<<boost::format(" DCMId=%u" )% getDCMId();
95  os<<boost::format(" DetId=%u" )% getDetId();
96  os<<boost::format(" DestBuff=%u" )% getDestBuffID(); //! Destination buffer node
97  os<<boost::format(" Partition=%u" )% getPartition(); //! Partition
98  os<<boost::format(" TimeStartLow=%u" )% getTimeStartLow(); //! Time start 0-31 bits for the MilliSlice
99  os<<boost::format(" TimeStartHigh=%u" )% getTimeStartHigh();//! Time start 32-55 bits for the MilliSlice
100  os<<boost::format(" TimeLength=%u" )% getTimeLength(); //! Time length of the MilliSlice
101  os<<boost::format(" isComplete=%u" )% isComplete(); //! Status word
102  os<<boost::format(" isMode=%u" )% getMode(); //! Status word
103  os<<boost::format(" isConnectionInitialization=%u")% isConnectionInitialization(); //! Status word
104  os<<boost::format(" isCloseConnection=%u" )% isCloseConnection(); //! Status word
105  os<<boost::format(" isCorruptData=%u" )% isCorruptData(); //! Status word
106  os<<boost::format(" isMissingData=%u" )% isMissingData(); //! Status word
107  os<<boost::format(" SliceSEQ=%u" )% getMilliSliceSEQ(); //! MilliSlice sequence identifier
108  os<<boost::format(" FrameSEQ=%u" )% getFrameSEQ(); //! Frame sequence identifier for current 5ms time slice
109  os<<boost::format(" SliceSize=%u" )% getSliceSize(); //! The MilliSlice size in words excluding the header
110  os<<boost::format(" MicroSliceNumber=%u" )% getMicrosliceNumber(); //! Number of subframes in the millislice
111  os<<boost::format(" MilliSliceIndexNumber=%u" )% getMilliSliceIndexNumber();
112  os<<boost::format(" MicroSliceTimeLength_usec=%u" )% getMicroSliceTimeLength_usec();
113  os<<boost::format(" MonteCarloFlag=%u" )% getMonteCarloFlag();
114  os<<boost::format(" isCRCCalculationUsed=%u" )% isCRCCalculationUsed();
115  os<<boost::format(" isMilliSliceIndexUsed=%u" )% isMilliSliceIndexUsed();
116 
117  const uint32_t size_of_data = sizeofdata();
118 
119  os<<"\nMilliSliceHeader RAW 32bit words (converted, if required, to native endian format):";
120  for(uint32_t i = 0; i < size_of_data; ++i){
121  os<<" ";
122  printWord(i, false, os);
123  }
124 
125  os<<"\nMilliSliceHeader RAW bits (converted, if required, to native endian format):";
126  for(uint32_t i = 0; i < size_of_data; ++i){
127  os<<std::endl;
128  printWord(i, true, os);
129  }
130 
131 }
132 
133 }// end of namespace
uint64_t getUint64_t(uint32_t low_word, uint32_t hi_word) const
Get uint64_t from low and hi word.
Definition: RawDAQData.cpp:908
TSpline3 lo("lo", xlo, ylo, 12,"0")
rawmillihdr::Mode_t getMode() const
#define sizeofdata_t
Definition: FunctionBind.h:30
bool setBufferSource(const void *)
We are not going to overload these funtions, so no need to declare them virtual.
Definition: RawDAQData.cpp:880
void * readDataFromBuffer(const void *buffer)
void printStandard(std::ostream &os=std::cout) const
virtual void copy(const RawDAQData &)
Deep copy from the DAQDataFormat.
Definition: RawDAQData.cpp:830
bool getLoAndHi(uint64_t input_data, uint32_t &output_low_word, uint32_t &output_hi_word) const
Definition: RawDAQData.cpp:910
void lastOperationsInDeepCopy(const RawDAQData &copy_in)
Need to perform these operations in Deep Copy constructor.
Definition: RawDAQData.cpp:151
#define BITFIELDGET(block, mask, shift)
Definition: BitFields.h:23
TSpline3 hi("hi", xhi, yhi, 18,"0")
#define print_t
Definition: FunctionBind.h:31
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
virtual bool clear()
reset _Buffer to point to InternalBuffer
Definition: RawDAQData.cpp:573
#define BITFIELDSET(block, data, mask, shift)
Definition: BitFields.h:24
#define setBufferSource_t
Definition: FunctionBind.h:33
bool setMode(const rawmillihdr::Mode_t)
#define RAWBUFF32
Definition: RawDAQData.h:16
#define readData_t
Definition: FunctionBind.h:32
void printWord(const uint32_t iword, const bool is_bynary_printing, std::ostream &os=std::cout) const
Print word from Buffer.
Definition: RawDAQData.cpp:440
Class to hold the data from the FEBs in correct formats.
#define init_t
Definition: FunctionBind.h:29