evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::RecordHeader Class Reference

#include <RecordHeader.h>

Public Member Functions

 RecordHeader ()
 Default, no-arg constructor. More...
 
 RecordHeader (const RecordHeader &head)
 Copy constructor. More...
 
 RecordHeader (const HeaderType &type)
 Constructor which sets the type of header this is. More...
 
 RecordHeader (size_t pos, uint32_t len, uint32_t ent)
 Constructor. More...
 
 ~RecordHeader ()=default
 
RecordHeaderoperator= (const RecordHeader &head)
 
void copy (std::shared_ptr< RecordHeader > const &head)
 Copy method. More...
 
void reset ()
 Reset generated data. More...
 
const HeaderTypegetHeaderType () const
 Get the type of header this is. More...
 
uint32_t getUncompressedRecordLength () const
 Get the padded length in bytes of the entire uncompressed record. More...
 
uint32_t getCompressedRecordLength () const
 Get the padded length in bytes of the entire compressed record. More...
 
uint32_t getLength () const
 Get the total length of this record in bytes. More...
 
uint32_t getLengthWords () const
 Get the total length of this record in 32 bit words. More...
 
uint32_t getEntries () const
 Get the number of events or entries in index. More...
 
uint32_t getUserHeaderLength () const
 Get the length of the user-defined header in bytes. More...
 
uint32_t getUserHeaderLengthWords () const
 Get the length of the user-defined header in words. More...
 
uint32_t getDataLength () const
 Get the length of the uncompressed data in bytes. More...
 
uint32_t getDataLengthWords () const
 Get the length of the uncompressed data in words (padded). More...
 
uint32_t getIndexLength () const
 Get the length of the index array in bytes. More...
 
uint32_t getCompressedDataLength () const
 Get the length of the compressed data in bytes. More...
 
uint32_t getCompressedDataLengthPadding () const
 Get the padding of the compressed data in bytes. More...
 
uint32_t getCompressedDataLengthWords () const
 Get the length of the compressed data in words (padded). More...
 
uint32_t getHeaderLength () const
 Get the length of this header in bytes (NOT including user header or index). More...
 
uint32_t getRecordNumber () const
 Get the record number. More...
 
uint64_t getUserRegisterFirst () const
 Get the first user-defined 64-bit register. More...
 
uint64_t getUserRegisterSecond () const
 Get the second user-defined 64-bit register. More...
 
size_t getPosition () const
 Get the position of this record in a file. More...
 
Compressor::CompressionType getCompressionType () override
 Get the type of compression used. More...
 
uint32_t setBitInfo (bool isLastRecord, bool haveDictionary)
 Set the bit info word for a record header. More...
 
uint32_t getBitInfoWord () const
 Get the bit info word. More...
 
void setBitInfoWord (uint32_t word)
 Set the bit info word and related values. More...
 
void setBitInfoWord (std::bitset< 24 > const &set)
 Set the bit info word and related values. More...
 
uint32_t hasDictionary (bool hasFirst)
 Set the bit which says record has a dictionary in the user header. More...
 
uint32_t isLastRecord (bool isLast)
 Set the bit which says record is last in file/buffer. More...
 
bool isLastRecord () const
 Is this the header of the last record? More...
 
bool isCompressed () override
 Does this header indicate compressed data? More...
 
bool isEvioTrailer () const
 Is this header an evio trailer? More...
 
bool isEvioRecord () const
 Is this header an evio record? More...
 
bool isHipoTrailer () const
 Is this header a hipo trailer? More...
 
bool isHipoRecord () const
 Is this header a hipo record? More...
 
uint32_t setBitInfoEventType (uint32_t type)
 Set the bit info of a record header for a specified CODA event type. More...
 
RecordHeadersetHeaderType (HeaderType const &type)
 Set this header's type. More...
 
RecordHeadersetPosition (size_t pos)
 Set the position of this record in a file. More...
 
RecordHeadersetRecordNumber (uint32_t num)
 Set the record number. More...
 
RecordHeadersetLength (uint32_t length)
 Set the record length in bytes & words. More...
 
RecordHeadersetDataLength (uint32_t length)
 Set the uncompressed data length in bytes & words and the padding. More...
 
RecordHeadersetCompressedDataLength (uint32_t length)
 Set the compressed data length in bytes & words and the padding. More...
 
RecordHeadersetIndexLength (uint32_t length)
 Set the length of the index array in bytes. More...
 
RecordHeadersetCompressionType (Compressor::CompressionType type)
 Set the compression type. More...
 
RecordHeadersetEntries (uint32_t n)
 Set the number of events or index entries. More...
 
RecordHeadersetUserHeaderLength (uint32_t length)
 Set the user-defined header's length in bytes & words and the padding. More...
 
RecordHeadersetHeaderLength (uint32_t length)
 Set the this header's length in bytes & words. More...
 
RecordHeadersetUserRegisterFirst (uint64_t reg)
 Set the first, 64-bit, user-defined register. More...
 
RecordHeadersetUserRegisterSecond (uint64_t reg)
 Set the second, 64-bit, user-defined register. More...
 
void writeHeader (ByteBuffer &buf, size_t off=0)
 Writes this header into the given byte buffer. More...
 
void writeHeader (std::shared_ptr< ByteBuffer > &buffer, size_t off=0)
 Writes this header into the given byte buffer. More...
 
void writeHeader (uint8_t *array, const ByteOrder &order)
 Writes this header at the given pointer. More...
 
void readHeader (ByteBuffer &buffer, size_t offset=0)
 Reads the header information from a byte buffer and validates it by checking the magic word (8th word). More...
 
void readHeader (std::shared_ptr< ByteBuffer > &buffer, size_t offset=0)
 Reads the header information from a byte buffer and validates it by checking the magic word (8th word). More...
 
void readHeader (uint8_t *src, ByteOrder order)
 Reads the header information from a byte buffer and validates it by checking the magic word (8th word). More...
 
