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

This holds an evio block header, also known as a physical record header. More...

#include <BlockHeaderV4.h>

Public Member Functions

 BlockHeaderV4 ()=default
 Constructor initializes all fields to default values. More...
 
 BlockHeaderV4 (uint32_t sz, uint32_t num)
 Creates a BlockHeader for evio version 4 format. More...
 
 BlockHeaderV4 (std::shared_ptr< BlockHeaderV4 > &blkHeader)
 This copy constructor creates an evio version 4 BlockHeader from another object of this class. More...
 
void copy (std::shared_ptr< BlockHeaderV4 > &blkHeader)
 This method copies another header's contents. More...
 
uint32_t getSize () override
 Get the size of the block (record) in 32 bit words.
Returns
size of the block (record) in 32 bit words.
More...
 
void setSize (uint32_t sz)
 Set the size of the block (physical record). More...
 
uint32_t getEventCount () const
 Get the number of events completely contained in the block. More...
 
void setEventCount (uint32_t count)
 Set the number of events completely contained in the block. More...
 
uint32_t getNumber () override
 Get the block number for this block (record).In a file, this is usually sequential, starting at 1.

Returns
the block number for this block (record).
More...
 
void setNumber (uint32_t num)
 Set the block number for this block (physical record). More...
 
uint32_t getHeaderLength () const
 Get the block header length in ints. More...
 
uint32_t getHeaderWords () override
 Get the block (record) header length, in 32 bit words.
Returns
block (record) header length, in 32 bit words.
More...
 
void setHeaderLength (uint32_t len)
 Set the block header length, in ints. More...
 
uint32_t getVersion () override
 Get the evio version of the block (record) header.
Returns
evio version of the block (record) header.
More...
 
void setVersion (uint32_t ver)
 Sets the evio version. More...
 
bool hasFirstEvent () override
 Does this block/record contain the "first event" (first event to be written to each file split)?
Returns
true if this record has the first event, else false. Evio versions 1-3 always return false.
More...
 
bool hasDictionary () override
 Does this block contain an evio dictionary?
Returns
true if this block contains an evio dictionary, else false. Always returns false for versions 1-3 (not implemented).
More...
 
bool isLastBlock () override
 Is this the last block in the file or being sent over the network?
Returns
true if this is the last block in the file or being sent over the network, else false. Always returns false for versions 1-3 (not implemented).
More...
 
bool isCompressed () override
 Is this the data in this block compressed?
Returns
true if the data in this block is compressed, else false.
More...
 
Compressor::CompressionType getCompressionType () override
 Get the type of data compression used.
Returns
type of data compression used.
More...
 
bool hasFirstEvent () const
 Does this block contain the "first event" (first event to be written to each file split)? More...
 
uint32_t getEventType () override
 Get the type of events in block/record (see values of DataType.This is not supported by versions 1-3 which returns 0.

Returns
type of events in block/record, or 0 if evio version 1-3.
More...
 
std::bitset< 24 > getBitInfo ()
 Gets a copy of all stored bit information. More...
 
bool getBitInfo (uint32_t bitIndex)
 Gets the value of a particular bit in the bitInfo field. More...
 
void setBit (uint32_t bitIndex, bool value)
 Sets a particular bit in the bitInfo field. More...
 
uint32_t getSixthWord ()
 Calculates the sixth word of this header which has the version number in the lowest 8 bits and the bit info in the highest 24 bits. More...
 
void parseToBitInfo (uint32_t word)
 Parses the argument into the bit info fields. More...
 
uint32_t getSourceId () override
 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.
More...
 
uint32_t getReserved1 () const
 Get the first reserved word. More...
 
void setReserved1 (uint32_t r1)
 Sets the value of reserved1. More...
 
uint32_t getReserved2 () const
 Get the 2nd reserved word. More...
 
void setReserved2 (uint32_t r2)
 Sets the value of reserved2. More...
 
uint32_t getMagicNumber () override
 Get the magic number the block (record) header which should be 0xc0da0100.
Returns
magic number in the block (record).
More...
 
void setMagicNumber (uint32_t magicNum)
 Sets the value of magicNumber. More...
 
ByteOrdergetByteOrder () override
 Get the byte order of the data being read.
Returns
byte order of the data being read.
More...
 
void setByteOrder (ByteOrder &order)
 Sets the byte order of data being read. More...
 
std::string toString () override
 Get the string representation of the block (record) header.
Returns
string representation of the block (record) header.
More...
 
size_t getBufferEndingPosition () override
 Get the position in the buffer (bytes) of this block's last data word.

Returns
position in the buffer (bytes) of this block'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.
This is not part of the block header proper. It is a position in a memory buffer of the start of the block (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.
More...
 
void setBufferStartingPosition (size_t pos) override
 Set the starting position in the buffer (bytes) from which this header was read–if that happened.
This is not part of the block header proper. It is a position in a memory buffer of the start of the block (record). It is kept for convenience. It is up to the reader to set it.
Parameters
posstarting position in buffer from which this header was read–if that happened.
More...
 
size_t nextBufferStartingPosition () override
 Determines where the start of the next block (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 block (record) header in some buffer is located (bytes).
More...
 
size_t firstEventStartingPosition () override
 Determines where the start of the first event in this block (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 block (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.
More...
 
size_t bytesRemaining (size_t position) override
 Gives the bytes remaining in this block (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
positionthe absolute current position in a byte buffer.
Returns
the number of bytes remaining in this block (record).
Exceptions
EvioExceptionif position out of bounds
More...
 
size_t write (ByteBuffer &byteBuffer) override
 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.
Exceptions
overflow_errorif insufficient room to write header into buffer.
More...
 

Static Public Member Functions

static bool hasDictionary (uint32_t i)
 Does this integer indicate that there is an evio dictionary (assuming it's the header's sixth word)? More...
 
static bool isLastBlock (uint32_t i)
 Does this integer indicate that this is the last block (assuming it's the header's sixth word)? More...
 
static uint32_t setLastBlockBit (uint32_t i)
 Set the bit in the given arg which indicates this is the last block. More...
 
static uint32_t clearLastBlockBit (uint32_t i)
 Clear the bit in the given arg to indicate it is NOT the last block. More...
 
static bool hasFirstEvent (uint32_t i)
 Does this integer indicate that block has the first event (assuming it's the header's sixth word)? Only makes sense if the integer arg comes from the first block header of a file or buffer. More...
 
static uint32_t setFirstEventBit (uint32_t i)
 Set the bit in the given arg which indicates this block has a first event. More...
 
static uint32_t clearFirstEventBit (uint32_t i)
 Clear the bit in the given arg to indicate this block does NOT have a first event. More...
 
static void setFirstEvent (std::bitset< 24 > &bSet)
 Encode the "is first event" into the bit info word which will be in evio block header. More...
 
static void unsetFirstEvent (std::bitset< 24 > &bSet)
 Encode the "is NOT first event" into the bit info word which will be in evio block header. More...
 
static void setEventType (std::bitset< 24 > &bSet, uint32_t type)
 Sets the right bits in bit set (2-5 when starting at 0) to hold 4 bits of the given type value. More...
 
static uint32_t generateSixthWord (std::bitset< 24 > const &set)
 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 uint32_t generateSixthWord (std::bitset< 24 > const &bSet, bool hasDictionary, bool isEnd)
 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 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 > bSet, uint32_t version, bool hasDictionary, bool isEnd, uint32_t eventType)
 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...
 

Public Attributes

uint32_t size = 0
 The block (physical record) size in 32 bit ints. More...
 
uint32_t number = 1
 The block number. More...
 
uint32_t headerLength = 8
 The block header length. More...
 
uint32_t eventCount = 0
 Since blocks only contain whole events in this version, this stores the number of events contained in a block. More...
 
uint32_t version = 4
 The evio version, always 4. More...
 
uint32_t reserved1 = 0
 Value of first reserved word. More...
 
uint32_t reserved2 = 0
 Value of second reserved word. More...
 
std::bitset< 24 > bitInfo
 Bit information. More...
 
uint32_t magicNumber = MAGIC_NUMBER
 This is the magic word, 0xc0da0100, used to check endianness. More...
 
ByteOrder byteOrder {ByteOrder::ENDIAN_LOCAL}
 This is the byte order of the data being read. More...
 
int64_t bufferStartingPosition = 0L
 This is not part of the block header proper. More...
 

Static Public Attributes

static const uint32_t HEADER_SIZE = 8
 The minimum and expected block header size in 32 bit ints. More...
 
static const uint32_t EV_DICTIONARY_MASK = 0x100
 Dictionary presence is 9th bit in version/info word. More...
 
static const uint32_t EV_LASTBLOCK_MASK = 0x200
 "Last block" is 10th bit in version/info word More...
 
static const uint32_t EV_EVENTTYPE_MASK = 0x3C00
 "Event type" is 11-14th bits` in version/info word More...
 
static const uint32_t EV_FIRSTEVENT_MASK = 0x4000
 "First event" is 15th bit in version/info word More...
 
static const uint32_t EV_BLOCKSIZE = 0
 Position of word for size of block in 32-bit words. More...
 
static const uint32_t EV_BLOCKNUM = 1
 Position of word for block number, starting at 1. More...
 
static const uint32_t EV_HEADERSIZE = 2
 Position of word for size of header in 32-bit words (=8). More...
 
static const uint32_t EV_COUNT = 3
 Position of word for number of events in block. More...
 
static const uint32_t EV_RESERVED1 = 4
 Position of word for reserved. More...
 
static const uint32_t EV_VERSION = 5
 Position of word for version of file format. More...
 
static const uint32_t EV_RESERVED2 = 6
 Position of word for reserved. More...
 
static const uint32_t EV_MAGIC = 7
 Position of word for magic number for endianness tracking. More...
 
static const uint32_t MAGIC_NUMBER = 0xc0da0100
 The magic number, should be the value of magicNumber. More...
 
static const uint32_t MAGIC_OFFSET = 28
 Byte offset from beginning of header to the magic number. More...
 
static const uint32_t BIT_INFO_OFFSET = 20
 Byte offset from beginning of header to bit info word. More...
 
static const uint32_t VERSION_MASK = 0xff
 Mask to get version number from bitinfo word in header. More...
 

Detailed Description

This holds an evio block header, also known as a physical record header.

Unfortunately, in versions 1, 2 & 3, evio files impose an anachronistic block structure. The complication that arises is that logical records (events) will sometimes cross physical record boundaries. This block structure is changed in version 4 so that blocks only contain integral numbers of events. The information stored in this block header has also changed.


################################
Evio block header, version 4:
################################
MSB(31)                          LSB(0)
<---  32 bits ------------------------>
_______________________________________
|            Block Length             |
|_____________________________________|
|            Block Number             |
|_____________________________________|
|          Header Length = 8          |
|_____________________________________|
|             Event Count             |
|_____________________________________|
|             reserved 1              |
|_____________________________________|
|          Bit info & Version         |
|_____________________________________|
|             reserved 2              |
|_____________________________________|
|             Magic Int               |
|_____________________________________|
     Block Length       = number of ints in block (including this one).
     Block Number       = id number (starting at 1)
     Header Length      = number of ints in this header (8)
     Event Count        = number of events in this block (always an integral #).
                          NOTE: this value should not be used to parse the following
                          events since the first block may have a dictionary whose
                          presence is not included in this count.
     Reserved 1         = If bits 11-14 in bit info are RocRaw (1), then (in the first block)
                          this contains the CODA id of the source
     Bit info & Version = Lowest 8 bits are the version number (4).
                          Upper 24 bits contain bit info.
                          If a dictionary is included as the first event, bit #9 is set (=1)
                          If a last block, bit #10 is set (=1)
     Reserved 2         = unused
     Magic Int          = magic number (0xc0da0100) used to check endianness
Bit info has the following bits defined (bit numbers start with 1):
  Bit  9     = true if dictionary is included (relevant for first block only)
  Bit  10    = true if this block is the last block in file or network transmission
  Bits 11-14 = type of events following (ROC Raw = 0, Physics = 1, PartialPhysics = 2,
               DisentangledPhysics = 3, User = 4, Control = 5, Other = 15).
  Bit 15     = true if next (non-dictionary) event in this block is a "first event" to
               be placed at the beginning of each written file and its splits.
               Bits 11-15 are useful ONLY for the CODA online use of evio.
               That's because only a single CODA event type is placed into
               a single (ET, cMsg) buffer, and each user or control event has its own
               buffer as well. That buffer then is parsed by an EvioReader or
               EvioCompactReader object. Thus all events will be of a single CODA type.
Author
heddle
timmer

Constructor & Destructor Documentation

evio::BlockHeaderV4::BlockHeaderV4 ( )
default

Constructor initializes all fields to default values.

evio::BlockHeaderV4::BlockHeaderV4 ( uint32_t  sz,
uint32_t  num 
)
inline

Creates a BlockHeader for evio version 4 format.

Only the block size and block number are provided. The other words, which can be modified by setters, are initialized to these values:

  • headerLength is initialized to 8
  • version is initialized to 4
  • bitInfo is initialized to all bits off
  • magicNumber is initialized to MAGIC_NUMBER.
Parameters
szthe size of the block in ints.
numthe block number–usually sequential.

References number, and size.

evio::BlockHeaderV4::BlockHeaderV4 ( std::shared_ptr< BlockHeaderV4 > &  blkHeader)
inlineexplicit

This copy constructor creates an evio version 4 BlockHeader from another object of this class.

Parameters
blkHeaderblock header object to copy

References copy().

Member Function Documentation

size_t evio::BlockHeaderV4::bytesRemaining ( size_t  position)
inlineoverridevirtual

Gives the bytes remaining in this block (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
positionthe absolute current position in a byte buffer.
Returns
the number of bytes remaining in this block (record).
Exceptions
EvioExceptionif position out of bounds

Implements evio::IBlockHeader.

References bufferStartingPosition, and nextBufferStartingPosition().

static uint32_t evio::BlockHeaderV4::clearFirstEventBit ( uint32_t  i)
inlinestatic

Clear the bit in the given arg to indicate this block does NOT have a first event.

Parameters
iinteger in which to clear the first event bit
Returns
arg with first event bit cleared

References EV_FIRSTEVENT_MASK.

static uint32_t evio::BlockHeaderV4::clearLastBlockBit ( uint32_t  i)
inlinestatic

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

Parameters
iinteger in which to clear the last-block bit
Returns
arg with last-block bit cleared

References EV_LASTBLOCK_MASK.

void evio::BlockHeaderV4::copy ( std::shared_ptr< BlockHeaderV4 > &  blkHeader)
inline

This method copies another header's contents.

Parameters
blkHeaderblock header object to copy

References bitInfo, bufferStartingPosition, byteOrder, eventCount, headerLength, magicNumber, number, reserved1, reserved2, size, and version.

Referenced by BlockHeaderV4().

size_t evio::BlockHeaderV4::firstEventStartingPosition ( )
inlineoverridevirtual

Determines where the start of the first event in this block (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 block (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.

References bufferStartingPosition, and headerLength.

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

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.

Parameters
setBitset containing all bits to be set
Returns
generated sixth word of this header.
static uint32_t evio::BlockHeaderV4::generateSixthWord ( std::bitset< 24 > const &  bSet,
bool  hasDictionary,
bool  isEnd 
)
inlinestatic

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.

Parameters
bSetBitset containing all bits to be set
hasDictionarydoes this block include an evio xml dictionary as the first event?
isEndis this the last block of a file or a buffer?
Returns
generated sixth word of this header.
static uint32_t evio::BlockHeaderV4::generateSixthWord ( uint32_t  version,
bool  hasDictionary,
bool  isEnd,
uint32_t  eventType 
)
inlinestatic

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.

References version.

static uint32_t evio::BlockHeaderV4::generateSixthWord ( std::bitset< 24 >  bSet,
uint32_t  version,
bool  hasDictionary,
bool  isEnd,
uint32_t  eventType 
)
inlinestatic

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.

Parameters
bSetBitset 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
Returns
generated sixth word of this header.

References version.

std::bitset<24> evio::BlockHeaderV4::getBitInfo ( )
inline

Gets a copy of all stored bit information.

Returns
copy of bitset containing all stored bit information.

References bitInfo.

bool evio::BlockHeaderV4::getBitInfo ( uint32_t  bitIndex)
inline

Gets the value of a particular bit in the bitInfo field.

Parameters
bitIndexindex of bit to get
Returns
BitSet containing all stored bit information.

References bitInfo.

size_t evio::BlockHeaderV4::getBufferEndingPosition ( )
inlineoverridevirtual

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

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

Implements evio::IBlockHeader.

References bufferStartingPosition, and size.

Referenced by nextBufferStartingPosition().

size_t evio::BlockHeaderV4::getBufferStartingPosition ( )
inlineoverridevirtual

Get the starting position in the buffer (bytes) from which this header was read–if that happened.
This is not part of the block header proper. It is a position in a memory buffer of the start of the block (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.

References bufferStartingPosition.

Referenced by toString().

ByteOrder& evio::BlockHeaderV4::getByteOrder ( )
inlineoverridevirtual

Get the byte order of the data being read.

Returns
byte order of the data being read.

Implements evio::IBlockHeader.

References byteOrder.

Compressor::CompressionType evio::BlockHeaderV4::getCompressionType ( )
inlineoverridevirtual

Get the type of data compression used.

Returns
type of data compression used.

Implements evio::IBlockHeader.

References evio::Compressor::UNCOMPRESSED.

uint32_t evio::BlockHeaderV4::getEventCount ( ) const
inline

Get the number of events completely contained in the block.

NOTE: There are no partial events, only complete events stored in one block.

Returns
the number of events in the block.

References eventCount.

uint32_t evio::BlockHeaderV4::getEventType ( )
inlineoverridevirtual

Get the type of events in block/record (see values of DataType.This is not supported by versions 1-3 which returns 0.

Returns
type of events in block/record, or 0 if evio version 1-3.

Implements evio::IBlockHeader.

References bitInfo.

uint32_t evio::BlockHeaderV4::getHeaderLength ( ) const
inline

Get the block header length in ints.

This should be 8.

Returns
block header length in ints.

References headerLength.

uint32_t evio::BlockHeaderV4::getHeaderWords ( )
inlineoverridevirtual

Get the block (record) header length, in 32 bit words.

Returns
block (record) header length, in 32 bit words.

Implements evio::IBlockHeader.

References headerLength.

uint32_t evio::BlockHeaderV4::getMagicNumber ( )
inlineoverridevirtual

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

Returns
magic number in the block (record).

Implements evio::IBlockHeader.

References magicNumber.

uint32_t evio::BlockHeaderV4::getNumber ( )
inlineoverridevirtual

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

Returns
the block number for this block (record).

Implements evio::IBlockHeader.

References number.

uint32_t evio::BlockHeaderV4::getReserved1 ( ) const
inline

Get the first reserved word.

Returns
the first reserved word.

References reserved1.

uint32_t evio::BlockHeaderV4::getReserved2 ( ) const
inline

Get the 2nd reserved word.

Returns
the 2nd reserved word.

References reserved2.

uint32_t evio::BlockHeaderV4::getSixthWord ( )
inline

Calculates the sixth word of this header which has the version number in the lowest 8 bits and the bit info in the highest 24 bits.

Returns
sixth word of this header.

References bitInfo, and version.

Referenced by toString(), and write().

uint32_t evio::BlockHeaderV4::getSize ( )
inlineoverridevirtual

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

Returns
size of the block (record) in 32 bit words.

Implements evio::IBlockHeader.

References size.

uint32_t evio::BlockHeaderV4::getSourceId ( )
inlineoverridevirtual

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.

References reserved1.

uint32_t evio::BlockHeaderV4::getVersion ( )
inlineoverridevirtual

Get the evio version of the block (record) header.

Returns
evio version of the block (record) header.

Implements evio::IBlockHeader.

References version.

static bool evio::BlockHeaderV4::hasDictionary ( uint32_t  i)
inlinestatic

Does this integer indicate that there is an evio dictionary (assuming it's the header's sixth word)?

Parameters
iinteger to examine.
Returns
true if this int indicates an evio dictionary, else false

References EV_DICTIONARY_MASK.

bool evio::BlockHeaderV4::hasDictionary ( )
inlineoverridevirtual

Does this block contain an evio dictionary?

Returns
true if this block contains an evio dictionary, else false. Always returns false for versions 1-3 (not implemented).

Implements evio::IBlockHeader.

References bitInfo.

Referenced by toString().

bool evio::BlockHeaderV4::hasFirstEvent ( )
inlineoverridevirtual

Does this block/record contain the "first event" (first event to be written to each file split)?

Returns
true if this record has the first event, else false. Evio versions 1-3 always return false.

Implements evio::IBlockHeader.

References bitInfo.

bool evio::BlockHeaderV4::hasFirstEvent ( ) const
inline

Does this block contain the "first event" (first event to be written to each file split)?

Returns
true if this contains the first event, else false

References bitInfo.

static bool evio::BlockHeaderV4::hasFirstEvent ( uint32_t  i)
inlinestatic

Does this integer indicate that block has the first event (assuming it's the header's sixth word)? Only makes sense if the integer arg comes from the first block header of a file or buffer.

Parameters
iinteger to examine.
Returns
true if this int indicates the block has a first event, else false

References EV_FIRSTEVENT_MASK.

bool evio::BlockHeaderV4::isCompressed ( )
inlineoverridevirtual

Is this the data in this block compressed?

Returns
true if the data in this block is compressed, else false.

Implements evio::IBlockHeader.

bool evio::BlockHeaderV4::isLastBlock ( )
inlineoverridevirtual

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

Returns
true if this is the last block in the file or being sent over the network, else false. Always returns false for versions 1-3 (not implemented).

Implements evio::IBlockHeader.

References bitInfo.

Referenced by toString().

static bool evio::BlockHeaderV4::isLastBlock ( uint32_t  i)
inlinestatic

Does this integer indicate that this is the last block (assuming it's the header's sixth word)?

Parameters
iinteger to examine.
Returns
true if this int indicates the last block, else false

References EV_LASTBLOCK_MASK.

size_t evio::BlockHeaderV4::nextBufferStartingPosition ( )
inlineoverridevirtual

Determines where the start of the next block (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 block (record) header in some buffer is located (bytes).

Implements evio::IBlockHeader.

References getBufferEndingPosition().

Referenced by bytesRemaining(), and toString().

void evio::BlockHeaderV4::parseToBitInfo ( uint32_t  word)
inline

Parses the argument into the bit info fields.

This ignores the version in the lowest 8 bits.

Parameters
wordinteger to parse into bit info fields

References bitInfo.

void evio::BlockHeaderV4::setBit ( uint32_t  bitIndex,
bool  value 
)
inline

Sets a particular bit in the bitInfo field.

Parameters
bitIndexindex of bit to change
valuevalue to set bit to

References bitInfo.

void evio::BlockHeaderV4::setBufferStartingPosition ( size_t  pos)
inlineoverridevirtual

Set the starting position in the buffer (bytes) from which this header was read–if that happened.
This is not part of the block header proper. It is a position in a memory buffer of the start of the block (record). It is kept for convenience. It is up to the reader to set it.

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

Implements evio::IBlockHeader.

References bufferStartingPosition.

void evio::BlockHeaderV4::setByteOrder ( ByteOrder order)
inline

Sets the byte order of data being read.

Parameters
orderthe new value for data's byte order.

References byteOrder.

void evio::BlockHeaderV4::setEventCount ( uint32_t  count)
inline

Set the number of events completely contained in the block.

NOTE: There are no partial events, only complete events stored in one block.

Parameters
countthe new number of events in the block.
Exceptions
EvioExceptionif count < 0

References eventCount.

static void evio::BlockHeaderV4::setEventType ( std::bitset< 24 > &  bSet,
uint32_t  type 
)
inlinestatic

Sets the right bits in bit set (2-5 when starting at 0) to hold 4 bits of the given type value.

Useful when generating a bitset for use with EventWriter constructor.

Parameters
bSetBitset containing all bits to be set
typeevent type as int
static void evio::BlockHeaderV4::setFirstEvent ( std::bitset< 24 > &  bSet)
inlinestatic

Encode the "is first event" into the bit info word which will be in evio block header.

Parameters
bSetbit set which will become part of the bit info word
static uint32_t evio::BlockHeaderV4::setFirstEventBit ( uint32_t  i)
inlinestatic

Set the bit in the given arg which indicates this block has a first event.

Parameters
iinteger in which to set the last-block bit
Returns
arg with first event bit set

References EV_FIRSTEVENT_MASK.

void evio::BlockHeaderV4::setHeaderLength ( uint32_t  len)
inline

Set the block header length, in ints.

Although technically speaking this value is variable, it should be 8. However, since this is usually read as part of reading the physical record header, it is a good check to have a setter rather than just fix its value at 8.

Parameters
lenthe new block header length. This should be 8.

References HEADER_SIZE, and headerLength.

static uint32_t evio::BlockHeaderV4::setLastBlockBit ( uint32_t  i)
inlinestatic

Set the bit in the given arg which indicates this is the last block.

Parameters
iinteger in which to set the last-block bit
Returns
arg with last-block bit set

References EV_LASTBLOCK_MASK.

void evio::BlockHeaderV4::setMagicNumber ( uint32_t  magicNum)
inline

Sets the value of magicNumber.

This should match the constant MAGIC_NUMBER. If it doesn't, some obvious possibilities:
1) The evio data (perhaps from a file) is screwed up.
2) The reading algorithm is screwed up.
3) The endianness is not being handled properly.

Parameters
magicNumthe new value for magic number.
Exceptions
EvioExceptionif magic number not the correct value.

References evio::IBlockHeader::MAGIC_NUMBER, and magicNumber.

void evio::BlockHeaderV4::setNumber ( uint32_t  num)
inline

Set the block number for this block (physical record).

In a file, this is usually sequential, starting at 1. This is not checked.

Parameters
numthe number of the block (physical record).

References number.

void evio::BlockHeaderV4::setReserved1 ( uint32_t  r1)
inline

Sets the value of reserved1.

Parameters
r1the value for reserved1.

References reserved1.

void evio::BlockHeaderV4::setReserved2 ( uint32_t  r2)
inline

Sets the value of reserved2.

Parameters
r2the value for reserved2.

References reserved2.

void evio::BlockHeaderV4::setSize ( uint32_t  sz)
inline

Set the size of the block (physical record).

Some trivial checking is done.

Parameters
szthe new value for the size, in ints.
Exceptions
EvioExceptionif size < 8

References size.

void evio::BlockHeaderV4::setVersion ( uint32_t  ver)
inline

Sets the evio version.

Should be 4 but no check is performed here.

Parameters
verthe evio version of evio.

References version.

std::string evio::BlockHeaderV4::toString ( )
inlineoverridevirtual

Get the string representation of the block (record) header.

Returns
string representation of the block (record) header.

Implements evio::IBlockHeader.

References bitInfo, eventCount, getBufferStartingPosition(), getSixthWord(), hasDictionary(), headerLength, isLastBlock(), magicNumber, nextBufferStartingPosition(), number, reserved1, size, and version.

static void evio::BlockHeaderV4::unsetFirstEvent ( std::bitset< 24 > &  bSet)
inlinestatic

Encode the "is NOT first event" into the bit info word which will be in evio block header.

Parameters
bSetbit set which will become part of the bit info word
size_t evio::BlockHeaderV4::write ( ByteBuffer byteBuffer)
inlineoverridevirtual

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.
Exceptions
overflow_errorif insufficient room to write header into buffer.

Implements evio::IBlockHeader.

References eventCount, getSixthWord(), headerLength, magicNumber, number, evio::ByteBuffer::putInt(), evio::ByteBuffer::remaining(), and size.

Member Data Documentation

const uint32_t evio::IBlockHeader::BIT_INFO_OFFSET = 20
staticinherited

Byte offset from beginning of header to bit info word.

Referenced by evio::Util::findEvioVersion().

std::bitset<24> evio::BlockHeaderV4::bitInfo

Bit information.

Bit one: is the first event a dictionary?

Referenced by copy(), getBitInfo(), getEventType(), getSixthWord(), hasDictionary(), hasFirstEvent(), isLastBlock(), parseToBitInfo(), setBit(), and toString().

int64_t evio::BlockHeaderV4::bufferStartingPosition = 0L

This is not part of the block header proper.

It is a position in a memory buffer of the start of the block (physical record). It is kept for convenience.

Referenced by bytesRemaining(), copy(), firstEventStartingPosition(), getBufferEndingPosition(), getBufferStartingPosition(), and setBufferStartingPosition().

ByteOrder evio::BlockHeaderV4::byteOrder {ByteOrder::ENDIAN_LOCAL}

This is the byte order of the data being read.

Referenced by copy(), getByteOrder(), and setByteOrder().

const uint32_t evio::BlockHeaderV4::EV_BLOCKNUM = 1
static

Position of word for block number, starting at 1.

const uint32_t evio::BlockHeaderV4::EV_BLOCKSIZE = 0
static

Position of word for size of block in 32-bit words.

const uint32_t evio::BlockHeaderV4::EV_COUNT = 3
static

Position of word for number of events in block.

const uint32_t evio::BlockHeaderV4::EV_DICTIONARY_MASK = 0x100
static

Dictionary presence is 9th bit in version/info word.

Referenced by hasDictionary().

const uint32_t evio::BlockHeaderV4::EV_EVENTTYPE_MASK = 0x3C00
static

"Event type" is 11-14th bits` in version/info word

const uint32_t evio::BlockHeaderV4::EV_FIRSTEVENT_MASK = 0x4000
static

"First event" is 15th bit in version/info word

Referenced by clearFirstEventBit(), hasFirstEvent(), and setFirstEventBit().

const uint32_t evio::BlockHeaderV4::EV_HEADERSIZE = 2
static

Position of word for size of header in 32-bit words (=8).

const uint32_t evio::BlockHeaderV4::EV_LASTBLOCK_MASK = 0x200
static

"Last block" is 10th bit in version/info word

Referenced by clearLastBlockBit(), isLastBlock(), and setLastBlockBit().

const uint32_t evio::BlockHeaderV4::EV_MAGIC = 7
static

Position of word for magic number for endianness tracking.

const uint32_t evio::BlockHeaderV4::EV_RESERVED1 = 4
static

Position of word for reserved.

const uint32_t evio::BlockHeaderV4::EV_RESERVED2 = 6
static

Position of word for reserved.

const uint32_t evio::BlockHeaderV4::EV_VERSION = 5
static

Position of word for version of file format.

uint32_t evio::BlockHeaderV4::eventCount = 0

Since blocks only contain whole events in this version, this stores the number of events contained in a block.

Referenced by copy(), getEventCount(), setEventCount(), toString(), and write().

const uint32_t evio::BlockHeaderV4::HEADER_SIZE = 8
static

The minimum and expected block header size in 32 bit ints.

Referenced by evio::EvioReaderV4::parseFirstHeader(), evio::EvioReaderV4::processNextBlock(), and setHeaderLength().

uint32_t evio::BlockHeaderV4::headerLength = 8

The block header length.

Should be 8 in all cases, so getting this correct constitutes a check.

Referenced by copy(), firstEventStartingPosition(), getHeaderLength(), getHeaderWords(), setHeaderLength(), toString(), and write().

const uint32_t evio::IBlockHeader::MAGIC_NUMBER = 0xc0da0100
staticinherited

The magic number, should be the value of magicNumber.

Referenced by evio::Util::findEvioVersion(), evio::EvioReaderV4::parseFirstHeader(), evio::BlockHeaderV2::setMagicNumber(), and setMagicNumber().

const uint32_t evio::IBlockHeader::MAGIC_OFFSET = 28
staticinherited

Byte offset from beginning of header to the magic number.

Referenced by evio::Util::findEvioVersion().

uint32_t evio::BlockHeaderV4::magicNumber = MAGIC_NUMBER

This is the magic word, 0xc0da0100, used to check endianness.

Referenced by copy(), getMagicNumber(), setMagicNumber(), toString(), and write().

uint32_t evio::BlockHeaderV4::number = 1

The block number.

In a file, this is usually sequential.

Referenced by BlockHeaderV4(), copy(), getNumber(), setNumber(), toString(), and write().

uint32_t evio::BlockHeaderV4::reserved1 = 0

Value of first reserved word.

Referenced by copy(), getReserved1(), getSourceId(), setReserved1(), and toString().

uint32_t evio::BlockHeaderV4::reserved2 = 0

Value of second reserved word.

Referenced by copy(), getReserved2(), and setReserved2().

uint32_t evio::BlockHeaderV4::size = 0

The block (physical record) size in 32 bit ints.

Referenced by BlockHeaderV4(), copy(), getBufferEndingPosition(), getSize(), setSize(), toString(), and write().

uint32_t evio::BlockHeaderV4::version = 4

The evio version, always 4.

Referenced by copy(), generateSixthWord(), getSixthWord(), getVersion(), setVersion(), and toString().

const uint32_t evio::IBlockHeader::VERSION_MASK = 0xff
staticinherited

Mask to get version number from bitinfo word in header.

Referenced by evio::Util::findEvioVersion().


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