Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
daqdataformats::RawMilliSlice Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-01/DAQDataFormats/cxx/include/RawMilliSlice.h"

Inheritance diagram for daqdataformats::RawMilliSlice:
daqdataformats::RawDAQData

Public Member Functions

 RawMilliSlice (const uint32_t bufsize=DEFAULT_MILLISLICE_SIZE, const uint32_t tlvl=0)
 
 RawMilliSlice (const RawMilliSlice &copy_in)
 The default constructor. More...
 
 RawMilliSlice (const void *millislice_buffer, const uint32_t buffersize=DEFAULT_MILLISLICE_SIZE)
 Deep copy constructor. More...
 
 ~RawMilliSlice ()
 Destructor. More...
 
void init ()
 
uint32_t sizeofdata () const
 
bool setBufferSource (const void *)
 
readDataStatus readData (const int fd)
 From the File descriptor. More...
 
bool addMicroSlice (const void *microslice_buffer, const bool indexate=false, const bool check_mc_flag=false)
 
bool addData (const void *buffer, const uint32_t size, const uint32_t number_of_microslices, const bool check_mc_flag=false)
 
bool clear ()
 Clear Internal Buffer and zero out _fd_read_bytes. More...
 
bool softclear ()
 zero out _fd_read_bytes, but leaving buffer alone More...
 
daqdataformats::RawMilliSliceHeadergetHeader () const
 
daqdataformats::RawMicroSlicegetFloatingMicroSlice () const
 
daqdataformats::RawMilliSliceIndexgetMilliSliceIndex () const
 
uint32_t getVersion () const
 
uint32_t getMarker () const
 
uint32_t getDestBuffID () const
 
uint32_t getPartition () const
 
uint64_t getTimeStart () const
 
uint32_t getTimeStartLow () const
 
uint32_t getTimeStartHigh () const
 
uint32_t getTimeLength () const
 
rawmillihdr::Mode_t getMode () const
 
uint32_t getMilliSliceSEQ () const
 
uint32_t getFrameSEQ () const
 
uint32_t getSliceSize () const
 
uint32_t getMicrosliceNumber () const
 
uint32_t getDiblockId () const
 
uint32_t getDCMId () const
 
uint32_t getDetId () const
 
uint32_t getGlobalDCMID () const
 
uint32_t getMilliSliceIndexNumber () const
 
uint32_t getMicroSliceTimeLength_usec () const
 
bool getMonteCarloFlag () const
 
uint32_t isComplete () const
 
uint32_t isCRCCalculationUsed () const
 
uint32_t isMilliSliceIndexUsed () const
 
uint32_t isConnectionInitialization () const
 
uint32_t isCloseConnection () const
 
uint32_t isCorruptData () const
 
uint32_t isMissingData () const
 
uint32_t getCRC () const
 
bool setDiblockId (const uint32_t a)
 
bool setDCMId (const uint32_t a)
 
bool setDetId (const uint32_t a)
 
bool setGlobalDCMID (const uint32_t a)
 
bool setDestBuffID (const uint32_t a)
 
bool setPartition (const uint32_t a)
 
bool setTimeStart (const uint64_t a)
 
bool setTimeStartLow (const uint32_t a)
 
bool setTimeStartHigh (const uint32_t a)
 
bool setTimeLength (const uint32_t a)
 
bool setComplete (const bool a)
 
bool setMode (const rawmillihdr::Mode_t a)
 
bool setConnectionInitialization (const bool a)
 
bool setCloseConnection (const bool a)
 
bool setCorruptData (const bool a)
 
bool setMissingData (const bool a)
 
bool setMilliSliceSEQ (const uint32_t a)
 
bool setMicroSliceTimeLength_usec (const uint32_t a)
 
bool setMonteCarloFlag (const bool a)
 
bool setMilliSliceIndexUsed (const bool a)
 
bool setFrameSEQ (const uint32_t a)
 
bool setFloatingMicroSlice (const uint32_t) const
 
bool close (const bool produce_crc=false)
 
virtual void copy (const RawDAQData &)
 Deep copy from the DAQDataFormat. More...
 
virtual void copy (const void *buffer)
 Shallow copy from the external buffer. More...
 
voidreadData (const void *buffer)
 Shallow copy constructor. More...
 
voidreadData (const void *buffer, const uint32_t size_of_data)
 Read from the buffer if the size of data is known. More...
 
voidwriteData (const void *buffer) const
 Write Data to target memory location. Return is the address of the end of the write. NULL on error. More...
 
ssize_t writeData (const int fd) const
 Write Data to target file descriptor. Return is the number of bytes written. -1 on error. More...
 
uint32_t calculateCheckSum (const uint32_t skip_last_words) const
 
voidgetBuffer () const
 
bool resetBufferSource ()
 
bool reset ()
 Reset. More...
 
bool isInternalBuffer () const
 
void print (std::ostream &os=std::cout) const
 Method for printing the content of the Buffer. More...
 
void print (std::string &output_string) const
 print into the string More...
 
virtual bool addCheckSum ()
 Add the CRC into the end of fBuffer. CRC of all but the last words of the _Buffer. More...
 

Protected Member Functions

version_t figureOutTheVersion (const void *) const
 
bool setFunctionPointers ()
 
uint32_t predefinedSize () const
 
bool setFloatingMicroSliceToBufferSource (const void *) const
 
voidreadDataFromBuffer (const void *)
 
void printStandard (std::ostream &os=std::cout) const
 
