Namespace podio

namespace podio

Typedefs

template<typename T>
using UVecPtr = std::unique_ptr<std::vector<T>>
using CollRefCollection = std::vector<UVecPtr<podio::ObjectID>>
using VectorMembersInfo = std::vector<std::pair<std::string, void*>>
using RelationNameMapping = std::vector<std::tuple<std::string_view, std::vector<std::string_view>, std::vector<std::string_view>>>

Type alias for storing the names of all Relations and VectorMembers for all datatypes of an EDM.

Populated for each EDM at code generation time. The structure is of each element in the outer vector is:

  • get<0>: The name of the datatype

  • get<1>: The names of all Relations, where OneToManyRelations comes before OneToOneRelations (in the order as they appear in the YAML file)

  • get<2>: The names of all VectorMembers (in the order of the file YAML)

template<typename FromT, typename ToT>
using LinkObjPointerContainer = std::deque<LinkObj<FromT, ToT>*>
using LinkDataContainer = std::vector<LinkData>
template<typename FromT, typename ToT>
using Link = LinkT<detail::GetDefaultHandleType<FromT>, detail::GetDefaultHandleType<ToT>, false>
template<typename FromT, typename ToT>
using MutableLink = LinkT<detail::GetDefaultHandleType<FromT>, detail::GetDefaultHandleType<ToT>, true>
template<typename FromT, typename ToT>
using LinkCollectionIterator = LinkCollectionIteratorT<FromT, ToT, false>
template<typename FromT, typename ToT>
using LinkMutableCollectionIterator = LinkCollectionIteratorT<FromT, ToT, true>
using SupportedGenericDataTypes = std::tuple<int, float, std::string, double>

The types which are supported in the GenericParameters.

using SchemaVersionT = uint32_t

The type used for schema versions throughout.

using SupportedUserDataTypes = std::tuple<float, double, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t>

tuple of basic types supported in user vector

template<typename T>
using EnableIfSupportedUserType = std::enable_if_t<detail::isInTuple<T, SupportedUserDataTypes>>

Enums

enum class Backend

Values:

enumerator ROOT
enumerator SIO

Functions

ROOT::RDataFrame CreateDataFrame(const std::vector<std::string> &filePathList, const std::vector<std::string> &collsToRead = {})

Create RDataFrame from multiple Podio files.

Parameters:
  • filePathList[in] List of file paths from which the RDataFrame will be created.

  • collsToRead[in] List of collection names that should be made available

Returns:

RDataFrame created from input file list.

ROOT::RDataFrame CreateDataFrame(const std::string &filePath, const std::vector<std::string> &collsToRead = {})

Create RDataFrame from a Podio file or glob pattern matching multiple Podio files.

Parameters:
  • filePath[in] File path from which the RDataFrame will be created. The file path can include glob patterns to match multiple files.

  • collsToRead[in] List of collection names that should be made available

Returns:

RDataFrame created from input file list.

template<typename FromT, typename ToT>
std::ostream &operator<<(std::ostream &os, const Link<FromT, ToT> &link)
template<typename FromT, typename ToT>
std::ostream &operator<<(std::ostream &o, const LinkCollection<FromT, ToT> &v)
template<FrameDataType FrameData>
std::optional<podio::CollectionReadBuffers> unpack(FrameData *data, const std::string &name)
inline std::string collMetadataParamName(const std::string &collName, const std::string &paramName)

Create a parameterName that encodes the collection name and the parameter Name into one string.

This codifies a convention that was decided on to store collection level parameters. These are parameters / metadata that are valid for all collections of a given name in a file, e.g. CellID encoding strings. These parameters are usually stored in a dedicated metadata Frame inside a file, see the predefined category names in the Category namespace.

Parameters:
  • collName – the name of the collection

  • paramName – the name of the parameter

Returns:

A single key string that combines the collection and parameter name

inline std::ostream &operator<<(std::ostream &os, const podio::ObjectID &id)
Reader makeReader(const std::string &filename)

Create a Reader that is able to read the file or files matching a glob pattern.

This will inspect the filename as well as peek at the file contents to instantiate the correct low level reader to open and read the file

Parameters:

filename – The (path to the) file to read from. The file path can include glob patterns to match multiple files.

Returns:

A Reader that has been initialized and that can be used for reading data from the passed file

Reader makeReader(const std::vector<std::string> &filenames)

Create a Reader that is able to read the files.

This will inspect the filenames as well as peek into the first file only to decide based on the contents which low level reader to instantiate for reading. All files are assumed to be of the same I/O format, no switching between formats is possible.

Note

For SIO files this will only work with exactly one file!

Parameters:

filenames – The (paths to the) files to read from

Throws:

std::runtime_error – in case the file extensions differ or in case support for the necessary I/O backend has not been built or in case multiple files for the SIO backend are passed

Returns:

A Reader that has been initialized and that can be used for reading data from the passed files

template<typename devT, typename PODData>
void handlePODDataSIO(devT &device, const PODData *data, size_t size)
template<typename MapLikeT>
void writeMapLike(sio::write_device &device, const MapLikeT &map)

Write anything that iterates like an std::map.

template<typename MapLikeT>
void readMapLike(sio::read_device &device, MapLikeT &map)

Read anything that iterates like an std::map.

template<SupportedUserDataType BasicType>
const char *userDataTypeName()

helper template to provide readable type names for basic types with macro PODIO_ADD_USER_TYPE(type)

template<SupportedUserDataType BasicType>
const char *userDataCollTypeName()

Helper template to provide the fully qualified name of a UserDataCollection.

Implementations are populated by the PODIO_ADD_USER_TYPE macro.

template<SupportedUserDataType BasicType>
std::ostream &operator<<(std::ostream &o, const podio::UserDataCollection<BasicType> &coll)
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

Variables

template<typename T>
static bool isSupportedGenericDataType = detail::isAnyOrVectorOf<T, SupportedGenericDataTypes>

Static bool for determining if a type T is a supported GenericParameters type.

static detail::links::ReturnFromTag ReturnFrom

Tag variable to select the lookup of From objects have links with a To object in podio::LinkNavigator::getLinked.

static detail::links::ReturnToTag ReturnTo

Tag variable to select the lookup of To objects that have links with a From object in podio::LinkNavigator::getLinked.

class CollectionBase
#include <podio/CollectionBase.h>

Subclassed by podio::LinkCollection< FromT, ToT >, podio::UserDataCollection< BasicType, typename >

Public Functions

CollectionBase(const CollectionBase&) = delete

No copy c’tor because collections are move-only.

CollectionBase &operator=(const CollectionBase&) = delete

No copy assignment because collections are move-only.

virtual void prepareForWrite() const = 0

prepare buffers for serialization

virtual void prepareAfterRead() = 0

re-create collection from buffers after read

virtual bool setReferences(const ICollectionProvider *collectionProvider) = 0

initialize references after read

virtual void setID(uint32_t id) = 0

set collection ID

virtual uint32_t getID() const = 0

get collection ID

virtual podio::CollectionWriteBuffers getBuffers() = 0

Get the collection buffers for this collection.

virtual bool isValid() const = 0

check for validity of the container after read

virtual size_t size() const = 0

number of elements in the collection

virtual std::size_t max_size() const = 0

maximal number of elements in the collection

virtual bool empty() const = 0

Is the collection empty.

virtual const std::string_view getTypeName() const = 0

fully qualified type name

virtual const std::string_view getValueTypeName() const = 0

fully qualified type name of elements - with namespace

virtual const std::string_view getDataTypeName() const = 0

fully qualified type name of stored POD elements - with namespace

virtual SchemaVersionT getSchemaVersion() const = 0

schema version of the collection

virtual ~CollectionBase() = default

destructor

virtual void clear() = 0

clear the collection and all internal states

virtual bool isSubsetCollection() const = 0

check if this collection is a subset collection

virtual void setSubsetCollection(bool setSubset = true) = 0

declare this collection to be a subset collection

virtual void print(std::ostream &os = std::cout, bool flush = true) const = 0

print this collection to the passed stream

virtual size_t getDatamodelRegistryIndex() const = 0

Get the index in the DatatypeRegistry of the EDM this collection belongs to.

class CollectionBufferFactory
#include <podio/CollectionBufferFactory.h>

The CollectionBufferFactory allows one to create buffers of known datatypes, which can then be populated by e.g.

readers. In order to support schema evolution, the buffers have a version and this factory will also require a schema version to create buffers.

It is implemented as a singleton, which is populated at the time a shared datamodel library is loaded. It is assumed that that happens early on in the startup of an application, such that only a single thread will access the factory instance for registering datatypes. Since the necessary creation functions are part of the core datamodel library, this should be very easy to achieve by simply linking to that library. Once the factory is populated it can be safely accessed from multiple threads concurrently to obtain buffers.

Public Functions

CollectionBufferFactory(CollectionBufferFactory const&) = delete

The buffer factory is a singleton so we disable all copy and move constructors explicitly.

CollectionBufferFactory &operator=(CollectionBufferFactory const&) = delete
CollectionBufferFactory(CollectionBufferFactory&&) = delete
CollectionBufferFactory &operator=(CollectionBufferFactory&&) = delete
~CollectionBufferFactory() = default
std::optional<podio::CollectionReadBuffers> createBuffers(const std::string &collType, SchemaVersionT version, bool subsetColl) const

Create buffers for a given collection type of a given schema version.

Parameters:
  • collType – The collection type name (e.g. from collection->getTypeName())

  • version – The schema version the created buffers should have

  • subsetColl – Should the buffers be for a subset collection or not

Returns:

CollectionReadBuffers if a creation function for this collection type has been registered, otherwise an empty optional

void registerCreationFunc(const std::string &collType, SchemaVersionT version, const CreationFuncT &creationFunc)

Register a creation function for a given collection type and schema version.

Parameters:
  • collType – The collection type name (i.e. what collection->getTypeName() returns)

  • version – The schema version for which this creation function is valid

  • creationFunc – The function that when invoked returns buffers for this collection type and schema version. The signature has to be podio::CollectionReadBuffers(bool) where the boolean parameter steers whether the buffers are for a subset collection or not.

Public Static Functions

static CollectionBufferFactory &mutInstance()

Mutable instance only used for the initial registration of functions during library loading.

static CollectionBufferFactory const &instance()

Get the factory instance.

class CollectionIDTable
#include <podio/CollectionIDTable.h>

Public Functions

CollectionIDTable() = default
~CollectionIDTable() = default
CollectionIDTable(const CollectionIDTable&) = delete
CollectionIDTable &operator=(const CollectionIDTable&) = delete
CollectionIDTable(CollectionIDTable&&) = default
CollectionIDTable &operator=(CollectionIDTable&&) = default
CollectionIDTable(std::vector<uint32_t> &&ids, std::vector<std::string> &&names)

constructor from existing ID:name mapping

CollectionIDTable(const std::vector<uint32_t> &ids, const std::vector<std::string> &names)
std::optional<uint32_t> collectionID(const std::string &name) const

return collection ID for given name

std::optional<const std::string> name(uint32_t collectionID) const

return name for given collection ID

bool present(const std::string &name) const

Check if collection name is known.

bool present(uint32_t collectionID) const

