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

Class to hold the MicroSlice data. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/DAQDataFormats/cxx/include/RawMicroSlice.h"

Inheritance diagram for daqdataformats::RawMicroSlice:
daqdataformats::RawDAQData

Public Member Functions

 RawMicroSlice (const uint32_t buffersize=rawmicro::DEFAULT_MICROSLICE_SIZE, const bool resize_buffer=false, const version_t microsliceheader_version=rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION)
 If resize_buffer=true, then we resize the whole internal Buffer with zeros on the construction. More...
 
 RawMicroSlice (const RawMicroSlice &copy_in)
 
 RawMicroSlice (const void *microslice_buffer, const uint32_t buffersize=rawmicro::DEFAULT_MICROSLICE_SIZE, const version_t microsliceheader_version=rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION)
 Deep copy constructor. More...
 
 ~RawMicroSlice ()
 Destructor. More...
 
version_t getVersion () const
 
bool setVersion (const version_t)
 
void addNanoSlice (const void *nanoslice_buffer, const bool check_mc_flag=true)
 
void addData (const void *buffer, const uint32_t nwords, const bool check_mc_flag=true)
 
void generate (const version_t version_nanoslice=nanosliceheader::RAWNANOSLICE_DEFAULT_VERSION)
 
daqdataformats::RawMicroSliceHeadergetHeader () const
 
daqdataformats::RawTimingMarkergetTimingMarker () const
 Get the MicroSlice Header. More...
 
daqdataformats::RawNanoSlicegetFloatingNanoSlice () const
 Get the MicroSlice Timing Marker. More...
 
bool getDataPresent () const
 Get Floating NanoSlice. More...
 
bool getMonteCarloFlag () const
 Get the Data Present bit of the Header. More...
 
uint32_t getByteCount () const
 Get the Data Present bit of the Header. More...
 
uint32_t getLowWord () const
 Get the byte count value of the header. More...
 
uint32_t getHighWord () const
 Get method for lower half of timing word. More...
 
uint64_t getTime () const
 Get method for upper half of timing word. More...
 
float getHitProbability () const
 Get the time-stamp as a single 64-bit value. More...
 
uint32_t getNumNanoSlices () const
 Get current Hit Probability (for a microslice generation) More...
 
bool setMonteCarloFlag (const bool)
 Get number of NanoSlices in the MicroSlice. More...
 
bool setFloatingNanoSlice (const uint32_t inano) const
 Set the SIM flag. More...
 
bool setLowWord (const uint32_t)
 We are allowed to change the floating nanoslice, thus it's const. More...
 
bool setHighWord (const uint32_t)
 Set method for lower half of timing word. More...
 
bool setTime (const uint64_t)
 Set method for upper half of timing word. More...
 
bool setHitProbability (const float hit_prob)
 
uint32_t getNanoSliceSize () const
 Getting a nanoslice size. It could be different for different versions. More...
 
readDataStatus readData (const int file_descriptor)
 Read Data From File Descriptor. More...
 
void init ()
 
uint32_t sizeofdata () const
 
bool setBufferSource (const void *pointer)
 Setting Buffer, Header and Timing marker. Don't bother Floating NanoSlice. More...
 
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 ()
 
virtual bool clear ()
 reset _Buffer to point to InternalBuffer More...
 
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

voidreadDataFromBuffer (const void *)
 
void printStandard (std::ostream &os=std::cout) const
 
bool areThereNanoSlices () const
 
version_t figureOutTheVersion (const void *) const
 Read the NanoSlice version from the buffer. More...
 
uint32_t getPredeterminedSize () const
 
bool setFunctionPointers ()
 
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

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...
 

Private Attributes

daqdataformats::RawMicroSliceHeader_Header
 MicroSlice Header. More...
 
daqdataformats::RawTimingMarker_TimingMarker
 MicroSlice Timing Marker. More...
 
daqdataformats::RawNanoSlice_FloatingNanoSlice
 
float _HitProbability
 Pixel Hit probability. Used when generating a MicroSlice. More...
 
version_t _nanosliceVersion
 
version_t _microSliceHeaderVersion
 

Detailed Description

Class to hold the MicroSlice data.

Currently, MicroSlice does not have versioning

Definition at line 48 of file RawMicroSlice.h.

Constructor & Destructor Documentation

daqdataformats::RawMicroSlice::RawMicroSlice ( const uint32_t  buffersize = rawmicro::DEFAULT_MICROSLICE_SIZE,
const bool  resize_buffer = false,
const version_t  microsliceheader_version = rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION 
)

If resize_buffer=true, then we resize the whole internal Buffer with zeros on the construction.

Check if the size is legal

Set the size of the Internal Buffer

Definition at line 10 of file RawMicroSlice.cpp.

References daqdataformats::RawDAQData::defaultConstructorFloatingSize(), GENERATE_DATAFORMAT_EXCEPTION, getPredeterminedSize(), lem_server::msg, daqdataformats::RawDAQData::reserveInternalBuffer(), daqdataformats::RawDAQData::resizeInternalBuffer(), and string.

10  :
11  RawDAQData( 0
17  )
18  , _Header (NULL)
19  , _TimingMarker (NULL)
20  , _FloatingNanoSlice (NULL)
21  , _HitProbability (0.0)
24 {
25 
26  /// Check if the size is legal
27  if (size < getPredeterminedSize()) {
28  std::string msg("An external input buffer was given to the ");
29  msg.append("RawMicroSlice constructor that was too small (size=");
30  msg.append(boost::lexical_cast<std::string>(size) + ", minimum size=");
31  msg.append(boost::lexical_cast<std::string>(getPredeterminedSize()) + ").");
33  }// end of checking if the size is legal
34 
35  /// Set the size of the Internal Buffer
36  if(resize_buffer){
38  }
39  else
41 
43 }
#define GENERATE_DATAFORMAT_EXCEPTION(msg)
#define sizeofdata_t
Definition: FunctionBind.h:30
bool setBufferSource(const void *pointer)
Setting Buffer, Header and Timing marker. Don&#39;t bother Floating NanoSlice.
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
uint32_t getPredeterminedSize() const
RawDAQData()
Default Constructor.
Definition: RawDAQData.cpp:14
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
float _HitProbability
Pixel Hit probability. Used when generating a MicroSlice.
void * readDataFromBuffer(const void *)
#define print_t
Definition: FunctionBind.h:31
void printStandard(std::ostream &os=std::cout) const
daqdataformats::RawNanoSlice * _FloatingNanoSlice
const XML_Char * version
Definition: expat.h:187
#define setBufferSource_t
Definition: FunctionBind.h:33
#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
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
#define init_t
Definition: FunctionBind.h:29
bool resizeInternalBuffer(const uint32_t size_of_data)
Resize the internal buffer.
Definition: RawDAQData.cpp:292
enum BeamMode string
daqdataformats::RawMicroSlice::RawMicroSlice ( const RawMicroSlice copy_in)

Definition at line 45 of file RawMicroSlice.cpp.

References daqdataformats::RawDAQData::lastOperationsInDeepCopy().

45  :
46  RawDAQData(copy_in)
47  , _Header (NULL)
48  , _TimingMarker (NULL)
49  , _FloatingNanoSlice (NULL)
50  , _HitProbability (copy_in._HitProbability)
51  , _nanosliceVersion (copy_in._nanosliceVersion)
52  , _microSliceHeaderVersion(copy_in._microSliceHeaderVersion)
53 {
54  lastOperationsInDeepCopy(copy_in);
55 }
void lastOperationsInDeepCopy(const RawDAQData &copy_in)
Need to perform these operations in Deep Copy constructor.
Definition: RawDAQData.cpp:151
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
RawDAQData()
Default Constructor.
Definition: RawDAQData.cpp:14
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
float _HitProbability
Pixel Hit probability. Used when generating a MicroSlice.
daqdataformats::RawNanoSlice * _FloatingNanoSlice
daqdataformats::RawMicroSlice::RawMicroSlice ( const void microslice_buffer,
const uint32_t  buffersize = rawmicro::DEFAULT_MICROSLICE_SIZE,
const version_t  microsliceheader_version = rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION 
)

Deep copy constructor.

Check if the size is legal

In addition to standard shallow copy routine, set the maximum size

Definition at line 58 of file RawMicroSlice.cpp.

References daqdataformats::RawDAQData::copy(), GENERATE_DATAFORMAT_EXCEPTION, getPredeterminedSize(), lem_server::msg, daqdataformats::RawDAQData::reserveInternalBuffer(), and string.

58  :
59  RawDAQData( 0
65  )
66  , _Header (NULL)
67  , _TimingMarker (NULL)
68  , _FloatingNanoSlice (NULL)
69  , _HitProbability (0.0)
71  , _microSliceHeaderVersion(microsliceheader_version) ///< we'll figure it out in setBufferSource
72 {
73  /// Check if the size is legal
74  if (size < getPredeterminedSize()) {
75  std::string msg("An external input buffer was given to the ");
76  msg.append("RawMicroSlice constructor that was too small (size=");
77  msg.append(boost::lexical_cast<std::string>(size) + ", minimum size=");
78  msg.append(boost::lexical_cast<std::string>(getPredeterminedSize()) + ").");
80  }// end of checking if the size is legal
81 
82  /// In addition to standard shallow copy routine, set the maximum size
84 
85  RawDAQData::copy(microslice_buffer);
86 }
#define GENERATE_DATAFORMAT_EXCEPTION(msg)
#define sizeofdata_t
Definition: FunctionBind.h:30
bool setBufferSource(const void *pointer)
Setting Buffer, Header and Timing marker. Don&#39;t bother Floating NanoSlice.
virtual void copy(const RawDAQData &)
Deep copy from the DAQDataFormat.
Definition: RawDAQData.cpp:830
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
uint32_t getPredeterminedSize() const
RawDAQData()
Default Constructor.
Definition: RawDAQData.cpp:14
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
float _HitProbability
Pixel Hit probability. Used when generating a MicroSlice.
void * readDataFromBuffer(const void *)
#define print_t
Definition: FunctionBind.h:31
void printStandard(std::ostream &os=std::cout) const
daqdataformats::RawNanoSlice * _FloatingNanoSlice
#define setBufferSource_t
Definition: FunctionBind.h:33
#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
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
#define init_t
Definition: FunctionBind.h:29
enum BeamMode string
daqdataformats::RawMicroSlice::~RawMicroSlice ( )

Destructor.

Shallow copy constructor

Definition at line 91 of file RawMicroSlice.cpp.

References _FloatingNanoSlice, _Header, and _TimingMarker.

91  {
93  if(_Header) delete _Header;
94  if(_TimingMarker) delete _TimingMarker;
95 }
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
daqdataformats::RawNanoSlice * _FloatingNanoSlice

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 daqdataformats::RawMilliSlice::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
void daqdataformats::RawMicroSlice::addData ( const void buffer,
const uint32_t  nwords,
const bool  check_mc_flag = true 
)

Add a Some nwords of data to the internal buffer changing the MicroSlice Header appropriately If check_mc_flag = true, the method checks whether the nanoslice is MC generated and adds an appropriate flag to the MicroSlice Header.

Add the data from buffer into the _Buffer

After Reading data, Buffer could have changed position

Add byte count to the MicroSlice Header

Check if the NanoSlice is the MC generated If it is, set the appropriate MicroSlice MC flag

Definition at line 160 of file RawMicroSlice.cpp.

References _Header, daqdataformats::RawDAQData::checkBufferInternalness(), daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, daqdataformats::RawDAQData::readDataGeneral(), and setMonteCarloFlag().

Referenced by addNanoSlice().

160  {
161 
162  /// Add the data from buffer into the _Buffer
163  readDataGeneral(buffer, nwords);
164 
165  /// After Reading data, Buffer could have changed position
167 
168  /// Add byte count to the MicroSlice Header
169  _Header->addByteCount(nwords * sizeof(uint32_t));
170 
171  /// Check if the NanoSlice is the MC generated
172  /// If it is, set the appropriate MicroSlice MC flag
173  if(check_mc_flag){
174  RawNanoSliceHeader nano_header(buffer, rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION);
175  const uint32_t FEBStatus = nano_header.getFEBStatus();
176  if(FEBStatus > 0x0000003F) setMonteCarloFlag(true);
177  }// end of checking mc flag
178 
179 }// end of addData
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::RawMicroSliceHeader * _Header
MicroSlice Header.
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
bool setMonteCarloFlag(const bool)
Get number of NanoSlices in the MicroSlice.
void daqdataformats::RawMicroSlice::addNanoSlice ( const void nanoslice_buffer,
const bool  check_mc_flag = true 
)

Add a NanoSlice to the MicroSlice changing the MicroSlice Header appropriately If check_mc_flag = true, the method checks whether the nanoslice is MC generated and adds an appropriate flag to the MicroSlice Header.

Construct a temporary nanoslice with external buffer

This is its size

Now add that much data to MicroSlice

Definition at line 145 of file RawMicroSlice.cpp.

References addData().

Referenced by daqdataformats::MicroSliceUnitTest::basicFieldGetAndSetChecks(), daqdataformats::MicroSliceConstructor::fillDataFormat(), mcdatadaq::DCMSimulator::fillMicroSlice(), and generate().

145  {
146 
147  /// Construct a temporary nanoslice with external buffer
148  const RawNanoSlice tmp_nanoslice(buffer);
149  /// This is its size
150  const uint32_t nanoslice_size = tmp_nanoslice.sizeofdata();
151 
152  /// Now add that much data to MicroSlice
153  addData(buffer, nanoslice_size, check_mc_flag);
154 }
void addData(const void *buffer, const uint32_t nwords, const bool check_mc_flag=true)
::xsd::cxx::tree::buffer< char > buffer
Definition: Database.h:179
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
bool daqdataformats::RawMicroSlice::areThereNanoSlices ( ) const
protected

Sometimes we don't know the NanoSlice size yet, But we need to know if there are NanoSlices at all

Definition at line 258 of file RawMicroSlice.cpp.

References daqdataformats::rawmicro::PREDETERMINED_MICROSLICE_SIZE, and sizeofdata().

Referenced by getNanoSliceSize(), getNumNanoSlices(), and setFloatingNanoSlice().

static const uint32_t PREDETERMINED_MICROSLICE_SIZE
Definition: RawMicroSlice.h:40
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::RawDAQData::clear ( )
virtualinherited

reset _Buffer to point to InternalBuffer

Clear Internal Buffer

If buffer is internal, need to use assign, because vector may not have been initialized

Loop over the buffer and zero it The buffer could be either internal or external

Reimplemented in daqdataformats::RawMilliSlice.

Definition at line 573 of file RawDAQData.cpp.

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

Referenced by daqdataformats::RawMilliSlice::clear(), daqdataformats::RawMilliSliceHeader::init(), daqdataformats::RawDAQData::reset(), and daqdataformats::VERSION_NAMESPACE::RawDataBlock::~RawDataBlock().

573  {
574 
575  PRINT_ON_DEBUG(__PRETTY_FUNCTION__);
576 
577  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
578 
579  /// If buffer is internal, need to use assign, because vector may not have been initialized
580  if(isInternalBuffer()){
581  _InternalBuffer.assign(size_of_data, 0);
582  }
583  else{
584  /// Loop over the buffer and zero it
585  /// The buffer could be either internal or external
586  for(uint32_t i = 0; i < size_of_data; ++i)
587  RAWBUFF32[i] = 0;
588  }
589 
590  PRINT_ON_DEBUG("end of"<<__PRETTY_FUNCTION__);
591 
592  return true;
593 } // end of clear
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
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
Sizeof method for the current data block. Returns the size of the data block in 32bit words...
Definition: RawDAQData.cpp:990
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(), RawMicroSlice(), daqdataformats::RawMilliSlice::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::RawMicroSlice::figureOutTheVersion ( const void ) const
inlineprotectedvirtual

Read the NanoSlice version from the buffer.

Implements daqdataformats::RawDAQData.

Definition at line 130 of file RawMicroSlice.h.