void tprintf (unsigned lvl, const char *fmt,...) __attribute__((format(printf
 
voidreadDataGeneral (const void *buffer)
 General ReadData method when the sizeofdata is known. More...
 
voidreadDataGeneral (const void *buffer, const uint32_t size_of_data_to_read)
 Generic readData methods. More...
 
voidreadDataGeneral (const void *buffer, const uint32_t size_of_data_to_read, const uint32_t buffer_start_position)
 
bool checkBufferInternalness ()
 If the buffer should be internal, check it's pointers and reassign them. More...
 
voidsetBufferSourceGeneral (RawDAQData &, const void *)
 Set BufferSource of the input DataFormat and return pointer to the position right after the end of its buffer. More...
 
bool setBufferSourceUnknownVersion (const void *)
 
bool reserveInternalBuffer (const uint32_t size_of_data)
 Reserve space for the internal buffer to some predetermined size. More...
 
bool addToInternalBuffer (const uint32_t size_of_data_to_add)
 Add Zeros to internal buffer. More...
 
bool resizeInternalBuffer (const uint32_t size_of_data)
 Resize the internal buffer. More...
 
uint32_t boolToUint32_t (const bool number) const
 
bool uint32_tToBool (const uint32_t number) const
 
void printGeneral (std::ostream &os=std::cout) const
 
void printBuffer (std::ostream &os=std::cout, const bool print_offset=true,const bool print_ascii=true,const bool print_buffer_address=false,const bool print_internal_buffer=false,const bool print_size_of_data=false,const std::string separation_between_lines="\n",const uint32_t cols=4) const
 
void printWord (const uint32_t iword, const bool is_bynary_printing, std::ostream &os=std::cout) const
 Print word from Buffer. More...
 
void printWordBinary (const uint32_t word, std::ostream &os=std::cout) const
 ! Print the i-th word of _Buffer, is_bynary_printing: true = bynary, false = HEX More...
 
void printWordHex (const uint32_t word, std::ostream &os=std::cout) const
 
void printBinary (const void *buffer0, const uint32_t size, std::ostream &os=std::cout) const
 
void printHex (const void *buffer0, const uint32_t size, std::ostream &os=std::cout) const
 
void printUnknownVersion (std::ostream &out_stream=std::cout) const
 
bool functionIsNotAllowed (const std::string function="", const std::string message="") const
 One can call this function from another function, which usage is not allowed (for a particular version). More...
 
void defaultConstructorFixedSize ()
 
void defaultConstructorFixedSize (init_t)
 
void defaultConstructorFloatingSize ()
 
void defaultConstructorFloatingSize (init_t)
 
voidreadDataUnknownVersion (const void *buffer)
 Read data from the unknown version. More...
 
bool isVersionUnknown () const
 is current _version unknown? More...
 
bool isVersionUnknown (const version_t version) const
 is input version unknown? More...
 
uint64_t getUint64_t (uint32_t low_word, uint32_t hi_word) const
 Get uint64_t from low and hi word. More...
 
bool getLoAndHi (uint64_t input_data, uint32_t &output_low_word, uint32_t &output_hi_word) const
 
bool setUint64_t (uint64_t value, DELEGATE(RawDAQData, function_set_low_word, bool, uint32_t),)
 
std::string generateExceptionForWrongVersion (version_t maximum_version) const
 Generating exception message as the version of DAQDataFormat is greater than the maximum allowed. More...
 
void lastOperationsInDeepCopy (const RawDAQData &copy_in)
 Need to perform these operations in Deep Copy constructor. More...
 
 Init_t (_function_init)
 Some common function pointers used in each DAQDataFormats class. More...
 
 Sizeofdata_t (_function_sizeofdata)
 
 Print_t (_function_print)
 
 ReadData_t (_function_readData)
 
 SetBufferSource_t (_function_setBufferSource)
 
 EXECUTE_ON_DEBUG (std::string _dataFormatClassName)
 These variables are only for Debugging purposes. More...
 
 EXECUTE_ON_DEBUG (std::string _dataFormatConstructor)
 

Protected Attributes

daqdataformats::RawMilliSliceHeader_Header
 
daqdataformats::RawMilliSliceIndex_Index
 MilliSlice Header. More...
 
daqdataformats::RawMicroSlice_FloatingMicroSlice
 MilliSlice Index. More...
 
int _FloatingMicroSliceNumber
 Floating MicroSlice. More...
 
size_t _fd_read_bytes
 Floating MicroSlice Number. More...
 
uint32_t _tlvl
 
void_Buffer
 All data formats need to have _Buffer and a Data structure. _Buffer will be common. More...
 
std::vector< uint32_t > _InternalBuffer
 
bool _shouldBufferBeInternal
 Auxillary variable that holds whether the buffer should be external or internal. More...
 
version_t _version
 DataFormat Version. More...
 

Detailed Description

Definition at line 14 of file RawMilliSlice.h.

Constructor & Destructor Documentation

daqdataformats::RawMilliSlice::RawMilliSlice ( const uint32_t  bufsize = DEFAULT_MILLISLICE_SIZE,
const uint32_t  tlvl = 0 
)

Definition at line 12 of file RawMilliSlice.cpp.

References daqdataformats::RawDAQData::defaultConstructorFloatingSize(), and daqdataformats::RawDAQData::reserveInternalBuffer().

12  :
13  RawDAQData(0
19  ,_Header (NULL)
20  ,_Index (NULL)
21  ,_FloatingMicroSlice (NULL)
23  ,_fd_read_bytes (0)
24  ,_tlvl (tlvl)
25 {
28 }
#define sizeofdata_t
Definition: FunctionBind.h:30
bool setBufferSource(const void *)
RawDAQData()
Default Constructor.
Definition: RawDAQData.cpp:14
int _FloatingMicroSliceNumber
Floating MicroSlice.
void printStandard(std::ostream &os=std::cout) const
daqdataformats::RawMilliSliceHeader * _Header
daqdataformats::RawMicroSlice * _FloatingMicroSlice
MilliSlice Index.
#define print_t
Definition: FunctionBind.h:31
uint32_t predefinedSize() const
#define setBufferSource_t
Definition: FunctionBind.h:33
void * readDataFromBuffer(const void *)
#define readData_t
Definition: FunctionBind.h:32
bool reserveInternalBuffer(const uint32_t size_of_data)
Reserve space for the internal buffer to some predetermined size.
Definition: RawDAQData.cpp:271
size_t _fd_read_bytes
Floating MicroSlice Number.
#define init_t
Definition: FunctionBind.h:29
daqdataformats::RawMilliSliceIndex * _Index
MilliSlice Header.
daqdataformats::RawMilliSlice::RawMilliSlice ( const RawMilliSlice copy_in)

The default constructor.

Definition at line 31 of file RawMilliSlice.cpp.

References daqdataformats::RawDAQData::lastOperationsInDeepCopy().

31  :
32  RawDAQData(copy_in)
33  ,_Header (NULL)
34  ,_Index (NULL)
35  ,_FloatingMicroSlice (NULL)
37  ,_fd_read_bytes (0)
38  ,_tlvl (copy_in._tlvl)
39 {
40  lastOperationsInDeepCopy(copy_in);
41 }
void lastOperationsInDeepCopy(const RawDAQData &copy_in)
Need to perform these operations in Deep Copy constructor.
Definition: RawDAQData.cpp:151
RawDAQData()
Default Constructor.
Definition: RawDAQData.cpp:14
int _FloatingMicroSliceNumber
Floating MicroSlice.
daqdataformats::RawMilliSliceHeader * _Header
daqdataformats::RawMicroSlice * _FloatingMicroSlice
MilliSlice Index.
size_t _fd_read_bytes
Floating MicroSlice Number.
daqdataformats::RawMilliSliceIndex * _Index
MilliSlice Header.
daqdataformats::RawMilliSlice::RawMilliSlice ( const void millislice_buffer,
const uint32_t  buffersize = DEFAULT_MILLISLICE_SIZE 
)

Deep copy constructor.

Definition at line 44 of file RawMilliSlice.cpp.

References daqdataformats::RawDAQData::copy(), and daqdataformats::RawDAQData::reserveInternalBuffer().

44  :
45  RawDAQData(0
51  ,_Header (NULL)
52  ,_Index (NULL)
53  ,_FloatingMicroSlice (NULL)
55  ,_fd_read_bytes (0)
56  ,_tlvl (0)
57 {
58 
60  copy(millislice_buffer);
61 }
#define sizeofdata_t
Definition: FunctionBind.h:30
bool setBufferSource(const void *)
virtual void copy(const RawDAQData &)
Deep copy from the DAQDataFormat.
Definition: RawDAQData.cpp:830
RawDAQData()
Default Constructor.
Definition: RawDAQData.cpp:14
int _FloatingMicroSliceNumber
Floating MicroSlice.
void printStandard(std::ostream &os=std::cout) const
daqdataformats::RawMilliSliceHeader * _Header
daqdataformats::RawMicroSlice * _FloatingMicroSlice
MilliSlice Index.
#define print_t
Definition: FunctionBind.h:31
uint32_t predefinedSize() const
#define setBufferSource_t
Definition: FunctionBind.h:33
void * readDataFromBuffer(const void *)
#define readData_t
Definition: FunctionBind.h:32
bool reserveInternalBuffer(const uint32_t size_of_data)
Reserve space for the internal buffer to some predetermined size.
Definition: RawDAQData.cpp:271
size_t _fd_read_bytes
Floating MicroSlice Number.
#define init_t
Definition: FunctionBind.h:29
daqdataformats::RawMilliSliceIndex * _Index
MilliSlice Header.
daqdataformats::RawMilliSlice::~RawMilliSlice ( )

Destructor.

Shallow copy constructor

Definition at line 64 of file RawMilliSlice.cpp.

References _FloatingMicroSlice, _Header, and _Index.

64  {
65  if(_Header) delete _Header;
66  if(_Index) delete _Index;
68  }
daqdataformats::RawMilliSliceHeader * _Header
daqdataformats::RawMicroSlice * _FloatingMicroSlice
MilliSlice Index.
daqdataformats::RawMilliSliceIndex * _Index
MilliSlice Header.

Member Function Documentation

bool daqdataformats::RawDAQData::addCheckSum ( )
virtualinherited

Add the CRC into the end of fBuffer. CRC of all but the last words of the _Buffer.

Calculate CRC for the buffer, skipping the last word

Do the swab

Write the CRC at the last word of the Buffer

Definition at line 550 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer, daqdataformats::RawDAQData::calculateCheckSum(), EXECUTE_FUNCTION, daqdataformats::RawDAQData::isInternalBuffer(), RAWBUFF32, daqdataformats::RawDAQData::sizeofdata(), and SWAB32.

Referenced by close().

550  {
551 
552  /// Calculate CRC for the buffer, skipping the last word
553  uint32_t crc = calculateCheckSum(1);
554 
555  /// Do the swab
556  crc = SWAB32(crc);
557 
558  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
559 
560  if(isInternalBuffer() && _InternalBuffer.size() < size_of_data){
561  _InternalBuffer.push_back(crc);
562  }
563  else {
564  /// Write the CRC at the last word of the Buffer
565  RAWBUFF32[size_of_data - 1] = crc;
566  }
567 
568  return true;
569 }// end of RawDAQData::addCheckSum()
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
uint32_t calculateCheckSum(const uint32_t skip_last_words) const
Definition: RawDAQData.cpp:541
#define SWAB32(word)
Definition: BitFields.h:14
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
bool isInternalBuffer() const
Definition: RawDAQData.h:141
#define RAWBUFF32
Definition: RawDAQData.h:16
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
bool daqdataformats::RawMilliSlice::addData ( const void buffer,
const uint32_t  size,
const uint32_t  number_of_microslices,
const bool  check_mc_flag = false 
)

Add some data containing NumberofMicroslices MicroSlices into the MilliSlice changing the MilliSlice Header appropriately If check_mc_flag = true, the method checks whether the microslice is MC generated and adds an appropriate flag to the MilliSlice Header. bool check_mc_flag = true

Just read the chunk of Microslices straight from the buffer into the end of the (internal) Buffer

Advance the MilliSlice frame number (MicroSlice number in the MilliSlice)

Change the MilliSlice size

Check if the first MicroSlice is MC generated If it is, set the appropriate MilliSlice MC flag checking/setting MC flag making it consistent with the MicroSlice

Definition at line 121 of file RawMilliSlice.cpp.

References _Header, daqdataformats::RawMilliSliceHeader::addSliceSize(), daqdataformats::RawDAQData::checkBufferInternalness(), daqdataformats::RawDAQData::readDataGeneral(), and setMonteCarloFlag().

Referenced by addMicroSlice(), and sizeofdata().

121  {
122 
123  /// Just read the chunk of Microslices straight from the buffer into the end of the (internal) Buffer
125 
127 
128  /// Advance the MilliSlice frame number (MicroSlice number in the MilliSlice)
129  _Header->setMicrosliceNumber(_Header->getMicrosliceNumber() + number_of_microslices);
130  /// Change the MilliSlice size
132 
133  /// Check if the first MicroSlice is MC generated
134  /// If it is, set the appropriate MilliSlice MC flag
135  /// checking/setting MC flag making it consistent with the MicroSlice
136  if(check_mc_flag){
137  RawMicroSliceHeader micro_header(buffer);
138  setMonteCarloFlag(micro_header.getMonteCarloFlag());
139  }// end of checking/setting MC flag making it consistent with the MicroSlice
140 
141  return true;
142 }
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
bool checkBufferInternalness()
If the buffer should be internal, check it&#39;s pointers and reassign them.
Definition: RawDAQData.cpp:612
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
daqdataformats::RawMilliSliceHeader * _Header
bool setMonteCarloFlag(const bool a)
Definition: RawMilliSlice.h:98
bool daqdataformats::RawMilliSlice::addMicroSlice ( const void microslice_buffer,
const bool  indexate = false,
const bool  check_mc_flag = false 
)

Add some data containing NumberofMicroslices MicroSlices into the MilliSlice changing the MilliSlice Header appropriately if indexate is true, produce an index for the MicroSlice If check_mc_flag = true, the method checks whether the microslice is MC generated and adds an appropriate flag to the MilliSlice Header. bool check_mc_flag = true

Construct a temporary nanoslice with external buffer

This is its size

Add an index if told so.

Get Time length and offset

If MilliSlice Index is not constructed yet, do it now

Definition at line 89 of file RawMilliSlice.cpp.

References _Index, addData(), daqdataformats::RawMilliSliceIndex::addIndex(), daqdataformats::RawMicroSlice::getMonteCarloFlag(), daqdataformats::RawMicroSlice::getTime(), getTimeStart(), daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE, PandAna.reco_validation.add_data::offset, setMonteCarloFlag(), sizeofdata(), and daqdataformats::RawMicroSlice::sizeofdata().

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), daqdataformats::MilliSliceConstructor::fillDataFormat(), mcdatadaq::DCMSimulator::fillMilliSlice(), and sizeofdata().

89  {
90 
91  /// Construct a temporary nanoslice with external buffer
92  const RawMicroSlice tmp_nanoslice(microslice_buffer);
93  /// This is its size
94  const uint32_t microslice_size = tmp_nanoslice.sizeofdata();
95 
96  // Add one microslice
97  addData(microslice_buffer, microslice_size, 1, false);
98 
99  /// Add an index if told so.
100  if(indexate){
101  /// Get Time length and offset
102  const uint32_t time = tmp_nanoslice.getTime() - getTimeStart();
104 
105  /// If MilliSlice Index is not constructed yet, do it now
106  if(!_Index) _Index = new RawMilliSliceIndex();
107 
108  // Add the index
109  _Index->addIndex(time, offset);
110  }// end of adding index
111 
112  // Check if the MicroSlice is MC generated
113  // If it is, set the appropriate MilliSlice MC flag
114  if(check_mc_flag){ setMonteCarloFlag(tmp_nanoslice.getMonteCarloFlag());}
115 
116  return true;
117 }
bool setMonteCarloFlag(const bool a)
Definition: RawMilliSlice.h:98
bool addData(const void *buffer, const uint32_t size, const uint32_t number_of_microslices, const bool check_mc_flag=false)
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
bool addIndex(const uint32_t, const uint32_t)
daqdataformats::RawMilliSliceIndex * _Index
MilliSlice Header.
uint64_t getTimeStart() const
Definition: RawMilliSlice.h:55
bool daqdataformats::RawDAQData::addToInternalBuffer ( const uint32_t  size_of_data_to_add)
protectedinherited

Add Zeros to internal buffer.

Definition at line 284 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer, and MECModelEnuComparisons::i.

Referenced by daqdataformats::RawMilliSliceIndex::addIndex().

284  {
285  for(uint32_t i = 0; i < size_of_data; ++i)
286  _InternalBuffer.push_back(0);
287 
288  return true;
289 }
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
uint32_t daqdataformats::RawDAQData::boolToUint32_t ( const bool  number) const
inlineprotectedinherited

Conversions from bool to int and backwards We are not going to overload it, so no need to declare virtual

Definition at line 190 of file RawDAQData.h.

190 { return ((number) ? 1 : 0); }
uint32_t daqdataformats::RawDAQData::calculateCheckSum ( const uint32_t  skip_last_words) const
inherited

Calculate CRC of _Buffer (after skipping last skip_last_words words) using CRC32c algorythm with 0x8F6E37A0 polynomial. Usually use skip_last_words=1 as the _Buffer has an CRC in the end If on calculates with skip_last_words=0 (with CRC at the end), it should calculate to Zero (Property of Check Sum)

Definition at line 541 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_Buffer, EXECUTE_FUNCTION, daqdataformats::NOvACheckSum::getInstance(), daqdataformats::NOvACheckSum::processCRC(), and daqdataformats::RawDAQData::sizeofdata().

Referenced by daqdataformats::RawDAQData::addCheckSum(), RawMilliSliceTests::testCalculateCheckSum(), RawMilliSliceTests::testCalculateCheckSumCorrupt(), and daqdataformats::MilliSliceUnitTest::testMilliSliceCRC().

541  {
542 
543  NOvACheckSum* CheckSum = NOvACheckSum::getInstance();
544 
545  return CheckSum->processCRC(_Buffer, EXECUTE_FUNCTION(sizeofdata)() - skip_last_words);
546 }// end of calculateCheckSum
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
static NOvACheckSum * getInstance()
Method to obtain the class instance.
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
bool daqdataformats::RawDAQData::checkBufferInternalness ( )
protectedinherited
bool daqdataformats::RawMilliSlice::clear ( )
virtual

Clear Internal Buffer and zero out _fd_read_bytes.

Reimplemented from daqdataformats::RawDAQData.

Definition at line 321 of file RawMilliSlice.cpp.

References _fd_read_bytes, and daqdataformats::RawDAQData::clear().

Referenced by sizeofdata().

321  {
322  _fd_read_bytes = 0;
323 
324  return RawDAQData::clear();
325 }
virtual bool clear()
reset _Buffer to point to InternalBuffer
Definition: RawDAQData.cpp:573
size_t _fd_read_bytes
Floating MicroSlice Number.
bool daqdataformats::RawMilliSlice::close ( const bool  produce_crc = false)

First add the MilliSliceIndex if available

Close the index - produce the tail

Adjust the MilliSlice size

Set MilliSlice Index number in the header

Remember the current Buffer position

Add MILLISLICEHEADER_SIZE + 1 words to tthe size. We will add the tail (another MilliSlice header) and the CRC-word in the end of the MilliSlice

If CRC is calculated, set the isCRCCalculationUsed flag

Adding a tail Create a new Tail and assigning its pointer

Make it a tail

Set an appropriate Marker for the tail

If not, we still need to make zero at the end Check if we need to assign or push_back

Definition at line 156 of file RawMilliSlice.cpp.

References _Header, _Index, daqdataformats::RawDAQData::_InternalBuffer, daqdataformats::RawDAQData::addCheckSum(), daqdataformats::RawMilliSliceHeader::addSliceSize(), daqdataformats::RawDAQData::checkBufferInternalness(), daqdataformats::RawMilliSliceIndex::close(), daqdataformats::RawDAQData::getBuffer(), daqdataformats::RawMilliSliceIndex::getIndexNumber(), daqdataformats::RawDAQData::isInternalBuffer(), daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::Marker_value, daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE, daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE_PLUS_ONE, PRINT_ON_DEBUG, RAWBUFF32, daqdataformats::RawDAQData::readDataGeneral(), sizeofdata(), and daqdataformats::RawMilliSliceIndex::sizeofdata().

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), daqdataformats::MilliSliceConstructor::fillDataFormat(), mcdatadaq::DCMSimulator::fillMilliSlice(), daqdataformats::MilliSliceConstructor::getEmptyDataFormat(), setFrameSEQ(), RawMilliSliceTests::testCalculateCheckSum(), and RawMilliSliceTests::testCalculateCheckSumCorrupt().

156  {
157 
158  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<" 0 ");
159  /// First add the MilliSliceIndex if available
160  if(_Index){
161  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<" 1 ");
162 
163  /// Close the index - produce the tail
164  _Index->close();
165  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<" 2 ");
166 
167  const uint32_t size_of_index = _Index->sizeofdata();
168 
169  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<" 3 ");
170  // Copy the index to the end
171  readDataGeneral(_Index->getBuffer(), size_of_index);
173  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<" 4 ");
174 
175  /// Adjust the MilliSlice size
176  _Header->addSliceSize(size_of_index);
177 
178  /// Set MilliSlice Index number in the header
179  _Header->setMilliSliceIndexNumber(_Index->getIndexNumber());
180 
181  }// end of adding MilliSliceIndex
182 
183  const uint32_t size_before_adding_tail_and_crc = sizeofdata();
184 
185  /// Remember the current Buffer position
186  const void* current_buffer = &RAWBUFF32[size_before_adding_tail_and_crc];
187 
188  /// Add MILLISLICEHEADER_SIZE + 1 words to tthe size.
189  /// We will add the tail (another MilliSlice header) and the CRC-word in the end of the MilliSlice
191  /// If CRC is calculated, set the isCRCCalculationUsed flag
192  if(produce_crc)_Header->setCRCCalculationUsed(true);
193 
194  /// Adding a tail
195  /// Create a new Tail and assigning its pointer
196  readDataGeneral(_Header->getBuffer(), rawmillihdr::MILLISLICEHEADER_SIZE, size_before_adding_tail_and_crc);
198 
199  /// Make it a tail
200  RawMilliSliceHeader tail_tmp(current_buffer);
201  /// Set an appropriate Marker for the tail
202  tail_tmp.setMarker(rawmillihdr::Marker_value[1]);
203 
204  // Finally, add CRC at the very end of _Buffer if requested
205  if(produce_crc)
206  addCheckSum();
207  else{
208  /// If not, we still need to make zero at the end
209  /// Check if we need to assign or push_back
210  if(isInternalBuffer() && _InternalBuffer.size() < sizeofdata())
211  _InternalBuffer.push_back(0);
212  else
213  RAWBUFF32[sizeofdata() - 1] = 0;
214  }
215 
216  return true;
217 } // close
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
virtual bool addCheckSum()
Add the CRC into the end of fBuffer. CRC of all but the last words of the _Buffer.
Definition: RawDAQData.cpp:550
void * getBuffer() const
Definition: RawDAQData.h:131
bool checkBufferInternalness()
If the buffer should be internal, check it&#39;s pointers and reassign them.
Definition: RawDAQData.cpp:612
daqdataformats::RawMilliSliceHeader * _Header
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
bool isInternalBuffer() const
Definition: RawDAQData.h:141
#define RAWBUFF32
Definition: RawDAQData.h:16
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
daqdataformats::RawMilliSliceIndex * _Index
MilliSlice Header.
void daqdataformats::RawDAQData::copy ( const RawDAQData copy_in)
virtualinherited