Check if collection ID is known.

inline const std::vector<std::string> &names() const

return registered names

inline const std::vector<uint32_t> &ids() const

return the ids

uint32_t add(const std::string &name)

register new name to the table returns assigned collection ID

void print() const

Prints collection information.

inline bool empty() const

Does this table hold any information?

struct CollectionReadBuffers
#include <podio/CollectionBuffers.h>

Public Types

using CreateFuncT = std::function<std::unique_ptr<podio::CollectionBase>(podio::CollectionReadBuffers, bool)>
using RecastFuncT = std::function<void(CollectionReadBuffers&)>
using DeleteFuncT = std::function<void(CollectionReadBuffers&)>

Public Functions

inline CollectionReadBuffers(void *d, CollRefCollection *ref, VectorMembersInfo *vec, SchemaVersionT version, std::string_view typ, CreateFuncT &&createFunc, RecastFuncT &&recastFunc, DeleteFuncT &&deleteFunc)
CollectionReadBuffers() = default
CollectionReadBuffers(const CollectionReadBuffers&) = default
CollectionReadBuffers &operator=(const CollectionReadBuffers&) = default
inline CollectionReadBuffers(CollectionWriteBuffers buffers)
template<typename DataT>
inline std::vector<DataT> *dataAsVector()

Public Members

void *data = {nullptr}
CollRefCollection *references = {nullptr}
VectorMembersInfo *vectorMembers = {nullptr}
SchemaVersionT schemaVersion = {0}
std::string_view type = {}
CreateFuncT createCollection = {}
RecastFuncT recast = {}
DeleteFuncT deleteBuffers = {}

Public Static Functions

template<typename T>
static inline std::vector<T> *asVector(void *raw)
struct CollectionWriteBuffers
#include <podio/CollectionBuffers.h>

Simple helper struct that bundles all the potentially necessary buffers that are necessary to represent a collection for I/O purposes.

Public Functions

template<typename DataT>
inline std::vector<DataT> *dataAsVector()

Public Members

void *data = {nullptr}
void *vecPtr = {nullptr}
CollRefCollection *references = {nullptr}
VectorMembersInfo *vectorMembers = {nullptr}

Public Static Functions

template<typename T>
static inline std::vector<T> *asVector(void *raw)
class DatamodelDefinitionCollector
#include <podio/utilities/DatamodelRegistryIOHelpers.h>

Helper class to collect the datamodel (JSON) definitions that should be written.

Public Functions

void registerDatamodelDefinition(const podio::CollectionBase *coll, const std::string &name)

Register the datamodel definition of the EDM this collection is from to be written.

Parameters:
  • coll – A collection of an EDM

  • name – The name under which this collection is stored on file

std::vector<std::tuple<std::string, std::string>> getDatamodelDefinitionsToWrite() const

Get all the names and JSON definitions that need to be written.

class DatamodelDefinitionHolder
#include <podio/utilities/DatamodelRegistryIOHelpers.h>

Helper class to hold and provide the datamodel (JSON) definitions for reader classes.

Public Types

using MapType = std::vector<std::tuple<std::string, std::string>>

The “map” type that is used internally.

using VersionList = std::vector<std::tuple<std::string, podio::version::Version>>

The “map” mapping names and datamodel versions (where available)

Public Functions

inline DatamodelDefinitionHolder(MapType &&definitions, VersionList &&versions)

Constructor from an existing collection of names and datamodel definitions and versions.

DatamodelDefinitionHolder() = default
~DatamodelDefinitionHolder() = default
DatamodelDefinitionHolder(const DatamodelDefinitionHolder&) = delete
DatamodelDefinitionHolder &operator=(const DatamodelDefinitionHolder&) = delete
DatamodelDefinitionHolder(DatamodelDefinitionHolder&&) = default
DatamodelDefinitionHolder &operator=(DatamodelDefinitionHolder&&) = default
const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given datamodel name.

Returns an empty model definition if no model is stored under the given name.

Parameters:

name – The name of the datamodel

std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that have been read from file.

std::optional<podio::version::Version> getDatamodelVersion(const std::string &name) const
class DatamodelRegistry
#include <podio/DatamodelRegistry.h>

Global registry holding information about datamodels and datatypes defined therein that are currently known by podio (i.e.

which have been dynamically loaded).

This is a singleton which is (statically) populated during dynamic loading of generated EDMs. In this context an EDM refers to the shared library that is compiled from the generated code from a datamodel definition in YAML format. When we refer to a datamodel in this context we talk about the entity as a whole, i.e. its definition in a YAML file, but also the concrete implementation as an EDM, as well as all other information that is related to it. In the API of this registry this will be used, unless we want to highlight that we are referring to a specific part of a datamodel.

Public Functions

~DatamodelRegistry() = default
DatamodelRegistry(const DatamodelRegistry&) = delete
DatamodelRegistry &operator=(const DatamodelRegistry&) = delete
DatamodelRegistry(DatamodelRegistry&&) = delete
DatamodelRegistry &operator=(const DatamodelRegistry&&) = delete
const std::string_view getDatamodelDefinition(std::string_view name) const

Get the definition (in JSON format) of the datamodel with the given edmName.

If no datamodel with the given name can be found, an empty datamodel definition, i.e. an empty JSON object (“{}”), is returned.

Parameters:

name – The name of the datamodel

Returns:

The high level definition of the datamodel in JSON format

const std::string_view getDatamodelDefinition(size_t index) const

Get the definition (in JSON format) of the datamodel with the given index.

If no datamodel is found under the given index, an empty datamodel definition, i.e. an empty JSON object (“{}”), is returned.

Parameters:

index – The datamodel definition index that can be obtained from each collection

Returns:

The high level definition of the datamodel in JSON format

const std::string &getDatamodelName(size_t index) const

Get the name of the datamodel that is stored under the given index.

If no datamodel is found under the given index, an empty string is returned

Parameters:

index – The datamodel definition index that can be obtained from each collection

Returns:

The name of the datamodel

std::optional<podio::version::Version> getDatamodelVersion(const std::string &name) const
size_t registerDatamodel(std::string name, std::string_view definition, const podio::RelationNameMapping &relationNames)

Register a datamodel and return its index in the registry.

This is the hook that is called during dynamic loading of an EDM to register information for this EDM. If an EDM has already been registered under this name, than the index to the existing EDM in the registry will be returned.

Parameters:
  • name – The name of the EDM that should be registered

  • definition – The datamodel definition from which this EDM has been generated in JSON format

  • relationNames – the names of the relations and vector members for all datatypes that are defined for this EDM

Returns:

The index of this datamodel in the registry

size_t registerDatamodel(std::string name, std::string_view definition, const podio::RelationNameMapping &relationNames, podio::version::Version version)
RelationNames getRelationNames(std::string_view typeName) const

Get the names of the relations and vector members of a datatype.

Public Static Functions

static const DatamodelRegistry &instance()

Get the registry.

static DatamodelRegistry &mutInstance()

Public Static Attributes

static size_t NoDefinitionNecessary = -1

Dedicated index value for collections that don’t have a datamodel definition (e.g.

UserDataCollection)

static size_t NoDefinitionAvailable = -2

Dedicated index value for error checking, used to default init the generated RegistryIndex.

class DataSource : public ROOT::RDF::RDataSource
#include <podio/DataSource.h>

Public Functions

explicit DataSource(const std::string &filePath, int nEvents = -1, const std::vector<std::string> &collsToRead = {})

Construct the podio::DataSource from the provided file.

Parameters:
  • filePath – Path to the file that should be read

  • nEvents – Number of events to process (optional, defaults to -1 for all events)

  • collsToRead – The collections that should be made available (optional, defaults to empty vector for all collections)

explicit DataSource(const std::vector<std::string> &filePathList, int nEvents = -1, const std::vector<std::string> &collsToRead = {})

Construct the podio::DataSource from the provided file list.

Parameters:
  • filePathList – Paths to the files that should be read

  • nEvents – Number of events to process (optional, defaults to -1 for all events)

  • collsToRead – The collections that should be made available (optional, defaults to empty vector for all collections)

void SetNSlots(unsigned int nSlots) override

Inform the podio::DataSource of the desired level of parallelism.

void Initialize() override

Inform podio::DataSource that an event-loop is about to start.

std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() override

Retrieve from podio::DataSource a set of ranges of entries that can be processed concurrently.

void InitSlot(unsigned int slot, ULong64_t firstEntry) override

Inform podio::DataSource that a certain thread is about to start working on a certain range of entries.

bool SetEntry(unsigned int slot, ULong64_t entry) override

Inform podio::DataSource that a certain thread is about to start working on a certain entry.

void FinalizeSlot(unsigned int slot) override

Inform podio::DataSource that a certain thread finished working on a certain range of entries.

void Finalize() override

Inform podio::DataSource that an event-loop finished.

const std::vector<std::string> &GetColumnNames() const override

Returns a reference to the collection of the dataset’s column names.

bool HasColumn(std::string_view columnName) const override

Checks if the dataset has a certain column.

std::string GetTypeName(std::string_view columnName) const override

Type of a column as a string.

Required for JITting.

inline std::string GetLabel() override
class Frame
#include <podio/Frame.h>

The Frame is a generalized (event) data container that aggregates all relevant data.

It is possible to store collections as well as parameters / meta data in a Frame and all I/O facilities of podio operate on Frames.

Public Functions

inline Frame()

Empty Frame constructor.

template<FrameDataType FrameData>
Frame(std::unique_ptr<FrameData>)

Frame constructor from (almost) arbitrary raw data.

Template Parameters:

FrameData – Arbitrary data container that provides access to the collection buffers as well as the metadata, when requested by the Frame. The unique_ptr has to be checked for validity before calling this constructor.

Throws:

std::invalid_argument – if the passed pointer is a nullptr.

template<RValueFrameDataType FrameData>
Frame(FrameData&&)

Frame constructor from (almost) arbitrary raw data.

This r-value overload is mainly present for enabling the python bindings, where cppyy seems to strip the std::unique_ptr somewhere in the process

Template Parameters:

FrameData – Arbitrary data container that provides access to the collection buffers as well as the metadata, when requested by the Frame.

Frame(const Frame&) = delete

A Frame is move-only.

Frame &operator=(const Frame&) = delete

A Frame is move-only.

Frame(Frame&&) = default

Frame move constructor.

Frame &operator=(Frame&&) = default

Frame move assignment operator.

~Frame() = default

Frame destructor.

Note

Since the Frame owns all the collections that have been put into it, or that can be obtained from it, this invalidates all references to these collections.

template<CollectionType CollT>
const CollT &get(const std::string &name) const

Get a collection from the Frame by name.

Template Parameters:

CollT – The type of the desired collection

Parameters:

name – The name of the collection

Returns:

A const reference to the collection if it is available or to an empty (static) collection

inline const podio::CollectionBase *get(const std::string &name) const

Get a collection pointer from the Frame by name.

This is a type-erased version that is also used by the python bindings.

Returns:

A const pointer to a collection if it is available or a nullptr if it is not

template<CollectionRValueType CollT>
const CollT &put(CollT &&coll, const std::string &name)

(Destructively) move a collection into the Frame and get a reference to the inserted collection back for further use.

The collection that is passed into the Frame has to be moved into it explicitly and the moved-from collection will be in the typical valid but undefined state in c++.

Template Parameters:

CollT – The type of the collection

Parameters:
  • coll – An rvalue reference to the collection to put into the Frame.

  • name – The name under which this collection should be stored in the Frame

Returns:

A const reference to the collection that has just been inserted

inline void put(std::unique_ptr<podio::CollectionBase> coll, const std::string &name)

(Destructively) move a collection into the Frame.

Parameters:
  • coll – The collection that should be moved into the Frame

  • name – The name under which this collection should be stored in the Frame

template<ValidGenericDataType T>
inline void putParameter(const std::string &key, T value)

Add a value to the parameters of the Frame (if the type is supported).

Template Parameters:

T – The type of the parameter. Has to be one of the types that is supported by GenericParameters

Parameters:
  • key – The name under which this parameter should be stored

  • value – The value of the parameter. A copy will be put into the Frame

inline void putParameter(const std::string &key, std::string value)

Add a string value to the parameters of the Frame.

This is a dedicated overload for enabling on-the-fly conversion from string literals.

Parameters:
  • key – The name under which this parameter should be stored

  • value – The value of the parameter. A copy will be put into the Frame

inline void putParameter(const std::string &key, std::vector<std::string> values)

Add a vector of strings value the parameters of the Frame.

This is a dedicated overload for enabling on-the-fly conversion from an initializer_list of string literals

Parameters:
  • key – The name under which this parameter should be stored

  • values – The values of the parameter. A copy will be put into the Frame

template<ValidGenericDataType T>
inline void putParameter(const std::string &key, std::initializer_list<T> &&values)

Add a vector of values to the parameters of the Frame (if the type is supported).

This is a dedicated overload for enabling on-the-fly conversions of initializer_list of values

Template Parameters:

T – The type of the parameter. Has to be one of the types that is supported by GenericParameters

Parameters:
  • key – The name under which this parameter should be stored

  • values – The values of the parameter. A copy will be put into the Frame

template<ValidGenericDataType T>
inline auto getParameter(const std::string &key) const

Retrieve parameters via key from the internal store.

Template Parameters:

T – The desired type of the parameter (can also be std::vector<T>)

Parameters:

key – The key under which the value is stored

Returns:

An optional holding the value if it is present

inline const podio::GenericParameters &getParameters() const

Retrieve all parameters stored in this Frame.

This is mainly intended for I/O purposes and we encourage to use the Frame functionality of getParameter or getParameterKeys in general.

Returns:

The internally used GenericParameters

template<ValidGenericDataType T>
inline std::vector<std::string> getParameterKeys() const

Get the keys of all stored parameters for a given type.

Template Parameters:

T – The desired parameter type

Returns:

A vector of keys for this parameter type

inline std::vector<std::string> getAvailableCollections() const

Get all currently available collection names.

Returns:

The names of all collections, including those that might still need unpacking from the internal FrameData

inline std::optional<std::string> getName(const podio::CollectionBase &coll) const

Get the name of the passed collection.

Parameters:

coll – The collection for which the name should be obtained

Returns:

The name of the collection or an empty optional if this collection is not known to the Frame

inline std::optional<std::string> getName(const uint32_t collectionID) const

Get the name for the passed collectionID.

Parameters:

collectionID – The collection ID of the collection for which the name should be obtained

Returns:

The name of the collection or an empty optional if this collectionID is not known to the Frame

inline const podio::CollectionBase *getCollectionForWrite(const std::string &name) const

Get a collection for writing.

Note

This method is intended for I/O purposes only and should not be used in other code.

Returns:

The collection pointer in a prepared and “ready-to-write” state

inline podio::CollectionIDTable getCollectionIDTableForWrite() const

Get the internal CollectionIDTable for writing.

Note

This method is intended for I/O purposes only and should not be used in other code.

Returns:

A copy of the internal collection id table

class GenericParameters
#include <podio/GenericParameters.h>

GenericParameters objects allow one to store generic named parameters of type int, float and string or vectors of these types.

They can be used to store (user) meta data that is run, event or collection dependent. (based on lcio::LCParameters)

Author

F. Gaede, DESY

Date

Apr 2020

Public Types

template<typename T>
using MapType = std::map<std::string, std::vector<T>>

Public Functions

GenericParameters() = default
GenericParameters(const GenericParameters&)

GenericParameters are copyable.

Note

This is currently mainly done to keep the ROOT I/O happy, because that needs a copy constructor

GenericParameters &operator=(const GenericParameters&) = delete
GenericParameters(GenericParameters&&) = default

GenericParameters are default moveable.

GenericParameters &operator=(GenericParameters&&) = default
~GenericParameters() = default
template<ValidGenericDataType T>
std::optional<T> get(const std::string &key) const
template<ValidGenericDataType T>
void set(const std::string &key, T value)

Store (a copy of) the passed value under the given key.

inline void set(const std::string &key, const char *value)

Overload for catching const char* setting for string values.

inline void set(const std::string &key, std::vector<std::string> values)

Overload for catching initializer list setting of string vector values.

template<ValidGenericDataType T>
inline void set(const std::string &key, std::initializer_list<T> &&values)

Overload for catching initializer list setting for vector values.

template<typename T, template<typename...> typename VecLike>
void loadFrom(VecLike<std::string> keys, VecLike<std::vector<T>> values)

Load multiple key value pairs simultaneously.

template<ValidGenericDataType T>
size_t getN(const std::string &key) const

Get the number of elements stored under the given key for a type.

template<ValidGenericDataType T>
std::vector<std::string> getKeys() const

Get all available keys for a given type.

template<ValidGenericDataType T>
std::tuple<std::vector<std::string>, std::vector<std::vector<T>>> getKeysAndValues() const

Get all the available values for a given type.

inline void clear()

erase all elements

void print(std::ostream &os = std::cout, bool flush = true) const
inline bool empty() const

Check if no parameter is stored (i.e. if all internal maps are empty)

template<typename T>
inline const MapType<detail::GetVectorType<T>> &getMap() const

Get a reference to the internal map for a given type.

class ICollectionProvider
#include <podio/ICollectionProvider.h>

Public Functions

virtual ~ICollectionProvider() = default

destructor

virtual bool get(uint32_t collectionID, CollectionBase *&collection) const = 0

access a collection by ID. returns true if successful

template<typename FromT, typename ToT>
class LinkCollection : public podio::CollectionBase
#include <podio/detail/LinkCollectionImpl.h>

Public Types

using from_type = FromT
using to_type = ToT
using value_type = Link<FromT, ToT>
using mutable_type = MutableLink<FromT, ToT>
using const_iterator = LinkCollectionIterator<FromT, ToT>
using iterator = LinkMutableCollectionIterator<FromT, ToT>
using difference_type = ptrdiff_t
using size_type = size_t
using const_reverse_iterator = std::reverse_iterator<const_iterator>
using reverse_iterator = std::reverse_iterator<iterator>

Public Functions

LinkCollection() = default
inline LinkCollection(CollectionDataT &&data, bool isSubsetColl)
LinkCollection(const LinkCollection&) = delete
LinkCollection &operator=(const LinkCollection&) = delete
LinkCollection(LinkCollection&&) = default
LinkCollection &operator=(LinkCollection&&) = default
inline ~LinkCollection() override
inline mutable_type create()

Append a new link to the collection and return this object.

inline value_type operator[](std::size_t index) const

Returns the immutable object of given index.

inline mutable_type operator[](std::size_t index)

Returns the mutable object of given index.

inline value_type at(std::size_t index) const

Returns the immutable object of given index.

inline mutable_type at(std::size_t index)

Returns the mutable object of given index.

inline void push_back(mutable_type object)
inline void push_back(value_type object)
inline virtual size_t size() const override

Number of elements in the collection.

inline virtual std::size_t max_size() const override

maximal number of elements in the collection

inline virtual bool empty() const override

Is the collection empty.

inline virtual void clear() override

clear the collection and all internal states

inline virtual void print(std::ostream &os = std::cout, bool flush = true) const override

print this collection to the passed stream

inline const_iterator begin() const
inline const_iterator cbegin() const
inline const_iterator end() const
inline const_iterator cend() const
inline iterator begin()
inline iterator end()
inline reverse_iterator rbegin()
inline const_reverse_iterator rbegin() const
inline const_reverse_iterator crbegin() const
inline reverse_iterator rend()
inline const_reverse_iterator rend() const
inline const_reverse_iterator crend() const
inline virtual bool isValid() const override

check for validity of the container after read

inline virtual podio::CollectionWriteBuffers getBuffers() override

Get the collection buffers for this collection.

inline virtual const std::string_view getTypeName() const override

fully qualified type name

inline virtual const std::string_view getValueTypeName() const override

fully qualified type name of elements - with namespace

inline virtual const std::string_view getDataTypeName() const override

fully qualified type name of stored POD elements - with namespace

inline virtual bool isSubsetCollection() const override

check if this collection is a subset collection

inline virtual void setSubsetCollection(bool setSubset = true) override

declare this collection to be a subset collection

inline virtual void setID(uint32_t id) override

set collection ID

inline virtual uint32_t getID() const override

get collection ID

inline virtual void prepareForWrite() const override

prepare buffers for serialization

inline virtual void prepareAfterRead() override

re-create collection from buffers after read

inline virtual bool setReferences(const ICollectionProvider *collectionProvider) override

initialize references after read

inline virtual SchemaVersionT getSchemaVersion() const override

schema version of the collection

inline virtual size_t getDatamodelRegistryIndex() const override

Get the index in the DatatypeRegistry of the EDM this collection belongs to.

Public Static Functions

static inline void __cppyy_pythonize__(PyObject *klass, const std::string &name)

Cppyy protocol to setup the pythonizations for this class. Not to be called directly.

Public Static Attributes

static std::string_view typeName = podio::utils::static_concatenate_v<podio::detail::link_coll_name_prefix, FromT::typeName, podio::detail::link_name_infix, ToT::typeName, podio::detail::link_name_suffix>
static std::string_view valueTypeName = value_type::typeName
static std::string_view dataTypeName = "podio::LinkData"
static SchemaVersionT schemaVersion = 1
template<typename FromT, typename ToT>
class LinkCollectionData
#include <podio/detail/LinkCollectionData.h>

Public Functions

inline LinkCollectionData()
inline LinkCollectionData(podio::CollectionReadBuffers buffers, bool isSubsetColl)
LinkCollectionData(const LinkCollectionData&) = delete
LinkCollectionData &operator=(const LinkCollectionData&) = delete
LinkCollectionData(LinkCollectionData&&) = default
LinkCollectionData &operator=(LinkCollectionData&&) = default
~LinkCollectionData() = default
inline podio::CollectionWriteBuffers getCollectionBuffers(bool isSubsetColl)
inline void clear(bool isSubsetColl)
inline void prepareForWrite(bool isSubsetColl)
inline void prepareAfterRead(uint32_t collectionID)
inline bool setReferences(const podio::ICollectionProvider *collectionProvider, bool isSubsetColl)
inline void makeSubsetCollection()

Public Members

