File Writer.h
-
namespace podio
Functions
-
Writer makeWriter(const std::string &filename, const std::string &type = "default")
Create a Writer that is able to write files for the desired backend.
Will look at the desired filename as well as the type argument to decide on the backend.
- Parameters:
filename – The filename of the output file that will be created.
type – The (optional) type argument to switch between RNTuple and TTree based backend in case the suffix is “.root”. Will be ignored in case the suffix is “.sio”
- Throws:
std::runtime_error – In case the suffix can not be associated to an I/O backend or if support for the desired I/O backend has not been built
- Returns:
A fully initialized Writer for the I/O backend that has been determined
-
class Writer
- #include <podio/Writer.h>
Generic (type erased) writer class that can handle different I/O backends (almost) transparently.
Offers some more high level functionality compared to the lower level backend specific writers that this class wraps. In addition, it provides convenience methods to deal specifically with the “events” frame category.
Note
Since this simply wraps lower level writers, some of the limitations of the wrapped writers will still apply, e.g. if used for writing ROOT files frames of a given category will have to have the same contents.
Note
The recommended way to construct is to use the makeWriter() function since that handles the instantiation of the correct low level writers
Public Functions
-
template<typename T>
inline Writer(std::unique_ptr<T> writer) Create a Writer from a lower level writer.
- Template Parameters:
T – the type of the low level writer (will be deduced)
- Parameters:
writer – A low level writer that does the actual work
-
Writer(const Writer&) = delete
-
Writer(Writer&&) = default
-
~Writer() = default
Destructor.
This also takes care of writing all the necessary metadata to read files back again.
-
inline void writeFrame(const podio::Frame &frame, const std::string &category)
Store the given frame with the given category.
This stores all available categories from the passed frame
- Parameters:
frame – The frame to write
category – The category name under which this frame should be stored
-
inline void writeFrame(const podio::Frame &frame, const std::string &category, const std::vector<std::string> &collections)
Store the given Frame with the given category.
This stores only the desired collections and not the complete frame.
- Parameters:
frame – The Frame to store
category – The category name under which this Frame should be stored
collections – The collection names that should be written
-
inline void writeEvent(const podio::Frame &frame)
Store the given frame under the “events” category.
This stores all available categories from the passed frame
- Parameters:
frame – The frame to write
-
inline void writeEvent(const podio::Frame &frame, const std::vector<std::string> &collections)
Store the given Frame under the “events” category.
This stores only the desired collections and not the complete frame.
- Parameters:
frame – The Frame to store
collections – The collection names that should be written
-
inline void finish()
Write the current file, including all the necessary metadata to read it again.
Note
The destructor will also call this, so letting a Writer go out of scope is also a viable way to write a readable file
Private Members
-
std::unique_ptr<WriterConcept> m_self = {nullptr}
-
struct WriterConcept
-
template<typename T>
struct WriterModel : public podio::Writer::WriterConcept Public Functions
-
WriterModel(const WriterModel&) = delete
-
WriterModel &operator=(const WriterModel&) = delete
-
WriterModel(WriterModel&&) = default
-
WriterModel &operator=(WriterModel&&) = default
-
~WriterModel() override = default
-
inline void writeFrame(const podio::Frame &frame, const std::string &category, const std::vector<std::string> &collections) override
-
inline void finish() override
-
WriterModel(const WriterModel&) = delete
-
template<typename T>
-
Writer makeWriter(const std::string &filename, const std::string &type = "default")