130 {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
void daqdataformats::RawMicroSlice::generate ( const version_t  version_nanoslice = nanosliceheader::RAWNANOSLICE_DEFAULT_VERSION)

Generate a MicroSlice Need to provide the version of NanoSlices to generate

Set the MC flag

Generate the timing marker of the microslice

Declare the front end boards simulators

Attempt to generate a nanoslice hit on a given pixel

Check to see if it has nonzero data

Definition at line 184 of file RawMicroSlice.cpp.

References _HitProbability, _nanosliceVersion, _TimingMarker, addNanoSlice(), daqdataformats::RawTimingMarker::generate(), daqdataformats::FEBSimulator::generateNanoSlice(), daqdataformats::FEBSimulator::getLastNanoSlice(), daqdataformats::rawmicro::MAXIMUM_FRONTEND_BOARDS, daqdataformats::FEBSimulator::nonEmptyNanoSlice(), and setMonteCarloFlag().

184  {
185 
186  _nanosliceVersion = (version_t)version_of_nanoslice;
187 
188  /// Set the MC flag
189  setMonteCarloFlag(true);
190 
191  /// Generate the timing marker of the microslice
193 
194  // Loop over all the front end boards generating hits
195  // and writing them to the buffers
196  for(uint32_t boardID = 0; boardID < rawmicro::MAXIMUM_FRONTEND_BOARDS; ++boardID){
197 
198  /// Declare the front end boards simulators
199  FEBSimulator FrontEndBoard(boardID, _HitProbability, _nanosliceVersion);
200 
201  for(int pixelID = 0; pixelID < 32; ++pixelID){
202  /// Attempt to generate a nanoslice hit on a given pixel
203  FrontEndBoard.generateNanoSlice(pixelID);
204 
205  /// Check to see if it has nonzero data
206  if(FrontEndBoard.nonEmptyNanoSlice()){
207  // /Add the nanoslice from the FEB to the buffer
208  addNanoSlice(FrontEndBoard.getLastNanoSlice()->getBuffer());
209  } // endif NonEmptyNanoSlice
210  } // endfor pixelID
211  } // endfor boardID
212 }// end of RawMicroSlice::unpack()
static const uint32_t MAXIMUM_FRONTEND_BOARDS
Definition: RawMicroSlice.h:39
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
float _HitProbability
Pixel Hit probability. Used when generating a MicroSlice.
int32_t version_t
Definition: RawDAQData.h:72
void addNanoSlice(const void *nanoslice_buffer, const bool check_mc_flag=true)
void generate()
! Set the time-stamp as a single 64-bit value
bool setMonteCarloFlag(const bool)
Get number of NanoSlices in the MicroSlice.
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::RawMicroSlice::getByteCount ( ) const

Get the Data Present bit of the Header.

Definition at line 230 of file RawMicroSlice.cpp.

References _Header.

Referenced by daqqc::QualityCheck::checkMicroSlice(), and daqdataformats::VERSION_NAMESPACE::RawMicroBlock::sizeofdata().

231 {
232  return _Header->getByteCount();
233 } // Get Method for Byte Count
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
bool daqdataformats::RawMicroSlice::getDataPresent ( ) const

Get Floating NanoSlice.

Definition at line 222 of file RawMicroSlice.cpp.

References _Header.

Referenced by daqqc::QualityCheck::checkMicroSlice(), and dq::DAQEventUnpack::UnpackMicroSlice().

223 {
224  return _Header->getDataPresent();
225 } // Get Method for Data present bit
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
daqdataformats::RawNanoSlice * daqdataformats::RawMicroSlice::getFloatingNanoSlice ( ) const
daqdataformats::RawMicroSliceHeader * daqdataformats::RawMicroSlice::getHeader ( ) const

Definition at line 217 of file RawMicroSlice.cpp.

References _Header.

Referenced by daqdataformats::MicroSliceUnitTest::basicFieldGetAndSetChecks(), novaddt::OnlineUnpack::ProcessRawEvent_(), daq2raw::OnlineUnpack::ProcessRawEvent_(), and om::RawEventUnpacker::UnpackMicroSlice().

217  {
218  return _Header;
219 } // Get MicroSlice Header pointer
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
uint32_t daqdataformats::RawMicroSlice::getHighWord ( ) const

Get method for lower half of timing word.

Definition at line 236 of file RawMicroSlice.cpp.

References _TimingMarker, and daqdataformats::RawTimingMarker::getHighWord().

Referenced by novaddt::DAQHit::DAQHit(), novaddt::WaveformProcessor::initdcs(), and novaddt::WaveformProcessor::initmulti().

236 { return _TimingMarker->getHighWord();} // Get method for upper half of timing word
uint32_t getHighWord() const
! Get method for lower half of timing word
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
float daqdataformats::RawMicroSlice::getHitProbability ( ) const

Get the time-stamp as a single 64-bit value.

Definition at line 238 of file RawMicroSlice.cpp.

References _HitProbability.

238 { return _HitProbability;}
float _HitProbability
Pixel Hit probability. Used when generating a MicroSlice.
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::RawMicroSlice::getLowWord ( ) const

Get the byte count value of the header.

Definition at line 235 of file RawMicroSlice.cpp.

References _TimingMarker, and daqdataformats::RawTimingMarker::getLowWord().

235 { return _TimingMarker->getLowWord();} // Get method for lower half of timing word
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
bool daqdataformats::RawMicroSlice::getMonteCarloFlag ( ) const

Get the Data Present bit of the Header.

Definition at line 226 of file RawMicroSlice.cpp.

References _Header.

Referenced by daqdataformats::RawMilliSlice::addMicroSlice(), and daqqc::QualityCheck::checkMicroSlice().

227 {
228  return _Header->getMonteCarloFlag();
229 } // Get Method for SIM bit
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
uint32_t daqdataformats::RawMicroSlice::getNanoSliceSize ( ) const

Getting a nanoslice size. It could be different for different versions.

Could be zero nanoslices, then we don't know the nanoslice size

If floating nanoslice is not set, set it to zeroth nanoslice

Definition at line 272 of file RawMicroSlice.cpp.

References _FloatingNanoSlice, areThereNanoSlices(), and setFloatingNanoSlice().

Referenced by getNumNanoSlices(), and setFloatingNanoSlice().

272  {
273 
274  /// Could be zero nanoslices, then we don't know the nanoslice size
275  if(!areThereNanoSlices())return 0;
276 
277  /// If floating nanoslice is not set, set it to zeroth nanoslice
278  if(_FloatingNanoSlice == NULL && !setFloatingNanoSlice(0)) return 0;
279 
280  return _FloatingNanoSlice->sizeofdata();
281 }// end of getNanoSliceSize
bool setFloatingNanoSlice(const uint32_t inano) const
Set the SIM flag.
daqdataformats::RawNanoSlice * _FloatingNanoSlice
uint32_t daqdataformats::RawMicroSlice::getNumNanoSlices ( ) const

Get current Hit Probability (for a microslice generation)

Could be zero nanoslices

Definition at line 241 of file RawMicroSlice.cpp.

References areThereNanoSlices(), GENERATE_DATAFORMAT_EXCEPTION, getNanoSliceSize(), lem_server::msg, daqdataformats::rawmicro::PREDETERMINED_MICROSLICE_SIZE, sizeofdata(), and string.

Referenced by daqdataformats::MicroSliceUnitTest::basicFieldGetAndSetChecks(), daqqc::QualityCheck::checkEvent(), daqqc::QualityCheck::checkMicroSlice(), daqdataformats::MilliSliceConstructor::getNanoSlicesVersion(), daqdataformats::MicroSliceConstructor::getNanoSlicesVersion(), printStandard(), novaddt::OnlineUnpack::ProcessRawEvent_(), daq2raw::OnlineUnpack::ProcessRawEvent_(), NovaDDTHitProducer::produce(), setFloatingNanoSlice(), dq::DAQEventUnpack::UnpackMicroSlice(), and om::RawEventUnpacker::UnpackMicroSlice().

241  {
242 
243  /// Could be zero nanoslices
244  if(!areThereNanoSlices())return 0;
245 
246  const uint32_t nanoslice_size = getNanoSliceSize();
247  if(nanoslice_size == 0){
248  std::string msg("From RawMicroSlice::getNumNanoSlices. NanoSLice size is zero.");
250  }// end of checking whether nanoslice size is zero
251 
252  return (sizeofdata() - rawmicro::PREDETERMINED_MICROSLICE_SIZE) / nanoslice_size;
253 }
#define GENERATE_DATAFORMAT_EXCEPTION(msg)
static const uint32_t PREDETERMINED_MICROSLICE_SIZE
Definition: RawMicroSlice.h:40
uint32_t getNanoSliceSize() const
Getting a nanoslice size. It could be different for different versions.
enum BeamMode string
uint32_t daqdataformats::RawMicroSlice::getPredeterminedSize ( ) const
inlineprotected

Definition at line 132 of file RawMicroSlice.h.

References daqdataformats::rawmicro::PREDETERMINED_MICROSLICE_SIZE.

Referenced by RawMicroSlice().

static const uint32_t PREDETERMINED_MICROSLICE_SIZE
Definition: RawMicroSlice.h:40
uint64_t daqdataformats::RawMicroSlice::getTime ( ) const

Get method for upper half of timing word.

Definition at line 237 of file RawMicroSlice.cpp.

References _TimingMarker, and daqdataformats::RawTimingMarker::getTime().

Referenced by daqdataformats::RawMilliSlice::addMicroSlice(), daqdataformats::MilliSliceUnitTest::basicFieldGetAndSetChecks(), daqdataformats::MilliSliceConstructor::fillDataFormat(), and novaddt::OnlineUnpack::ProcessRawEvent_().

237 { return _TimingMarker->getTime();} // Get the time-stamp as a single 64-bit value */
uint64_t getTime() const
! Get method for upper half of timing word
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
daqdataformats::RawTimingMarker * daqdataformats::RawMicroSlice::getTimingMarker ( ) const

Get the MicroSlice Header.

Definition at line 220 of file RawMicroSlice.cpp.

References _TimingMarker.

Referenced by daqdataformats::MicroSliceUnitTest::basicFieldGetAndSetChecks().

220 { return _TimingMarker; } // Get Timing Marker pointer
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
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;}
version_t daqdataformats::RawMicroSlice::getVersion ( ) const
inline
void daqdataformats::RawMicroSlice::init ( )

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