LinkObjPointerContainer<FromT, ToT> entries = {}
template<typename FromT, typename ToT, bool Mutable>
class LinkCollectionIteratorT
#include <podio/detail/LinkCollectionIterator.h>

Public Types

using value_type = LinkType
using difference_type = ptrdiff_t
using reference = LinkType
using pointer = LinkType*
using iterator_category = std::input_iterator_tag
using iterator_concept = std::random_access_iterator_tag

Public Functions

inline LinkCollectionIteratorT(size_t index, const LinkObjPointerContainer<FromT, ToT> *coll)
LinkCollectionIteratorT() = default
LinkCollectionIteratorT(const LinkCollectionIteratorT&) = default
LinkCollectionIteratorT &operator=(const LinkCollectionIteratorT&) = default
LinkCollectionIteratorT(LinkCollectionIteratorT&&) = default
LinkCollectionIteratorT &operator=(LinkCollectionIteratorT&&) = default
~LinkCollectionIteratorT() = default
inline auto operator<=>(const LinkCollectionIteratorT &other) const
inline bool operator==(const LinkCollectionIteratorT &other) const
inline LinkType operator*() const
inline LinkType *operator->()
inline LinkCollectionIteratorT &operator++()
inline LinkCollectionIteratorT operator++(int)
inline LinkCollectionIteratorT &operator--()
inline LinkCollectionIteratorT operator--(int)
inline LinkCollectionIteratorT &operator+=(difference_type n)
inline LinkCollectionIteratorT operator+(difference_type n) const
inline LinkCollectionIteratorT &operator-=(difference_type n)
inline LinkCollectionIteratorT operator-(difference_type n) const
inline LinkType operator[](difference_type n) const
inline difference_type operator-(const LinkCollectionIteratorT &other) const

Friends

inline friend LinkCollectionIteratorT operator+(difference_type n, const LinkCollectionIteratorT &it)
struct LinkData
#include <podio/detail/LinkFwd.h>

Simple struct to keep implementation more in line with generated links and to ease evolution of generated links into templated ones.

Public Members

float weight = {}
template<typename LinkCollT>
class LinkNavigator
#include <podio/LinkNavigator.h>

A helper class to more easily handle one-to-many links.

Internally simply populates two maps in its constructor and then queries them to retrieve objects that are linked with another.

Note

There are no guarantees on the order of the objects in these maps. Hence, there are also no guarantees on the order of the returned objects, even if there inherintly is an order to them in the underlying links collection.

Public Functions

LinkNavigator(const LinkCollT &links)

Construct a navigator from an link collection.

LinkNavigator() = delete

We do only construct from a collection.

LinkNavigator(const LinkNavigator&) = default
LinkNavigator &operator=(const LinkNavigator&) = default
LinkNavigator(LinkNavigator&&) = default
LinkNavigator &operator=(LinkNavigator&&) = default
~LinkNavigator() = default
inline std::vector<WeightedObject<FromT>> getLinked(const ToT &object, podio::detail::links::ReturnFromTag) const

Get all the From objects and weights that have links with the passed object.

You will get this overload if you pass the podio::ReturnFrom tag as second argument

Note

This overload works always, even if the LinkCollection that was used to construct this instance of the LinkNavigator has the same From and To types.

Parameters:
  • object – The object that is labeled To in the link

  • . – tag variable for selecting this overload

Returns:

A vector of all objects and their weights that have links with the passed object

template<typename ToU = ToT>
inline std::enable_if_t<!std::is_same_v<FromT, ToU>, std::vector<WeightedObject<FromT>>> getLinked(const ToT &object) const

Get all the From objects and weights that have links with the passed object.

Note

This overload will automatically do the right thing (TM) in case the LinkCollection that has been passed to construct this LinkNavigator has different From and To types.

Parameters:

object – The object that is labeled To in the link

Returns:

A vector of all objects and their weights that have links with the passed object

inline std::vector<WeightedObject<ToT>> getLinked(const FromT &object, podio::detail::links::ReturnToTag) const

Get all the To objects and weights that have links with the passed object.

You will get this overload if you pass the podio::ReturnTo tag as second argument

Note

This overload works always, even if the LinkCollection that was used to construct this instance of the LinkNavigator has the same From and To types.

Parameters:
  • object – The object that is labeled From in the link

  • . – tag variable for selecting this overload

Returns:

A vector of all objects and their weights that have links with the passed object

template<typename FromU = FromT>
inline std::enable_if_t<!std::is_same_v<FromU, ToT>, std::vector<WeightedObject<ToT>>> getLinked(const FromT &object) const

Get all the To objects and weights that have links with the passed object.

Note

This overload will automatically do the right thing (TM) in case the LinkCollection that has been passed to construct this LinkNavigator has different From and To types.

Parameters:

object – The object that is labeled From in the link

Returns:

A vector of all objects and their weights that have links with the passed object

template<typename FromT, typename ToT>
class LinkObj
#include <podio/detail/LinkObj.h>

Public Functions

inline LinkObj()

Constructor.

inline LinkObj(const podio::ObjectID id_, LinkData data_)

Constructor from ObjectID and data (does not initialize relations yet!)

inline LinkObj(const LinkObj &other)

Copy constructor (deep-copy of relations)

LinkObj &operator=(const LinkObj&) = delete

No assignment operator.

~LinkObj() = default

Destructor.

Public Members

podio::ObjectID id = {}
LinkData data = {1.0f}
std::unique_ptr<FromT> m_from = {nullptr}
std::unique_ptr<ToT> m_to = {nullptr}
template<typename FromT, typename ToT>
class LinkSIOBlock : public podio::SIOBlock
#include <podio/detail/LinkSIOBlock.h>

Public Functions

inline LinkSIOBlock()
inline LinkSIOBlock(const std::string &name)
inline void read(sio::read_device &device, sio::version_type version) override
inline void write(sio::write_device &device) override
inline virtual SIOBlock *create(const std::string &name) const override
template<typename FromT, typename ToT, bool Mutable>
class LinkT
#include <podio/detail/Link.h>

Generalized Link type for both Mutable and immutable (default) versions.

User facing classes with the expected naming scheme are defined via template aliases in LinkFwd.h

Public Types

using mutable_type = podio::MutableLink<FromT, ToT>
using value_type = podio::Link<FromT, ToT>
using collection_type = podio::LinkCollection<FromT, ToT>

Public Functions

inline LinkT()

Constructor.

inline LinkT(float weight)

Constructor with weight.

LinkT(const LinkT &other) = default

Copy constructor.

inline LinkT &operator=(LinkT other) &

Assignment operators.

LinkT &operator=(LinkT other) && = delete
template<typename FromU, typename ToU> inline &&sameTypes< FromU, ToU > operator LinkT< FromU, ToU, false > () const

Implicit conversion of mutable to immutable links.

template<typename FromU = FromT, typename ToU = ToT>
inline MutableLink<FromU, ToU> clone(bool cloneRelations = true) const

Create a mutable deep-copy.

Parameters:

cloneRelations – if set to false only the weight will be cloned but not the relations to the objects this link points to. Defaults to true

Returns:

A mutable deep-copy of this link which is independent of the original one

~LinkT() = default

Destructor.

inline float getWeight() const

Get the weight of the link.

template<bool Mut = Mutable>
inline void setWeight(float value)

Set the weight of the link.

inline const FromT getFrom() const

Access the related-from object.

template<typename FromU>
inline void setFrom(FromU value)

Set the related-from object.

Note

All setFrom overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename FromU>
inline void setFrom(FromU value)

Set the related-from object.

Note

All setFrom overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename FromU>
inline void setFrom(FromU value)

Set the related-from object.

Note

All setFrom overloads are equivalent and the correct one is selected at compile time. We need this overload to allow for an implicit conversion to interface types in case the relation contains an interface type.

inline const ToT getTo() const

Access the related-to object.

template<typename ToU>
inline void setTo(ToU value)

Set the related-to object.

Note

All setTo overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename ToU>
inline void setTo(ToU value)

Set the related-to object.

Note

All setTo overloads are equivalent and the correct one is selected at compile time. We need to differentiate between the handles, only to make the python bindings work

template<typename ToU>
inline void setTo(ToU value)

Set the related-to object.

Note

All setTo overloads are equivalent and the correct one is selected at compile time. We need this overload to allow for an implicit conversion to interface types in case the relation contains an interface type.

template<typename T>
inline T get() const

Templated version for getting an element of the link by type.

Only available for Links where FromT and ToT are not the same type, and if the requested type is actually part of the Link. It is only possible to get the immutable types from this. Will result in a compilation error if any of these conditions is not met.

Template Parameters:

T – the desired type

Returns:

T the element of the Link

template<size_t Index>
inline auto get() const

Tuple like index based access to the elements of the Link.

Returns only immutable types of the links. This method enables structured bindings for Links.

Template Parameters:

Index – an index (smaller than 3) to access an element of the Link

Returns:

Depending on the value of Index:

  • 0: The From element of the Link

  • 1: The To element of the Link

  • 2: The weight of the Link

template<typename T>
inline void set(T value)

Templated version for setting an element of the link by type.

Only available for Links where FromT and ToT are not the same type, and if the requested type is actually part of the Link. Will result in a compilation error if any of these conditions is not met.

Template Parameters:

T – type of value (inferred!)

Parameters:

value – the element to set for this link.

inline bool isAvailable() const

check whether the object is actually available

inline void unlink()

disconnect from Link instance

inline podio::ObjectID getObjectID() const

Get the ObjectID.

inline podio::ObjectID id() const
inline bool operator==(const LinkT &other) const
inline bool operator!=(const LinkT &other) const
template<typename FromU, typename ToU>
inline bool operator==(const LinkT<FromU, ToU, !Mutable> &other) const
template<typename FromU, typename ToU>
inline bool operator!=(const LinkT<FromU, ToU, !Mutable> &other) const
inline bool operator<(const LinkT &other) const

Public Static Functions

template<bool Mut = Mutable>
static inline Link<FromT, ToT> makeEmpty()

Create an empty Link handle.

Public Static Attributes

static std::string_view typeName = utils::static_concatenate_v<detail::link_name_prefix, FromT::typeName, detail::link_name_infix, ToT::typeName, detail::link_name_suffix>

Friends

inline friend void swap(LinkT &a, LinkT &b)
class ObjectID
#include <podio/ObjectID.h>

Public Functions

inline bool operator==(const ObjectID &other) const

index and collectionID uniquely defines the object.

this operator is necessary for meaningful comparisons in python

inline bool operator!=(const ObjectID &other) const

Public Members

int index = {untracked}

index of object in collection

uint32_t collectionID = {static_cast<uint32_t>(untracked)}

ID of the collection.

Public Static Attributes

static const int untracked = -1

not part of a collection

static const int invalid = -2

invalid or non-available object

class Reader
#include <podio/Reader.h>

Generic (type erased) reader class that can handle different I/O backends transparently.

Offers some more high level functionality compared to the lower level backend specific readers that this class wraps. In contrast to the lower level readers that usually return arbitrary FrameData, this interface class will return fully constructed Frames. In addition, it provides convenience methods to deal specifically with the “events” frame category.

Note