std::string eventTypeToString () const
 Return a meaningful string associated with event type. More...
 
uint32_t getSize () override
 Get the size of the record)in 32 bit words. More...
 
uint32_t getNumber () override
 Get the block number for this record) In a file, this is usually sequential. More...
 
uint32_t getHeaderWords () override
 Get the length of this header in words. More...
 
uint32_t getSourceId () override
 Get the source ID number if in CODA online context and data is coming from ROC. More...
 
bool hasFirstEvent () override
 Does this header have a first event in the user header? More...
 
uint32_t getEventType () override
 Get the type of events in record (see values of DataType. More...
 
uint32_t getVersion () override
 Get the Evio format version number. More...
 
uint32_t getMagicNumber () override
 Get the magic number the record)header which should be 0xc0da0100. More...
 
ByteOrdergetByteOrder () override
 Get the byte order of the file/buffer this header was read from. More...
 
bool hasDictionary () override
 Does this record have a dictionary in the user header? More...
 
bool isLastBlock () override
 Is this the last record in the file or being sent over the network? More...
 
std::string toString () override
 Returns a string representation of this record. More...
 
size_t write (ByteBuffer &byteBuffer) override
 Write myself out into a byte buffer. More...
 
size_t getBufferEndingPosition () override
 Get the position in the buffer (bytes) of this record's last data word. More...
 
size_t getBufferStartingPosition () override
 Get the starting position in the buffer (bytes) from which this header was read–if that happened. More...
 
void setBufferStartingPosition (size_t bufferStartingPosition) override
 Set the starting position in the buffer (bytes) from which this header was read–if that happened. More...
 
size_t nextBufferStartingPosition () override
 Determines where the start of the next record header in some buffer is located (bytes). More...
 
size_t firstEventStartingPosition () override
 Determines where the start of the first event in this record is located (bytes). More...
 
size_t bytesRemaining (size_t pos) override
 Gives the bytes remaining in this record given a buffer position. More...
 
int main (int argc, char **argv)
 Run this class as an executable which tests the writing and reading of a record. More...
 

Static Public Member Functions

static uint32_t getWords (uint32_t length)
 Returns length padded to 4-byte boundary for given length in bytes. More...
 
static uint32_t getPadding (uint32_t length)
 Returns number of bytes needed to pad to 4-byte boundary for the given length. More...
 
static uint32_t generateSixthWord (std::bitset< 24 > const &set)
 Calculates the sixth word of this header which has the version number (6) in the lowest 8 bits and the set in the upper 24 bits. More...
 
static uint32_t generateSixthWord (uint32_t version, bool hasDictionary, bool isEnd, uint32_t eventType)
 Calculates the sixth word of this header which has the version number in the lowest 8 bits. More...
 
static uint32_t generateSixthWord (std::bitset< 24 > const &set, uint32_t version, bool hasDictionary, bool isEnd, uint32_t eventType, uint32_t headerType=0)
 Calculates the sixth word of this header which has the version number (4) in the lowest 8 bits and the set in the upper 24 bits. More...
 
static bool hasDictionary (int bitInfo)
 Does this bitInfo arg indicate the existence of a dictionary in the user header? More...
 
static bool isLastRecord (uint32_t bitInfo)
 Does this word indicate this is the header of the last record? More...
 
static bool isEvioTrailer (uint32_t bitInfo)
 Does this arg indicate its header is an evio trailer? More...
 
static bool isEvioRecord (uint32_t bitInfo)
 Does this arg indicate its header is an evio record? More...
 
static bool isHipoTrailer (uint32_t bitInfo)
 Does this arg indicate its header is a hipo trailer? More...
 
static bool isHipoRecord (uint32_t bitInfo)
 Does this arg indicate its header is a hipo record? More...
 
static uint32_t clearLastRecordBit (uint32_t i)
 Clear the bit in the given arg to indicate it is NOT the last record. More...
 
static void writeTrailer (uint8_t *array, size_t arrayLen, uint32_t recordNum, const ByteOrder &order, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr)
 
static void writeTrailer (std::vector< uint8_t > &array, size_t off, uint32_t recordNum, const ByteOrder &order, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr)
 
static void writeTrailer (ByteBuffer &buf, size_t off, uint32_t recordNum, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr)
 
static void writeTrailer (std::shared_ptr< ByteBuffer > &buf, size_t off, uint32_t recordNum, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr)
 
static bool isCompressed (ByteBuffer &buffer, size_t offset)
 Quickly check to see if this buffer contains compressed data or not. More...
 
static bool isCompressed (std::shared_ptr< ByteBuffer > &buffer, size_t offset)
 Quickly check to see if this buffer contains compressed data or not. More...
 

Static Public Attributes

static const uint32_t HEADER_SIZE_WORDS = 14
 Number of 32-bit words in a normal sized header. More...
 
static const uint32_t HEADER_SIZE_BYTES = 56
 Number of bytes in a normal sized header. More...
 
static const uint32_t HEADER_MAGIC = 0xc0da0100
 Magic number used to track endianness. More...
 
static const uint32_t RECORD_LENGTH_OFFSET = 0
 Byte offset from beginning of header to the record length. More...
 
static const uint32_t RECORD_NUMBER_OFFSET = 4
 Byte offset from beginning of header to the record number. More...
 
static const uint32_t HEADER_LENGTH_OFFSET = 8
 Byte offset from beginning of header to the header length. More...
 
static const uint32_t EVENT_COUNT_OFFSET = 12
 Byte offset from beginning of header to the event index count. More...
 
static const uint32_t INDEX_ARRAY_OFFSET = 16
 Byte offset from beginning of header to the index array length. More...
 
static const uint32_t BIT_INFO_OFFSET = 20
 Byte offset from beginning of header to bit info word. More...
 