Deep copy from the DAQDataFormat.

Get version

Copy the entire internal buffer

Set function pointers

Definition at line 830 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer, daqdataformats::RawDAQData::_version, daqdataformats::RawDAQData::lastOperationsInDeepCopy(), and daqdataformats::RawDAQData::setFunctionPointers().

Referenced by daqdataformats::RawDCMChan::RawDCMChan(), daqdataformats::RawMicroSlice::RawMicroSlice(), RawMilliSlice(), daqdataformats::RawMilliSliceHeader::RawMilliSliceHeader(), daqdataformats::RawMilliSliceIndex::RawMilliSliceIndex(), daqdataformats::RawMilliSliceIndexHeader::RawMilliSliceIndexHeader(), and daqdataformats::RawTimingMarker::RawTimingMarker().

830  {
831 
832  /// Get version
833  _version = copy_in._version;
834 
835  /// Copy the entire internal buffer
836  _InternalBuffer = copy_in._InternalBuffer;
837 
838  /// Set function pointers
840 
841  lastOperationsInDeepCopy(copy_in);
842 }// end of copy(const RawDAQData& copy_in)
version_t _version
DataFormat Version.
Definition: RawDAQData.h:289
void lastOperationsInDeepCopy(const RawDAQData &copy_in)
Need to perform these operations in Deep Copy constructor.
Definition: RawDAQData.cpp:151
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
virtual bool setFunctionPointers()=0
void daqdataformats::RawDAQData::copy ( const void buffer)
virtualinherited

Shallow copy from the external buffer.

If input version is -1, then we don't really know what version it is and will try to read it

figure out the version

At this point version should be known

Now, need to define functions

Also, we don't initialize internal buffer, because the pointer is set to the external buffer

Definition at line 846 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_Buffer, daqdataformats::RawDAQData::_version, om::cout, EXECUTE_FUNCTION, daqdataformats::RawDAQData::EXECUTE_ON_DEBUG(), daqdataformats::RawDAQData::figureOutTheVersion(), daqdataformats::RawDAQData::isVersionUnknown(), PRINT_ON_DEBUG, daqdataformats::RawDAQData::setBufferSource(), and daqdataformats::RawDAQData::setFunctionPointers().

846  {
847  /// If input version is -1, then we don't really know what version it is and will try to read it
848  if(isVersionUnknown()){
849  PRINT_ON_DEBUG(__PRETTY_FUNCTION__ <<"version unknown");
850  /// figure out the version
851  _version = figureOutTheVersion(external_buffer);
852  }
853 
854  /// At this point version should be known
855  PRINT_ON_DEBUG(__PRETTY_FUNCTION__ <<"Picked up version "<<_version);
856  /// Now, need to define functions
858 
859  PRINT_ON_DEBUG(__PRETTY_FUNCTION__ << " 32 (about to do setBufferSource)");
860  EXECUTE_ON_DEBUG(if(!_function_setBufferSource)std::cout<<"sbf is not binded\n");
861  // Now set the pointer to the external buffer
862  EXECUTE_FUNCTION(setBufferSource)(external_buffer);
863  //setBufferSource(external_buffer);
864  PRINT_ON_DEBUG(__PRETTY_FUNCTION__ << " 4");
865 
866  EXECUTE_ON_DEBUG(if(_Buffer != external_buffer)
867  std::cout<<"Something is wrong in RawDAQData::copy";
868  else
869  std::cout<<"From RawDAQData::copy Buffer is set to "<<_Buffer<<"\n"
870  );
871 
872  // Don't need to initialize any other fields,
873  // because supposedly they should have been initialized before (by somebody else)
874 
875  /// Also, we don't initialize internal buffer, because the pointer is set to the external buffer
876 
877 }// end of copy(const void* external_buffer)
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
version_t _version
DataFormat Version.
Definition: RawDAQData.h:289
bool setBufferSource(const void *)
We are not going to overload these funtions, so no need to declare them virtual.
Definition: RawDAQData.cpp:880
bool isVersionUnknown() const
is current _version unknown?
Definition: RawDAQData.h:240
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
virtual version_t figureOutTheVersion(const void *buffer) const =0
OStream cout
Definition: OStream.cxx:6
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
EXECUTE_ON_DEBUG(std::string _dataFormatClassName)
These variables are only for Debugging purposes.
virtual bool setFunctionPointers()=0
void daqdataformats::RawDAQData::defaultConstructorFixedSize ( )
protectedinherited

General routines for the default constructor of main class for fixed size data formats, like RawNanoSliceHeader, Timing marker etc. (they can be different from version to version though) But the difference is that we want to clear out the internal buffer for them, whereas for floating data formats don't need to have that, since the data may be overwritten anyways

Definition at line 625 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::defaultConstructorGeneral(), daqdataformats::RawDAQData::Init_t(), daqdataformats::RawDAQData::reset(), and resetBufferSource_t.

Referenced by daqdataformats::RawDCMChan::RawDCMChan(), daqdataformats::RawMilliSliceHeader::RawMilliSliceHeader(), daqdataformats::RawMilliSliceIndexHeader::RawMilliSliceIndexHeader(), and daqdataformats::RawTimingMarker::RawTimingMarker().

625  {
627 }// end of defaultConstructorFixedSize(version_t)
#define resetBufferSource_t
Definition: FunctionBind.h:34
void defaultConstructorGeneral(resetBufferSource_t)
void daqdataformats::RawDAQData::defaultConstructorFixedSize ( init_t  )
protectedinherited
void daqdataformats::RawDAQData::defaultConstructorFloatingSize ( )
protectedinherited
void daqdataformats::RawDAQData::defaultConstructorFloatingSize ( init_t  )
protectedinherited
daqdataformats::RawDAQData::EXECUTE_ON_DEBUG ( std::string  _dataFormatClassName)
protectedinherited
daqdataformats::RawDAQData::EXECUTE_ON_DEBUG ( std::string  _dataFormatConstructor)
protectedinherited
version_t daqdataformats::RawMilliSlice::figureOutTheVersion ( const void buffer) const
inlineprotectedvirtual

Method which returns the version of the DataFormat given the pointer to the buffer It has to be implemented for all DataFormats.

Implements daqdataformats::RawDAQData.

Definition at line 107 of file RawMilliSlice.h.

107 {return 0;}
bool daqdataformats::RawDAQData::functionIsNotAllowed ( const std::string  function = "",
const std::string  message = "" 
) const
protectedinherited

One can call this function from another function, which usage is not allowed (for a particular version).

The output message string

Generate the exception

Definition at line 962 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_version, gen_flatrecord::size, and string.

962  {
963 
964  /// The output message string
965  std::string output_message;
966 
967  if(function.size() > 0){
968  output_message = "\nFunction " + function + " ";
969  }
970  else{
971  output_message = "Operation ";
972  }
973 
974  output_message.append(" is Not allowed");
975  output_message.append(" for version " + boost::lexical_cast<std::string>(_version));
976  output_message.append(".");
977 
978  if(message.size() > 0)
979  output_message += " " + message;
980 
981  /// Generate the exception
982  throw daqdataformats::DataFormatException((const std::string)output_message);
983 
984  return false;
985 }
version_t _version
DataFormat Version.
Definition: RawDAQData.h:289
enum BeamMode string
std::string daqdataformats::RawDAQData::generateExceptionForWrongVersion ( version_t  maximum_version) const
protectedinherited

Generating exception message as the version of DAQDataFormat is greater than the maximum allowed.

Definition at line 950 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_version, lem_server::msg, and string.

950  {
951 
952  std::string msg = "The version of the DataFormat is too high! ";
953  msg += "The version is " + boost::lexical_cast<std::string>(_version)
954  + ". Whereas the maximum version allowed is " + boost::lexical_cast<std::string>(maximum_version);
955 
956  return msg;
957 }// end of generateExceptionForWrongVersion
version_t _version
DataFormat Version.
Definition: RawDAQData.h:289
enum BeamMode string
void* daqdataformats::RawDAQData::getBuffer ( ) const
inlineinherited
uint32_t daqdataformats::RawMilliSlice::getCRC ( ) const

Definition at line 145 of file RawMilliSlice.cpp.

References _Header, RAWBUFF32, and sizeofdata().

Referenced by isMissingData(), and daqdataformats::MilliSliceUnitTest::testMilliSliceCRC().

145  {
146 
147  if(!_Header->isCRCCalculationUsed()) return 0;
148 
149  return RAWBUFF32[sizeofdata() - 1];
150 }
daqdataformats::RawMilliSliceHeader * _Header
#define RAWBUFF32
Definition: RawDAQData.h:16
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
uint32_t daqdataformats::RawMilliSlice::getDCMId ( ) const
inline

Definition at line 65 of file RawMilliSlice.h.

References _Header.