The recommended way to construct is to use the makeReader() functions since they handle the instantiation of the correct low level readers

Public Functions

template<typename T>
Reader(std::unique_ptr<T> actualReader)

Create a reader from a low level reader.

Template Parameters:

T – The type of the low level reader (will be deduced)

Parameters:

actualReader – a low level reader that provides access to FrameDataT

Reader(const Reader&) = delete
Reader &operator=(const Reader&) = delete
Reader(Reader&&) = default
Reader &operator=(Reader&&) = default
~Reader() = default
inline podio::Frame readNextFrame(const std::string &name, const std::vector<std::string> &collsToRead = {})

Read the next frame of a given category.

Parameters:
  • name – The category name for which to read the next frame

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case the category is not available or in case no more entries are available

Returns:

A fully constructed Frame with the contents read from file

inline podio::Frame readNextEvent(const std::vector<std::string> &collsToRead = {})

Read the next frame of the “events” category.

Parameters:

collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case no (more) events are available

Returns:

A fully constructed Frame with the contents read from file

inline podio::Frame readFrame(const std::string &name, size_t index, const std::vector<std::string> &collsToRead = {})

Read a specific frame for a given category.

Parameters:
  • name – The category name for which to read the next entry

  • index – The entry number to read

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case the category is not available or in case the specified entry is not available

Returns:

A fully constructed Frame with the contents read from file

inline podio::Frame readEvent(size_t index, const std::vector<std::string> &collsToRead = {})

Read a specific frame of the “events” category.

Parameters:
  • index – The event number to read

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case the desired event is not available

Returns:

A fully constructed Frame with the contents read from file

inline size_t getEntries(const std::string &name) const

Get the number of entries for the given name.

Parameters:

name – The name of the category

Returns:

The number of entries that are available for the category

inline size_t getEvents() const

Get the number of events.

Returns:

The number of entries that are available for the category

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

Returns:

The podio build version

inline std::optional<podio::version::Version> currentFileVersion(const std::string &name) const

Get the (build) version of a datamodel that has been used to write the current file.

Parameters:

name – The name of the datamodel

Returns:

The (build) version of the datamodel if available or an empty optional

inline std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s).

Returns:

The names of the available categories from the file

inline const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given name.

Parameters:

name – The name of the datamodel

Returns:

The high level definition of the datamodel in JSON format

inline std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that are available from this reader.

Returns:

The names of the datamodels

struct RelationNames
#include <podio/DatamodelRegistry.h>

Information on the names of the OneTo[One|Many]Relations as well as the VectorMembers of a datatype.

The contents are populated by the code generation, where we simply generate static vectors that we make available as const& here.

Public Members

const std::vector<std::string_view> &relations

The names of the relations (OneToMany before OneToOne)

const std::vector<std::string_view> &vectorMembers

The names of the vector members.

template<typename ReferenceType>
class RelationRange
#include <podio/RelationRange.h>

A simple helper class that allows one to return related objects in a way that makes it possible to use the return type in a range-based for loop.

Public Types

using ConstIteratorType = typename std::vector<ReferenceType>::const_iterator

Public Functions

RelationRange() = delete
inline RelationRange(ConstIteratorType begin, ConstIteratorType end)
inline ConstIteratorType begin() const

begin of the range (necessary for range-based for loop)

inline ConstIteratorType end() const

end of the range (necessary for range-based for loop)

inline ConstIteratorType cbegin() const

constant begin of the range

inline ConstIteratorType cend() const

constant end of the range

inline size_t size() const

convenience overload for size

inline bool empty() const

convenience overload to check if the range is empty

inline explicit operator bool() const

check whether the range is not empty

inline ReferenceType operator[](size_t i) const

Indexed access.

inline ReferenceType front() const

First element of the range.

inline ReferenceType back() const

Last element of the range.

inline ReferenceType at(size_t i) const

Indexed access with range check.

class RNTupleReader
#include <podio/RNTupleReader.h>

The RNTupleReader can be used to read files that have been written with the RNTuple backend.

The RNTupleReader provides the data as ROOTFrameData from which a podio::Frame can be constructed. It can be used to read files written by the RNTupleWriter.

Public Functions

RNTupleReader() = default

Create a RNTupleReader.

~RNTupleReader() = default

Destructor.

RNTupleReader(const RNTupleReader&) = delete

The RNTupleReader is not copy-able.

RNTupleReader &operator=(const RNTupleReader&) = delete

The RNTupleReader is not copy-able.

void openFile(const std::string &filename)

Open a single file for reading.

Parameters:

filename – The name of the input file

void openFiles(const std::vector<std::string> &filenames)

Open multiple files for reading and then treat them as if they are one file.

Note

All of the files are assumed to have the same structure. Specifically this means:

  • The same categories are available from all files

  • The collections that are contained in the individual categories are the same across all files

  • This usually boils down to “the files have been written with the same

    ”settings”, e.g. they are outputs of a batched process.

Parameters:

filenames – The filenames of all input files that should be read

std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string &name, const std::vector<std::string> &collsToRead = {})

Read the next data entry for a given category.

Parameters:
  • name – The category name for which to read the next entry

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case collsToRead contains collection names that are not available

Returns:

FrameData from which a podio::Frame can be constructed if the category exists and if there are still entries left to read. Otherwise a nullptr

std::unique_ptr<podio::ROOTFrameData> readEntry(const std::string &name, const unsigned entry, const std::vector<std::string> &collsToRead = {})

Read the desired data entry for a given category.

Parameters:
  • name – The category name for which to read the next entry

  • entry – The entry number to read

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case collsToRead contains collection names that are not available

Returns:

FrameData from which a podio::Frame can be constructed if the category and the desired entry exist. Otherwise a nullptr

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s).

Returns:

The names of the available categores from the file

unsigned getEntries(const std::string &name)

Get the number of entries for the given name.

Parameters:

name – The name of the category

Returns:

The number of entries that are available for the category

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

Returns:

The podio build version

inline std::optional<podio::version::Version> currentFileVersion(const std::string &name) const

Get the (build) version of a datamodel that has been used to write the current file.

Parameters:

name – The name of the datamodel

Returns:

The (build) version of the datamodel if available or an empty optional

inline const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given name.

Parameters:

name – The name of the datamodel

Returns:

The high level definition of the datamodel in JSON format

inline std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that are available from this reader.

Returns:

The names of the datamodels

class RNTupleWriter
#include <podio/RNTupleWriter.h>

The RNTupleWriter writes podio files into ROOT files using the new RNTuple format.

Each category gets its own RNTuple. Additionally, there is a podio_metadata RNTuple that contains metadata that is necessary for interpreting the files for reading.

Files written with the RNTupleWriter can be read with the RNTupleReader.

Public Functions

RNTupleWriter(const std::string &filename)

Create a RNTupleWriter to write to a file.

Note

Existing files will be overwritten without warning.

Parameters:

filename – The path to the file that will be created.

~RNTupleWriter()

RNTupleWriter destructor.

This also takes care of writing all the necessary metadata in order to be able to read files back again.

RNTupleWriter(const RNTupleWriter&) = delete

The RNTupleWriter is not copy-able.

RNTupleWriter &operator=(const RNTupleWriter&) = delete

The RNTupleWriter is not copy-able.

void writeFrame(const podio::Frame &frame, const std::string &category)

Store the given frame with the given category.

This stores 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.

Parameters:
  • frame – The Frame to store

  • category – The category name under which this Frame should be stored

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

Store the given Frame with the given category.

This stores only the desired collections and not the complete 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.

Parameters:
  • frame – The Frame to store

  • category – The category name under which this Frame should be stored

  • collsToWrite – The collection names that should be written

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 RNTupleWriter go out of scope is also a viable way to write a readable file

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.

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.

Parameters:
  • collsToWrite – The collection names that should be checked for consistency

  • category – The category name for which consistency should be checked

Returns:

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.

class ROOTFrameData
#include <podio/ROOTFrameData.h>

Public Types

using BufferMap = std::unordered_map<std::string, podio::CollectionReadBuffers>

Public Functions

ROOTFrameData() = delete
~ROOTFrameData()
ROOTFrameData(ROOTFrameData&&) = default
ROOTFrameData &operator=(ROOTFrameData&&) = default
ROOTFrameData(const ROOTFrameData&) = delete
ROOTFrameData &operator=(const ROOTFrameData&) = delete
ROOTFrameData(BufferMap &&buffers, CollIDPtr &&idTable, podio::GenericParameters &&params)
std::optional<podio::CollectionReadBuffers> getCollectionBuffers(const std::string &name)
podio::CollectionIDTable getIDTable() const
std::unique_ptr<podio::GenericParameters> getParameters()
std::vector<std::string> getAvailableCollections() const
class ROOTLegacyReader
#include <podio/ROOTLegacyReader.h>

A root reader for reading legacy podio root files that have been written using the legacy, non Frame based I/O model.

This reader grants Frame based access to those files, by mimicking the Frame I/O functionality and the interfaces of those readers.

Note

Since there was only one category (“events”) for those legacy podio files this reader will really only work if you try to read that category, and will simply return no data if you try to read anything else.

Public Functions

ROOTLegacyReader() = default

Create a SIOLegacyReader.

~ROOTLegacyReader() = default

Destructor.

ROOTLegacyReader(const ROOTLegacyReader&) = delete

The SIOLegacyReader is not copy-able.

ROOTLegacyReader &operator=(const ROOTLegacyReader&) = delete

The SIOLegacyReader is not copy-able.

void openFile(const std::string &filename)

Open a single file for reading.

Parameters:

filename – The name of the input file

void openFiles(const std::vector<std::string> &filenames)

Open multiple files for reading and then treat them as if they are one file.

This usually boils down to “the files have been written with the same

”settings”, e.g. they are outputs of a batched process.

Note

All of the files are assumed to have the same structure. Specifically this means:

  • The collections that are contained in the individual event are always the same

Parameters:

filenames – The filenames of all input files that should be read

std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string&, const std::vector<std::string>& = {})

Read the next data entry from which a Frame can be constructed.

Note

the category name has to be “events” in this case, as only that category is available for legacy files. Also the collections to read argument will be ignored.

Returns:

FrameData from which a podio::Frame can be constructed if there are still entries left to read. Otherwise a nullptr

std::unique_ptr<podio::ROOTFrameData> readEntry(const std::string&, const unsigned entry, const std::vector<std::string>& = {})

Read the desired data entry from which a Frame can be constructed.

Note

the category name has to be “events” in this case, as only that category is available for legacy files. Also the collections to read argument will be ignored.

Returns:

FrameData from which a podio::Frame can be constructed if the desired entry exists. Otherwise a nullptr

unsigned getEntries(const std::string &name) const

Get the number of entries for the given name.

Parameters:

name – The name of the category

Returns:

The number of entries that are available for the category

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

Returns:

The podio build version

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s).

Returns:

The names of the available categories from the file

class ROOTReader
#include <podio/ROOTReader.h>

This class has the function to read available data from disk in ROOTs TTree format.

The ROOTReader provides the data as ROOTFrameData from which a podio::Frame can be constructed. It can be used to read files written by the ROOTWriter.

Public Functions

ROOTReader() = default

