RawTimingMarker.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawTimingMarker.h"
2 #include "DAQDataFormats/TimeStampCounter.h"
3 #include "DAQDataFormats/BitFields.h"
4 #include "DAQDataFormats/Macros.h"
5 
6 #include <boost/format.hpp>
7 
8 namespace daqdataformats {
9 
10 //------------------------------------------------------------------------------
11 // Default constructor
13  RawDAQData( 0
14  , (init_t) &RawDAQData::init
15  , (sizeofdata_t) &RawTimingMarker::sizeofdata
16  , (setBufferSource_t)&RawDAQData::setBufferSource
17  , (print_t) &RawTimingMarker::printStandard
18  , (readData_t) &RawTimingMarker::readDataFromBuffer
19  )
20 {
21  /// Perform general routines
23 }
24 //------------------------------------------------------------------------------
26  RawDAQData(copy_in)
27 {
28  lastOperationsInDeepCopy(copy_in);
29 }
30 
31 //------------------------------------------------------------------------------
32 RawTimingMarker::RawTimingMarker(const void* timingmarker_buffer):
33  RawDAQData( 0
34  , (init_t) &RawDAQData::init
39  )
40 {
41  copy(timingmarker_buffer);
42 }
43 
44 //------------------------------------------------------------------------------
45 // Destructor
47 
48 //------------------------------------------------------------------------------
49 // Getters
50 uint32_t RawTimingMarker::getLowWord() const { return BITFIELDGET(RAWBUFF32[timmarker::WORD_Lo], timmarker::MASK_Lo, timmarker::SHIFT_Lo);}
51 uint32_t RawTimingMarker::getHighWord() const { return BITFIELDGET(RAWBUFF32[timmarker::WORD_Hi], timmarker::MASK_Hi, timmarker::SHIFT_Hi);}
52 /**
53  * Return the timestamp as a single 64-bit variable
54  *
55  * @return full timestamp in clock ticks
56  */
57 uint64_t RawTimingMarker::getTime() const { return getUint64_t(getLowWord(), getHighWord()); }
58 
59 //------------------------------------------------------------------------------
60 // Setters
61 bool RawTimingMarker::setLowWord (const uint32_t word) {BITFIELDSET(RAWBUFF32[timmarker::WORD_Lo], word, timmarker::MASK_Lo, timmarker::SHIFT_Lo); return true;}
62 bool RawTimingMarker::setHighWord(const uint32_t word) {BITFIELDSET(RAWBUFF32[timmarker::WORD_Hi], word, timmarker::MASK_Hi, timmarker::SHIFT_Lo); return true;}
63 /**
64  * Set time using 64-bit argument
65  *
66  * @param timestamp as 64-bit
67  */
68 bool RawTimingMarker::setTime(const uint64_t timestamp) {
69  uint32_t low, high;
70  getLoAndHi(timestamp, low, high);
71 
72  setHighWord(high);
73  return setLowWord(low);
74 }
75 //------------------------------------------------------------------------------
76 // Generate a time stamp
78  cycle_t full_timestamp;
79 
80  full_timestamp.full_time = tsc();
81 
82  setLowWord (full_timestamp.time[0]);
83  setHighWord(full_timestamp.time[1]);
84 }
85 
86 //------------------------------------------------------------------------------
87 // Print the Timing Marker
88 void RawTimingMarker::printStandard(std::ostream& os) const {
89 
90  os<<boost::format("\nTiming Marker: HighWord=%u LowWord=%u")%getHighWord()
91  %getLowWord();
92 
93  os<<" RAW=";
94  printWord(0,false, os);
95  os<<" ";
96  printWord(1,false, os);
97  os<<std::endl;
98 }
99 
100 //------------------------------------------------------------------------------
101 // Size of the timing marker in words
103 
104 }// end of namespace daqdataformats
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
void printStandard(std::ostream &os=std::cout) const
uint32_t getHighWord() const
! Get method for lower half of timing word
#define sizeofdata_t
Definition: FunctionBind.h:30
static const uint32_t RAWTIMINGMARKER_SIZE
bool setBufferSource(const void *)
We are not going to overload these funtions, so no need to declare them virtual.
Definition: RawDAQData.cpp:880
bool setLowWord(const uint32_t)
! Get the time-stamp as a single 64-bit value
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
bool setHighWord(const uint32_t)
! Set method for lower half of timing word
uint64_t getTime() const
! Get method for upper half of timing word
#define BITFIELDGET(block, mask, shift)
Definition: BitFields.h:23
#define print_t
Definition: FunctionBind.h:31
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
#define BITFIELDSET(block, data, mask, shift)
Definition: BitFields.h:24
#define setBufferSource_t
Definition: FunctionBind.h:33
Class to hold the timing markers used in the construction of Microslices in the DCMs.
#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
void * readDataFromBuffer(const void *buffer)
Class to hold the data from the FEBs in correct formats.
void generate()
! Set the time-stamp as a single 64-bit value
#define init_t
Definition: FunctionBind.h:29
bool setTime(const uint64_t)
! Set method for upper half of timing word