File ROOTFrameWriter.h

namespace podio
class ROOTFrameWriter
#include <podio/ROOTFrameWriter.h>

Public Functions

ROOTFrameWriter(const std::string &filename)
~ROOTFrameWriter()
ROOTFrameWriter(const ROOTFrameWriter&) = delete
ROOTFrameWriter &operator=(const ROOTFrameWriter&) = delete
void writeFrame(const podio::Frame &frame, const std::string &category)

Store the given frame with the given category.

Store all available collections from the Frame.

NOTE: The contents of the first Frame that is written in this way determines the contents that will be written for all subsequent Frames.

void writeFrame(const podio::Frame &frame, const std::string &category, const std::vector<std::string> &collsToWrite)

Store the given Frame with the given category.

Store only the collections that are passed.

NOTE: The contents of the first Frame that is written in this way determines the contents that will be written for all subsequent Frames.

void finish()

Write the current file, including all the necessary metadata to read it again.

std::tuple<std::vector<std::string>, std::vector<std::string>> checkConsistency(const std::vector<std::string> &collsToWrite, const std::string &category) const

Check whether the collsToWrite are consistent with the state of the passed category.

Return two vectors of collection names. The first one contains all the names that were missing from the collsToWrite but were present in the category. The second one contains the names that are present in the collsToWrite only. If both vectors are empty the category and the passed collsToWrite are consistent.

NOTE: This will only be a meaningful check if the first Frame of the passed category has already been written. Also, this check is rather expensive as it has to effectively do two set differences.

Private Types

using StoreCollection = std::pair<const std::string&, podio::CollectionBase*>
using CollectionInfoT = std::tuple<uint32_t, std::string, bool, unsigned int>

Private Functions

void initBranches(CategoryInfo &catInfo, const std::vector<StoreCollection> &collections, podio::GenericParameters &parameters)

Initialize the branches for this category.

CategoryInfo &getCategoryInfo(const std::string &category)

Get the (potentially uninitialized category information for this category)

Private Members

std::unique_ptr<TFile> m_file = {nullptr}

The storage file.

std::unordered_map<std::string, CategoryInfo> m_categories = {}

All categories.

DatamodelDefinitionCollector m_datamodelCollector = {}
bool m_finished = {false}

Whether writing has been actually done.

Private Static Functions

static void resetBranches(std::vector<root_utils::CollectionBranches> &branches, const std::vector<ROOTFrameWriter::StoreCollection> &collections, podio::GenericParameters *parameters)
struct CategoryInfo

Helper struct to group together all necessary state to write / process a given category.

Created during the first writing of a category

Public Members

TTree *tree = {nullptr}

The TTree to which this category is written.

std::vector<root_utils::CollectionBranches> branches = {}

The branches for this category.

std::vector<CollectionInfoT> collInfo = {}

Collection info for this category.

podio::CollectionIDTable idTable = {}

The collection id table for this category.

std::vector<std::string> collsToWrite = {}

The collections to write for this category.