Create a ROOTReader.

~ROOTReader() = default

Destructor.

ROOTReader(const ROOTReader&) = delete

The ROOTReader is not copy-able.

ROOTReader &operator=(const ROOTReader&) = delete

The ROOTReader is not copy-able.

void openFile(const std::string &filename)

Open a single file for reading.

Parameters:

filename – The name of the input file

void openFiles(const std::vector<std::string> &filenames)

Open multiple files for reading and then treat them as if they are one file.

Note

All of the files are assumed to have the same structure. Specifically this means:

  • The same categories are available from all files

  • The collections that are contained in the individual categories are the same across all files

  • This usually boils down to “the files have been written with the same

    ”settings”, e.g. they are outputs of a batched process.

Parameters:

filenames – The filenames of all input files that should be read

std::unique_ptr<podio::ROOTFrameData> readNextEntry(const std::string &name, const std::vector<std::string> &collsToRead = {})

Read the next data entry for a given category.

Parameters:
  • name – The category name for which to read the next entry

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case collsToRead contains collection names that are not available

Returns:

FrameData from which a podio::Frame can be constructed if the category exists and if there are still entries left to read. Otherwise a nullptr

std::unique_ptr<podio::ROOTFrameData> readEntry(const std::string &name, const unsigned entry, const std::vector<std::string> &collsToRead = {})

Read the desired data entry for a given category.

Parameters:
  • name – The category name for which to read the next entry

  • entry – The entry number to read

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Throws:

std::invalid_argument – in case collsToRead contains collection names that are not available

Returns:

FrameData from which a podio::Frame can be constructed if the category and the desired entry exist. Otherwise a nullptr

unsigned getEntries(const std::string &name) const

Get the number of entries for the given name.

Parameters:

name – The name of the category

Returns:

The number of entries that are available for the category

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

Returns:

The podio build version

inline std::optional<podio::version::Version> currentFileVersion(const std::string &name) const

Get the (build) version of a datamodel that has been used to write the current file.

Parameters:

name – The name of the datamodel

Returns:

The (build) version of the datamodel if available or an empty optional

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s).

Returns:

The names of the available categories from the file

inline const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given name.

Parameters:

name – The name of the datamodel

Returns:

The high level definition of the datamodel in JSON format

inline std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that are available from this reader.

Returns:

The names of the datamodels

class ROOTWriter
#include <podio/ROOTWriter.h>

The ROOTWriter writes podio files into ROOT files using TTrees.

Each category gets its own TTree. Additionally, there is a podio_metadata TTree that contains metadata that is necessary for interpreting the files for reading.

Files written with the ROOTWriter can be read with the ROOTReader.

Public Functions

ROOTWriter(const std::string &filename)

Create a ROOTWriter to write to a file.

Note

Existing files will be overwritten without warning.

Parameters:

filename – The path to the file that will be created.

~ROOTWriter()

ROOTWriter destructor.

This also takes care of writing all the necessary metadata to read files back again.

ROOTWriter(const ROOTWriter&) = delete

The ROOTWriter is not copy-able.

ROOTWriter &operator=(const ROOTWriter&) = delete

The ROOTWriter is not copy-able.

void writeFrame(const podio::Frame &frame, const std::string &category)

Store the given frame with the given category.

This stores 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.

Parameters:
  • frame – The Frame to store

  • category – The category name under which this Frame should be stored

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

Store the given Frame with the given category.

This stores only the desired collections and not the complete 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.

Parameters:
  • frame – The Frame to store

  • category – The category name under which this Frame should be stored

  • collsToWrite – The collection names that should be written

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 ROOTWriter go out of scope is also a viable way to write a readable file

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.

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.

Parameters:
  • collsToWrite – The collection names that should be checked for consistency

  • category – The category name for which consistency should be checked

Returns:

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.

class SchemaEvolution
#include <podio/SchemaEvolution.h>

The SchemaEvolution holds evolution functions that allow to transform CollectionReadBuffers of known datatypes from a previous schema version to the current schema version.

From the evolved buffers it is then possible to create collections.

It is implemented as a singleton that is populated at the time shared datamodel libraries (or their schema evolution libraries) are loaded. It is assumed that this happens early on in the startup of any application, such that the registration still happens on a single thread. After this initialization evolutions can be done from multiple threads.

Public Types

enum class Priority

Enum to make it possible to prioritize evolution functions during registration, making AutoGenerated lower priority than UserDefined.

Values:

enumerator AutoGenerated
enumerator UserDefined

Public Functions

SchemaEvolution(const SchemaEvolution&) = delete

The SchemaEvolution is a singleton so we disable all copy and move constructors explicitly.

SchemaEvolution &operator=(const SchemaEvolution&) = delete
SchemaEvolution(SchemaEvolution&&) = delete
SchemaEvolution &operator=(SchemaEvolution&&) = delete
~SchemaEvolution() = default
podio::CollectionReadBuffers evolveBuffers(const podio::CollectionReadBuffers &oldBuffers, SchemaVersionT fromVersion, const std::string &collType) const

Evolve the passed in buffers to the current version of the datatype that can be constructed from them.

Internally this will first check if the schema version of the buffers is already the current one and in that case immediately return the passed in buffers again as they do not need schema evolution. If that is not the case it will look up the correct evolution function for the passed in version and call that on the passed in buffers.

Note

that these could also be the unchanged input buffers.

Parameters:
  • oldBuffers – The buffers to be evolved

  • fromVersion – The schema version of the buffers

  • collType – The fully qualified collection type

Returns:

CollectionReadBuffers that have been evolved to the current version.

void registerEvolutionFunc(const std::string &collType, SchemaVersionT fromVersion, SchemaVersionT currentVersion, const EvolutionFuncT &evolutionFunc, Priority priority = Priority::UserDefined)

Register an evolution function for a given collection type and given versions from where to where the evolution applies.

Several assumptions are in place here:

  • The current version has to be the same for all invocations for a given datatype.

  • An evolution function has to be registered for all possible versions from 1 to N - 1, where N is the current version

  • An evolution function can only be registered once for a given datatype and fromVersion

  • For auto generated code the passed in priority has to be AutoGenerated otherwise it might override user defined functions

  • Even if a datatype does not require schema evolution it has to register an evolution function (e.g. the noOpSchemaEvolution below) in order to be known to the internal map.

Parameters:
  • collType – The fully qualified collection data type

  • fromVersion – The version from which this evolution function should apply

  • currentVersion – The current schema version for the data type

  • evolutionFunc – The evolution function that evolves passed in buffers from fromVersion to currentVersion

  • priority – The priority of this evolution function. Defaults to UserDefined which overrides auto generated functionality.

Public Static Functions

static SchemaEvolution &mutInstance()

Mutable instance only used for the initial registration of functions during library loading.

static SchemaEvolution const &instance()

Get the instance for evolving buffers.

static podio::CollectionReadBuffers noOpSchemaEvolution(podio::CollectionReadBuffers &&buffers, SchemaVersionT)

A no-op schema evolution function that returns the buffers unchanged.

This can be used for registering an evolution function for datatypes that do not require schema evolution, but need to register themselves with SchemaEvolution

class SIOBlock : public sio::block
#include <podio/SIOBlock.h>

Base class for sio::block handlers used with PODIO.

Subclassed by podio::LinkSIOBlock< FromT, ToT >, podio::SIOBlockUserData< BasicType >

Public Functions

inline SIOBlock(const std::string &nam, sio::version_type vers)
SIOBlock() = delete
SIOBlock(const SIOBlock&) = delete
SIOBlock &operator=(const SIOBlock&) = delete
inline const podio::CollectionReadBuffers &getBuffers() const
inline std::string name()
inline void setSubsetCollection(bool subsetColl)
inline void setCollection(podio::CollectionBase *col)
virtual SIOBlock *create(const std::string &name) const = 0
class SIOBlockFactory
#include <podio/SIOBlock.h>

factory for creating sio::blocks for a given type of EDM-collection

Public Functions

inline void registerBlockForCollection(const std::string &type, SIOBlock *b)
std::shared_ptr<SIOBlock> createBlock(const podio::CollectionBase *col, const std::string &name) const
std::shared_ptr<SIOBlock> createBlock(const std::string &typeStr, const std::string &name, const bool isRefColl = false) const

Public Static Functions

static inline SIOBlockFactory &instance()
class SIOBlockLibraryLoader
#include <podio/SIOBlock.h>

Public Static Functions

static inline SIOBlockLibraryLoader &instance()
template<SupportedUserDataType BasicType>
class SIOBlockUserData : public podio::SIOBlock
#include <podio/SIOBlockUserData.h>

Public Functions

inline SIOBlockUserData()
inline SIOBlockUserData(const std::string &name)
inline void read(sio::read_device &device, sio::version_type version) override
inline void write(sio::write_device &device) override
inline virtual SIOBlock *create(const std::string &name) const override
class SIOCollectionIDTableBlock : public sio::block
#include <podio/SIOBlock.h>

A dedicated block for handling the I/O of the CollectionIDTable.

Public Functions

