HIPO  4.3.0
High Performance Output data format for experimental physics
hipo::reader Class Reference

Sequential reader for HIPO files. More...

#include <reader.h>

Public Member Functions

 reader ()
 Default constructor. More...
 
 reader (const char *file)
 Construct and open a HIPO file. More...
 
 reader (const char *file, std::vector< int > tags)
 Construct and open a HIPO file with event tag filtering. More...
 
 reader (const reader &r)
 
 ~reader ()
 
void about ()
 Print file information to stdout. More...
 
void rewind ()
 Rewind to the beginning of the file. More...
 
void readDictionary (hipo::dictionary &dict)
 Read the schema dictionary from the file header. More...
 
void getStructure (hipo::structure &structure, int group, int item)
 Extract a structure from the current event by group and item. More...
 
void getStructureNoCopy (hipo::structure &structure, int group, int item)
 Extract a structure without copying (zero-copy). More...
 
void readUserConfig (std::map< std::string, std::string > &mapConfig)
 Read user configuration key-value pairs from the file header. More...
 
void open (const char *filename)
 Open a HIPO file for reading. More...
 
bool is_open ()
 
void setTags (int tag)
 Add an event tag to the read filter. More...
 
void setTags (std::vector< long > tags)
 Set the event tag filter list. More...
 
void setVerbose (short level=1)
 Set the verbosity level. More...
 
bool hasNext ()
 Check if more events are available without advancing. More...
 
bool next ()
 Advance to the next event. More...
 
bool gotoEvent (int eventNumber)
 Jump to a specific event number. More...
 
bool gotoRecord (int irec)
 Jump to a specific record. More...
 
bool next (hipo::event &dataevent)
 Read the next event into the given event object. More...
 
bool next (std::vector< hipo::bank > &list)
 Read the next event and populate a list of banks. More...
 
std::vector< hipo::bankgetBanks (std::vector< std::string > names)
 Create bank objects for the given bank names. More...
 
void read (hipo::event &dataevent)
 Read the current event into the given event object. More...
 
void printWarning ()
 Print a warning message (e.g., end of file). More...
 
int getNRecords () const
 
bool nextInRecord ()
 Advance to the next event within the current record. More...
 
bool loadRecord (int irec)
 Load a specific record by index into the internal buffer. More...
 
bool loadRecord (hipo::record &record, int irec)
 Load a specific record into an external record object. More...
 
int getEntries ()
 
std::vector< int > getInt (const char *bank, const char *column, int max=-1)
 Read all integer values from a bank column across events. More...
 
std::vector< float > getFloat (const char *bank, const char *column, int max=-1)
 Read all float values from a bank column across events. More...
 

Detailed Description

Sequential reader for HIPO files.

Reads events from a HIPO file one at a time, with support for random access via event/record indices. The dictionary (schema definitions) is read from the file header.

hipo::reader reader("data.hipo");
reader.readDictionary(dict);
hipo::bank particles(dict.getSchema("REC::Particle"));
while(reader.next()) {
reader.read(event);
event.read(particles);
for(int i = 0; i < particles.getRows(); i++)
printf("pid = %d\n", particles.getInt("pid", i));
}
Represents a HIPO bank, a tabular data structure with rows and typed columns.
Definition: bank.h:352
Collection of schema definitions, typically read from a HIPO file header.
Definition: dictionary.h:248
schema & getSchema(const char *name)
Retrieve a schema by name.
Definition: dictionary.h:271
Represents a HIPO event, a container for multiple structures/banks.
Definition: event.h:77
Sequential reader for HIPO files.
Definition: reader.h:250
reader()
Default constructor.
Definition: reader.cpp:58

Definition at line 250 of file reader.h.

Constructor & Destructor Documentation

◆ reader() [1/4]

hipo::reader::reader ( )

Default constructor.

The constructor for reader, printWarning routine will printout a warning message if the library was not compiled with compression libraries LZ4 or GZIP

Definition at line 58 of file reader.cpp.

◆ reader() [2/4]

hipo::reader::reader ( const char *  file)
inline

Construct and open a HIPO file.

Parameters
filePath to the HIPO file

Definition at line 281 of file reader.h.

◆ reader() [3/4]

hipo::reader::reader ( const char *  file,
std::vector< int >  tags 
)
inline

Construct and open a HIPO file with event tag filtering.

Parameters
filePath to the HIPO file
tagsList of event tags to read

Definition at line 288 of file reader.h.

◆ reader() [4/4]

hipo::reader::reader ( const reader r)
inline

Definition at line 294 of file reader.h.

◆ ~reader()

hipo::reader::~reader ( )

Default destructor. Does nothing

Definition at line 66 of file reader.cpp.

Member Function Documentation

◆ about()

void hipo::reader::about ( )

Print file information to stdout.

Definition at line 72 of file reader.cpp.

◆ getBanks()

std::vector< hipo::bank > hipo::reader::getBanks ( std::vector< std::string >  names)

Create bank objects for the given bank names.

Parameters
namesList of bank names (e.g., "REC::Particle")
Returns
Vector of initialized bank objects

Definition at line 273 of file reader.cpp.

◆ getEntries()

int hipo::reader::getEntries ( )
inline
Returns
Total number of events in the file.

Definition at line 379 of file reader.h.

◆ getFloat()

std::vector< float > hipo::reader::getFloat ( const char *  bank,
const char *  column,
int  max = -1 
)

Read all float values from a bank column across events.

Parameters
bankBank name
columnColumn name
maxMaximum number of events to read (-1 for all)

Definition at line 417 of file reader.cpp.

◆ getInt()

std::vector< int > hipo::reader::getInt ( const char *  bank,
const char *  column,
int  max = -1 
)

Read all integer values from a bank column across events.

Parameters
bankBank name
columnColumn name
maxMaximum number of events to read (-1 for all)

Definition at line 402 of file reader.cpp.

◆ getNRecords()

int hipo::reader::getNRecords ( ) const
inline
Returns
Number of records in the file (excluding trailer).

Definition at line 368 of file reader.h.

◆ getStructure()

void hipo::reader::getStructure ( hipo::structure structure,
int  group,
int  item 
)

Extract a structure from the current event by group and item.

Parameters
structureOutput structure to fill
groupGroup identifier
itemItem identifier

Definition at line 241 of file reader.cpp.

◆ getStructureNoCopy()

void hipo::reader::getStructureNoCopy ( hipo::structure structure,
int  group,
int  item 
)

Extract a structure without copying (zero-copy).

Parameters
structureOutput structure (points into internal buffer)
groupGroup identifier
itemItem identifier

Definition at line 254 of file reader.cpp.

◆ gotoEvent()

bool hipo::reader::gotoEvent ( int  eventNumber)

Jump to a specific event number.

Parameters
eventNumberTarget event number

Definition at line 353 of file reader.cpp.

◆ gotoRecord()

bool hipo::reader::gotoRecord ( int  irec)

Jump to a specific record.

Parameters
irecRecord index

Definition at line 379 of file reader.cpp.

◆ hasNext()

bool hipo::reader::hasNext ( )

Check if more events are available without advancing.

Checks if there are more events in the file to advance to.

Returns
true if there are events left to read, false - otherwise

Definition at line 207 of file reader.cpp.

◆ is_open()

bool hipo::reader::is_open ( )
inline
Returns
True if a file is currently open.

Definition at line 328 of file reader.h.

◆ loadRecord() [1/2]

bool hipo::reader::loadRecord ( hipo::record record,
int  irec 
)

Load a specific record into an external record object.

Parameters
recordOutput record object
irecRecord index

Definition at line 396 of file reader.cpp.

◆ loadRecord() [2/2]

bool hipo::reader::loadRecord ( int  irec)

Load a specific record by index into the internal buffer.

Parameters
irecRecord index

Definition at line 390 of file reader.cpp.

◆ next() [1/3]

bool hipo::reader::next ( )

Advance to the next event.

Returns
True if an event was read, false at end of file

Advances the event pointer to the next event. This does not read an event, but if the event goes beyond boundary of the record the next record is loaded into the memody.

Returns
returns true - if the are events available in the file, false - otherwise

Definition at line 334 of file reader.cpp.

◆ next() [2/3]

bool hipo::reader::next ( hipo::event dataevent)

Read the next event into the given event object.

Parameters
dataeventOutput event

Definition at line 213 of file reader.cpp.

◆ next() [3/3]

bool hipo::reader::next ( std::vector< hipo::bank > &  list)

Read the next event and populate a list of banks.

Parameters
listBanks to fill from the event

Definition at line 261 of file reader.cpp.

◆ nextInRecord()

bool hipo::reader::nextInRecord ( )

Advance to the next event within the current record.

Definition at line 433 of file reader.cpp.

◆ open()

void hipo::reader::open ( const char *  filename)

Open a HIPO file for reading.

Parameters
filenamePath to the file

Definition at line 81 of file reader.cpp.

◆ printWarning()

void hipo::reader::printWarning ( )

Print a warning message (e.g., end of file).

Prints out warning if the LZ4 library was not linked to the compiled library. In that case only uncompressed files can be read and written.

Definition at line 442 of file reader.cpp.

◆ read()

void hipo::reader::read ( hipo::event dataevent)

Read the current event into the given event object.

Parameters
dataeventOutput event

Definition at line 233 of file reader.cpp.

◆ readDictionary()

void hipo::reader::readDictionary ( hipo::dictionary dict)

Read the schema dictionary from the file header.

Parameters
dictDictionary to populate

Definition at line 311 of file reader.cpp.

◆ readUserConfig()

void hipo::reader::readUserConfig ( std::map< std::string, std::string > &  mapConfig)

Read user configuration key-value pairs from the file header.

Parameters
mapConfigOutput map to populate

Definition at line 283 of file reader.cpp.

◆ rewind()

void hipo::reader::rewind ( )
inline

Rewind to the beginning of the file.

Definition at line 301 of file reader.h.

◆ setTags() [1/2]

void hipo::reader::setTags ( int  tag)
inline

Add an event tag to the read filter.

Parameters
tagEvent tag value

Definition at line 331 of file reader.h.

◆ setTags() [2/2]

void hipo::reader::setTags ( std::vector< long >  tags)
inline

Set the event tag filter list.

Parameters
tagsVector of tag values

Definition at line 334 of file reader.h.

◆ setVerbose()

void hipo::reader::setVerbose ( short  level = 1)
inline

Set the verbosity level.

Parameters
levelVerbosity (0=quiet, 1=normal)

Definition at line 337 of file reader.h.


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