|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jlab.coda.jevio.BlockHeaderV4
public class BlockHeaderV4
This holds a 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 2-5 in bit info are RocRaw (1), then (in the first block)
this contains the total number of payload banks following
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)
Magic Int = magic number (0xc0da0100) used to check endianness
Bit info has the first (lowest) 6 bits taken:
Bit 0 = true if dictionary is included (relevant for first block only)
Bit 1 = true if this block is the last block in file or network transmission
Bits 2-5 = type of events following (ROC Raw = 0, Physics = 1, PartialPhysics = 2,
DisentangledPhysics = 3, User = 4, Control = 5, Prestart = 6, Go = 7,
Pause = 8, End = 9, Other = 15)
Field Summary | |
---|---|
static int |
EV_BLOCKNUM
Position of word for block number, starting at 0. |
static int |
EV_BLOCKSIZE
Position of word for size of block in 32-bit words. |
static int |
EV_COUNT
Position of word for number of events in block. |
static int |
EV_DICTIONARY_MASK
Dictionary presence is 9th bit in version/info word |
static int |
EV_HEADERSIZE
Position of word for size of header in 32-bit words (=8). |
static int |
EV_LASTBLOCK_MASK
"Last block" is 10th bit in version/info word |
static int |
EV_MAGIC
Position of word for magic number for endianness tracking. |
static int |
EV_RESERVED1
Position of word for reserved. |
static int |
EV_RESERVED2
Position of word for reserved. |
static int |
EV_VERSION
Position of word for version of file format. |
static int |
HEADER_SIZE
The minimum & expected block header size in 32 bit ints. |
static int |
MAX_BLOCK_SIZE
The maximum block size in 32 bit ints. |
Fields inherited from interface org.jlab.coda.jevio.IBlockHeader |
---|
MAGIC_NUMBER |
Constructor Summary | |
---|---|
BlockHeaderV4()
Null constructor initializes all fields to zero. |
|
BlockHeaderV4(BlockHeaderV4 blkHeader)
This copy constructor creates an evio version 4 BlockHeader from another object of this class. |
|
BlockHeaderV4(int size,
int number)
Creates a BlockHeader for evio version 4 format. |
Method Summary | |
---|---|
int |
bytesRemaining(int position)
Gives the bytes remaining in this block (physical record) given a buffer position. |
static int |
clearLastBlockBit(int i)
Clear the last-block bit in the given arg to indicate it is NOT the last block. |
java.lang.Object |
clone()
|
int |
firstEventStartingPosition()
Determines where the start of the first event (logical record) in this block (physical record) is located (in bytes). |
static int |
generateSixthWord(java.util.BitSet 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. |
static int |
generateSixthWord(java.util.BitSet bSet,
boolean isDictionary,
boolean 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. |
static int |
generateSixthWord(java.util.BitSet bSet,
boolean isDictionary,
boolean isEnd,
int 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. |
java.util.BitSet |
getBitInfo()
Gets a copy of all stored bit information. |
boolean |
getBitInfo(int bitIndex)
Gets the value of a particular bit in the bitInfo field. |
int |
getBufferEndingPosition()
Get the position in the buffer (in bytes) of this block's last data word. |
int |
getBufferStartingPosition()
Get the starting position in the buffer (in bytes) from which this header was read--if that happened. This is not part of the block header proper. |
int |
getEventCount()
Get the number of events completely contained in the block. |
int |
getEventType()
Get the value of bits 2-5. |
int |
getHeaderLength()
Get the block header length, in ints. |
int |
getMagicNumber()
Get the magic number the block (physical record) header which should be 0xc0da0100. |
int |
getNumber()
Get the block number for this block (physical record). |
int |
getReserved1()
Get the first reserved word. |
int |
getReserved2()
Get the second reserved word. |
int |
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. |
int |
getSize()
Get the size of the block (physical record). |
int |
getVersion()
Get the evio version of the block (physical record) header. |
boolean |
hasDictionary()
Is this block's first event is an evio dictionary? |
static boolean |
hasDictionary(int i)
Does this integer indicate that there is an evio dictionary (assuming it's the header's sixth word)? |
boolean |
isLastBlock()
Is this the last block in the file or being sent over the network? |
static boolean |
isLastBlock(int i)
Does this integer indicate that this is the last block (assuming it's the header's sixth word)? |
int |
nextBufferStartingPosition()
Determines where the start of the next block (physical record) header in some buffer is located (in bytes). |
void |
parseToBitInfo(int word)
Parses the argument into the bit info fields. |
void |
setBit(int bitIndex,
boolean value)
Sets a particular bit in the bitInfo field. |
void |
setBufferStartingPosition(int bufferStartingPosition)
Set the starting position in the buffer (in bytes) from which this header was read--if that happened. This is not part of the block header proper. |
void |
setEventCount(int count)
Set the number of events completely contained in the block. |
static void |
setEventType(java.util.BitSet bSet,
int type)
Sets the right bits in bit set (2-5 when starting at 0) to hold 4 bits of the given type value. |
void |
setHeaderLength(int headerLength)
Set the block header length, in ints. |
static int |
setLastBlockBit(int i)
Set the bit in the given arg which indicates this is the last block. |
void |
setMagicNumber(int magicNumber)
Sets the value of magicNumber. |
void |
setNumber(int number)
Set the block number for this block (physical record). |
void |
setReserved1(int reserved1)
Sets the value of first reserved word. |
void |
setReserved2(int reserved2)
Sets the value of second reserved word. |
void |
setSize(int size)
Set the size of the block (physical record). |
void |
setVersion(int version)
Sets the evio version. |
java.lang.String |
toString()
Obtain a string representation of the block (physical record) header. |
int |
write(java.nio.ByteBuffer byteBuffer)
Write myself out a byte buffer. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int HEADER_SIZE
public static final int MAX_BLOCK_SIZE
public static final int EV_DICTIONARY_MASK
public static final int EV_LASTBLOCK_MASK
public static final int EV_BLOCKSIZE
public static final int EV_BLOCKNUM
public static final int EV_HEADERSIZE
public static final int EV_COUNT
public static final int EV_RESERVED1
public static final int EV_VERSION
public static final int EV_RESERVED2
public static final int EV_MAGIC
Constructor Detail |
---|
public BlockHeaderV4()
public BlockHeaderV4(int size, int number)
block size
and block number
are provided. The other six words, which can be
modified by setters, are initialized to these values:headerLength
is initialized to 8start
is initialized to 8end
is initialized to size
version
is initialized to 4bitInfo
is initialized to all bits offmagicNumber
is initialized to MAGIC_NUMBER
size
- the size of the block in ints.number
- the block number--usually sequential.public BlockHeaderV4(BlockHeaderV4 blkHeader)
blkHeader
- block header object to copyMethod Detail |
---|
public int getSize()
getSize
in interface IBlockHeader
public java.lang.Object clone()
clone
in class java.lang.Object
public void setSize(int size) throws EvioException
size
- the new value for the size, in ints.
EvioException
public int getEventCount()
public void setEventCount(int count) throws EvioException
count
- the new number of events in the block.
EvioException
public int getNumber()
getNumber
in interface IBlockHeader
public void setNumber(int number)
number
- the number of the block (physical record).public int getHeaderLength()
getHeaderLength
in interface IBlockHeader
public void setHeaderLength(int headerLength)
public int getVersion()
getVersion
in interface IBlockHeader
public void setVersion(int version)
EvioReader.nextBlockHeader()
.
version
- the evio version of evio.public static boolean hasDictionary(int i)
true
if this int's indicates an evio dictionary, else false
public boolean hasDictionary()
hasDictionary
in interface IBlockHeader
true
if this block's first event is an evio dictionary, else false
public boolean isLastBlock()
isLastBlock
in interface IBlockHeader
true
if this is the last block in the file or being sent
over the network, else false
public static boolean isLastBlock(int i)
true
if this int's indicates the last block, else false
public static int setLastBlockBit(int i)
i
- integer in which to set the last-block bit
public static int clearLastBlockBit(int i)
i
- integer in which to clear the last-block bit
public int getEventType()
public java.util.BitSet getBitInfo()
public boolean getBitInfo(int bitIndex)
bitIndex
- index of bit to get
public void setBit(int bitIndex, boolean value)
bitIndex
- index of bit to changevalue
- value to set bit topublic static void setEventType(java.util.BitSet bSet, int type)
EventWriter
constructor.
bSet
- Bitset containing all bits to be settype
- event type as intpublic int getSixthWord()
public static int generateSixthWord(java.util.BitSet set)
set
- Bitset containing all bits to be set
public static int generateSixthWord(java.util.BitSet bSet, boolean isDictionary, boolean isEnd)
bSet
- Bitset containing all bits to be setisDictionary
- does this block include an evio xml dictionary as the first event?isEnd
- is this the last block of a file or a buffer?
public static int generateSixthWord(java.util.BitSet bSet, boolean isDictionary, boolean isEnd, int eventType)
bSet
- Bitset containing all bits to be setisDictionary
- does this block include an evio xml dictionary as the first event?isEnd
- is this the last block of a file or a buffer?eventType
- 4 bit type of events header is containing
public void parseToBitInfo(int word) throws EvioException
EvioException
public int getReserved1()
public void setReserved1(int reserved1)
reserved1
- the value for first reserved word.public int getReserved2()
public void setReserved2(int reserved2)
reserved2
- the value for second reserved word.public int getMagicNumber()
getMagicNumber
in interface IBlockHeader
public void setMagicNumber(int magicNumber) throws EvioException
magicNumber
- the new value for magic number.
EvioException
public java.lang.String toString()
toString
in interface IBlockHeader
toString
in class java.lang.Object
public int getBufferEndingPosition()
getBufferEndingPosition
in interface IBlockHeader
public int getBufferStartingPosition()
getBufferStartingPosition
in interface IBlockHeader
public void setBufferStartingPosition(int bufferStartingPosition)
setBufferStartingPosition
in interface IBlockHeader
bufferStartingPosition
- the starting position in the buffer from which this header was read--if that
happened.public int nextBufferStartingPosition()
nextBufferStartingPosition
in interface IBlockHeader
public int firstEventStartingPosition()
firstEventStartingPosition
in interface IBlockHeader
public int bytesRemaining(int position) throws EvioException
bufferStartingPosition
is
being maintained properly by the reader.
bytesRemaining
in interface IBlockHeader
position
- the absolute current position is a byte buffer.
EvioException
public int write(java.nio.ByteBuffer byteBuffer)
write
in interface IBlockHeader
write
in interface IEvioWriter
byteBuffer
- the byteBuffer to write to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |