fire v0.19.0
Framework for sImulation and Reconstruction of Events
UserReader.h
1#ifndef FIRE_USERREADER_H
2#define FIRE_USERREADER_H
3
4#include "fire/io/Reader.h"
5#include "fire/Event.h"
6
7namespace fire {
8
45 public:
51 UserReader(bool wrap_around = false);
52
62 UserReader(const std::string& fn, unsigned long int n = 0, bool wrap_around = false);
63
79 void open(const std::string& fn, unsigned long int n = 0);
80
95 bool next();
96
101 unsigned long int entries() const;
102
107 bool is_open() const;
108
119 template<typename T>
120 const T& get(const std::string& name, const std::string& pass = "") const {
121 return event_.get<T>(name,pass);
122 }
123 private:
129 unsigned long int i_entry_{0};
131 bool wrap_around_{false};
133 bool in_file_{false};
134};
135}
136
137#endif
Event class for interfacing with processors.
Definition: Event.h:28
const DataType & get(const std::string &name, const std::string &pass="") const
get a piece of data from the event
Definition: Event.h:349
class for easier reading of files written by fire
Definition: UserReader.h:44
unsigned long int entries() const
number of events in this file
Definition: UserReader.cxx:60
UserReader(bool wrap_around=false)
Configure the reading mode.
Definition: UserReader.cxx:19
bool is_open() const
check if reader is open or not
Definition: UserReader.cxx:64
const T & get(const std::string &name, const std::string &pass="") const
get the object for the current entry under the passed name
Definition: UserReader.h:120
Event event_
event bus for this reader
Definition: UserReader.h:125
unsigned long int i_entry_
index of entry within file that is open
Definition: UserReader.h:129
bool next()
go to the next event entry in the file
Definition: UserReader.cxx:37
std::unique_ptr< io::Reader > reader_
handle of underlying reader
Definition: UserReader.h:127
void open(const std::string &fn, unsigned long int n=0)
Open the provided file, skipping an initial number of entries.
Definition: UserReader.cxx:29
bool in_file_
have we started yet?
Definition: UserReader.h:133
bool wrap_around_
do we wrap from end to beginning or throw exception?
Definition: UserReader.h:131