inline SIOCollectionIDTableBlock()
inline SIOCollectionIDTableBlock(std::vector<std::string> &&names, std::vector<uint32_t> &&ids, std::vector<std::string> &&types, std::vector<short> &&isSubsetColl)
SIOCollectionIDTableBlock(const SIOCollectionIDTableBlock&) = delete
SIOCollectionIDTableBlock &operator=(const SIOCollectionIDTableBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override
inline podio::CollectionIDTable getTable()
inline const std::vector<std::string> &getTypeNames() const
inline const std::vector<short> &getSubsetCollectionBits() const
class SIOEventMetaDataBlock : public sio::block
#include <podio/SIOBlock.h>

A block for handling the EventMeta data.

Public Functions

inline SIOEventMetaDataBlock()
SIOEventMetaDataBlock(const SIOEventMetaDataBlock&) = delete
SIOEventMetaDataBlock &operator=(const SIOEventMetaDataBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override

Public Members

podio::GenericParameters *metadata = {nullptr}
class SIOFileTOCRecord
#include <podio/SIOBlock.h>

Public Types

using PositionType = sio_helpers::position_type

Public Functions

void addRecord(const std::string &name, PositionType startPos)
size_t getNRecords(const std::string &name) const
PositionType getPosition(const std::string &name, unsigned iEntry = 0) const

Get the position of the iEntry-th record with the given name.

If no entry with the given name is recorded, return 0. Note there is no internal check on whether the given name actually has iEntry records. Use getNRecords to check for that if necessary.

std::vector<std::string_view> getRecordNames() const

Get all the record names that are stored in this TOC record.

struct SIOFileTOCRecordBlock : public sio::block
#include <podio/SIOBlock.h>

Public Functions

inline SIOFileTOCRecordBlock()
inline SIOFileTOCRecordBlock(SIOFileTOCRecord *r)
SIOFileTOCRecordBlock(const SIOFileTOCRecordBlock&) = delete
SIOFileTOCRecordBlock &operator=(const SIOFileTOCRecordBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override

Public Members

SIOFileTOCRecord *record = {nullptr}
class SIOFrameData
#include <podio/SIOFrameData.h>

The Frame data container for the SIO backend.

It is constructed from the compressed sio::buffers that is read from file and does all the necessary unpacking and decompressing internally after construction.

Public Functions

SIOFrameData() = delete
~SIOFrameData()
SIOFrameData(const SIOFrameData&) = delete
SIOFrameData &operator=(const SIOFrameData&) = delete
SIOFrameData(SIOFrameData&&) = default
SIOFrameData &operator=(SIOFrameData&&) = default
SIOFrameData(sio::buffer &&collBuffers, std::size_t dataSize, sio::buffer &&tableBuffer, std::size_t tableSize, std::vector<std::string> limitColls = {})

Constructor from the collBuffers containing the collection data and a tableBuffer containing the necessary information for unpacking the collections.

The two size parameters denote the uncompressed size of the respective buffers.

In case the limitColls contain a collection name that is not available from the idTable names this throws an exception

std::optional<podio::CollectionReadBuffers> getCollectionBuffers(const std::string &name)
inline podio::CollectionIDTable getIDTable() const
std::unique_ptr<podio::GenericParameters> getParameters()
std::vector<std::string> getAvailableCollections()
class SIOLegacyReader
#include <podio/SIOLegacyReader.h>

A SIO reader for reading legacy podio .sio files that have been written using the legacy, non Frame based I/O model.

This reader grants Frame based access to those files, by mimicking Frame I/O functionality and the interfaces of those readers.

Note

Since there was only one category (“events”) for those legacy podio files this reader will really only work if you try to read that category, and will simply return no data if you try to read anything else.

Public Functions

SIOLegacyReader()

Create a SIOLegacyReader.

~SIOLegacyReader() = default

Destructor.

SIOLegacyReader(const SIOLegacyReader&) = delete

The SIOLegacyReader is not copy-able.

SIOLegacyReader &operator=(const SIOLegacyReader&) = delete

The SIOLegacyReader is not copy-able.

std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string&, const std::vector<std::string>& = {})

Read the next data entry from which a Frame can be constructed.

In case there are no more entries left, this returns a nullptr.

Note

the category name has to be “events” in this case, as only that category is available for legacy files. Also the collections to read argument will be ignored.

Returns:

FrameData from which a podio::Frame can be constructed if there are still entries left to read. Otherwise a nullptr

std::unique_ptr<podio::SIOFrameData> readEntry(const std::string&, const unsigned entry, const std::vector<std::string>& = {})

Read the desired data entry from which a Frame can be constructed.

Note

the category name has to be “events” in this case, as only that category is available for legacy files. Also the collections to read argument will be ignored.

Returns:

FrameData from which a podio::Frame can be constructed if the desired entry exists. Otherwise a nullptr

unsigned getEntries(const std::string &name) const

Get the number of entries for the given name.

Parameters:

name – The name of the category

Returns:

The number of entries that are available for the category

void openFile(const std::string &filename)

Open a single file for reading.

Parameters:

filename – The name of the input file

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

Returns:

The podio build version

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file(s).

Returns:

The names of the available categores from the file

template<typename KeyT, typename ValueT>
struct SIOMapBlock : public sio::block
#include <podio/SIOBlock.h>

A block to serialize anything that behaves similar in iterating as a map<KeyT, ValueT>, e.g.

vector<tuple<KeyT, ValueT>>, which is what is used internally to represent the data to be written.

Public Functions

inline SIOMapBlock()
inline SIOMapBlock(std::vector<std::tuple<KeyT, ValueT>> &&data)
SIOMapBlock(const SIOMapBlock&) = delete
SIOMapBlock &operator=(const SIOMapBlock&) = delete
inline void read(sio::read_device &device, sio::version_type) override
inline void write(sio::write_device &device) override

Public Members

std::vector<std::tuple<KeyT, ValueT>> mapData = {}
class SIONumberedMetaDataBlock : public sio::block
#include <podio/SIOBlock.h>

A block for handling the run and collection meta data.

Public Functions

inline SIONumberedMetaDataBlock(const std::string &name)
SIONumberedMetaDataBlock(const SIONumberedMetaDataBlock&) = delete
SIONumberedMetaDataBlock &operator=(const SIONumberedMetaDataBlock&) = delete
void read(sio::read_device &device, sio::version_type version) override
void write(sio::write_device &device) override

Public Members

std::map<int, GenericParameters> *data = {nullptr}
class SIOReader
#include <podio/SIOReader.h>

The SIOReader can be used to read files that have been written with the SIO backend.

The SIOReader provides the data as SIOFrameData from which a podio::Frame can be constructed. It can be used to read files written by the SIOWriter.

Public Functions

SIOReader()

Create an SIOReader.

~SIOReader() = default

SIOReader destructor.

SIOReader(const SIOReader&) = delete

The SIOReader is not copy-able.

SIOReader &operator=(const SIOReader&) = delete

The SIOReader is not copy-able.

std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string &name, const std::vector<std::string> &collsToRead = {})

Read the next data entry for a given category.

Note

Given how the SIO files are currently laid out it is in fact not possible to only read a subset of a Frame. Rather the subset of collections to read will be an artificial limit on the returned SIOFrameData. Limiting the collections to read will not improve I/O performance.

Parameters:
  • name – The category name for which to read the next entry

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Returns:

FrameData from which a podio::Frame can be constructed if the category exists and if there are still entries left to read. Otherwise a nullptr

std::unique_ptr<podio::SIOFrameData> readEntry(const std::string &name, const unsigned entry, const std::vector<std::string> &collsToRead = {})

Read the desired data entry for a given category.

Note

Given how the SIO files are currently laid out it is in fact not possible to only read a subset of a Frame. Rather the subset of collections to read will be an artificial limit on the returned SIOFrameData. Limiting the collections to read will not improve I/O performance.

Parameters:
  • name – The category name for which to read the next entry

  • entry – The entry number to read

  • collsToRead – (optional) the collection names that should be read. If not provided (or empty) all collections will be read

Returns:

FrameData from which a podio::Frame can be constructed if the category and the desired entry exist. Otherwise a nullptr

unsigned getEntries(const std::string &name) const

Get the number of entries for the given name.

Parameters:

name – The name of the category

Returns:

The number of entries that are available for the category

void openFile(const std::string &filename)

Open the passed file for reading.

Parameters:

filename – The path to the file to read from

inline podio::version::Version currentFileVersion() const

Get the build version of podio that has been used to write the current file.

Returns:

The podio build version

inline std::optional<podio::version::Version> currentFileVersion(const std::string &name) const

Get the (build) version of a datamodel that has been used to write the current file.

Parameters:

name – The name of the datamodel

Returns:

The (build) version of the datamodel if available or an empty optional

std::vector<std::string_view> getAvailableCategories() const

Get the names of all the available Frame categories in the current file.

Returns:

The names of the available categores from the file

inline const std::string_view getDatamodelDefinition(const std::string &name) const

Get the datamodel definition for the given name.

Parameters:

name – The name of the datamodel

Returns:

The high level definition of the datamodel in JSON format

inline std::vector<std::string> getAvailableDatamodels() const

Get all names of the datamodels that are available from this reader.

Returns:

The names of the datamodels

struct SIOVersionBlock : public sio::block
#include <podio/SIOBlock.h>

Public Functions

inline SIOVersionBlock()
inline SIOVersionBlock(podio::version::Version v)
inline void write(sio::write_device &device) override
inline void read(sio::read_device &device, sio::version_type) override

Public Members

podio::version::Version version = {}
class SIOWriter
#include <podio/SIOWriter.h>

The SIOWriter writes podio files into SIO files.

Each Frame is stored into an SIO record which are written in the order in which Frames are written. As part of the metadata a table of content record is written which is used in the reader to more quickly access the different records.

Files written with the SIOWriter can be read with the SIOReader

Public Functions

SIOWriter(const std::string &filename)

Create a SIOWriter to write to a file.

Note

Existing files will be overwritten without warning.

Parameters:

filename – The path to the file that will be created.

~SIOWriter()

SIOWriter destructor.

This also takes care of writing all the necessary metadata to read files back again.

SIOWriter(const SIOWriter&) = delete

The SIOWriter is not copy-able.

SIOWriter &operator=(const SIOWriter&) = delete

The SIOWriter is not copy-able.

void writeFrame(const podio::Frame &frame, const std::string &category)

Store the given frame with the given category.

This stores all available collections from the Frame. Frames of the same category can be independent of each other, i.e. they can have different collection contents.

Parameters:
  • frame – The Frame to store

  • category – The category name under which this Frame should be stored

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

Store the given Frame with the given category.

This stores only the desired collections and not the complete frame. Frames of the same category can be independent of each other, i.e. they can have different collection contents.

Parameters:
  • frame – The Frame to store

  • category – The category name under which this Frame should be stored

  • collsToWrite – The collection names that should be written

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 SIOWriter go out of scope is also a viable way to write a readable file

template<typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
class UserDataCollection : public podio::CollectionBase
#include <podio/UserDataCollection.h>

Collection of basic types for additional user data not defined in the EDM.

The data is stored in an std::vector<basic_type>. Supported are all basic types supported in PODIO, i.e. float, double and 8-64 bit fixed size signed and unsigned integers -

See also

SupportedUserDataTypes.

Author

F.Gaede, DESY

Date

Sep 2021

Public Types

using value_type = typename std::vector<BasicType>::value_type
using mutable_type = value_type
using const_iterator = typename std::vector<BasicType>::const_iterator
using iterator = typename std::vector<BasicType>::iterator
using difference_type = typename std::vector<BasicType>::difference_type
using size_type = typename std::vector<BasicType>::size_type
using const_reverse_iterator = typename std::vector<BasicType>::const_reverse_iterator
using reverse_iterator = typename std::vector<BasicType>::reverse_iterator

Public Functions

UserDataCollection() = default
inline UserDataCollection(std::vector<BasicType> &&vec)

Constructor from an existing vector (which will be moved from!)

UserDataCollection(const UserDataCollection&) = delete
UserDataCollection &operator=(const UserDataCollection&) = delete
UserDataCollection(UserDataCollection&&) = default
UserDataCollection &operator=(UserDataCollection&&) = default
~UserDataCollection() override = default
inline virtual void prepareForWrite() const override

prepare buffers for serialization

inline virtual void prepareAfterRead() override

re-create collection from buffers after read

inline virtual bool setReferences(const ICollectionProvider*) override

initialize references after read

inline virtual void setID(uint32_t id) override

set collection ID

inline virtual uint32_t getID() const override

get collection ID

inline virtual podio::CollectionWriteBuffers getBuffers() override

Get the collection buffers for this collection.

inline virtual bool isValid() const override

check for validity of the container after read

inline virtual size_t size() const override

number of elements in the collection

inline virtual size_t max_size() const override

maximal number of elements in the collection

inline virtual bool empty() const override

Is the collection empty.

inline virtual const std::string_view getTypeName() const override

fully qualified type name

inline virtual const std::string_view getValueTypeName() const override

fully qualified type name of elements - with namespace

inline virtual const std::string_view getDataTypeName() const override

fully qualified type name of stored POD elements - with namespace

inline virtual void clear() override

clear the collection and all internal states

inline virtual bool isSubsetCollection() const override

check if this collection is a subset collection - no subset possible

inline virtual void setSubsetCollection(bool) override

declare this collection to be a subset collection - no effect

inline virtual SchemaVersionT getSchemaVersion() const final

The schema version is fixed manually.

inline virtual void print(std::ostream &os = std::cout, bool flush = true) const override

Print this collection to the passed stream.

inline virtual size_t getDatamodelRegistryIndex() const override

Get the index in the DatatypeRegistry of the EDM this collection belongs to.

inline std::vector<BasicType>::reference create()
inline iterator begin()
inline iterator end()
inline const_iterator begin() const
inline const_iterator end() const
inline const_iterator cbegin() const
inline const_iterator cend() const
inline reverse_iterator rbegin()
inline const_reverse_iterator rbegin() const
inline const_reverse_iterator crbegin() const
inline reverse_iterator rend()
inline const_reverse_iterator rend() const
inline const_reverse_iterator crend() const
inline std::vector<BasicType>::reference operator[](size_t idx)
inline std::vector<BasicType>::const_reference operator[](size_t idx) const
inline std::vector<BasicType>::reference at(size_t idx)
inline std::vector<BasicType>::const_reference at(size_t idx) const
inline void resize(size_t count)
inline void push_back(const BasicType &value)
inline std::vector<BasicType> &vec()

access to the actual data vector

inline const std::vector<BasicType> &vec() const

const access to the actual data vector

Public Static Functions

static inline void __cppyy_pythonize__(PyObject *klass, const std::string &name)

Cppyy protocol to setup the pythonizations for this class. Not to be called directly.

Public Static Attributes

static SchemaVersionT schemaVersion = 1

The schema version of UserDataCollections.

static std::string_view typeName = userDataCollTypeName<BasicType>()
static std::string_view valueTypeName = userDataTypeName<BasicType>()
static std::string_view dataTypeName = userDataTypeName<BasicType>()
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 &operator=(const Writer&) = delete
Writer(Writer&&) = default
Writer &operator=(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

namespace Category

This namespace mimics an enum (at least in its usage) and simply defines either commonly used category names, or category names that form a convention.

Variables

const auto Event = "events"

The event category.

const auto Run = "runs"

The run category.

const auto Metadata = "metadata"

The metadata category that is used to store a single Frame that holds data that is valid for a whole file, for example collection level parameters.

namespace det

Typedefs

template<typename DefT, template<typename...> typename Op, typename ...Args>
using detected_or = detail::detector<DefT, void, Op, Args...>

Variables

template<template<typename...> typename Op, typename ...Args>
bool is_detected_v = requires { typename Op<Args...>; }
struct nonesuch
#include <podio/utilities/TypeHelpers.h>

Public Functions

~nonesuch() = delete
nonesuch(const nonesuch&) = delete
void operator=(const nonesuch&) = delete
namespace root_compat

Introduce a new namespace instead of potentially opening and polluting the ROOT namespace.

Typedefs

using RNTupleReader = ROOT::RNTupleReader
using REntry = ROOT::REntry
using RNTupleModel = ROOT::RNTupleModel
using RNTupleWriter = ROOT::RNTupleWriter
namespace root_utils

Typedefs

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

A collection name and a base pointer grouped together for writing.

Functions

GenericParameters loadParamsFrom(ROOT::VecOps::RVec<std::string> intKeys, ROOT::VecOps::RVec<std::vector<int>> intValues, ROOT::VecOps::RVec<std::string> floatKeys, ROOT::VecOps::RVec<std::vector<float>> floatValues, ROOT::VecOps::RVec<std::string> doubleKeys, ROOT::VecOps::RVec<std::vector<double>> doubleValues, ROOT::VecOps::RVec<std::string> stringKeys, ROOT::VecOps::RVec<std::vector<std::string>> stringValues)
struct CollectionBranches
#include <podio/utilities/RootHelpers.h>

Small helper struct to collect all branches that are necessary to read or write a collection.

Needed to cache the branch pointers and avoid having to get them from a TTree/TChain for every event.

Public Functions

CollectionBranches() = default
~CollectionBranches() = default
CollectionBranches(const CollectionBranches&) = delete
CollectionBranches &operator=(const CollectionBranches&) = delete
CollectionBranches(CollectionBranches&&) = default
CollectionBranches &operator=(CollectionBranches&&) = default
inline CollectionBranches(TBranch *dataBranch)

Public Members

TBranch *data = {nullptr}
std::vector<TBranch*> refs = {}
std::vector<TBranch*> vecs = {}
std::vector<std::string> refNames = {}

The names of the relation branches.

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

The names of the vector member branches.

struct CollectionWriteInfo
#include <podio/utilities/RootHelpers.h>

Public Members

uint32_t collectionID = {static_cast<uint32_t>(-1)}

collection id

std::string dataType = {}

The fully qualified data type of the collection.

bool isSubset = {false}

Whether this collection is a subset collection or not.

unsigned int schemaVersion = {0}

The schema version of the collection type.

std::string name = {}

The name of the collection.

std::string storageType = {}

The type in which the data is actually stored.

template<typename T>
struct ParamStorage
#include <podio/utilities/RootHelpers.h>

Pair of keys and values for one type of the ones that can be stored in GenericParameters.

Public Functions

ParamStorage() = default
~ParamStorage() = default
ParamStorage(const ParamStorage&) = delete
ParamStorage &operator=(const ParamStorage&) = delete
ParamStorage(ParamStorage&&) = default
ParamStorage &operator=(ParamStorage&&) = default
inline ParamStorage(std::tuple<std::vector<std::string>, std::vector<std::vector<T>>> keysValues)
inline auto keysPtr()

Get a pointer to the stored keys for binding it to a TBranch.

inline auto valuesPtr()

Get a pointer to the stored vectors for binding it to a TBranch.

Public Members

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

The keys for this type.

std::vector<std::vector<T>> values = {}

The values for this type.

namespace sio_helpers

Typedefs

using position_type = uint32_t

Variables

static uint32_t SIOTocMarker = 0xc001fea7

marker for showing that a TOC has been stored in the file

static int SIOTocInfoSize = sizeof(uint64_t)

the number of bits necessary to store the SIOTocMarker and the actual position of the start of the SIOFileTOCRecord

static const char *SIOTocRecordName = "podio_SIO_TOC_Record"

The name of the TOCRecord.

static const char *SIOEDMDefinitionName = "podio_SIO_EDMDefinitions"

The name of the record containing the EDM definitions in json format.

namespace utils

Functions

std::vector<std::string> expand_glob(const std::string &pattern)

Expands a given glob pattern into a list of matching file paths.

This function takes a glob pattern as input and returns a vector of strings containing the paths that match the pattern. It supports standard glob rules extended with tilde expansion and brace expansion. If the pattern doesn’t contain any wildcards then it is placed in the returned vector as is. Paths that cannot be accessed are displayed on std::cerr, but the expansion process is not aborted. On platforms without <glob.h> no expansion is done and vector containing the original pattern is returned

Parameters:

pattern – The glob pattern to expand.

Throws:

std::runtime_error – If no matches are found or if there is an error during glob expansion.

Returns:

A vector of strings containing the matching file paths.

bool is_glob_pattern(const std::string &pattern)

Checks if a given pattern is a glob pattern.

This function determines whether the provided pattern contains any standard glob or brace expansion wildcards.

Parameters:

pattern – The pattern to check.

Returns:

true if the pattern is a glob pattern, false otherwise.

template<typename T>
void swap(MaybeSharedPtr<T> &a, MaybeSharedPtr<T> &b)
inline std::vector<std::string> sortAlphabeticaly(std::vector<std::string> strings)

Sort the input vector of strings alphabetically, case insensitive.

Parameters:

strings – The strings that should be sorted alphabetically

Returns:

A vector of strings sorted alphabetically, case insensitive

inline auto splitString(const std::string_view str, const char delim)

Split a string (view) at the delimiter and return a range of views.

Parameters:
  • str – The string to split

  • delim – The delimeter at which to split

Returns:

A range of views into the original view

Variables

static auto MarkOwned = detail::MarkOwnedTag{}
template<const std::string_view&... strs>
std::string_view static_concatenate_v = static_concatenate<strs...>::value

Variable template for concatenating a set of string_views into a single string_view at compile time.

template<typename T>
class MaybeSharedPtr
#include <podio/utilities/MaybeSharedPtr.h>

“Semi-smart” pointer class for pointers that at some point during their lifetime might hand over management to another entity.

E.g. Objects that are added to a collection will hand over the management of their Obj* to collection. In such a case two things need to be considered:

  • Other Objects with the same Obj* instance should not delete the managed Obj*, even if the last Object goes out of scope

  • Even if the managed Obj* is gone (e.g. collection has gone out of scope or was cleared), the remaining Object instances should still be able to gracefully destruct, even if they are at this point merely an “empty husk” The MaybeSharedPtr achieves this by having an optional control block that controls the lifetime of itself and potentially the managed Obj*.

Public Functions

MaybeSharedPtr() = delete

There are no empty MaybeSharedPtrs.

inline explicit MaybeSharedPtr(T *p)

Constructor from raw pointer.

Assumes someone else manages the pointer already

inline explicit MaybeSharedPtr(T *p, detail::MarkOwnedTag)

Constructor from a raw pointer assuming ownership in the process.

inline MaybeSharedPtr(const MaybeSharedPtr &other)

Copy constructor.

inline MaybeSharedPtr &operator=(MaybeSharedPtr other)

Assignment operator.

inline MaybeSharedPtr(MaybeSharedPtr &&other)

Move constructor.

inline ~MaybeSharedPtr()

Destructor.

inline T *get() const

Get a raw pointer to the managed pointer.

Do not change anything concerning the management of the pointer

inline T *release()

Get a raw pointer to the managed pointer and assume ownership.

inline operator bool() const
inline T *operator->()
inline const T *operator->() const
inline T &operator*()
inline const T &operator*() const

Friends

template<typename U>
friend void swap(MaybeSharedPtr<U> &a, MaybeSharedPtr<U> &b)
template<const std::string_view&... strs>
struct static_concatenate
#include <podio/utilities/StaticConcatenate.h>

Helper struct to concatenate a set of string_views into a single string_view at compile time.

Public Static Functions

static inline auto init_arr()

Public Static Attributes

static auto array = init_arr()
static auto value = std::string_view(array.data(), array.size() - 1)
template<typename ...T>
struct TypeList
#include <podio/utilities/TypeHelpers.h>
namespace version

Functions

inline std::ostream &operator<<(std::ostream &os, const Version &v)
static Version decode_version(unsigned long version) noexcept

Decode a version from a 64 bit unsigned.

Variables

static Version build_version = {podio_VERSION_MAJOR, podio_VERSION_MINOR, podio_VERSION_PATCH}

The current build version.

struct Version
#include <podio/podioVersion.h>

Version class consisting of three 16 bit unsigned integers to hold the major, minor and patch version.

Provides constexpr comparison operators that allow one to use this class in constexpr-if clauses.

Public Members

uint16_t major = {0}
uint16_t minor = {0}
uint16_t patch = {0}

Friends

friend std::ostream &operator<<(std::ostream &os, const Version &v)