Definition at line 123 of file RawMicroSlice.cpp.

References _Header, _microSliceHeaderVersion, daqdataformats::RawDAQData::_shouldBufferBeInternal, _TimingMarker, daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, daqdataformats::RawDAQData::init(), daqdataformats::rawmicro::PREDETERMINED_MICROSLICE_SIZE, and daqdataformats::RawDAQData::resizeInternalBuffer().

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

124 {
125 
126  /// This is needed for the formats with variable size
127  /// If buffer is internal, need to resize it
130  }
131 
132  // Initialize the header and timing marker
134  _Header->initSoft();
135  else
136  _Header->init();
137 
138  _TimingMarker->init();
139 }
static const uint32_t PREDETERMINED_MICROSLICE_SIZE
Definition: RawMicroSlice.h:40
bool _shouldBufferBeInternal
Auxillary variable that holds whether the buffer should be external or internal.
Definition: RawDAQData.h:286
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
bool resizeInternalBuffer(const uint32_t size_of_data)
Resize the internal buffer.
Definition: RawDAQData.cpp:292
daqdataformats::RawDAQData::Init_t ( _function_init  )
protectedinherited
bool daqdataformats::RawDAQData::isInternalBuffer ( ) const
inlineinherited
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(), RawMicroSlice(), daqdataformats::RawMilliSlice::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
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 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::RawMicroSlice::printStandard ( std::ostream &  os = std::cout) const
protected

If number is nonzero, need to print them

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

Definition at line 353 of file RawMicroSlice.cpp.

References daqdataformats::RawDAQData::_Buffer, _Header, _microSliceHeaderVersion, _TimingMarker, daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, allTimeWatchdog::endl, getFloatingNanoSlice(), getNumNanoSlices(), MECModelEnuComparisons::i, daqdataformats::RawDAQData::print(), daqdataformats::RawDAQData::printBuffer(), setFloatingNanoSlice(), and sizeofdata().