65 {return _Header->getDCMId();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getDestBuffID ( ) const
inline

Definition at line 53 of file RawMilliSlice.h.

References _Header.

Referenced by mcdatadaq::DCMSimulator::nextEvent().

53 {return _Header->getDestBuffID();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getDetId ( ) const
inline

Definition at line 66 of file RawMilliSlice.h.

References _Header.

66 {return _Header->getDetId();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getDiblockId ( ) const
inline

Definition at line 64 of file RawMilliSlice.h.

References _Header.

64 {return _Header->getDiblockId();}
daqdataformats::RawMilliSliceHeader * _Header
daqdataformats::RawMicroSlice* daqdataformats::RawMilliSlice::getFloatingMicroSlice ( ) const
inline
uint32_t daqdataformats::RawMilliSlice::getFrameSEQ ( ) const
inline

Definition at line 61 of file RawMilliSlice.h.

References _Header.

61 {return _Header->getFrameSEQ();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getGlobalDCMID ( ) const
inline

Definition at line 67 of file RawMilliSlice.h.

References _Header.

67 {return _Header->getGlobalDCMID();}
daqdataformats::RawMilliSliceHeader * _Header
daqdataformats::RawMilliSliceHeader* daqdataformats::RawMilliSlice::getHeader ( ) const
inline

Definition at line 47 of file RawMilliSlice.h.

References _Header.

Referenced by mcdatadaq::DCMSimulator::nextEvent(), and NovaDDTHitProducer::produce().

47 {return _Header;}
daqdataformats::RawMilliSliceHeader * _Header
bool daqdataformats::RawDAQData::getLoAndHi ( uint64_t  input_data,
uint32_t &  output_low_word,
uint32_t &  output_hi_word 
) const
protectedinherited

Definition at line 910 of file RawDAQData.cpp.

Referenced by daqdataformats::RawTimingMarker::setTime(), daqdataformats::RawMilliSliceHeader::setTimeStart(), and daqdataformats::RawDAQData::setUint64_t().

910  {
911  out_low_word = input_data & 0xffffffff;
912  out_hi_word = input_data >> 32;
913  return true;
914 }// end of getLoAndHi
uint32_t daqdataformats::RawMilliSlice::getMarker ( ) const
inline

Definition at line 52 of file RawMilliSlice.h.

References _Header.

Referenced by readData().

52 {return _Header->getMarker();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getMicrosliceNumber ( ) const
inline
uint32_t daqdataformats::RawMilliSlice::getMicroSliceTimeLength_usec ( ) const
inline

Definition at line 69 of file RawMilliSlice.h.

References _Header.

69 {return _Header->getMicroSliceTimeLength_usec();}
daqdataformats::RawMilliSliceHeader * _Header
daqdataformats::RawMilliSliceIndex * daqdataformats::RawMilliSlice::getMilliSliceIndex ( ) const

If there are no MilliSlices Indeces in the header, then nothing to return - MilliSlice Index was not constructed

If the MilliSlice Index does not exist, then we need to figure out its pointer and construct the Index

At this point it is assumed that the MilliSlice is fully closed

Get the tail. It's the end of the buffer, minus CRC and MilliSliceTail Actually it's only tail, but we declare it as the MilliSliceIndex, because we need to know the size of the whole MilliSliceIndex

The true pointer to Index is pointer to the tail minus the size

Construct the Index

Definition at line 469 of file RawMilliSlice.cpp.

References _Index, getMilliSliceIndexNumber(), daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE_PLUS_ONE, RAWBUFF32, sizeofdata(), daqdataformats::RawMilliSliceIndex::sizeofdata(), and log_trawl::tail().

Referenced by getFloatingMicroSlice().

469  {
470 
471  /// If there are no MilliSlices Indeces in the header,
472  /// then nothing to return - MilliSlice Index was not constructed
473  if(getMilliSliceIndexNumber() == 0)
474  return NULL;
475 
476  /// If the MilliSlice Index does not exist,
477  /// then we need to figure out its pointer and construct the Index
478  if(!_Index){
479  /// At this point it is assumed that the MilliSlice is fully closed
480 
481  /// Get the tail. It's the end of the buffer, minus CRC and MilliSliceTail
482  /// Actually it's only tail, but we declare it as the MilliSliceIndex, because we need to know the size of the whole MilliSliceIndex
483  const uint32_t* pointer_to_tail = &RAWBUFF32[sizeofdata() - rawmillihdr::MILLISLICEHEADER_SIZE_PLUS_ONE];
484  const RawMilliSliceIndex tail(pointer_to_tail);
485 
486  /// The true pointer to Index is pointer to the tail minus the size
487  const uint32_t* pointer_to_millislice_index = pointer_to_tail + 1 - tail.sizeofdata();
488 
489  /// Construct the Index
490  _Index = new RawMilliSliceIndex(pointer_to_millislice_index);
491  }// end of checking whether Index is not constructed
492 
493  return _Index;
494 }
uint32_t getMilliSliceIndexNumber() const
Definition: RawMilliSlice.h:68
#define RAWBUFF32
Definition: RawDAQData.h:16
def tail(path, window=20)
Definition: log_trawl.py:24
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
daqdataformats::RawMilliSliceIndex * _Index
MilliSlice Header.
uint32_t daqdataformats::RawMilliSlice::getMilliSliceIndexNumber ( ) const
inline

Definition at line 68 of file RawMilliSlice.h.

References _Header.

Referenced by getMilliSliceIndex().

68 {return _Header->getMilliSliceIndexNumber();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getMilliSliceSEQ ( ) const
inline

Definition at line 60 of file RawMilliSlice.h.

References _Header.

60 {return _Header->getMilliSliceSEQ();}
daqdataformats::RawMilliSliceHeader * _Header
rawmillihdr::Mode_t daqdataformats::RawMilliSlice::getMode ( ) const
inline

Definition at line 59 of file RawMilliSlice.h.

References _Header, and daqdataformats::RawMilliSliceHeader::getMode().

59 {return _Header->getMode();}
rawmillihdr::Mode_t getMode() const
daqdataformats::RawMilliSliceHeader * _Header
bool daqdataformats::RawMilliSlice::getMonteCarloFlag ( ) const
inline

Definition at line 70 of file RawMilliSlice.h.

References _Header.

70 {return _Header->getMonteCarloFlag();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getPartition ( ) const
inline

Definition at line 54 of file RawMilliSlice.h.

References _Header.

54 {return _Header->getPartition();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getSliceSize ( ) const
inline

Definition at line 62 of file RawMilliSlice.h.

References _Header.

62 {return _Header->getSliceSize();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getTimeLength ( ) const
inline

Definition at line 58 of file RawMilliSlice.h.

References _Header.

58 {return _Header->getTimeLength();}
daqdataformats::RawMilliSliceHeader * _Header
uint64_t daqdataformats::RawMilliSlice::getTimeStart ( ) const
inline

Definition at line 55 of file RawMilliSlice.h.

References _Header, and daqdataformats::RawMilliSliceHeader::getTimeStart().

Referenced by addMicroSlice().

55 {return _Header->getTimeStart();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getTimeStartHigh ( ) const
inline

Definition at line 57 of file RawMilliSlice.h.

References _Header.

57 {return _Header->getTimeStartHigh();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::getTimeStartLow ( ) const
inline

Definition at line 56 of file RawMilliSlice.h.

References _Header.

56 {return _Header->getTimeStartLow();}
daqdataformats::RawMilliSliceHeader * _Header
uint64_t daqdataformats::RawDAQData::getUint64_t ( uint32_t  low_word,
uint32_t  hi_word 
) const
protectedinherited

Get uint64_t from low and hi word.

Definition at line 908 of file RawDAQData.cpp.

Referenced by daqdataformats::RawTimingMarker::getTime(), and daqdataformats::RawMilliSliceHeader::getTimeStart().

908 { return (uint64_t) high<<32 | low;}
uint32_t daqdataformats::RawMilliSlice::getVersion ( ) const
inline

Definition at line 51 of file RawMilliSlice.h.

References _Header.

Referenced by daqdataformats::MilliSliceConstructor::getVersion().

51 {return _Header->getVersion();}
daqdataformats::RawMilliSliceHeader * _Header
void daqdataformats::RawMilliSlice::init ( )

This is needed for the formats with variable size If buffer is internal, need to resize it

Initialize the header

Initialize the _FloatingMicroSliceNumber

Definition at line 72 of file RawMilliSlice.cpp.

References _FloatingMicroSliceNumber, _Header, daqdataformats::RawDAQData::_InternalBuffer, daqdataformats::RawMilliSliceHeader::init(), daqdataformats::RawDAQData::isInternalBuffer(), and daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE.

Referenced by demo.App::__init__(), testem0.App::__init__(), Lesson1.App::__init__(), and ExN03.App::__init__().

72  {
73 
74  /// This is needed for the formats with variable size
75  /// If buffer is internal, need to resize it
76  if(isInternalBuffer())
78 
79  /// Initialize the header
80  _Header->init();
81 
82  /// Initialize the _FloatingMicroSliceNumber
84 }
int _FloatingMicroSliceNumber
Floating MicroSlice.
daqdataformats::RawMilliSliceHeader * _Header
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
bool isInternalBuffer() const
Definition: RawDAQData.h:141
daqdataformats::RawDAQData::Init_t ( _function_init  )
protectedinherited
uint32_t daqdataformats::RawMilliSlice::isCloseConnection ( ) const
inline

Definition at line 75 of file RawMilliSlice.h.

References _Header.

75 {return _Header->isCloseConnection();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::isComplete ( ) const
inline

Definition at line 71 of file RawMilliSlice.h.

References _Header.

71 {return _Header->isComplete();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::isConnectionInitialization ( ) const
inline

Definition at line 74 of file RawMilliSlice.h.

References _Header.

74 {return _Header->isConnectionInitialization();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::isCorruptData ( ) const
inline

Definition at line 76 of file RawMilliSlice.h.

References _Header.

76 {return _Header->isCorruptData();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::isCRCCalculationUsed ( ) const
inline

Definition at line 72 of file RawMilliSlice.h.

References _Header.

Referenced by daqdataformats::MilliSliceUnitTest::testMilliSliceCRC().

72 {return _Header->isCRCCalculationUsed();}
daqdataformats::RawMilliSliceHeader * _Header
bool daqdataformats::RawDAQData::isInternalBuffer ( ) const
inlineinherited
uint32_t daqdataformats::RawMilliSlice::isMilliSliceIndexUsed ( ) const
inline

Definition at line 73 of file RawMilliSlice.h.

References _Header.

73 {return _Header->isMilliSliceIndexUsed();}
daqdataformats::RawMilliSliceHeader * _Header
uint32_t daqdataformats::RawMilliSlice::isMissingData ( ) const
inline

Definition at line 77 of file RawMilliSlice.h.

References _Header, and getCRC().

77 {return _Header->isMissingData();}
daqdataformats::RawMilliSliceHeader * _Header
bool daqdataformats::RawDAQData::isVersionUnknown ( ) const
inlineprotectedinherited
bool daqdataformats::RawDAQData::isVersionUnknown ( const version_t  version) const
inlineprotectedinherited

is input version unknown?

Definition at line 242 of file RawDAQData.h.

References daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, DELEGATE, init_t, resetBufferSource_t, and string.

const XML_Char * version
Definition: expat.h:187
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
void daqdataformats::RawDAQData::lastOperationsInDeepCopy ( const RawDAQData copy_in)
protectedinherited

Need to perform these operations in Deep Copy constructor.

If buffer is null, nothing to do

Definition at line 151 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_Buffer, EXECUTE_FUNCTION, daqdataformats::RawDAQData::isInternalBuffer(), PRINT_ON_DEBUG, daqdataformats::RawDAQData::resetBufferSource(), and daqdataformats::RawDAQData::setBufferSource().

Referenced by daqdataformats::RawDAQData::copy(), daqdataformats::RawDCMChan::RawDCMChan(), daqdataformats::RawMicroSlice::RawMicroSlice(), RawMilliSlice(), daqdataformats::RawMilliSliceHeader::RawMilliSliceHeader(), daqdataformats::RawMilliSliceIndex::RawMilliSliceIndex(), daqdataformats::RawMilliSliceIndexHeader::RawMilliSliceIndexHeader(), and daqdataformats::RawTimingMarker::RawTimingMarker().

151  {
152 
153  /// If buffer is null, nothing to do
154  if(copy_in._Buffer == NULL) return;
155 
156  // Setup the main buffer pointer
157  // If the copy_in's buffer is external, point to that external memory
158  if(copy_in.isInternalBuffer()) {
160  }
161  else{
162  PRINT_ON_DEBUG("From RawDAQData::copy. Buffer is External. Using setBufferSource.");
163  EXECUTE_FUNCTION(setBufferSource)(copy_in._Buffer);
164  }
165 }
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
bool setBufferSource(const void *)
We are not going to overload these funtions, so no need to declare them virtual.
Definition: RawDAQData.cpp:880
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
uint32_t daqdataformats::RawMilliSlice::predefinedSize ( ) const
inlineprotected
void daqdataformats::RawDAQData::print ( std::ostream &  os = std::cout) const
inherited
void daqdataformats::RawDAQData::print ( std::string output_string) const
inherited

print into the string

Some temporary stream

perform standard print into the stream

Get the string out of the stream

Definition at line 503 of file RawDAQData.cpp.

References EXECUTE_FUNCTION, daqdataformats::RawDAQData::print(), and submit_syst::str.

503  {
504 
505  /// Some temporary stream
506  std::ostringstream str;
507  /// perform standard print into the stream
509  /// Get the string out of the stream
510  output_string = str.str();
511 
512 }
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
void print(std::ostream &os=std::cout) const
Method for printing the content of the Buffer.
Definition: RawDAQData.cpp:500
daqdataformats::RawDAQData::Print_t ( _function_print  )
protectedinherited
void daqdataformats::RawDAQData::printBinary ( const void buffer0,
const uint32_t  size,
std::ostream &  os = std::cout 
) const
protectedinherited

Definition at line 478 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::printWordBinary(), and gen_flatrecord::size.

478  {
479 
480  const uint32_t* buffer = (uint32_t*)buffer0;
481  for(uint32_t iword = 0; iword < size; ++iword){
482 // out_stream<<"Address "<<&buffer[iword]<<" ";
483  printWordBinary(buffer[iword], out_stream);
484  }// end of loop over buffer
485 }
void printWordBinary(const uint32_t word, std::ostream &os=std::cout) const
! Print the i-th word of _Buffer, is_bynary_printing: true = bynary, false = HEX
Definition: RawDAQData.cpp:456
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
void daqdataformats::RawDAQData::printBuffer ( std::ostream &  os = std::cout,
const bool  print_offset = true,
const bool  print_ascii = true,
const bool  print_buffer_address = false,
const bool  print_internal_buffer = false,
const bool  print_size_of_data = false,
const std::string  separation_between_lines = "\n",
const uint32_t  cols = 4 
) const
protectedinherited

Displays the data _Buffer Customazible for debugging purpose

If we havn't printed buffer address, need to print Internal Buffer address

Print whether the buffer is internal/external

print size

Size of data

Current pointer to a word

This is only for ascii buffer printing

Loop over buffer

Write the data word in hex

At the end of the line write the line in ASCII with suppression of non printing characters

printing the ascii for the word

Loop over 4 characters of the line

print the character

At the end of the line, put separation symbol

Definition at line 330 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_Buffer, daqdataformats::RawDAQData::_InternalBuffer, cols, allTimeWatchdog::endl, EXECUTE_FUNCTION, novadaq::HexUtils::format(), MECModelEnuComparisons::i, daqdataformats::RawDAQData::isInternalBuffer(), calib::j, and daqdataformats::RawDAQData::sizeofdata().

Referenced by daqdataformats::RawMicroSlice::printStandard().

338  {
339 
340  // print Buffer address
341  if(print_buffer_address){
342 
343  uint32_t* buf = (uint32_t*)_Buffer;
344  out_stream<<"Buffer address is "<<buf<<std::endl;
345  }
346 
347  // print internal buffer info
348  if(print_internal_buffer){
349  if(_InternalBuffer.size() > 0){
350  /// If we havn't printed buffer address, need to print Internal Buffer address
351  if(!print_buffer_address || !isInternalBuffer())
352  out_stream<<"Internal Buffer address "<<&_InternalBuffer[0]<<". ";
353 
354  /// Print whether the buffer is internal/external
355  if(isInternalBuffer())
356  out_stream<<"Using Internal Buffer.";
357  else
358  out_stream<<"Using External Buffer.";
359 
360  /// print size
361  out_stream<<" The size of the internal buffer is "<<_InternalBuffer.size()<<std::endl;
362  }
363  else{
364  out_stream<<"Internal Buffer size is ZERO"<<std::endl;
365  }// end of checking if the size of internal buffer is nonzero
366 
367  }// end of printing internal buffer info
368 
369  /// Size of data
370  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
371 
372  if(print_size_of_data)
373  out_stream<<"Size of data = "<<size_of_data<<std::endl;
374 
375  /// Current pointer to a word
376  uint32_t* data_buffer = (uint32_t*)_Buffer;
377 
378  /// This is only for ascii buffer printing
379  char* ascii_buffer = (char*)_Buffer;
380 
381  /// Loop over buffer
382  for(uint32_t i = 0; i < size_of_data; ++i){
383 
384  // At the start of the line write the address offset
385  if((print_offset && !(i % cols))){
386  out_stream<<boost::format("[Offset=%08x bytes] \t")%(uint32_t)((data_buffer-(uint32_t*)_Buffer)*sizeof(uint32_t));
387  }
388 
389  /// Write the data word in hex
390  out_stream<<boost::format("0x%08x\t")%*data_buffer;
391 
392  /// At the end of the line write the line in ASCII with suppression of
393  /// non printing characters
394  if((i + 1) % cols == 0 || i == size_of_data-1){
395 
396  /// printing the ascii for the word
397  if(print_ascii){
398 
399  uint32_t nsymbols = cols;
400 
401  if(i == size_of_data-1){
402  nsymbols = size_of_data % cols;
403  if(nsymbols == 0)
404  nsymbols = cols;
405  }
406 
407  if(size_of_data / cols){
408  for(uint32_t itab = 0; itab < cols - nsymbols; ++itab)
409  out_stream<<" ";
410  }
411 
412  out_stream<<"(ASCII=";
413 
414  /// Loop over 4 characters of the line
415  for(uint32_t j = 0; j < sizeof(uint32_t) * nsymbols; ++j){
416 
417  /// print the character
418  if( (*ascii_buffer < 32) || (*ascii_buffer > 126)){
419  out_stream<<".";
420  }else{
421  out_stream<<boost::format("%c") % (*ascii_buffer);
422  }// end of print the character
423 
424  ++ascii_buffer;
425  }// end of loop over charachters
426 
427  out_stream<<")";
428  }// end of printing ASCII
429 
430  /// At the end of the line, put separation symbol
431  out_stream<<separation_between_lines;
432  }// end of if the end of the line
433 
434  ++data_buffer;
435  }// end of loop over buffer
436 
437 }// end of RawDAQData::printBuffer()
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
const int cols[3]
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
bool isInternalBuffer() const
Definition: RawDAQData.h:141
const double j
Definition: BetheBloch.cxx:29
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
void daqdataformats::RawDAQData::printGeneral ( std::ostream &  os = std::cout) const
protectedinherited

Print methods Generic print

Definition at line 516 of file RawDAQData.cpp.

References allTimeWatchdog::endl, EXECUTE_FUNCTION, MECModelEnuComparisons::i, daqdataformats::RawDAQData::printWord(), and daqdataformats::RawDAQData::sizeofdata().

516  {
517 
518  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
519 
520  output_stream<<"----------General printing of a DAQDataFormat member-----------size="<<size_of_data<<std::endl;
521  output_stream<<std::endl<<"nRAW:";
522  for(uint32_t i = 0; i < size_of_data; ++i){
523  output_stream<<" ";
524  printWord(i, false, output_stream);
525  }
526 
527  output_stream<<"\nRAW:";
528  for(uint32_t i = 0; i < size_of_data; ++i){
529  if(i > 0)output_stream<<" ";
530  printWord(i, true, output_stream);
531  output_stream<<std::endl;
532  }
533 }// end of RawDAQData::printGeneral()
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
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
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
void daqdataformats::RawDAQData::printHex ( const void buffer0,
const uint32_t  size,
std::ostream &  os = std::cout 
) const
protectedinherited

Definition at line 488 of file RawDAQData.cpp.

References allTimeWatchdog::endl, daqdataformats::RawDAQData::printWordHex(), and gen_flatrecord::size.

488  {
489 
490  const uint32_t* buffer = (uint32_t*)buffer0;
491  for(uint32_t iword = 0; iword < size; ++iword){
492 // out_stream<<"Address "<<&buffer[iword]<<" ";
493  printWordHex(buffer[iword], out_stream);
494  out_stream<<std::endl;
495  }// end of loop over buffer
496 }
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
void printWordHex(const uint32_t word, std::ostream &os=std::cout) const
Definition: RawDAQData.cpp:473
void daqdataformats::RawMilliSlice::printStandard ( std::ostream &  os = std::cout) const
protected

If number is nonzero, need to print them

Get a copy of the MilliSlice this is so that we don't screw up the internal structure

Definition at line 395 of file RawMilliSlice.cpp.

References daqdataformats::RawDAQData::_Buffer, _Header, allTimeWatchdog::endl, novadaq::HexUtils::format(), getFloatingMicroSlice(), getMicrosliceNumber(), MECModelEnuComparisons::i, daqdataformats::RawDAQData::print(), daqdataformats::RawDAQData::printWord(), setFloatingMicroSlice(), and sizeofdata().

Referenced by predefinedSize().

395  {
396 
397  _Header->print(os);
398 
399  const uint32_t size_of_data = sizeofdata();
400 
401  os<<boost::format("\n---MilliSlice---------------------------------------------size = %u words\n")% size_of_data;
402 
403  os<<"\nMilliSlice Data RAW 32bit WORDs (converted, if required, to native endian format):";
404  for(uint32_t i = 0; i < size_of_data; ++i){
405  this->printWord(i, false, os);
406  os<<" ";
407  }
408 
409  os<<"\nMilliSlice Data RAW 32bit Bits (converted, if required, to native endian format):";
410  for(uint32_t i = 0; i < size_of_data; ++i){
411  os<<"\n ";
412  this->printWord(i, true, os);
413  }
414 
415  const uint32_t num_microslices = getMicrosliceNumber();
416  os<<std::endl<<"----------NumMicroSlices-------="<<num_microslices<<std::endl;
417 
418  /// If number is nonzero, need to print them
419  if(num_microslices){
420  /// Get a copy of the MilliSlice this is so that we don't screw up the internal structure
421  RawMilliSlice milli_copy(_Buffer, 0);
422 
423  for(uint32_t i = 0; i < num_microslices; ++i){
424  milli_copy.setFloatingMicroSlice(i);
425  milli_copy.getFloatingMicroSlice()->print(os);
426  }// end of loop over nanoslices
427  }// end of checking whether the number of nanoslices is non-zero
428 
429 }
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
void print(std::ostream &os=std::cout) const
Method for printing the content of the Buffer.
Definition: RawDAQData.cpp:500
daqdataformats::RawMilliSliceHeader * _Header
uint32_t getMicrosliceNumber() const
Definition: RawMilliSlice.h:63
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
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
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
RawMilliSlice(const uint32_t bufsize=DEFAULT_MILLISLICE_SIZE, const uint32_t tlvl=0)
void daqdataformats::RawDAQData::printUnknownVersion ( std::ostream &  out_stream = std::cout) const
inlineprotectedinherited

Definition at line 213 of file RawDAQData.h.

References allTimeWatchdog::endl, init_t, datagram_client::message, and string.

Referenced by daqdataformats::RawDAQData::RawDAQData().

213 { out_stream<<"DAQDataFormat is of unknown version"<<std::endl;}
void daqdataformats::RawDAQData::printWord ( const uint32_t  iword,
const bool  is_bynary_printing,
std::ostream &  os = std::cout 
) const
protectedinherited

Print word from Buffer.

Check if we want to print in a bynary mode

Definition at line 440 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::printWordBinary(), daqdataformats::RawDAQData::printWordHex(), RAWBUFF32, and SWAB32.

Referenced by daqdataformats::RawMilliSliceIndex::print(), daqdataformats::RawDCMChan::print(), daqdataformats::RawDAQData::printGeneral(), daqdataformats::RawTimingMarker::printStandard(), printStandard(), and daqdataformats::RawMilliSliceHeader::printStandard().

440  {
441 
442  const uint32_t rawbuf = RAWBUFF32[iword];
443  const uint32_t value = SWAB32(rawbuf);
444 
445  /// Check if we want to print in a bynary mode
446  if(is_bynary_printing){
447  printWordBinary(value, out_stream);
448  } else {
449  //Else print in hex mode
450  printWordHex(value, out_stream);
451  }// end of if(is_bynary_printing)
452 
453 }//end of void printWord
void printWordBinary(const uint32_t word, std::ostream &os=std::cout) const
! Print the i-th word of _Buffer, is_bynary_printing: true = bynary, false = HEX
Definition: RawDAQData.cpp:456
#define SWAB32(word)
Definition: BitFields.h:14
void printWordHex(const uint32_t word, std::ostream &os=std::cout) const
Definition: RawDAQData.cpp:473
const XML_Char int const XML_Char * value
Definition: expat.h:331
#define RAWBUFF32
Definition: RawDAQData.h:16
void daqdataformats::RawDAQData::printWordBinary ( const uint32_t  word,
std::ostream &  os = std::cout 
) const
protectedinherited

! Print the i-th word of _Buffer, is_bynary_printing: true = bynary, false = HEX

Definition at line 456 of file RawDAQData.cpp.

References allTimeWatchdog::endl, and MECModelEnuComparisons::i.

Referenced by daqdataformats::RawDAQData::printBinary(), and daqdataformats::RawDAQData::printWord().

456  {
457 
458  uint32_t value_copy = value;
459 
460  const int SHIFT = 8 * sizeof( unsigned ) - 1;
461  const unsigned MASK = 1 << SHIFT;
462 
463  for ( int i = 1; i <= SHIFT + 1; i++ ){
464  out_stream << ( value_copy & MASK ? '1' : '0' );
465  value_copy <<= 1;
466 
467  if ( i % 8 == 0 ) out_stream << ' ';
468  }
469  out_stream<<std::endl;
470 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
void daqdataformats::RawDAQData::printWordHex ( const uint32_t  word,
std::ostream &  os = std::cout 
) const
protectedinherited

Definition at line 473 of file RawDAQData.cpp.

References novadaq::HexUtils::format().

Referenced by daqdataformats::RawDAQData::printHex(), and daqdataformats::RawDAQData::printWord().

473  {
474  out_stream<<boost::format("0x%08x")% value;
475 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
readDataStatus daqdataformats::RawMilliSlice::readData ( const int  fd)
virtual

From the File descriptor.

Reimplemented from daqdataformats::RawDAQData.

Definition at line 248 of file RawMilliSlice.cpp.

References daqdataformats::RawDAQData::_Buffer, _fd_read_bytes, daqdataformats::RawDAQData::_InternalBuffer, getMarker(), daqdataformats::RawDAQData::isInternalBuffer(), daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::Marker_value, daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE, printf(), daqdataformats::rds_complete, daqdataformats::rds_error, daqdataformats::rds_incomplete, daqdataformats::RawDAQData::readData(), daqdataformats::RawDAQData::resetBufferSource(), sizeofdata(), ss, and tprintf().

Referenced by PandAna.core.core.loader::Go(), and sizeofdata().

249 {
250  if (fd >= 0)
251  {
252  if (isInternalBuffer())
253  {
254  size_t bytes_to_read;
255 
256  if (_fd_read_bytes < rawmillihdr::MILLISLICEHEADER_SIZE*sizeof(uint32_t))
257  { const size_t min_words = rawmillihdr::MILLISLICEHEADER_SIZE;
258  const size_t min_bytes = min_words*sizeof (uint32_t);
259  if (_InternalBuffer.size() < min_words)
260  {
261  _InternalBuffer.resize(min_words);
263  }
264 
265  bytes_to_read = min_bytes - _fd_read_bytes;
266  }
267  else
268  {
269  uint32_t ss=sizeofdata();
270  // check before using size
271  if ( (getMarker() != rawmillihdr::Marker_value[0])
272  || (ss > 0x400000/*arbitrary val*/) )
273  { tprintf(30,"no marker or size too big\n");
274  return rds_error;
275  }
276  if (_InternalBuffer.size() < (size_t)ss)
277  { _InternalBuffer.resize( ss );
279  }
280  bytes_to_read = (size_t)ss*sizeof(uint32_t) - _fd_read_bytes;
281  }
282 
283  const ssize_t ss = read(fd, (char*)_Buffer+_fd_read_bytes, bytes_to_read );
284  if (ss==-1 || ss==0)
285  { tprintf(30,"read returned %ld\n", (long int)ss);
286  return rds_error;
287  }
288  _fd_read_bytes += ss;
289  if (ss != (int)bytes_to_read)
290  { return rds_incomplete;
291  }
292 
293  const uint32_t size_of_data = sizeofdata();
294 
295  // at this point, the header should have been read in and the
296  // size from within can be examined.
297  // check for resonableness
298  if ( (getMarker() != rawmillihdr::Marker_value[0])
299  || (size_of_data > 0x400000/*arbitrary val*/) )
300  { tprintf(30,"no marker or size too big (2)\n");
301  return rds_error;
302  }
303 
304  if (((size_t)size_of_data*sizeof (uint32_t)) == _fd_read_bytes)
305  return rds_complete;
306  return rds_incomplete;
307  }
308  else
309  {
310  printf("external buffer\n");
311  // assume there is enough space???
312  return RawDAQData::readData(fd);
313  }
314  }
315 
316  return rds_error;
317 } // readData( int )
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
Float_t ss
Definition: plot.C:24
void tprintf(unsigned lvl, const char *fmt,...) __attribute__((format(printf
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
printf("%d Experimental points found\n", nlines)
bool isInternalBuffer() const
Definition: RawDAQData.h:141
uint32_t getMarker() const
Definition: RawMilliSlice.h:52
void * readData(const void *buffer)
Shallow copy constructor.
Definition: RawDAQData.cpp:181
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
size_t _fd_read_bytes
Floating MicroSlice Number.
void * daqdataformats::RawDAQData::readData ( const void buffer)
inherited

Shallow copy constructor.

Definition at line 181 of file RawDAQData.cpp.

References RETURN_FUNCTION.

Referenced by daqdataformats::VERSION_NAMESPACE::RawTrigger::getTriggerMask(), daqdataformats::RawMicroSlice::getVersion(), PandAna.core.core.loader::Go(), readData(), daqdataformats::VERSION_NAMESPACE::RawDataBlock::readData(), daqdataformats::VERSION_NAMESPACE::RawDataBlock::readDataUnknownVersion(), daqdataformats::RawDAQData::readDataUnknownVersion(), sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawDataBlock::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawSummaryDCMDataHeader::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawTriggerRange::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawMicroBlockHeader::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawSummaryDroppedMicroblock::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawSummaryDCMDataPoint::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawEventTail::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawTriggerTimingMarker::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawTriggerMask::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawTriggerTime::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawTriggerHeader::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawNanoSlice::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawEventHeader::sizeofdata(), daqdataformats::RawMilliSliceHeader::sizeofdata(), and daqdataformats::VERSION_NAMESPACE::RawRunHeader::sizeofdata().

181  {
183 }
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
void * readData(const void *buffer)
Shallow copy constructor.
Definition: RawDAQData.cpp:181
void* daqdataformats::RawDAQData::readData ( const void buffer,
const uint32_t  size_of_data 
)
inlineinherited

Read from the buffer if the size of data is known.

Definition at line 114 of file RawDAQData.h.

References fd.

Referenced by PandAna.core.core.loader::Go().

114 {return readDataGeneral(buffer, size_of_data);}
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
daqdataformats::RawDAQData::ReadData_t ( _function_readData  )
protectedinherited
void * daqdataformats::RawMilliSlice::readDataFromBuffer ( const void millislice_buffer)
protected

Read the header and find out the size of the millislice

No need to check if the MilliSlice internal buffer went out. MilliSlice size is at least of the size of the header

Now, read the rest of the millislice

Check pointers after each read or resize buffer

Definition at line 221 of file RawMilliSlice.cpp.

References daqdataformats::RawDAQData::checkBufferInternalness(), daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE, daqdataformats::RawDAQData::readDataGeneral(), and sizeofdata().

Referenced by predefinedSize().

222 {
223  /// Read the header and find out the size of the millislice
224  void* millislice_buffer_new = readDataGeneral(millislice_buffer, rawmillihdr::MILLISLICEHEADER_SIZE, 0);
225 
226 
227  /// No need to check if the MilliSlice internal buffer went out.
228  /// MilliSlice size is at least of the size of the header
229 
230  /// Now, read the rest of the millislice
231  millislice_buffer_new = readDataGeneral(millislice_buffer_new, sizeofdata() - rawmillihdr::MILLISLICEHEADER_SIZE, rawmillihdr::MILLISLICEHEADER_SIZE);
232 
233  /// Check pointers after each read or resize buffer
235 
236  return millislice_buffer_new;
237 }// end of readData(void*)
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
bool checkBufferInternalness()
If the buffer should be internal, check it&#39;s pointers and reassign them.
Definition: RawDAQData.cpp:612
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
void * daqdataformats::RawDAQData::readDataGeneral ( const void buffer)
protectedinherited

General ReadData method when the sizeofdata is known.

Definition at line 186 of file RawDAQData.cpp.

References EXECUTE_FUNCTION, and daqdataformats::RawDAQData::sizeofdata().

Referenced by addData(), daqdataformats::RawMicroSlice::addData(), daqdataformats::RawMilliSliceIndex::close(), close(), daqdataformats::RawDAQData::RawDAQData(), daqdataformats::RawMilliSliceIndex::readData(), daqdataformats::VERSION_NAMESPACE::RawSummaryDCMDataHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawTriggerRange::readData(), daqdataformats::VERSION_NAMESPACE::RawMicroBlockHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawMicroSliceHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawSummaryDroppedMicroblock::readData(), daqdataformats::VERSION_NAMESPACE::RawConfigurationTail::readData(), daqdataformats::VERSION_NAMESPACE::RawEventTail::readData(), daqdataformats::VERSION_NAMESPACE::RawSummaryDCMDataPoint::readData(), daqdataformats::VERSION_NAMESPACE::RawTriggerTimingMarker::readData(), daqdataformats::VERSION_NAMESPACE::RawTriggerMask::readData(), daqdataformats::VERSION_NAMESPACE::RawTriggerTime::readData(), daqdataformats::VERSION_NAMESPACE::RawDataBlockHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawConfigurationHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawTriggerHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawNanoSlice::readData(), daqdataformats::VERSION_NAMESPACE::RawEventHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawNanoSliceHeader::readData(), daqdataformats::VERSION_NAMESPACE::RawRunHeader::readData(), readDataFromBuffer(), daqdataformats::RawMicroSlice::readDataFromBuffer(), and daqdataformats::RawDAQData::readDataGeneral().

186  {
188 }
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
void * daqdataformats::RawDAQData::readDataGeneral ( const void buffer,
const uint32_t  size_of_data_to_read 
)
protectedinherited

Generic readData methods.

Adding stuff to buffer.

Definition at line 191 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer, EXECUTE_FUNCTION, PRINT_ON_DEBUG, daqdataformats::RawDAQData::readDataGeneral(), and daqdataformats::RawDAQData::sizeofdata().

191  {
192 
193  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<"size of data "<<sizeofdata());
194  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<_InternalBuffer.size());
195 
196  return readDataGeneral(buffer_void, size_of_data_to_read, EXECUTE_FUNCTION(sizeofdata)());
197 }
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
void * daqdataformats::RawDAQData::readDataGeneral ( const void buffer,
const uint32_t  size_of_data_to_read,
const uint32_t  buffer_start_position 
)
protectedinherited

If it's negative, then nothing to assign

At first, we are going to be assigning things

Push back the rest

Since, it's the external buffer, then we are going to assign

Definition at line 200 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer, om::cout, daqdataformats::RawDAQData::EXECUTE_ON_DEBUG(), exit(), MECModelEnuComparisons::i, daqdataformats::RawDAQData::isInternalBuffer(), std::min(), PRINT_ON_DEBUG, and RAWBUFF32.

200  {
201 
202  PRINT_ON_DEBUG(__PRETTY_FUNCTION__);
203 
204  const uint32_t* buffer = (const uint32_t*)buffer_void;
205 
206  if(buffer == 0){return 0;}
207 
208 
209  if(isInternalBuffer()){
210  {
211  PRINT_ON_DEBUG ("Internal buffer");
212  }
213 
214  int32_t words_to_assign = int32_t(_InternalBuffer.size()) - int32_t(buffer_start_position);
215  {
216  PRINT_ON_DEBUG ("Size="<<_InternalBuffer.size()<<" buffer_start_pos="<<buffer_start_position<<" size_of_data_to_read="<<size_of_data_to_read);
217  PRINT_ON_DEBUG ("Words to assign1="<<words_to_assign);
218  EXECUTE_ON_DEBUG(if(words_to_assign < 0) {std::cout<<"FROM "<<__PRETTY_FUNCTION__<<"words_to_assign is negative("<<words_to_assign<<"). SOMETHING MUST BE WRONG\n";exit(1);});
219  }
220  /// If it's negative, then nothing to assign
221  if(words_to_assign > 0)
222  words_to_assign = std::min(int32_t(size_of_data_to_read), words_to_assign);
223  else
224  words_to_assign = 0;
225 
226  {
227  PRINT_ON_DEBUG ("Words to assign2="<<words_to_assign);
228  }
229  uint32_t i = 0;
230  ///At first, we are going to be assigning things
231  for(; i < uint32_t(words_to_assign); ++i ){
232  RAWBUFF32[buffer_start_position + i] = buffer[i];
233  }
234 
235  /// Push back the rest
236  for(; i < size_of_data_to_read; ++i ){
237  _InternalBuffer.push_back(buffer[i]);;
238  }
239  }
240  else {
241  /// Since, it's the external buffer, then we are going to assign
242  for(uint32_t i = 0; i < size_of_data_to_read; ++i ){
243  RAWBUFF32[buffer_start_position + i] = buffer[i];
244  }
245 
246  }// end if buffer is internal or external
247 
248  // Return the address of the buffer advanced by 1 word;
249  return (void*)(buffer + size_of_data_to_read);
250 }
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
bool isInternalBuffer() const
Definition: RawDAQData.h:141
OStream cout
Definition: OStream.cxx:6
#define RAWBUFF32
Definition: RawDAQData.h:16
exit(0)
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
T min(const caf::Proxy< T > &a, T b)
EXECUTE_ON_DEBUG(std::string _dataFormatClassName)
These variables are only for Debugging purposes.
void * daqdataformats::RawDAQData::readDataUnknownVersion ( const void buffer)
protectedinherited

Read data from the unknown version.

Read data from the unknown version Reading data to the format with unknown version can only happen when the buffer is set to internal source, because if it was set to external source, then we already figured out the version from it and wouldn't call this method After reading the data, the DataFormat is fully initialized

get the version

Now that we know the version, initialize function pointers, including readData

Resize internal buffer

Reset buffer source, so that we can construct other things (like headers and such)

Don't need to initialize the fields (use init()) because we are going to read new values from the buffer anyways... Like now

Definition at line 805 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_version, EXECUTE_FUNCTION, daqdataformats::RawDAQData::figureOutTheVersion(), daqdataformats::RawDAQData::isInternalBuffer(), PRINT_ON_DEBUG, daqdataformats::RawDAQData::readData(), daqdataformats::RawDAQData::resetBufferSource(), daqdataformats::RawDAQData::resizeInternalBuffer(), RETURN_FUNCTION, daqdataformats::RawDAQData::setFunctionPointers(), and daqdataformats::RawDAQData::sizeofdata().

Referenced by daqdataformats::RawDAQData::RawDAQData().

805  {
806 
807  PRINT_ON_DEBUG(__PRETTY_FUNCTION__);
808  /// get the version
810 
811  /// Now that we know the version, initialize function pointers,
812  /// including readData
814 
815  /// Resize internal buffer
816  if(isInternalBuffer()){
818 
819  /// Reset buffer source, so that we can construct other things (like headers and such)
821  }// end of if isInternalBuffer
822 
823  /// Don't need to initialize the fields (use init()) because we are going to read new values from the buffer anyways...
824  /// Like now
826 }// end of readDataUnknownVersion
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
version_t _version
DataFormat Version.
Definition: RawDAQData.h:289
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
virtual version_t figureOutTheVersion(const void *buffer) const =0
bool isInternalBuffer() const
Definition: RawDAQData.h:141
void * readData(const void *buffer)
Shallow copy constructor.
Definition: RawDAQData.cpp:181
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
virtual bool setFunctionPointers()=0
bool resizeInternalBuffer(const uint32_t size_of_data)
Resize the internal buffer.
Definition: RawDAQData.cpp:292
bool daqdataformats::RawDAQData::reserveInternalBuffer ( const uint32_t  size_of_data)
protectedinherited

Reserve space for the internal buffer to some predetermined size.

We use vector::reserve instead of vector::resize, because resize not only reserves things, it initializes them to zero value. We don't have to do that, because we may overwrite things.

Definition at line 271 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer.

Referenced by daqdataformats::RawMicroSlice::RawMicroSlice(), RawMilliSlice(), and daqdataformats::RawMilliSliceIndex::RawMilliSliceIndex().

271  {
272 
273  /// We use vector::reserve instead of vector::resize,
274  /// because resize not only reserves things,
275  /// it initializes them to zero value.
276  /// We don't have to do that, because we may overwrite things.
277  if(_InternalBuffer.capacity() < size_of_data)
278  _InternalBuffer.reserve(size_of_data);
279 
280  return true;
281 }
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
bool daqdataformats::RawDAQData::reset ( )
inherited

Reset.

Definition at line 596 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::clear(), om::cout, daqdataformats::RawDAQData::EXECUTE_ON_DEBUG(), PRINT_ON_DEBUG, and daqdataformats::RawDAQData::resetBufferSource().

Referenced by daqdataformats::RawDAQData::defaultConstructorFixedSize().

596  {
597  PRINT_ON_DEBUG(__PRETTY_FUNCTION__);
599  EXECUTE_ON_DEBUG(clear(); std::cout<<"End of "<<__PRETTY_FUNCTION__<<"\n"; return true);
600  return clear();
601 }// end of reset
virtual bool clear()
reset _Buffer to point to InternalBuffer
Definition: RawDAQData.cpp:573
OStream cout
Definition: OStream.cxx:6
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
EXECUTE_ON_DEBUG(std::string _dataFormatClassName)
These variables are only for Debugging purposes.
bool daqdataformats::RawDAQData::resetBufferSource ( )
inherited

Definition at line 605 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer, PRINT_ON_DEBUG, RETURN_FUNCTION, and daqdataformats::RawDAQData::setBufferSource().

Referenced by daqdataformats::RawDAQData::checkBufferInternalness(), daqdataformats::RawDAQData::defaultConstructorFloatingSize(), daqdataformats::RawDAQData::lastOperationsInDeepCopy(), readData(), daqdataformats::RawDAQData::readDataUnknownVersion(), and daqdataformats::RawDAQData::reset().

605  {
606  PRINT_ON_DEBUG(__PRETTY_FUNCTION__);
607 
609 } // end of reset _Buffer to point to InternalBuffer
bool setBufferSource(const void *)
We are not going to overload these funtions, so no need to declare them virtual.
Definition: RawDAQData.cpp:880
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
bool daqdataformats::RawDAQData::resizeInternalBuffer ( const uint32_t  size_of_data)
protectedinherited

Resize the internal buffer.

Definition at line 292 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_InternalBuffer.

Referenced by daqdataformats::RawDAQData::defaultConstructorFloatingSize(), daqdataformats::RawMicroSlice::init(), daqdataformats::RawMicroSlice::RawMicroSlice(), daqdataformats::RawMicroSlice::readData(), and daqdataformats::RawDAQData::readDataUnknownVersion().

292  {
293 
294  if(_InternalBuffer.size() < size_of_data)
295  _InternalBuffer.resize(size_of_data);
296 
297  return true;
298 }
std::vector< uint32_t > _InternalBuffer
Definition: RawDAQData.h:283
bool daqdataformats::RawMilliSlice::setBufferSource ( const void pointer)

If Header is already defined, then set its buffer source Otherwise, need to construct it

< version of the MilliSLiceSliceHeader equals the version of the MilliSlice

Definition at line 432 of file RawMilliSlice.cpp.

References daqdataformats::RawDAQData::_Buffer, _Header, daqdataformats::RawDAQData::_shouldBufferBeInternal, daqdataformats::RawDAQData::isInternalBuffer(), daqdataformats::RawDAQData::setBufferSource(), sizeofdata(), and sizeofdata_t.

Referenced by sizeofdata().

432  {
433 
434  _Buffer = (void*)pointer;
435 
437 
438  /// If Header is already defined, then set its buffer source
439  /// Otherwise, need to construct it
440  if(_Header)return _Header->setBufferSource(pointer);
441 
442  _Header = new RawMilliSliceHeader(_Buffer); ///< version of the MilliSLiceSliceHeader equals the version of the MilliSlice
443 
444  _function_sizeofdata = (sizeofdata_t) &RawMilliSlice::sizeofdata;
445 
446  return true;
447 }
#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 * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
bool _shouldBufferBeInternal
Auxillary variable that holds whether the buffer should be external or internal.
Definition: RawDAQData.h:286
daqdataformats::RawMilliSliceHeader * _Header
bool isInternalBuffer() const
Definition: RawDAQData.h:141
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
daqdataformats::RawDAQData::SetBufferSource_t ( _function_setBufferSource  )
protectedinherited
void * daqdataformats::RawDAQData::setBufferSourceGeneral ( RawDAQData dataformat,
const void pointer 
)
protectedinherited

Set BufferSource of the input DataFormat and return pointer to the position right after the end of its buffer.

Definition at line 888 of file RawDAQData.cpp.

References PRINT_ON_DEBUG, daqdataformats::RawDAQData::setBufferSource(), and daqdataformats::RawDAQData::sizeofdata().

888  {
889  dataformat.setBufferSource(pointer);
890  const uint32_t* next_block_pointer = ((uint32_t*)(pointer)) + dataformat.sizeofdata();
891  PRINT_ON_DEBUG(__PRETTY_FUNCTION__<<" Size of data="<<dataformat.sizeofdata()<<". Next pointer will be"<<next_block_pointer);
892  return (void*)next_block_pointer;
893 }// end of setBufferSourceGeneral(RawDAQData& dataformat, const void* pointer)
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
bool daqdataformats::RawDAQData::setBufferSourceUnknownVersion ( const void pointer)
protectedinherited

First, figure out version

Now, set Function pointers accordingly

Now, execute setBuffer Source

Definition at line 896 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_version, daqdataformats::RawDAQData::figureOutTheVersion(), RETURN_FUNCTION, daqdataformats::RawDAQData::setBufferSource(), and daqdataformats::RawDAQData::setFunctionPointers().

Referenced by daqdataformats::RawDAQData::RawDAQData().

896  {
897  /// First, figure out version
898  _version = figureOutTheVersion(pointer);
899 
900  /// Now, set Function pointers accordingly
902 
903  /// Now, execute setBuffer Source
905 }// end of setBufferSourceUnknownVersion(const void* pointer)
version_t _version
DataFormat Version.
Definition: RawDAQData.h:289
bool setBufferSource(const void *)
We are not going to overload these funtions, so no need to declare them virtual.
Definition: RawDAQData.cpp:880
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
virtual version_t figureOutTheVersion(const void *buffer) const =0
virtual bool setFunctionPointers()=0
bool daqdataformats::RawMilliSlice::setCloseConnection ( const bool  a)
inline

Definition at line 93 of file RawMilliSlice.h.

References _Header.

93 {return _Header->setCloseConnection(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setComplete ( const bool  a)
inline

Definition at line 90 of file RawMilliSlice.h.

References _Header.

Referenced by mcdatadaq::DCMSimulator::DCMSimulator().

90 {return _Header->setComplete(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setConnectionInitialization ( const bool  a)
inline

Definition at line 92 of file RawMilliSlice.h.

References _Header.

92 {return _Header->setConnectionInitialization(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setCorruptData ( const bool  a)
inline

Definition at line 94 of file RawMilliSlice.h.

References _Header.

94 {return _Header->setCorruptData(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setDCMId ( const uint32_t  a)
inline

Definition at line 81 of file RawMilliSlice.h.

References _Header.

Referenced by mcdatadaq::DCMSimulator::DCMSimulator(), RawMilliSliceTests::testCalculateCheckSum(), and RawMilliSliceTests::testCalculateCheckSumCorrupt().

81 {return _Header->setDCMId(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setDestBuffID ( const uint32_t  a)
inline

Definition at line 84 of file RawMilliSlice.h.

References _Header.

Referenced by mcdatadaq::DCMSimulator::DCMSimulator(), mcdatadaq::DCMSimulator::nextEvent(), RawMilliSliceTests::testCalculateCheckSum(), and RawMilliSliceTests::testCalculateCheckSumCorrupt().

84 {return _Header->setDestBuffID(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setDetId ( const uint32_t  a)
inline

Definition at line 82 of file RawMilliSlice.h.

References _Header.

Referenced by mcdatadaq::DCMSimulator::DCMSimulator(), RawMilliSliceTests::testCalculateCheckSum(), and RawMilliSliceTests::testCalculateCheckSumCorrupt().

82 {return _Header->setDetId(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setDiblockId ( const uint32_t  a)
inline
bool daqdataformats::RawMilliSlice::setFloatingMicroSlice ( const uint32_t  imicro) const

Check whether MicroSlice is valid

If it's already the same, nothing needs to be done

Pointer that we are going to use

If microslice number is greater than current floating Microslice number, then no need to loop over all MicroSlices, just start from the current floating MicroSlice

Otherwise, start from scratch First point to the first MicroSlice

Set floating MicroSlice to pointer If it doesn't exist, create it

Pointer to the end of the buffer for checks

Start loop over microslices

Check if the pointer is not valid

Definition at line 334 of file RawMilliSlice.cpp.

References _FloatingMicroSlice, _FloatingMicroSliceNumber, daqdataformats::RawDAQData::getBuffer(), getMicrosliceNumber(), makeTrainCVSamples::int, daqdataformats::CURRENT_FIELDS_SUB_NAMESPACE::MILLISLICEHEADER_SIZE, RAWBUFF32, daqdataformats::RawMicroSlice::setBufferSource(), setFloatingMicroSliceToBufferSource(), sizeofdata(), and daqdataformats::RawMicroSlice::sizeofdata().

Referenced by mcdatadaq::BufferNodeSimulator::addMilliSlice(), daqdataformats::DataBlockConstructor::fillDataFormat(), daqdataformats::MilliSliceConstructor::getNanoSlicesVersion(), printStandard(), and setFrameSEQ().

334  {
335 
336  /// Check whether MicroSlice is valid
337  if(imicro >= getMicrosliceNumber())
338  return false;
339 
340  /// If it's already the same, nothing needs to be done
341  if((int)imicro == _FloatingMicroSliceNumber)
342  return true;
343 
344  /// Pointer that we are going to use
345  uint32_t* pointer;
346 
347  /// If microslice number is greater than current floating Microslice number, then no need
348  /// to loop over all MicroSlices, just start from the current floating MicroSlice
349  if((int)imicro > _FloatingMicroSliceNumber && _FloatingMicroSliceNumber > -1){
350  pointer = (uint32_t*)_FloatingMicroSlice->getBuffer();
351  }
352  else{
353  /// Otherwise, start from scratch
354  /// First point to the first MicroSlice
355  pointer = (uint32_t*)&RAWBUFF32[rawmillihdr::MILLISLICEHEADER_SIZE];
356 
357  /// Set floating MicroSlice to pointer
358  /// If it doesn't exist, create it
361  }// end of setting the first floating MicroSlice
362 
363  /// Pointer to the end of the buffer for checks
364  const uint32_t* end_of_buffer_pointer = &RAWBUFF32[sizeofdata()];
365 
366  /// Start loop over microslices
368  pointer += _FloatingMicroSlice->sizeofdata();
369 
370  /// Check if the pointer is not valid
371  if (pointer >= end_of_buffer_pointer)
372  return false;
373 
375  }
376 
377  return true;
378 }
bool setBufferSource(const void *pointer)
Setting Buffer, Header and Timing marker. Don&#39;t bother Floating NanoSlice.
bool setFloatingMicroSliceToBufferSource(const void *) const
void * getBuffer() const
Definition: RawDAQData.h:131
int _FloatingMicroSliceNumber
Floating MicroSlice.
uint32_t getMicrosliceNumber() const
Definition: RawMilliSlice.h:63
daqdataformats::RawMicroSlice * _FloatingMicroSlice
MilliSlice Index.
#define RAWBUFF32
Definition: RawDAQData.h:16
uint32_t sizeofdata() const
Definition: RawMilliSlice.h:25
bool daqdataformats::RawMilliSlice::setFloatingMicroSliceToBufferSource ( const void buffer) const
protected

If it exists, just set its buffer

Otherwise, create new Floating MicroSlice pointing to the buffer

Definition at line 381 of file RawMilliSlice.cpp.

References _FloatingMicroSlice, and daqdataformats::RawMicroSlice::setBufferSource().

Referenced by predefinedSize(), and setFloatingMicroSlice().

381  {
382 
383  /// If it exists, just set its buffer
386 
387  /// Otherwise, create new Floating MicroSlice pointing to the buffer
388  _FloatingMicroSlice = new RawMicroSlice(buffer);
389 
390  return true;
391 }
bool setBufferSource(const void *pointer)
Setting Buffer, Header and Timing marker. Don&#39;t bother Floating NanoSlice.
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
daqdataformats::RawMicroSlice * _FloatingMicroSlice
MilliSlice Index.
bool daqdataformats::RawMilliSlice::setFrameSEQ ( const uint32_t  a)
inline

Definition at line 100 of file RawMilliSlice.h.

References _Header, close(), and setFloatingMicroSlice().

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), and daqdataformats::MilliSliceConstructor::fillDataFormat().

100 {return _Header->setFrameSEQ(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setFunctionPointers ( )
inlineprotectedvirtual

Function where we set all function pointers. At this point we don't know it It is to be derived in the final user readable class

Implements daqdataformats::RawDAQData.

Definition at line 108 of file RawMilliSlice.h.

108 {return true;}
bool daqdataformats::RawMilliSlice::setGlobalDCMID ( const uint32_t  a)
inline

Definition at line 83 of file RawMilliSlice.h.

References _Header.

83 {return _Header->setGlobalDCMID(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setMicroSliceTimeLength_usec ( const uint32_t  a)
inline

Definition at line 97 of file RawMilliSlice.h.

References _Header.

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), and daqdataformats::MilliSliceConstructor::fillDataFormat().

97 {return _Header->setMicroSliceTimeLength_usec(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setMilliSliceIndexUsed ( const bool  a)
inline

Definition at line 99 of file RawMilliSlice.h.

References _Header.

99 {return _Header->setMilliSliceIndexUsed(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setMilliSliceSEQ ( const uint32_t  a)
inline

Definition at line 96 of file RawMilliSlice.h.

References _Header.

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), and daqdataformats::MilliSliceConstructor::fillDataFormat().

96 {return _Header->setMilliSliceSEQ(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setMissingData ( const bool  a)
inline

Definition at line 95 of file RawMilliSlice.h.

References _Header.

95 {return _Header->setMissingData(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setMode ( const rawmillihdr::Mode_t  a)
inline

Definition at line 91 of file RawMilliSlice.h.

References _Header, and daqdataformats::RawMilliSliceHeader::setMode().

91 {return _Header->setMode(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool setMode(const rawmillihdr::Mode_t)
bool daqdataformats::RawMilliSlice::setMonteCarloFlag ( const bool  a)
inline
bool daqdataformats::RawMilliSlice::setPartition ( const uint32_t  a)
inline
bool daqdataformats::RawMilliSlice::setTimeLength ( const uint32_t  a)
inline

Definition at line 89 of file RawMilliSlice.h.

References _Header.

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), and daqdataformats::MilliSliceConstructor::fillDataFormat().

89 {return _Header->setTimeLength(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setTimeStart ( const uint64_t  a)
inline

Definition at line 86 of file RawMilliSlice.h.

References _Header, and daqdataformats::RawMilliSliceHeader::setTimeStart().

Referenced by mcdatadaq::DCMSimulator::fillMilliSlice().

86 {return _Header->setTimeStart(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setTimeStartHigh ( const uint32_t  a)
inline

Definition at line 88 of file RawMilliSlice.h.

References _Header.

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), and daqdataformats::MilliSliceConstructor::fillDataFormat().

88 {return _Header->setTimeStartHigh(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawMilliSlice::setTimeStartLow ( const uint32_t  a)
inline

Definition at line 87 of file RawMilliSlice.h.

References _Header.

Referenced by daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), and daqdataformats::MilliSliceConstructor::fillDataFormat().

87 {return _Header->setTimeStartLow(a);}
daqdataformats::RawMilliSliceHeader * _Header
const double a
bool daqdataformats::RawDAQData::setUint64_t ( uint64_t  value,
DELEGATE(RawDAQData, function_set_low_word, bool, uint32_t)   
)
protectedinherited

Definition at line 937 of file RawDAQData.cpp.

References DELEGATE, EXECUTE_GENERAL_FUNCTION, and daqdataformats::RawDAQData::getLoAndHi().

940  {
941  uint32_t low, high;
942  getLoAndHi(value, low, high);
943 
944  EXECUTE_GENERAL_FUNCTION(function_set_low_word)(low);
945  return EXECUTE_GENERAL_FUNCTION(function_set_hi_word)(high);
946 }// end of setUint64_t
bool getLoAndHi(uint64_t input_data, uint32_t &output_low_word, uint32_t &output_hi_word) const
Definition: RawDAQData.cpp:910
const XML_Char int const XML_Char * value
Definition: expat.h:331
#define EXECUTE_GENERAL_FUNCTION(FULLFUNCTIONNAME)
Macro to execute the function given a function pointer.
Definition: FunctionBind.h:37
uint32_t daqdataformats::RawMilliSlice::sizeofdata ( ) const
inline
daqdataformats::RawDAQData::Sizeofdata_t ( _function_sizeofdata  )
protectedinherited
bool daqdataformats::RawMilliSlice::softclear ( )

zero out _fd_read_bytes, but leaving buffer alone

Definition at line 328 of file RawMilliSlice.cpp.

References _fd_read_bytes.

Referenced by sizeofdata().

328  {
329  _fd_read_bytes = 0;
330  return true;
331 }
size_t _fd_read_bytes
Floating MicroSlice Number.
void daqdataformats::RawMilliSlice::tprintf ( unsigned  lvl,
const char *  fmt,
  ... 
)
protected

Definition at line 450 of file RawMilliSlice.cpp.

References _tlvl, art::detail::indent(), local, printf(), and submit_syst::str.

Referenced by readData().

450  {
451 
452  if (lvl > 31) lvl=31;
453  if (_tlvl & (1<<lvl))
454  { timeval tv;
455  char str[80];
456  time_t local;
457  const char* indent=" ";//32 spaces
458  va_list ap;
459  va_start( ap, fmt);
460  gettimeofday( &tv, NULL );
461  local = tv.tv_sec;
462  strftime( str, sizeof(str), "%T", localtime(&local) );
463  printf( "%s.%06ld%s", str, (long)tv.tv_usec, &indent[31-lvl] );
464  vprintf( fmt, ap );
465  }
466 } // tprintf
#define local
Definition: gzguts.h:107
std::string indent(std::size_t const i)
printf("%d Experimental points found\n", nlines)
bool daqdataformats::RawDAQData::uint32_tToBool ( const uint32_t  number) const
inlineprotectedinherited

Definition at line 191 of file RawDAQData.h.

References cols, om::cout, gen_flatrecord::size, and string.

191 { return ((number) ? true : false); }
void * daqdataformats::RawDAQData::writeData ( const void buffer) const
inherited

Write Data to target memory location. Return is the address of the end of the write. NULL on error.

General write method that writes the raw formated data block to the target memory We are not going to overload it, so no need to declare virtual

Loop over words of the buffer

Definition at line 302 of file RawDAQData.cpp.

References EXECUTE_FUNCTION, MECModelEnuComparisons::i, RAWBUFF32, and daqdataformats::RawDAQData::sizeofdata().

302  {
303 
304  if(buffer == 0){return 0;}
305 
306  uint32_t* write_buffer = (uint32_t*)buffer;
307 
308  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
309  /// Loop over words of the buffer
310  for(uint32_t i = 0; i < size_of_data; ++i){
311  *write_buffer = RAWBUFF32[i];
312  ++write_buffer;
313  } // endfor
314 
315  return write_buffer;
316 }// end of RawDAQData::writeData(void* buffer)
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
#define RAWBUFF32
Definition: RawDAQData.h:16
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
ssize_t daqdataformats::RawDAQData::writeData ( const int  fd) const
inherited

Write Data to target file descriptor. Return is the number of bytes written. -1 on error.

Definition at line 320 of file RawDAQData.cpp.

References daqdataformats::RawDAQData::_Buffer, EXECUTE_FUNCTION, daqdataformats::RawDAQData::sizeofdata(), and pclistAnalyser::write.

320  {
321  if(fd>0){
322  return write(fd, _Buffer, (size_t)EXECUTE_FUNCTION(sizeofdata)()*sizeof(uint32_t));
323  }else{
324  return -1;
325  }
326 }// end of RawDAQData::writeData(int fd)
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
write
Run ND cosmics.
uint32_t sizeofdata() const
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990

Member Data Documentation

void* daqdataformats::RawDAQData::_Buffer
protectedinherited
size_t daqdataformats::RawMilliSlice::_fd_read_bytes
protected

Floating MicroSlice Number.

Definition at line 129 of file RawMilliSlice.h.

Referenced by clear(), readData(), and softclear().

daqdataformats::RawMicroSlice* daqdataformats::RawMilliSlice::_FloatingMicroSlice
mutableprotected
int daqdataformats::RawMilliSlice::_FloatingMicroSliceNumber
mutableprotected

Floating MicroSlice.

Definition at line 126 of file RawMilliSlice.h.

Referenced by init(), and setFloatingMicroSlice().

daqdataformats::RawMilliSliceHeader* daqdataformats::RawMilliSlice::_Header
protected
daqdataformats::RawMilliSliceIndex* daqdataformats::RawMilliSlice::_Index
mutableprotected

MilliSlice Header.

Definition at line 123 of file RawMilliSlice.h.

Referenced by addMicroSlice(), close(), getMilliSliceIndex(), and ~RawMilliSlice().

std::vector<uint32_t> daqdataformats::RawDAQData::_InternalBuffer
protectedinherited
bool daqdataformats::RawDAQData::_shouldBufferBeInternal
protectedinherited
uint32_t daqdataformats::RawMilliSlice::_tlvl
protected

Definition at line 131 of file RawMilliSlice.h.

Referenced by tprintf().

version_t daqdataformats::RawDAQData::_version
protectedinherited

The documentation for this class was generated from the following files: