Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HDEVIO Class Reference

#include <HDEVIO.h>

Classes

struct  BLOCKHEADER_t
 
struct  BORHEADER_t
 
struct  CDAQPHYSICSHEADER_t
 
struct  EPICSHEADER_t
 
struct  EVENTHEADER_t
 
class  EVIOBlockRecord
 
class  EVIOEventRecord
 
struct  PHYSICSHEADER_t
 

Public Types

enum  {
  HDEVIO_OK =0, HDEVIO_EOF, HDEVIO_FILE_NOT_OPEN, HDEVIO_FILE_TRUNCATED,
  HDEVIO_EVENT_BIGGER_THAN_BLOCK, HDEVIO_BAD_BLOCK_HEADER, HDEVIO_BLOCKSIZE_GREATER_THAN_LIMIT, HDEVIO_MEMORY_ALLOCATION_ERROR,
  HDEVIO_NO_EVENTS_IN_BUFFER, HDEVIO_USER_BUFFER_TOO_SMALL, HDEVIO_BANK_TRUNCATED, HDEVIO_UNKNOWN_BANK_TYPE
}
 
enum  BLOCKTYPE {
  kBT_UNKNOWN, kBT_BOR, kBT_EPICS, kBT_SYNC,
  kBT_PRESTART, kBT_GO, kBT_PAUSE, kBT_END,
  kBT_PHYSICS
}
 

Public Member Functions

 HDEVIO (string filename, bool read_map_file=true, int verbose=1)
 
virtual ~HDEVIO ()
 
bool ReadBlock (void)
 
bool read (uint32_t *user_buff, uint32_t user_buff_len, bool allow_swap=true)
 
bool readSparse (uint32_t *user_buff, uint32_t user_buff_len, bool allow_swap=true)
 
bool readNoFileBuff (uint32_t *user_buff, uint32_t user_buff_len, bool allow_swap=true)
 
void rewind (void)
 
uint64_t GetNWordsLeftInFile (void)
 
uint32_t swap_bank (uint32_t *outbuff, uint32_t *inbuff, uint32_t len)
 
uint32_t swap_tagsegment (uint32_t *outbuff, uint32_t *inbuff, uint32_t len)
 
uint32_t swap_segment (uint32_t *outbuff, uint32_t *inbuff, uint32_t len)
 
void Print_fbuff (void)
 
void PrintEVIOBlockHeader (void)
 
void PrintStats (void)
 
void PrintFileSummary (void)
 
void SaveFileMap (string fname="")
 
void ReadFileMap (string fname="", bool warn_if_not_found=false)
 
uint32_t GetEventMask (void)
 
uint32_t SetEventMask (uint32_t mask)
 
uint32_t SetEventMask (string types_str)
 
uint32_t AddToEventMask (string type_str)
 
vector< EVIOBlockRecord > & GetEVIOBlockRecords (void)
 
string HexStr (uint32_t v)
 
string HexStr (uint16_t v)
 
string HexStr (uint8_t v)
 
void swap_block (uint16_t *inbuff, uint16_t len, uint16_t *outbuff)
 
void swap_block (uint32_t *inbuff, uint32_t len, uint32_t *outbuff)
 
void swap_block (uint64_t *inbuff, uint64_t len, uint64_t *outbuff)
 

Public Attributes

enum HDEVIO:: { ... }  ERRORCODE_t
 
string filename
 
ifstream ifs
 
bool is_open
 
uint32_t * fbuff
 
uint32_t * fnext
 
uint32_t * fbuff_end
 
uint64_t fbuff_size
 
uint64_t fbuff_len
 
uint64_t _gcount
 
uint32_t * buff
 
uint32_t * next
 
uint32_t * buff_end
 
uint32_t buff_size
 
uint32_t buff_len
 
uint32_t buff_limit
 
bool swap_needed
 
BLOCKHEADER_tbh
 
streampos last_event_pos
 
uint32_t last_event_len
 
int VERBOSE
 
bool IGNORE_EMPTY_BOR
 
bool SKIP_EVENT_MAPPING
 
stringstream err_mess
 
uint32_t err_code
 
uint64_t Nblocks
 
uint64_t Nevents
 
uint64_t Nerrors
 
uint64_t Nbad_blocks
 
uint64_t Nbad_events
 

Protected Member Functions

void MapBlocks (bool print_ticker=true)
 
void MapEvents (BLOCKHEADER_t &bh, EVIOBlockRecord &br)
 
void ClearErrorMessage (void)
 
void SetErrorMessage (string mess)
 
void buff_read (char *s, streamsize n)
 
void buff_seekg (streamoff off, ios_base::seekdir way)
 
streamsize buff_gcount () const
 

Protected Attributes

uint32_t event_type_mask
 
bool is_mapped
 
uint64_t total_size_bytes
 
vector< EVIOBlockRecordevio_blocks
 
vector< EVIOBlockRecord >::iterator sparse_block_iter
 
uint32_t sparse_event_idx
 
EVIOBlockRecord NB_block_record
 
streampos NB_next_pos
 

Detailed Description

Definition at line 45 of file HDEVIO.h.

Member Enumeration Documentation

anonymous enum
Enumerator
HDEVIO_OK 
HDEVIO_EOF 
HDEVIO_FILE_NOT_OPEN 
HDEVIO_FILE_TRUNCATED 
HDEVIO_EVENT_BIGGER_THAN_BLOCK 
HDEVIO_BAD_BLOCK_HEADER 
HDEVIO_BLOCKSIZE_GREATER_THAN_LIMIT 
HDEVIO_MEMORY_ALLOCATION_ERROR 
HDEVIO_NO_EVENTS_IN_BUFFER 
HDEVIO_USER_BUFFER_TOO_SMALL 
HDEVIO_BANK_TRUNCATED 
HDEVIO_UNKNOWN_BANK_TYPE 

Definition at line 50 of file HDEVIO.h.

Enumerator
kBT_UNKNOWN 
kBT_BOR 
kBT_EPICS 
kBT_SYNC 
kBT_PRESTART 
kBT_GO 
kBT_PAUSE 
kBT_END 
kBT_PHYSICS 

Definition at line 65 of file HDEVIO.h.

Constructor & Destructor Documentation

HDEVIO::~HDEVIO ( )
virtual

Definition at line 103 of file HDEVIO.cc.

References buff, fbuff, and ifs.

Member Function Documentation

uint32_t HDEVIO::AddToEventMask ( string  type_str)

Definition at line 715 of file HDEVIO.cc.

streamsize HDEVIO::buff_gcount ( ) const
inlineprotected

Definition at line 242 of file HDEVIO.h.

Referenced by ReadBlock().

void HDEVIO::buff_read ( char *  s,
streamsize  n 
)
protected

Read n bytes into the specified buffer. This will read from the file if needed, or simply copy the bytes from the existing fbuff. It is purposely meant as a drop-in replacement for ifstream::read so that we can make actual reads from the file in larger chunks and avoid backwards seeks on the actual file. This is needed because the Lustre filesystem is optimized for large data reads but smaller reads with backwards seeks tend to cripple its performance. The main difference between this and ifstream::read is that this does not return an istream& reference.

Definition at line 117 of file HDEVIO.cc.

References _gcount, fbuff, fbuff_end, fbuff_len, fbuff_size, fnext, and ifs.

Referenced by ReadBlock().

void HDEVIO::buff_seekg ( streamoff  off,
ios_base::seekdir  way 
)
protected

Definition at line 188 of file HDEVIO.cc.

References _DBG_, _gcount, fbuff, fbuff_end, fbuff_len, fnext, and ifs.

Referenced by ReadBlock().

void HDEVIO::ClearErrorMessage ( void  )
inlineprotected
uint32_t HDEVIO::GetEventMask ( void  )
inline

Definition at line 217 of file HDEVIO.h.

vector< HDEVIO::EVIOBlockRecord > & HDEVIO::GetEVIOBlockRecords ( void  )

Definition at line 723 of file HDEVIO.cc.

References evio_blocks, is_mapped, and MapBlocks().

Referenced by main(), and PrintSummary().

uint64_t HDEVIO::GetNWordsLeftInFile ( void  )

Definition at line 681 of file HDEVIO.cc.

References NB_next_pos, and total_size_bytes.

Referenced by JEventSource_EVIOpp::Dispatcher().

string HDEVIO::HexStr ( uint32_t  v)
inline

Definition at line 250 of file HDEVIO.h.

References sprintf(), str, and string.

Referenced by PrintEVIOBlockHeader(), and ReadBlock().

string HDEVIO::HexStr ( uint16_t  v)
inline

Definition at line 261 of file HDEVIO.h.

References sprintf(), str, and string.

string HDEVIO::HexStr ( uint8_t  v)
inline

Definition at line 272 of file HDEVIO.h.

References sprintf(), str, and string.

void HDEVIO::Print_fbuff ( void  )

Definition at line 1186 of file HDEVIO.cc.

References _gcount, fbuff, fbuff_end, fbuff_len, fbuff_size, and fnext.

void HDEVIO::PrintEVIOBlockHeader ( void  )

Definition at line 1200 of file HDEVIO.cc.

References buff, HexStr(), and swap_needed.

void HDEVIO::PrintStats ( void  )
bool HDEVIO::read ( uint32_t *  user_buff,
uint32_t  user_buff_len,
bool  allow_swap = true 
)

Read the next EVIO event into the user supplied buffer. Return true if successful and false otherwise. Details of the error will be in err_mess.

Definition at line 329 of file HDEVIO.cc.

References buff, buff_len, ClearErrorMessage(), err_code, err_mess, event_type_mask, HDEVIO_EVENT_BIGGER_THAN_BLOCK, HDEVIO_NO_EVENTS_IN_BUFFER, HDEVIO_OK, HDEVIO_USER_BUFFER_TOO_SMALL, last_event_len, Nbad_blocks, Nerrors, Nevents, next, ReadBlock(), readSparse(), SetErrorMessage(), swap_bank(), swap_block(), and swap_needed.

bool HDEVIO::readNoFileBuff ( uint32_t *  user_buff,
uint32_t  user_buff_len,
bool  allow_swap = true 
)

This is an alternative to the read(...) method above that does not use a large primary file buffer. A single EVIO header is read in at a time and the events within the block mapped just like when using readSparse. The difference is that here, only a single block is mapped at a time rather than trying to map the entire file before starting. This gives a faster start up. This may be quicker for most desktop filesystems but may be slower for Lustre file systems that are configured for large volume data transfers and show perfomance degredation with small reads.

Definition at line 499 of file HDEVIO.cc.

References bh, HDEVIO::EVIOBlockRecord::block_len, ClearErrorMessage(), err_code, err_mess, HDEVIO::EVIOEventRecord::event_len, HDEVIO::EVIOBlockRecord::evio_events, HDEVIO::EVIOBlockRecord::first_event, HDEVIO_BAD_BLOCK_HEADER, HDEVIO_EOF, HDEVIO_EVENT_BIGGER_THAN_BLOCK, HDEVIO_FILE_TRUNCATED, HDEVIO_OK, HDEVIO_USER_BUFFER_TOO_SMALL, ifs, HDEVIO::EVIOBlockRecord::last_event, last_event_len, last_event_pos, HDEVIO::BLOCKHEADER_t::length, HDEVIO::BLOCKHEADER_t::magic, MapEvents(), NB_block_record, NB_next_pos, Nbad_blocks, Nblocks, Nerrors, Nevents, HDEVIO::EVIOEventRecord::pos, HDEVIO::EVIOBlockRecord::pos, SetErrorMessage(), swap_bank(), swap_block(), HDEVIO::EVIOBlockRecord::swap_needed, swap_needed, and total_size_bytes.

Referenced by JEventSource_EVIOpp::Dispatcher(), MapEVIOWords(), DMagneticFieldMapFineMesh::ReadEvioFile(), and JEventSource_EVIOpp::SearchFileForRunNumber().

bool HDEVIO::readSparse ( uint32_t *  user_buff,
uint32_t  user_buff_len,
bool  allow_swap = true 
)

This is an alternative to the read(...) method above that is used when the user has specified that only certain event types are desired. This really only makes sense for EPICS and SYNC events. This method does not use the fbuff system and instead reads directly from the file after seeking to the desired location determined from a previously generated map.

Definition at line 404 of file HDEVIO.cc.

References ClearErrorMessage(), err_code, err_mess, HDEVIO::EVIOEventRecord::event_len, HDEVIO::EVIOEventRecord::event_type, event_type_mask, evio_blocks, HDEVIO::EVIOBlockRecord::evio_events, HDEVIO_EOF, HDEVIO_EVENT_BIGGER_THAN_BLOCK, HDEVIO_OK, HDEVIO_USER_BUFFER_TOO_SMALL, ifs, is_mapped, last_event_len, last_event_pos, MapBlocks(), Nbad_blocks, Nerrors, Nevents, HDEVIO::EVIOEventRecord::pos, SetErrorMessage(), sparse_block_iter, sparse_event_idx, swap_bank(), HDEVIO::EVIOBlockRecord::swap_needed, and swap_needed.

Referenced by read().

void HDEVIO::rewind ( void  )

This can be used whe reading from a file to reset the file pointer and other position holders to the begining of the file. This is done when the "LOOP_FOREVER" option is used in the event source to continuously re-read a file, essesntially making it an infinite stream of events that can be used for testing.

Definition at line 655 of file HDEVIO.cc.

References ClearErrorMessage(), err_code, evio_blocks, HDEVIO::EVIOBlockRecord::evio_events, HDEVIO_OK, ifs, NB_block_record, NB_next_pos, sparse_block_iter, and sparse_event_idx.

Referenced by JEventSource_EVIOpp::Dispatcher().

void HDEVIO::SaveFileMap ( string  fname = "")

Definition at line 1362 of file HDEVIO.cc.

References evio_blocks, filename, is_mapped, MapBlocks(), sprintf(), str, and swap_needed.

Referenced by PrintSummary().

void HDEVIO::SetErrorMessage ( string  mess)
inlineprotected
uint32_t HDEVIO::SetEventMask ( uint32_t  mask)

Definition at line 689 of file HDEVIO.cc.

References event_type_mask.

uint32_t HDEVIO::SetEventMask ( string  types_str)

Definition at line 700 of file HDEVIO.cc.

References event_type_mask, kBT_BOR, kBT_EPICS, and kBT_PHYSICS.

uint32_t HDEVIO::swap_bank ( uint32_t *  outbuff,
uint32_t *  inbuff,
uint32_t  len 
)

Swap an EVIO bank. If the bank contains data, it is automatically swapped according to it's type. If the bank is a container of other containers, then this repeatedly calls the swapper methods for the appropriate container type (bank, tagsegment, segment). This means that this method will be recursive in the cases where it is a bank of banks.

Definition at line 973 of file HDEVIO.cc.

References ClearErrorMessage(), err_code, err_mess, HDEVIO_BANK_TRUNCATED, HDEVIO_UNKNOWN_BANK_TYPE, Nbad_events, Nerrors, SetErrorMessage(), swap_block(), swap_segment(), and swap_tagsegment().

Referenced by read(), readNoFileBuff(), and readSparse().

void HDEVIO::swap_block ( uint16_t *  inbuff,
uint16_t  len,
uint16_t *  outbuff 
)
inline

Definition at line 283 of file HDEVIO.h.

References swap16.

Referenced by MapBlocks(), MapEvents(), read(), ReadBlock(), readNoFileBuff(), swap_bank(), swap_segment(), and swap_tagsegment().

void HDEVIO::swap_block ( uint32_t *  inbuff,
uint32_t  len,
uint32_t *  outbuff 
)
inline

Definition at line 293 of file HDEVIO.h.

References swap32.

void HDEVIO::swap_block ( uint64_t *  inbuff,
uint64_t  len,
uint64_t *  outbuff 
)
inline

Definition at line 303 of file HDEVIO.h.

References swap64.

uint32_t HDEVIO::swap_segment ( uint32_t *  outbuff,
uint32_t *  inbuff,
uint32_t  len 
)

Swap an EVIO segment.

Definition at line 1127 of file HDEVIO.cc.

References ClearErrorMessage(), err_code, err_mess, HDEVIO_BANK_TRUNCATED, Nbad_events, Nerrors, SetErrorMessage(), and swap_block().

Referenced by swap_bank().

uint32_t HDEVIO::swap_tagsegment ( uint32_t *  outbuff,
uint32_t *  inbuff,
uint32_t  len 
)

Swap an EVIO tagsegment.

Definition at line 1068 of file HDEVIO.cc.

References ClearErrorMessage(), err_code, err_mess, HDEVIO_BANK_TRUNCATED, Nbad_events, Nerrors, SetErrorMessage(), and swap_block().

Referenced by swap_bank().

Member Data Documentation

uint64_t HDEVIO::_gcount

Definition at line 172 of file HDEVIO.h.

Referenced by buff_read(), buff_seekg(), HDEVIO(), and Print_fbuff().

BLOCKHEADER_t* HDEVIO::bh

Definition at line 182 of file HDEVIO.h.

Referenced by MapBlocks(), ReadBlock(), and readNoFileBuff().

uint32_t* HDEVIO::buff

Definition at line 175 of file HDEVIO.h.

Referenced by HDEVIO(), PrintEVIOBlockHeader(), read(), ReadBlock(), and ~HDEVIO().

uint32_t* HDEVIO::buff_end

Definition at line 177 of file HDEVIO.h.

Referenced by ReadBlock().

uint32_t HDEVIO::buff_len

Definition at line 179 of file HDEVIO.h.

Referenced by HDEVIO(), read(), and ReadBlock().

uint32_t HDEVIO::buff_limit

Definition at line 180 of file HDEVIO.h.

Referenced by HDEVIO(), and ReadBlock().

uint32_t HDEVIO::buff_size

Definition at line 178 of file HDEVIO.h.

Referenced by HDEVIO(), and ReadBlock().

enum { ... } HDEVIO::ERRORCODE_t
uint32_t HDEVIO::event_type_mask
protected

Definition at line 225 of file HDEVIO.h.

Referenced by HDEVIO(), read(), readSparse(), and SetEventMask().

vector<EVIOBlockRecord> HDEVIO::evio_blocks
protected
uint32_t* HDEVIO::fbuff

Definition at line 167 of file HDEVIO.h.

Referenced by buff_read(), buff_seekg(), HDEVIO(), Print_fbuff(), and ~HDEVIO().

uint32_t* HDEVIO::fbuff_end

Definition at line 169 of file HDEVIO.h.

Referenced by buff_read(), buff_seekg(), HDEVIO(), and Print_fbuff().

uint64_t HDEVIO::fbuff_len

Definition at line 171 of file HDEVIO.h.

Referenced by buff_read(), buff_seekg(), HDEVIO(), and Print_fbuff().

uint64_t HDEVIO::fbuff_size

Definition at line 170 of file HDEVIO.h.

Referenced by buff_read(), HDEVIO(), and Print_fbuff().

string HDEVIO::filename

Definition at line 164 of file HDEVIO.h.

Referenced by HDEVIO(), PrintStats(), ReadFileMap(), and SaveFileMap().

uint32_t* HDEVIO::fnext

Definition at line 168 of file HDEVIO.h.

Referenced by buff_read(), buff_seekg(), HDEVIO(), and Print_fbuff().

ifstream HDEVIO::ifs
bool HDEVIO::IGNORE_EMPTY_BOR

Definition at line 188 of file HDEVIO.h.

Referenced by HDEVIO(), JEventSource_EVIOpp::JEventSource_EVIOpp(), and MapEvents().

bool HDEVIO::is_mapped
protected
uint32_t HDEVIO::last_event_len
streampos HDEVIO::last_event_pos

Definition at line 183 of file HDEVIO.h.

Referenced by JEventSource_EVIOpp::Dispatcher(), HDEVIO(), readNoFileBuff(), and readSparse().

EVIOBlockRecord HDEVIO::NB_block_record
protected

Definition at line 234 of file HDEVIO.h.

Referenced by readNoFileBuff(), and rewind().

streampos HDEVIO::NB_next_pos
protected

Definition at line 235 of file HDEVIO.h.

Referenced by GetNWordsLeftInFile(), HDEVIO(), readNoFileBuff(), and rewind().

uint64_t HDEVIO::Nbad_blocks

Definition at line 197 of file HDEVIO.h.

Referenced by HDEVIO(), PrintStats(), read(), ReadBlock(), readNoFileBuff(), and readSparse().

uint64_t HDEVIO::Nbad_events

Definition at line 198 of file HDEVIO.h.

Referenced by HDEVIO(), MapEvents(), PrintStats(), swap_bank(), swap_segment(), and swap_tagsegment().

uint64_t HDEVIO::Nblocks

Definition at line 194 of file HDEVIO.h.

Referenced by HDEVIO(), MapBlocks(), PrintStats(), ReadBlock(), and readNoFileBuff().

uint64_t HDEVIO::Nerrors
uint64_t HDEVIO::Nevents
uint32_t* HDEVIO::next

Definition at line 176 of file HDEVIO.h.

Referenced by HDEVIO(), read(), and ReadBlock().

bool HDEVIO::SKIP_EVENT_MAPPING

Definition at line 189 of file HDEVIO.h.

Referenced by HDEVIO(), MapBlocks(), and PrintSummary().

vector<EVIOBlockRecord>::iterator HDEVIO::sparse_block_iter
protected

Definition at line 232 of file HDEVIO.h.

Referenced by MapBlocks(), readSparse(), and rewind().

uint32_t HDEVIO::sparse_event_idx
protected

Definition at line 233 of file HDEVIO.h.

Referenced by MapBlocks(), readSparse(), and rewind().

bool HDEVIO::swap_needed
uint64_t HDEVIO::total_size_bytes
protected

Definition at line 228 of file HDEVIO.h.

Referenced by GetNWordsLeftInFile(), HDEVIO(), MapBlocks(), PrintFileSummary(), and readNoFileBuff().

int HDEVIO::VERBOSE

Definition at line 187 of file HDEVIO.h.

Referenced by MapEvents(), and ReadFileMap().


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