static const uint32_t USER_LENGTH_OFFSET = 24
 Byte offset from beginning of header to the user header length. More...
 
static const uint32_t MAGIC_OFFSET = 28
 Byte offset from beginning of header to the magic number. More...
 
static const uint32_t UNCOMPRESSED_LENGTH_OFFSET = 32
 Byte offset from beginning of header to the uncompressed data length. More...
 
static const uint32_t COMPRESSION_TYPE_OFFSET = 36
 Byte offset from beginning of header to the compression type & compressed data length word. More...
 
static const uint32_t REGISTER1_OFFSET = 40
 Byte offset from beginning of header to the user register #1. More...
 
static const uint32_t REGISTER2_OFFSET = 48
 Byte offset from beginning of header to the user register #2. More...
 
static const uint32_t DICTIONARY_BIT = 0x100
 8th bit set in bitInfo word in header means contains dictionary. More...
 
static const uint32_t LAST_RECORD_BIT = 0x200
 9th bit set in bitInfo word in header means is last in stream or file. More...
 
static const uint32_t DATA_ROC_RAW_BITS = 0x000
 11-14th bits in bitInfo word in header for CODA data type, ROC raw = 0. More...
 
static const uint32_t DATA_PHYSICS_BITS = 0x800
 11-14th bits in bitInfo word in header for CODA data type, physics = 1. More...
 
static const uint32_t DATA_PARTIAL_BITS = 0x1000
 11-14th bits in bitInfo word in header for CODA data type, partial physics = 2. More...
 
static const uint32_t DATA_DISENTANGLED_BITS = 0x1800
 11-14th bits in bitInfo word in header for CODA data type, disentangled = 3. More...
 
static const uint32_t DATA_USER_BITS = 0x2000
 11-14th bits in bitInfo word in header for CODA data type, user = 4. More...
 
static const uint32_t DATA_CONTROL_BITS = 0x2800
 11-14th bits in bitInfo word in record header for CODA data type, control = 5. More...
 
static const uint32_t DATA_OTHER_BITS = 0x7800
 11-14th bits in bitInfo word in record header for CODA data type, other = 15. More...
 
static const uint32_t VERSION_MASK = 0xff
 Mask to get version number from 6th int in header. More...
 
static const uint32_t LAST_RECORD_MASK = 0x400
 "Last record" is 11th bit in bitInfo word. More...
 
static const uint32_t MAGIC_NUMBER = 0xc0da0100
 The magic number, should be the value of magicNumber. More...
 

Detailed Description

GENERAL RECORD HEADER STRUCTURE ( 56 bytes, 14 integers (32 bit) )
   +----------------------------------+
 1 |         Record Length            | // 32bit words, inclusive
   +----------------------------------+
 2 +         Record Number            |
   +----------------------------------+
 3 +         Header Length            | // 14 (words)
   +----------------------------------+
 4 +       Event (Index) Count        |
   +----------------------------------+
 5 +      Index Array Length          | // bytes
   +-----------------------+----------+
 6 +       Bit Info        | Version  | // version (8 bits)
   +-----------------------+----------+
 7 +      User Header Length          | // bytes
   +----------------------------------+
 8 +          Magic Number            | // 0xc0da0100
   +----------------------------------+
 9 +     Uncompressed Data Length     | // bytes
   +------+---------------------------+
10 +  CT  |  Data Length Compressed   | // CT = compression type (4 bits); compressed len in words
   +----------------------------------+
11 +          User Register 1         | // UID 1st (64 bits)
   +--                              --+
12 +                                  |
   +----------------------------------+
13 +          User Register 2         | // UID 2nd (64 bits)
   +--                              --+
14 +                                  |
   +----------------------------------+
-------------------
  Compression Type
-------------------
    0  = none
    1  = LZ4 fastest
    2  = LZ4 best
    3  = gzip
-------------------
  Bit Info Word
-------------------
    0-7  = version
    8    = true if dictionary is included (relevant for first record only)
    9    = true if this record has "first" event (to be in every split file)
   10    = true if this record is the last in file or stream
   11-14 = type of events contained: 0 = ROC Raw,
                                     1 = Physics
                                     2 = PartialPhysics
                                     3 = DisentangledPhysics
                                     4 = User
                                     5 = Control
                                    15 = Other
   15-19 = reserved
   20-21 = pad 1
   22-23 = pad 2
   24-25 = pad 3
   26-27 = reserved
   28-31 = general header type: 0 = Evio record,
                                3 = Evio file trailer
                                4 = HIPO record,
                                7 = HIPO file trailer
------------------------------------------------------------
------------------------------------------------------------
  TRAILER HEADER STRUCTURE ( 56 bytes, 14 integers (32 bit) )
   +----------------------------------+
 1 |         Record Length            | // 32bit words, inclusive
   +----------------------------------+
 2 +         Record Number            |
   +----------------------------------+
 3 +               14                 |
   +----------------------------------+
 4 +                0                 |
   +----------------------------------+
 5 +      Index Array Length          | // bytes
   +-----------------------+----------+
 6 +       Bit Info        | Version  |
   +-----------------------+----------+
 7 +                0                 |
   +----------------------------------+
 8 +           0xc0da0100             |
   +----------------------------------+
 9 +     Uncompressed Data Length     | // bytes
   +----------------------------------+
10 +                0                 |
   +----------------------------------+
11 +                0                 |
   +--                              --+
12 +                0                 |
   +----------------------------------+
13 +                0                 |
   +--                              --+
14 +                0                 |
   +----------------------------------+
-------------------
  Bit Info Word
  bit number  =  value
-------------------
    0-7  = 6
    8    = 0
    9    = 0
   10    = 1
   11-14 = 0
   15-19 = 0
   20-21 = 0
   22-23 = 0
   24-25 = 0
   26-27 = 0
   28-31 = 3
        THE FULL TRAILER FORMAT IS:
   +----------------------------------+
   |         Trailer Header           |
   |          (14 words)              |
   +----------------------------------+
   +----------------------------------+
   |            Optional              |
   |      Uncompressed Array of       |
   |     a record length in bytes,    |
   |           followed by            |
   |  an event count for that record  |
   |       (2 words / record)         |
   |          (all records)           |
   +----------------------------------+
------------------------------------------------------------
Version
6.0
Since
6.0 4/9/2019
Author
timmer

Constructor & Destructor Documentation

evio::RecordHeader::RecordHeader ( )

Default, no-arg constructor.

evio::RecordHeader::RecordHeader ( const RecordHeader head)

Copy constructor.

Parameters
headheader to copy.
evio::RecordHeader::RecordHeader ( const HeaderType type)
explicit

Constructor which sets the type of header this is.

Parameters
typetype of header this is
Exceptions
EvioExceptionif type is for file
evio::RecordHeader::RecordHeader ( size_t  pos,
uint32_t  len,
uint32_t  ent 
)

Constructor.

Parameters
posposition in file.
lenlength of record in bytes
entnumber of events
evio::RecordHeader::~RecordHeader ( )
default

Member Function Documentation

size_t evio::RecordHeader::bytesRemaining ( size_t  pos)
overridevirtual

Gives the bytes remaining in this record given a buffer position.

The position is an absolute position in a byte buffer. This assumes that the absolute position in bufferStartingPosition is being maintained properly by the reader.

Parameters
posthe absolute current position in a byte buffer.
Returns
the number of bytes remaining in this record.
Exceptions
EvioExceptionif position out of bounds

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::clearLastRecordBit ( uint32_t  i)
static

Clear the bit in the given arg to indicate it is NOT the last record.

Parameters
iinteger in which to clear the last-record bit
Returns
arg with last-record bit cleared
void evio::RecordHeader::copy ( std::shared_ptr< RecordHeader > const &  head)

Copy method.

Parameters
headheader to copy.
string evio::RecordHeader::eventTypeToString ( ) const

Return a meaningful string associated with event type.

Returns
a meaningful string associated with event type.
size_t evio::RecordHeader::firstEventStartingPosition ( )
overridevirtual

Determines where the start of the first event in this record is located (bytes).

This assumes the start position has been maintained by the object performing the buffer read.

Returns
where the start of the first event in this record is located (bytes). In evio format version 2, returns 0 if start is 0, signaling that this entire record is part of a logical record that spans at least three physical records.

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::generateSixthWord ( std::bitset< 24 > const &  set)
static

Calculates the sixth word of this header which has the version number (6) in the lowest 8 bits and the set in the upper 24 bits.

NOT FOR GENERAL USE!

Parameters
setreference to bitset containing all bits to be set
Returns
generated sixth word of this header.

Referenced by evio::CompactEventBuilder::toFile().

uint32_t evio::RecordHeader::generateSixthWord ( uint32_t  version,
bool  hasDictionary,
bool  isEnd,
uint32_t  eventType 
)
static

Calculates the sixth word of this header which has the version number in the lowest 8 bits.

The arg hasDictionary is set in the 9th bit and isEnd is set in the 10th bit. Four bits of an int (event type) are set in bits 11-14.

Parameters
versionevio version number
hasDictionarydoes this block include an evio xml dictionary as the first event?
isEndis this the last block of a file or a buffer?
eventType4 bit type of events header is containing
Returns
generated sixth word of this header.
uint32_t evio::RecordHeader::generateSixthWord ( std::bitset< 24 > const &  set,
uint32_t  version,
bool  hasDictionary,
bool  isEnd,
uint32_t  eventType,
uint32_t  headerType = 0 
)
static

Calculates the sixth word of this header which has the version number (4) in the lowest 8 bits and the set in the upper 24 bits.

The arg isDictionary is set in the 9th bit and isEnd is set in the 10th bit. Four bits of an int (event type) are set in bits 11-14. Four bits of this header type are set in bits 28-31 (defaults to 0 which is an evio record header).

Parameters
setreference to bitset containing all bits to be set
versionevio version number
hasDictionarydoes this block include an evio xml dictionary as the first event?
isEndis this the last block of a file or a buffer?
eventType4 bit type of events header is containing
headerType4 bit type of this header (defaults to 0 which is an evio record header).
Returns
generated sixth word of this header.
uint32_t evio::RecordHeader::getBitInfoWord ( ) const

Get the bit info word.

Will initialize if not already done.

Returns
bit info word.

Referenced by evio::RecordInput::uncompressRecord().

size_t evio::RecordHeader::getBufferEndingPosition ( )
overridevirtual

Get the position in the buffer (bytes) of this record's last data word.


Returns
position in the buffer (bytes) of this record's last data word.

Implements evio::IBlockHeader.

size_t evio::RecordHeader::getBufferStartingPosition ( )
overridevirtual

Get the starting position in the buffer (bytes) from which this header was read–if that happened.


This is not part of the record header proper. It is a position in a memory buffer of the start of the record It is kept for convenience. It is up to the reader to set it.

Returns
starting position in buffer (bytes) from which this header was read–if that happened.

Implements evio::IBlockHeader.

ByteOrder & evio::RecordHeader::getByteOrder ( )
overridevirtual

Get the byte order of the file/buffer this header was read from.

Defaults to little endian.

Returns
byte order of the file/buffer this header was read from.

Implements evio::IBlockHeader.

Referenced by evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().

uint32_t evio::RecordHeader::getCompressedDataLength ( ) const

Get the length of the compressed data in bytes.

Returns
length of the compressed data in bytes.

Referenced by evio::RecordInput::uncompressRecord().

uint32_t evio::RecordHeader::getCompressedDataLengthPadding ( ) const

Get the padding of the compressed data in bytes.

Returns
padding of the compressed data in bytes.
uint32_t evio::RecordHeader::getCompressedDataLengthWords ( ) const

Get the length of the compressed data in words (padded).

Returns
length of the compressed data in words (padded).

Referenced by main().

uint32_t evio::RecordHeader::getCompressedRecordLength ( ) const

Get the padded length in bytes of the entire compressed record.

If the data is not compressed, then this returns 0;

Returns
padded length in bytes of the entire compressed record, else 0 if not compressed.
Compressor::CompressionType evio::RecordHeader::getCompressionType ( )
overridevirtual

Get the type of compression used.

0=none, 1=LZ4 fast, 2=LZ4 best, 3=gzip.

Returns
type of compression used.

Implements evio::IBlockHeader.

Referenced by evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().

uint32_t evio::RecordHeader::getDataLength ( ) const

Get the length of the uncompressed data in bytes.

Returns
length of the uncompressed data in bytes.
uint32_t evio::RecordHeader::getDataLengthWords ( ) const

Get the length of the uncompressed data in words (padded).

Returns
length of the uncompressed data in words (padded).

Referenced by evio::RecordInput::uncompressRecord().

uint32_t evio::RecordHeader::getEntries ( ) const

Get the number of events or entries in index.

Returns
number of events or entries in index.

Referenced by evio::Reader::forceScanFile(), evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().

uint32_t evio::RecordHeader::getEventType ( )
overridevirtual

Get the type of events in record (see values of DataType.

Returns
type of events in record.

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::getHeaderLength ( ) const

Get the length of this header in bytes (NOT including user header or index).

Returns
length of this header in bytes.

Referenced by evio::Reader::scanBuffer(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().

const HeaderType & evio::RecordHeader::getHeaderType ( ) const

Get the type of header this is.

Returns
type of header this is.
uint32_t evio::RecordHeader::getHeaderWords ( )
overridevirtual

Get the length of this header in words.

Returns
length of this header in words.

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::getIndexLength ( ) const

Get the length of the index array in bytes.

Returns
length of the index array in bytes.

Referenced by evio::Reader::scanFile(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().

uint32_t evio::RecordHeader::getLength ( ) const

Get the total length of this record in bytes.

Returns
total length of this record in bytes.

Referenced by evio::Reader::forceScanFile(), evio::Reader::scanBuffer(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().

uint32_t evio::RecordHeader::getLengthWords ( ) const

Get the total length of this record in 32 bit words.

Returns
total length of this record in 32 bit words.
uint32_t evio::RecordHeader::getMagicNumber ( )
overridevirtual

Get the magic number the record)header which should be 0xc0da0100.

Returns
magic number in the record)

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::getNumber ( )
overridevirtual

Get the block number for this record) In a file, this is usually sequential.

Returns
the number for this record)

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::getPadding ( uint32_t  length)
static

Returns number of bytes needed to pad to 4-byte boundary for the given length.

Parameters
lengthlength in bytes.
Returns
number of bytes needed to pad to 4-byte boundary.
size_t evio::RecordHeader::getPosition ( ) const

Get the position of this record in a file.

Returns
position of this record in a file.
uint32_t evio::RecordHeader::getRecordNumber ( ) const

Get the record number.

Returns
record number.

Referenced by evio::Reader::forceScanFile(), evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().

uint32_t evio::RecordHeader::getSize ( )
overridevirtual

Get the size of the record)in 32 bit words.

Returns
size of the record)in 32 bit words.

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::getSourceId ( )
overridevirtual

Get the source ID number if in CODA online context and data is coming from ROC.

Returns
source ID number if in CODA online context and data is coming from ROC.

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::getUncompressedRecordLength ( ) const

Get the padded length in bytes of the entire uncompressed record.

Returns
padded length in bytes of the entire uncompressed record.

Referenced by evio::Reader::scanBuffer(), and evio::RecordInput::uncompressRecord().

uint32_t evio::RecordHeader::getUserHeaderLength ( ) const

Get the length of the user-defined header in bytes.

Returns
length of the user-defined header in bytes.
uint32_t evio::RecordHeader::getUserHeaderLengthWords ( ) const

Get the length of the user-defined header in words.

Returns
length of the user-defined header in words.

Referenced by evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().

uint64_t evio::RecordHeader::getUserRegisterFirst ( ) const

Get the first user-defined 64-bit register.

Returns
first user-defined 64-bit register.
uint64_t evio::RecordHeader::getUserRegisterSecond ( ) const

Get the second user-defined 64-bit register.

Returns
second user-defined 64-bit register.
uint32_t evio::RecordHeader::getVersion ( )
overridevirtual

Get the Evio format version number.

Returns
Evio format version number.

Implements evio::IBlockHeader.

Referenced by evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().

uint32_t evio::RecordHeader::getWords ( uint32_t  length)
static

Returns length padded to 4-byte boundary for given length in bytes.

Parameters
lengthlength in bytes.
Returns
length in bytes padded to 4-byte boundary.
uint32_t evio::RecordHeader::hasDictionary ( bool  hasFirst)

Set the bit which says record has a dictionary in the user header.

Parameters
hasFirsttrue if record has a dictionary in the user header.
Returns
new bitInfo word.

Referenced by evio::Writer::createRecord().

bool evio::RecordHeader::hasDictionary ( int  bitInfo)
static

Does this bitInfo arg indicate the existence of a dictionary in the user header?

Parameters
bitInfobitInfo word.
Returns
true if header has a dictionary in the user header, else false.
bool evio::RecordHeader::hasDictionary ( )
overridevirtual

Does this record have a dictionary in the user header?

Returns
true if record has a dictionary in the user header, else false.

Implements evio::IBlockHeader.

bool evio::RecordHeader::hasFirstEvent ( )
overridevirtual

Does this header have a first event in the user header?

Returns
true if header has a first event in the user header, else false.

Implements evio::IBlockHeader.

bool evio::RecordHeader::isCompressed ( )
overridevirtual