353  {
354 
355  const uint32_t size_of_data = sizeofdata();
356  os<<"----------MicroSlice----------------------------------------size="<<size_of_data<<std::endl;
357  printBuffer(os);
359  _Header->print(os);
360  }
361 
362  _TimingMarker->print(os);
363 
364 
365  const uint32_t num_nanoslices = getNumNanoSlices();
366 
367  os<<std::endl<<"----------NumNanoSlices-------="<<num_nanoslices<<std::endl;
368 
369  /// If number is nonzero, need to print them
370  if(num_nanoslices){
371  /// Get a copy of the MicroSlice this is so that we don't screw up the internal structure
372  const RawMicroSlice micro_copy(_Buffer, 3);
373 
374  for(uint32_t i = 0; i < num_nanoslices; ++i){
375  micro_copy.setFloatingNanoSlice(i);
376  micro_copy.getFloatingNanoSlice()->print(os);
377  }// end of loop over nanoslices
378  }// end of checking whether the number of nanoslices is non-zero
379 
380 
381 }// end of print1
RawMicroSlice(const uint32_t buffersize=rawmicro::DEFAULT_MICROSLICE_SIZE, const bool resize_buffer=false, const version_t microsliceheader_version=rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION)
If resize_buffer=true, then we resize the whole internal Buffer with zeros on the construction...
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
uint32_t getNumNanoSlices() const
Get current Hit Probability (for a microslice generation)
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
void print(std::ostream &os=std::cout) const
Method for printing the content of the Buffer.
Definition: RawDAQData.cpp:500
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
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
Definition: RawDAQData.cpp:330
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
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(), daqdataformats::RawMilliSlice::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
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(), getVersion(), PandAna.core.core.loader::Go(), daqdataformats::RawMilliSlice::readData(), daqdataformats::VERSION_NAMESPACE::RawDataBlock::readData(), daqdataformats::VERSION_NAMESPACE::RawDataBlock::readDataUnknownVersion(), daqdataformats::RawDAQData::readDataUnknownVersion(), daqdataformats::RawMilliSlice::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::RawTriggerTimingMarker::sizeofdata(), daqdataformats::VERSION_NAMESPACE::RawEventTail::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
readDataStatus daqdataformats::RawMicroSlice::readData ( const int  file_descriptor)
virtual

Read Data From File Descriptor.

Check if the file descriptor is invalid

Read the Header

Figure out version

Check if the reading was OK

Check if the reading was complete

After reading the header, now we know the whole MicroSlice size In words

Check whether we need to adjust the Internal Buffer size

Read the rest of the MicroSlice

Check if the reading was OK

Check if the reading was complete

Reimplemented from daqdataformats::RawDAQData.

Definition at line 414 of file RawMicroSlice.cpp.

References daqdataformats::RawDAQData::_Buffer, daqdataformats::RawDAQData::_shouldBufferBeInternal, daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, getVersion(), daqdataformats::RAWMICROSLICEHEADER_SIZE, daqdataformats::rds_complete, daqdataformats::rds_error, daqdataformats::rds_incomplete, daqdataformats::RawDAQData::resizeInternalBuffer(), setVersion(), and sizeofdata().

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

415 {
416 
417  /// Check if the file descriptor is invalid
418  if(fd < 0) return rds_error;
419 
420  char* current_buffer = (char*)_Buffer;
421 
422  /// Read the Header
423  ssize_t bytes_read = read(fd, current_buffer, (size_t)(RAWMICROSLICEHEADER_SIZE*sizeof(uint32_t)));
424  current_buffer += bytes_read;
425 
426  /// Figure out version
428  setVersion(RawMicroSliceHeader::figureOutTheVersionStatic(_Buffer));
429  }
430 
431  /// Check if the reading was OK
432  if (bytes_read == -1 || bytes_read == 0) return rds_error;
433 
434  /// Check if the reading was complete
435  if ((uint32_t)bytes_read != RAWMICROSLICEHEADER_SIZE*sizeof(uint32_t)) return rds_incomplete;
436 
437  /// After reading the header, now we know the whole MicroSlice size
438  /// In words
439  const uint32_t microslice_size = sizeofdata();
440  const uint32_t rest_of_microslice_size = microslice_size - RAWMICROSLICEHEADER_SIZE;
441 
442  /// Check whether we need to adjust the Internal Buffer size
444  resizeInternalBuffer(microslice_size);
445  }
446 
447  /// Read the rest of the MicroSlice
448  bytes_read = read(fd, current_buffer, (size_t)rest_of_microslice_size*sizeof(uint32_t));
449 
450  /// Check if the reading was OK
451  if (bytes_read == -1 || bytes_read == 0) return rds_error;
452 
453  /// Check if the reading was complete
454  if ((uint32_t)bytes_read != rest_of_microslice_size*sizeof(uint32_t)) return rds_incomplete;
455 
456  return rds_complete;
457 }
bool setVersion(const version_t)
void * _Buffer
All data formats need to have _Buffer and a Data structure. _Buffer will be common.
Definition: RawDAQData.h:276
version_t getVersion() const
Definition: RawMicroSlice.h:67
bool _shouldBufferBeInternal
Auxillary variable that holds whether the buffer should be external or internal.
Definition: RawDAQData.h:286
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
static const uint32_t RAWMICROSLICEHEADER_SIZE
bool resizeInternalBuffer(const uint32_t size_of_data)
Resize the internal buffer.
Definition: RawDAQData.cpp:292
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::RawMicroSlice::readDataFromBuffer ( const void microslice_buffer)
protected

Figure out version

First, read Header and Timing marker

Now, read the rest of the the _Buffer

Check pointers after each read or resize buffer

Definition at line 392 of file RawMicroSlice.cpp.

References daqdataformats::RawDAQData::checkBufferInternalness(), daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, getVersion(), daqdataformats::rawmicro::PREDETERMINED_MICROSLICE_SIZE, daqdataformats::RawDAQData::readDataGeneral(), setVersion(), and sizeofdata().

393 {
394  /// Figure out version
396  setVersion(RawMicroSliceHeader::figureOutTheVersionStatic(microslice_buffer));
397  }
398 
399  /// First, read Header and Timing marker
400  void* microslice_buffer_new = readDataGeneral(microslice_buffer, rawmicro::PREDETERMINED_MICROSLICE_SIZE, 0);
401 
402  /// Now, read the rest of the the _Buffer
403  microslice_buffer_new = readDataGeneral(microslice_buffer_new
406  );
407  /// Check pointers after each read or resize buffer
409 
410  return microslice_buffer_new;
411 }
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
bool setVersion(const version_t)
static const uint32_t PREDETERMINED_MICROSLICE_SIZE
Definition: RawMicroSlice.h:40
version_t getVersion() const
Definition: RawMicroSlice.h:67
bool checkBufferInternalness()
If the buffer should be internal, check it&#39;s pointers and reassign them.
Definition: RawDAQData.cpp:612
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
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 daqdataformats::RawMilliSlice::addData(), addData(), daqdataformats::RawMilliSliceIndex::close(), daqdataformats::RawMilliSlice::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(), daqdataformats::RawMilliSlice::readDataFromBuffer(), 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 RawMicroSlice(), daqdataformats::RawMilliSlice::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(), daqdataformats::RawMilliSlice::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(), init(), 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::RawMicroSlice::setBufferSource ( const void pointer)

Setting Buffer, Header and Timing marker. Don't bother Floating NanoSlice.

See if header and Timing marker are already constructed

Definition at line 318 of file RawMicroSlice.cpp.

References daqdataformats::RawDAQData::_Buffer, _Header, _microSliceHeaderVersion, daqdataformats::RawDAQData::_shouldBufferBeInternal, _TimingMarker, daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, daqdataformats::RawDAQData::isInternalBuffer(), RAWBUFF32, daqdataformats::RawDAQData::setBufferSource(), daqdataformats::RawMicroSliceHeader::setVersionSoft(), sizeofdata(), and sizeofdata_t.

Referenced by daqdataformats::VERSION_NAMESPACE::RawMicroBlock::setBufferSource(), daqdataformats::RawMilliSlice::setFloatingMicroSlice(), and daqdataformats::RawMilliSlice::setFloatingMicroSliceToBufferSource().

318  {
319 
320  _Buffer = (void*)pointer;
321 
323 
325  _microSliceHeaderVersion = daqdataformats::RawMicroSliceHeader::figureOutTheVersionStatic(pointer);
326  //assert(_microSliceHeaderVersion != rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION);
327  if(_Header) {
329  }
330  }
331 
332  /// See if header and Timing marker are already constructed
333  if(_Header) {
334  _Header->setBufferSource(_Buffer);
335  const uint32_t* timing_marker_pointer = &RAWBUFF32[0] + _Header->sizeofdata();
336  return _TimingMarker->setBufferSource(timing_marker_pointer);
337  }
338 
339  uint32_t* timing_marker_pointer = &RAWBUFF32[0];
340 
342  timing_marker_pointer += _Header->sizeofdata();
343 
344  _TimingMarker = new RawTimingMarker(timing_marker_pointer);
345 
346  _function_sizeofdata = (sizeofdata_t) &RawMicroSlice::sizeofdata;
347 
348  return true;
349 }// end of setBufferSource1
#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::RawMicroSliceHeader * _Header
MicroSlice Header.
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
bool isInternalBuffer() const
Definition: RawDAQData.h:141
bool setVersionSoft(const version_t)
Don&#39;t change the field.
#define RAWBUFF32
Definition: RawDAQData.h:16
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
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::RawMicroSlice::setFloatingNanoSlice ( const uint32_t  inano) const

Set the SIM flag.

If there are no nanoslices, then can't the floating NanoSlice

Check whether NanoSlice is valid If nanoslice is zero, then nothing to check

counting nanoslices from zero if inano is zero, then don't need to calculate NanoSlice size

See if we need to create a new Nanoslice or just set the pointer

Definition at line 285 of file RawMicroSlice.cpp.

References _FloatingNanoSlice, _nanosliceVersion, areThereNanoSlices(), daqdataformats::RawNanoSlice::getHeader(), getNanoSliceSize(), getNumNanoSlices(), daqdataformats::rawmicro::PREDETERMINED_MICROSLICE_SIZE, and RAWBUFF32.

Referenced by daqqc::QualityCheck::checkEvent(), getNanoSliceSize(), daqdataformats::MicroSliceConstructor::getNanoSlicesVersion(), printStandard(), novaddt::OnlineUnpack::ProcessRawEvent_(), daq2raw::OnlineUnpack::ProcessRawEvent_(), NovaDDTHitProducer::produce(), dq::DAQEventUnpack::UnpackNanoSlice(), and om::RawEventUnpacker::UnpackNanoSlice().

285  {
286 
287  /// If there are no nanoslices, then can't the floating NanoSlice
288  if(!areThereNanoSlices())return false;
289 
290  /// Check whether NanoSlice is valid
291  /// If nanoslice is zero, then nothing to check
292  if(inano && inano >= getNumNanoSlices()){
293  //std::cout<<"Warning from RawMicroSlice::setFloatingNanoSlice : setting floating nanoslice to "<<inano
294  // <<"-th nanoslice, whereas only "<<this->getNumNanoSlices()<<"nanoslices are in the current MicroSlice."<<"\n";
295  return false;
296  }// end of checking whether NanoSlice is valid
297 
298  uint32_t* pointer = &RAWBUFF32[0] + rawmicro::PREDETERMINED_MICROSLICE_SIZE;
299 
300  /// counting nanoslices from zero
301  /// if inano is zero, then don't need to calculate NanoSlice size
302  if(inano) pointer += inano * getNanoSliceSize();
303 
304  /// See if we need to create a new Nanoslice or just set the pointer
305  if(_FloatingNanoSlice == NULL){
306  _FloatingNanoSlice = new RawNanoSlice(pointer, _nanosliceVersion);
308  }
309  else{
310  _FloatingNanoSlice->setBufferSource(pointer);
311  }
312 
313  return true;
314 }
IMPLEMENT_MAIN_STANDARD IMPLEMENT_MAIN_setBufferSource daqdataformats::RawNanoSliceHeader * getHeader() const
Get the NanoSlice header pointer.
Definition: RawNanoSlice.h:57
static const uint32_t PREDETERMINED_MICROSLICE_SIZE
Definition: RawMicroSlice.h:40
uint32_t getNumNanoSlices() const
Get current Hit Probability (for a microslice generation)
daqdataformats::RawNanoSlice * _FloatingNanoSlice
#define RAWBUFF32
Definition: RawDAQData.h:16
uint32_t getNanoSliceSize() const
Getting a nanoslice size. It could be different for different versions.
bool daqdataformats::RawMicroSlice::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 133 of file RawMicroSlice.h.

133 {return true;};
bool daqdataformats::RawMicroSlice::setHighWord ( const uint32_t  word)

Set method for lower half of timing word.

Definition at line 267 of file RawMicroSlice.cpp.

References _TimingMarker, and daqdataformats::RawTimingMarker::setHighWord().

267 { return _TimingMarker->setHighWord(word);}
bool setHighWord(const uint32_t)
! Set method for lower half of timing word
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
bool daqdataformats::RawMicroSlice::setHitProbability ( const float  hit_prob)

Set Hit probability of a pixel. Used when generating MicroSlices - method generate.

Definition at line 269 of file RawMicroSlice.cpp.

References _HitProbability.

269 { _HitProbability = hit_prob; return true; }
float _HitProbability
Pixel Hit probability. Used when generating a MicroSlice.
bool daqdataformats::RawMicroSlice::setLowWord ( const uint32_t  word)

We are allowed to change the floating nanoslice, thus it's const.

Set Floating NanoSlice to point to the "inano"-th NanoSlice

Definition at line 266 of file RawMicroSlice.cpp.

References _TimingMarker, and daqdataformats::RawTimingMarker::setLowWord().

266 { return _TimingMarker->setLowWord (word);}
bool setLowWord(const uint32_t)
! Get the time-stamp as a single 64-bit value
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
bool daqdataformats::RawMicroSlice::setMonteCarloFlag ( const bool  mc_flag)

Get number of NanoSlices in the MicroSlice.

Definition at line 262 of file RawMicroSlice.cpp.

References _Header.

Referenced by addData(), mcdatadaq::DCMSimulator::createMicroSlice(), and generate().

263 {
264  return _Header->setMonteCarloFlag(mc_flag);
265 }
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
bool daqdataformats::RawMicroSlice::setTime ( const uint64_t  timestamp)

Set method for upper half of timing word.

Set the time-stamp as a single 64-bit value

Definition at line 268 of file RawMicroSlice.cpp.

References _TimingMarker, and daqdataformats::RawTimingMarker::setTime().

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

268 { return _TimingMarker->setTime(timestamp);}
daqdataformats::RawTimingMarker * _TimingMarker
MicroSlice Timing Marker.
bool setTime(const uint64_t)
! Set method for upper half of timing word
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
bool daqdataformats::RawMicroSlice::setVersion ( const version_t  version)

Definition at line 98 of file RawMicroSlice.cpp.

References _Header, _microSliceHeaderVersion, daqdataformats::rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, GENERATE_DATAFORMAT_EXCEPTION, lem_server::msg, daqdataformats::RawMicroSliceHeader::setVersionSoft(), and string.

Referenced by daqdataformats::MicroSliceUnitTest::basicFieldGetAndSetChecks(), daqdataformats::MicroSliceConstructor::fillDataFormat(), readData(), and readDataFromBuffer().

99 {
101  std::string msg("Cannot set MicroSlice to version " + boost::lexical_cast<std::string>(version));
102  msg.append("\n It already has been set to " + boost::lexical_cast<std::string>(_microSliceHeaderVersion));
104  return false;
105  }
106 
108 
109  //if(_Buffer){
110  // setBufferSource(_Buffer);
111  //}
112 
113  if(_Header){
115  }
116 
117  return true;
118 }
#define GENERATE_DATAFORMAT_EXCEPTION(msg)
daqdataformats::RawMicroSliceHeader * _Header
MicroSlice Header.
bool setVersionSoft(const version_t)
Don&#39;t change the field.
const XML_Char * version
Definition: expat.h:187
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
enum BeamMode string
uint32_t daqdataformats::RawMicroSlice::sizeofdata ( ) const
daqdataformats::RawDAQData::Sizeofdata_t ( _function_sizeofdata  )
protectedinherited
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
daqdataformats::RawNanoSlice* daqdataformats::RawMicroSlice::_FloatingNanoSlice
mutableprivate

Floating NanoSlice. Allowed to be changed anywhere, even in const routines One can set the pointer of the nanoslice to any one within the MicroSlice

Definition at line 139 of file RawMicroSlice.h.

Referenced by getFloatingNanoSlice(), getNanoSliceSize(), setFloatingNanoSlice(), and ~RawMicroSlice().

daqdataformats::RawMicroSliceHeader* daqdataformats::RawMicroSlice::_Header
private
float daqdataformats::RawMicroSlice::_HitProbability
private

Pixel Hit probability. Used when generating a MicroSlice.

Definition at line 143 of file RawMicroSlice.h.

Referenced by generate(), getHitProbability(), and setHitProbability().

std::vector<uint32_t> daqdataformats::RawDAQData::_InternalBuffer
protectedinherited
version_t daqdataformats::RawMicroSlice::_microSliceHeaderVersion
mutableprivate

Definition at line 145 of file RawMicroSlice.h.

Referenced by init(), printStandard(), setBufferSource(), and setVersion().

version_t daqdataformats::RawMicroSlice::_nanosliceVersion
mutableprivate

Definition at line 144 of file RawMicroSlice.h.

Referenced by generate(), and setFloatingNanoSlice().

bool daqdataformats::RawDAQData::_shouldBufferBeInternal
protectedinherited
daqdataformats::RawTimingMarker* daqdataformats::RawMicroSlice::_TimingMarker
private
version_t daqdataformats::RawDAQData::_version
protectedinherited

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