fire v0.19.0
Framework for sImulation and Reconstruction of Events
|
Reading a file generated by fire. More...
#include <Reader.h>
Classes | |
class | Buffer |
Read buffer allowing individual element access from a dataset. More... | |
class | BufferHandle |
Type-less handle to the Buffer. More... | |
class | MirrorObject |
A mirror event object. More... | |
Public Member Functions | |
Reader (const std::string &name) | |
Open the file in read mode. More... | |
virtual void | load_into (BaseData &d) final override |
Load the next event into the passed data. More... | |
virtual std::vector< std::pair< std::string, std::string > > | availableObjects () final override |
Get the event objects available in the file. More... | |
virtual std::pair< std::string, int > | type (const std::string &path) final override |
Get the type of the input object. More... | |
virtual std::string | name () const final override |
Get the name of this file. More... | |
std::vector< std::string > | list (const std::string &group_path) const |
List the entries inside of a group. More... | |
HighFive::DataType | getDataSetType (const std::string &dataset) const |
Deduce the type of the dataset requested. More... | |
HighFive::ObjectType | getH5ObjectType (const std::string &path) const |
Get the H5 type of object at the input path. More... | |
std::string | getTypeName (const std::string &obj_name) const |
Get the 'type' attribute from the input group name. More... | |
std::size_t | entries () const final override |
Get the number of entries in the file. More... | |
std::size_t | runs () const final override |
Get the number of runs in the file. More... | |
virtual bool | canCopy () const final override |
We can copy. More... | |
virtual void | copy (unsigned long int i_entry, const std::string &path, Writer &output) final override |
Copy the input data set to the output file. More... | |
template<typename AtomicType > | |
void | load (const std::string &path, AtomicType &val) |
Try to load a single value of an atomic type into the input handle. More... | |
Reader (const Reader &)=delete | |
never want to copy a reader | |
void | operator= (const Reader &)=delete |
never want to copy a reader | |
Public Member Functions inherited from fire::io::Reader | |
Reader (const std::string &file_name) | |
open the file at the passed location More... | |
virtual | ~Reader ()=default |
virtual destructor so derived classes can be closed | |
virtual void | copy (long unsigned int i_entry, const std::string &path, Writer &output) |
Copy the input object into the output file. More... | |
Private Member Functions | |
void | mirror (const std::string &path, Writer &output) |
Mirror the structure of the passed path from us into the output file. More... | |
Private Attributes | |
HighFive::File | file_ |
our highfive file | |
const std::size_t | entries_ |
the number of entries in this file, set in constructor | |
const std::size_t | runs_ |
the number of runs in this file, set in constructor | |
std::size_t | rows_per_chunk_ {10000} |
the number of rows to keep in each chunk, read from DataSet? | |
std::unordered_map< std::string, std::unique_ptr< BufferHandle > > | buffers_ |
our in-memory buffers for the data to be read in from disk | |
std::unordered_map< std::string, std::unique_ptr< MirrorObject > > | mirror_objects_ |
our in-memory mirror objects for data being copied to the output file without processing | |
Additional Inherited Members | |
Public Types inherited from fire::io::Reader | |
using | Factory = ::fire::factory::Factory< Reader, std::unique_ptr< Reader >, const std::string & > |
Type of factory used to create readers. | |
Reading a file generated by fire.
This reader handles the buffering of data read in from an HDF5 file in a seamless manner so that individual entries can be requested at a time without making disk read operation each time Reader::load is called.
fire::io::h5::Reader::Reader | ( | const std::string & | name | ) |
Open the file in read mode.
Our read mode is the same as HDF5 Read Only mode
We also read the number of entries in this file by retrieving the size of the data set at constants::EVENT_GROUP / constants::EVENT_HEADER_NAME / constants::NUMBER_NAME This is reliable as long as
We inspect the size of the dataset located at constants::RUN_HEADER_NAME/constants::NUMBER_NAME in the file to get the number of runs. This will work as long as
number
HighFive::Exception | if file is not accessible. |
[in] | name | file name to open and read |
|
finaloverridevirtual |
Get the event objects available in the file.
We crawl the internal directory structure of the file we have open.
{ obj_name, pass }
Implements fire::io::Reader.
|
inlinefinaloverridevirtual |
|
finaloverridevirtual |
Copy the input data set to the output file.
This happens when the input data set has passed all of the drop/keep rules so it is supposed to be copied into the output file; however, noone has accessed it with Event::get yet so an in-memory class object has not been created for it yet.
[in] | i_entry | entry we are currently on |
[in] | path | full event object name |
[in] | output | handle to the writer writing the output file |
|
inlinefinaloverridevirtual |
Get the number of entries in the file.
This value was determined upon construction.
Implements fire::io::Reader.
HighFive::DataType fire::io::h5::Reader::getDataSetType | ( | const std::string & | dataset | ) | const |
Deduce the type of the dataset requested.
[in] | dataset | full in-file path to H5 dataset |
HighFive::ObjectType fire::io::h5::Reader::getH5ObjectType | ( | const std::string & | path | ) | const |
Get the H5 type of object at the input path.
[in] | path | in-file path to an HDF5 object |
std::string fire::io::h5::Reader::getTypeName | ( | const std::string & | obj_name | ) | const |
Get the 'type' attribute from the input group name.
We retrieve the attribute named TYPE_ATTR_NAME from the group located at EVENT_GROUP/obj_name. This enables us to construct the list of products within an inputfile in Event::setInputFile.
[in] | obj_name | Name of event object to retrieve type of |
std::vector< std::string > fire::io::h5::Reader::list | ( | const std::string & | group_path | ) | const |
List the entries inside of a group.
[in] | group_path | full in-file path to H5 group to list elements of |
|
inline |
Try to load a single value of an atomic type into the input handle.
If the input path does not exist in our list of buffers, then we create a new buffer for the requested type and load the first chunk of data into memory.
Besides that, we access the Buffer and call its Buffer::read method, allowing the Buffer to handle the necessary disk reading operations.
std::bad_cast | if mismatched type is passed |
HighFive::DataSetException | if requested dataset doesn't exist |
[in] | path | Full in-file path to dataset to load |
[out] | val | Set to the next entry in the dataset |
|
finaloverridevirtual |
Load the next event into the passed data.
As instructed by fire::io::Reader, we simply call the data's load function with a reference to ourselves.
[in] | d | Data to load data into |
Implements fire::io::Reader.
|
private |
Mirror the structure of the passed path from us into the output file.
[in] | path | path to the group (and potential subgroups) to mirror |
[in] | output | output file to mirror this structure to |
|
finaloverridevirtual |
|
inlinefinaloverridevirtual |
Get the number of runs in the file.
This value was determined upon construction
Implements fire::io::Reader.
|
finaloverridevirtual |
Get the type of the input object.
We retrieve the attributes named TYPE_ATTR_NAME and VERS_ATTR_NAME from the group located at EVENT_GROUP/obj_name. This enables us to construct the list of products within an inputfile in Event::setInputFile.
[in] | obj_name | Name of event object to retrieve type of |
Implements fire::io::Reader.