Does this header indicate compressed data?

Returns
true if header indicates compressed data, else false.

Implements evio::IBlockHeader.

Referenced by evio::Reader::scanBuffer().

bool evio::RecordHeader::isCompressed ( ByteBuffer buffer,
size_t  offset 
)
static

Quickly check to see if this buffer contains compressed data or not.

The offset must point to the beginning of a valid hipo/evio record in the buffer.

Parameters
bufferbuffer to read from.
offsetposition of record header to be read.
Returns
true if data in record is compressed, else false.
Exceptions
EvioExceptionif buffer contains too little data, or is not in proper format.

References evio::ByteBuffer::getInt(), evio::ByteBuffer::limit(), evio::ByteBuffer::order(), and SWAP_32.

bool evio::RecordHeader::isCompressed ( std::shared_ptr< ByteBuffer > &  buffer,
size_t  offset 
)
static

Quickly check to see if this buffer contains compressed data or not.

The offset must point to the beginning of a valid hipo/evio record in the buffer.

Parameters
bufferbuffer to read from.
offsetposition of record header to be read.
Returns
true if data in record is compressed, else false.
Exceptions
EvioExceptionif buffer contains too little data, or is not in proper format.
bool evio::RecordHeader::isEvioRecord ( ) const

Is this header an evio record?

Returns
true if this is an evio record, else false.
bool evio::RecordHeader::isEvioRecord ( uint32_t  bitInfo)
static

Does this arg indicate its header is an evio record?

Parameters
bitInfobitInfo word.
Returns
true if arg represents an evio record, else false.
bool evio::RecordHeader::isEvioTrailer ( ) const

Is this header an evio trailer?

Returns
true if this is an evio trailer, else false.
bool evio::RecordHeader::isEvioTrailer ( uint32_t  bitInfo)
static

Does this arg indicate its header is an evio trailer?

Parameters
bitInfobitInfo word.
Returns
true if arg represents an evio trailer, else false.
bool evio::RecordHeader::isHipoRecord ( ) const

Is this header a hipo record?

Returns
true if this is a hipo record, else false.
bool evio::RecordHeader::isHipoRecord ( uint32_t  bitInfo)
static

Does this arg indicate its header is a hipo record?

Parameters
bitInfobitInfo word.
Returns
true if arg represents a hipo record, else false.
bool evio::RecordHeader::isHipoTrailer ( ) const

Is this header a hipo trailer?

Returns
true if this is a hipo trailer, else false.
bool evio::RecordHeader::isHipoTrailer ( uint32_t  bitInfo)
static

Does this arg indicate its header is a hipo trailer?

Parameters
bitInfobitInfo word.
Returns
true if arg represents a hipo trailer, else false.
bool evio::RecordHeader::isLastBlock ( )
overridevirtual

Is this the last record in the file or being sent over the network?

Returns
true if this is the last record in the file or being sent over the network, else false.

Implements evio::IBlockHeader.

uint32_t evio::RecordHeader::isLastRecord ( bool  isLast)

Set the bit which says record is last in file/buffer.

Parameters
isLasttrue if record is last in file/buffer.
Returns
new bitInfo word.

Referenced by evio::Reader::scanBuffer().

bool evio::RecordHeader::isLastRecord ( ) const

Is this the header of the last record?

Returns
true if this is the header of the last record, else false.
bool evio::RecordHeader::isLastRecord ( uint32_t  bitInfo)
static

Does this word indicate this is the header of the last record?

Parameters
bitInfobitInfo word.
Returns
true if this is the header of the last record, else false.
int evio::RecordHeader::main ( int  argc,
char **  argv 
)
size_t evio::RecordHeader::nextBufferStartingPosition ( )
overridevirtual

Determines where the start of the next record header in some buffer is located (bytes).

This assumes the start position has been maintained by the object performing the buffer read.

Returns
the start of the next record header in some buffer is located (bytes).

Implements evio::IBlockHeader.

RecordHeader & evio::RecordHeader::operator= ( const RecordHeader head)
void evio::RecordHeader::readHeader ( ByteBuffer buffer,
size_t  offset = 0 
)

Reads the header information from a byte buffer and validates it by checking the magic word (8th word).

This magic word also determines the byte order.

Parameters
bufferbuffer to read from.
offsetposition of first word to be read.
Exceptions
EvioExceptionif buffer contains too little data, is not in proper format, or version earlier than 6.

References evio::ByteBuffer::capacity(), evio::ByteBuffer::getInt(), evio::ByteBuffer::getLong(), evio::ByteBuffer::order(), evio::ByteBuffer::printBytes(), and SWAP_32.

Referenced by evio::Reader::forceScanFile(), main(), evio::Reader::scanFile(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().

void evio::RecordHeader::readHeader ( std::shared_ptr< ByteBuffer > &  buffer,
size_t  offset = 0 
)

Reads the header information from a byte buffer and validates it by checking the magic word (8th word).

This magic word also determines the byte order.

Parameters
bufferbuffer to read from.
offsetposition of first word to be read.
Exceptions
EvioExceptionif buffer contains too little data, is not in proper format, or version earlier than 6.
void evio::RecordHeader::readHeader ( uint8_t *  src,
ByteOrder  order 
)

Reads the header information from a byte buffer and validates it by checking the magic word (8th word).

This magic word also determines the byte order.

Parameters
srcdata to read from.
orderbyte order when reading.
Exceptions
EvioExceptionif src arg is null, is not in proper format, or version earlier than 6.

References SWAP_32.

void evio::RecordHeader::reset ( )

Reset generated data.

uint32_t evio::RecordHeader::setBitInfo ( bool  isLastRecord,
bool  haveDictionary 
)

Set the bit info word for a record header.

Current value of bitInfo is lost.

Parameters
isLastRecordtrue if record is last in stream or file.
haveDictionarytrue if record has dictionary in user header.
Returns
new bit info word.
uint32_t evio::RecordHeader::setBitInfoEventType ( uint32_t  type)

Set the bit info of a record header for a specified CODA event type.

Must be called AFTER setBitInfo(bool, bool) or setBitInfoWord(uint32_t) in order to have change preserved.

Parameters
typeevent type (0=ROC raw, 1=Physics, 2=Partial Physics, 3=Disentangled, 4=User, 5=Control, 15=Other, else = nothing set).
Returns
new bit info word.
void evio::RecordHeader::setBitInfoWord ( uint32_t  word)

Set the bit info word and related values.

NOT FOR GENERAL USE!

Parameters
wordbit info word.
void evio::RecordHeader::setBitInfoWord ( std::bitset< 24 > const &  set)

Set the bit info word and related values.

NOT FOR GENERAL USE!

Parameters
setreference to bitset containing all bits to be set
void evio::RecordHeader::setBufferStartingPosition ( size_t  bufferStartingPosition)
overridevirtual

Set the starting position in the buffer (bytes) from which this header was read–if that happened.


This is not part of the record header proper. It is a position in a memory buffer of the start of the record It is kept for convenience. It is up to the reader to set it.

Parameters
bufferStartingPositionstarting position in buffer from which this header was read–if that happened.

Implements evio::IBlockHeader.

RecordHeader & evio::RecordHeader::setCompressedDataLength ( uint32_t  length)

Set the compressed data length in bytes & words and the padding.

Parameters
lengthlength of compressed data in bytes.
Returns
this object.

Referenced by main(), and evio::RecordInput::uncompressRecord().

RecordHeader & evio::RecordHeader::setCompressionType ( Compressor::CompressionType  type)

Set the compression type.

0=none, 1=LZ4 fast, 2=LZ4 best, 3=gzip. No compression for other values.

Parameters
typecompression type.
Returns
this object.

Referenced by main(), and evio::RecordInput::uncompressRecord().

RecordHeader & evio::RecordHeader::setDataLength ( uint32_t  length)

Set the uncompressed data length in bytes & words and the padding.

Parameters
lengthlength of uncompressed data in bytes.
Returns
this object.

Referenced by main().

RecordHeader & evio::RecordHeader::setEntries ( uint32_t  n)

Set the number of events or index entries.

No compression for other values.

Parameters
nnumber of events or index entries.
Returns
this object.

Referenced by main().

RecordHeader & evio::RecordHeader::setHeaderLength ( uint32_t  length)

Set the this header's length in bytes & words.

If length is not a multiple of 4, you're on your own!

Parameters
lengththis header's length in bytes.
Returns
this object.

Referenced by main().

RecordHeader & evio::RecordHeader::setHeaderType ( HeaderType const &  type)

Set this header's type.

Normally done in constructor. Limited access.

Parameters
typetype of header.
Returns
this object.

References evio::HeaderType::getValue().

RecordHeader & evio::RecordHeader::setIndexLength ( uint32_t  length)

Set the length of the index array in bytes.

Length is forced to be a multiple of 4!

Parameters
lengthlength of index array in bytes.
Returns
this object.

Referenced by main().

RecordHeader & evio::RecordHeader::setLength ( uint32_t  length)

Set the record length in bytes & words.

If length is not a multiple of 4, you're on your own!

Parameters
lengthlength of record in bytes.
Returns
this object.

Referenced by main(), and evio::RecordInput::uncompressRecord().

RecordHeader & evio::RecordHeader::setPosition ( size_t  pos)

Set the position of this record in a file.

Parameters
posposition of this record in a file.
Returns
this object.
RecordHeader & evio::RecordHeader::setRecordNumber ( uint32_t  num)

Set the record number.

Parameters
numrecord number.
Returns
this object.

Referenced by main().

RecordHeader & evio::RecordHeader::setUserHeaderLength ( uint32_t  length)

Set the user-defined header's length in bytes & words and the padding.

Parameters
lengthuser-defined header's length in bytes.
Returns
this object.

Referenced by main().

RecordHeader & evio::RecordHeader::setUserRegisterFirst ( uint64_t  reg)

Set the first, 64-bit, user-defined register.

Parameters
regfirst, 64-bit, user-defined register.
Returns
this object.

Referenced by main().

RecordHeader & evio::RecordHeader::setUserRegisterSecond ( uint64_t  reg)

Set the second, 64-bit, user-defined register.

Parameters
regsecond, 64-bit, user-defined register.
Returns
this object.

Referenced by main().

string evio::RecordHeader::toString ( )
overridevirtual

Returns a string representation of this record.

Returns
a string representation of this record.

Implements evio::IBlockHeader.

Referenced by main().

size_t evio::RecordHeader::write ( ByteBuffer byteBuffer)
overridevirtual

Write myself out into a byte buffer.

This write is relative–i.e., it uses the current position of the buffer.

Parameters
byteBufferthe byteBuffer to write to.
Returns
the number of bytes written.

Implements evio::IBlockHeader.

References evio::ByteBuffer::position().

void evio::RecordHeader::writeHeader ( ByteBuffer buf,
size_t  off = 0 
)

Writes this header into the given byte buffer.

Position & limit of given buffer does NOT change.

Parameters
bufbyte buffer to write header into.
offposition in buffer to begin writing.
Exceptions
EvioExceptionif buffer contains too little room.

References evio::ByteBuffer::limit(), evio::ByteBuffer::putInt(), and evio::ByteBuffer::putLong().

Referenced by main().

void evio::RecordHeader::writeHeader ( std::shared_ptr< ByteBuffer > &  buffer,
size_t  off = 0 
)

Writes this header into the given byte buffer.

Position & limit of given buffer does NOT change.

Parameters
bufferbyte buffer to write header into.
offposition in buffer to begin writing.
Exceptions
EvioExceptionif buffer contains too little room.
void evio::RecordHeader::writeHeader ( uint8_t *  array,
const ByteOrder order 
)

Writes this header at the given pointer.

Parameters
arraybyte array to write header into.
orderbyte order of data to be written.
Exceptions
EvioExceptionif array arg is null.
static void evio::RecordHeader::writeTrailer ( uint8_t *  array,
size_t  arrayLen,
uint32_t  recordNum,
const ByteOrder order,
const std::shared_ptr< std::vector< uint32_t >> &  recordLengths = nullptr 
)
static
static void evio::RecordHeader::writeTrailer ( std::vector< uint8_t > &  array,
size_t  off,
uint32_t  recordNum,
const ByteOrder order,
const std::shared_ptr< std::vector< uint32_t >> &  recordLengths = nullptr 
)
static
static void evio::RecordHeader::writeTrailer ( ByteBuffer buf,
size_t  off,
uint32_t  recordNum,
const std::shared_ptr< std::vector< uint32_t >> &  recordLengths = nullptr 
)
static
static void evio::RecordHeader::writeTrailer ( std::shared_ptr< ByteBuffer > &  buf,
size_t  off,
uint32_t  recordNum,
const std::shared_ptr< std::vector< uint32_t >> &  recordLengths = nullptr 
)
static

Member Data Documentation

const uint32_t evio::RecordHeader::BIT_INFO_OFFSET = 20
static

Byte offset from beginning of header to bit info word.

Referenced by evio::Writer::close(), evio::Reader::findRecordInfo(), and evio::RecordInput::uncompressRecord().

const uint32_t evio::RecordHeader::COMPRESSION_TYPE_OFFSET = 36
static

Byte offset from beginning of header to the compression type & compressed data length word.

Referenced by evio::Reader::findRecordInfo(), and evio::RecordInput::uncompressRecord().

const uint32_t evio::RecordHeader::DATA_CONTROL_BITS = 0x2800
static

11-14th bits in bitInfo word in record header for CODA data type, control = 5.

const uint32_t evio::RecordHeader::DATA_DISENTANGLED_BITS = 0x1800
static

11-14th bits in bitInfo word in header for CODA data type, disentangled = 3.

const uint32_t evio::RecordHeader::DATA_OTHER_BITS = 0x7800
static

11-14th bits in bitInfo word in record header for CODA data type, other = 15.

const uint32_t evio::RecordHeader::DATA_PARTIAL_BITS = 0x1000
static

11-14th bits in bitInfo word in header for CODA data type, partial physics = 2.

const uint32_t evio::RecordHeader::DATA_PHYSICS_BITS = 0x800
static

11-14th bits in bitInfo word in header for CODA data type, physics = 1.

const uint32_t evio::RecordHeader::DATA_ROC_RAW_BITS = 0x000
static

11-14th bits in bitInfo word in header for CODA data type, ROC raw = 0.

const uint32_t evio::RecordHeader::DATA_USER_BITS = 0x2000
static

11-14th bits in bitInfo word in header for CODA data type, user = 4.

const uint32_t evio::RecordHeader::DICTIONARY_BIT = 0x100
static

8th bit set in bitInfo word in header means contains dictionary.

const uint32_t evio::RecordHeader::EVENT_COUNT_OFFSET = 12
static

Byte offset from beginning of header to the event index count.

Referenced by evio::Reader::findRecordInfo().

const uint32_t evio::RecordHeader::HEADER_LENGTH_OFFSET = 8
static

Byte offset from beginning of header to the header length.

Referenced by evio::Reader::findRecordInfo().

const uint32_t evio::RecordHeader::HEADER_MAGIC = 0xc0da0100
static

Magic number used to track endianness.

Referenced by evio::CompactEventBuilder::toFile().

const uint32_t evio::RecordHeader::HEADER_SIZE_WORDS = 14
static

Number of 32-bit words in a normal sized header.

Referenced by evio::CompactEventBuilder::toFile().

const uint32_t evio::RecordHeader::INDEX_ARRAY_OFFSET = 16
static

Byte offset from beginning of header to the index array length.

Referenced by evio::Reader::findRecordInfo().

const uint32_t evio::RecordHeader::LAST_RECORD_BIT = 0x200
static

9th bit set in bitInfo word in header means is last in stream or file.

const uint32_t evio::RecordHeader::LAST_RECORD_MASK = 0x400
static

"Last record" is 11th bit in bitInfo word.

const uint32_t evio::IBlockHeader::MAGIC_NUMBER = 0xc0da0100
staticinherited
const uint32_t evio::RecordHeader::MAGIC_OFFSET = 28
static

Byte offset from beginning of header to the magic number.

const uint32_t evio::RecordHeader::RECORD_LENGTH_OFFSET = 0
static

Byte offset from beginning of header to the record length.

Referenced by evio::Reader::findRecordInfo(), and evio::RecordInput::uncompressRecord().

const uint32_t evio::RecordHeader::RECORD_NUMBER_OFFSET = 4
static

Byte offset from beginning of header to the record number.

const uint32_t evio::RecordHeader::REGISTER1_OFFSET = 40
static

Byte offset from beginning of header to the user register #1.

const uint32_t evio::RecordHeader::REGISTER2_OFFSET = 48
static

Byte offset from beginning of header to the user register #2.

const uint32_t evio::RecordHeader::UNCOMPRESSED_LENGTH_OFFSET = 32
static

Byte offset from beginning of header to the uncompressed data length.

Referenced by evio::Reader::addStructure(), evio::Reader::findRecordInfo(), and evio::Reader::removeStructure().

const uint32_t evio::RecordHeader::USER_LENGTH_OFFSET = 24
static

Byte offset from beginning of header to the user header length.

Referenced by evio::Reader::findRecordInfo().

const uint32_t evio::RecordHeader::VERSION_MASK = 0xff
static

Mask to get version number from 6th int in header.


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