PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio Namespace Reference

Namespaces

namespace  benchmark
 
namespace  detail
 
namespace  root_utils
 
namespace  sio_helpers
 
namespace  sio_utils
 
namespace  version
 

Classes

class  ASCIIWriter
 
class  CollectionBase
 
class  CollectionIDTable
 
struct  CollectionReadBuffers
 
struct  CollectionWriteBuffers
 
struct  ColWriter
 
struct  ColWriterBase
 
class  DatamodelDefinitionCollector
 
class  DatamodelDefinitionHolder
 
class  DatamodelRegistry
 
class  EventStore
 
class  Frame
 
class  GenericParameters
 
class  ICollectionProvider
 
class  IMetaDataProvider
 
class  IReader
 
class  ObjBase
 
class  ObjectID
 
class  PythonEventStore
 
class  RelationRange
 
class  ROOTFrameData
 
class  ROOTFrameReader
 
class  ROOTFrameWriter
 
class  ROOTLegacyReader
 
class  ROOTReader
 
class  ROOTWriter
 
class  SIOBlock
 Base class for sio::block handlers used with PODIO. More...
 
class  SIOBlockFactory
 factory for creating sio::blocks for a given type of EDM-collection More...
 
class  SIOBlockLibraryLoader
 
class  SIOBlockUserData
 
class  SIOCollectionIDTableBlock
 
class  SIOEventMetaDataBlock
 
class  SIOFileTOCRecord
 
struct  SIOFileTOCRecordBlock
 
class  SIOFrameData
 
class  SIOFrameReader
 
class  SIOFrameWriter
 
class  SIOLegacyReader
 
struct  SIOMapBlock
 
class  SIONumberedMetaDataBlock
 
class  SIOReader
 
struct  SIOVersionBlock
 
class  SIOWriter
 
class  TimedReader
 
class  TimedWriter
 
class  UserDataCollection
 

Typedefs

typedef std::map< std::string, ColWriterBase * > FunMap
 
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 * > >
 
typedef std::map< int, GenericParametersRunMDMap
 
typedef std::map< int, GenericParametersColMDMap
 
template<typename T >
using EnableIfCollection = typename std::enable_if_t< isCollection< T > >
 Alias template for enabling overloads only for Collections.
 
template<typename T >
using EnableIfCollectionRValue = typename std::enable_if_t< isCollection< T > &&!std::is_lvalue_reference_v< T > >
 Alias template for enabling overloads only for Collection r-values.
 
template<typename T >
using EnableIfRValue = typename std::enable_if_t<!std ::is_lvalue_reference_v< T > >
 Alias template for enabling overloads for r-values.
 
using SupportedGenericDataTypes = std::tuple< int, float, std::string, double >
 The types which are supported in the GenericParameters.
 
template<typename T >
using EnableIfValidGenericDataType = typename std::enable_if_t< isSupportedGenericDataType< T > >
 
template<typename T >
using GenericDataReturnType = typename detail::GenericDataReturnTypeHelper< T >::type
 
typedef std::vector< int > IntVec
 
typedef std::vector< float > FloatVec
 
typedef std::vector< std::string > StringVec
 
using SupportedUserDataTypes = std::tuple< float, double, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t >
 
template<typename T >
using EnableIfSupportedUserType = std::enable_if_t< detail::isInTuple< T, SupportedUserDataTypes > >
 

Functions

template<typename FrameDataT >
std::optional< podio::CollectionReadBuffersunpack (FrameDataT *data, const std::string &name)
 
template<typename devT , typename PODData >
void handlePODDataSIO (devT &device, 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<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
constexpr const char * userDataTypeName ()
 
template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::ostream & operator<< (std::ostream &o, const podio::UserDataCollection< BasicType > &coll)
 
std::unique_ptr< podio::IReadercreateReader (const std::string &filename)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const std::vector< T > &values)
 
template<typename MapType >
void printMap (const MapType &map, std::ostream &os)
 
std::tuple< std::vector< root_utils::CollectionBranches >, std::vector< std::pair< std::string, detail::CollectionInfo > > > createCollectionBranches (TChain *chain, const podio::CollectionIDTable &idTable, const std::vector< root_utils::CollectionInfoT > &collInfo)
 
std::vector< std::string > getAvailableCategories (TChain *metaChain)
 
void writeGenericParameters (sio::write_device &device, const GenericParameters &params)
 
void readGenericParameters (sio::read_device &device, GenericParameters &params, sio::version_type version)
 

Detailed Description

This is an example event store

The event store holds the object collections.

It is used to create new collections, and to access existing ones. When accessing a collection that is not yet in the event store, the event store makes use of a Reader to read the collection.

Typedef Documentation

◆ CollRefCollection

using podio::CollRefCollection = typedef std::vector<UVecPtr<podio::ObjectID> >

Definition at line 19 of file CollectionBuffers.h.

◆ ColMDMap

typedef std::map<int, GenericParameters> podio::ColMDMap

Definition at line 35 of file EventStore.h.

◆ EnableIfCollection

template<typename T >
using podio::EnableIfCollection = typedef typename std::enable_if_t<isCollection<T> >

Alias template for enabling overloads only for Collections.

Definition at line 24 of file Frame.h.

◆ EnableIfCollectionRValue

template<typename T >
using podio::EnableIfCollectionRValue = typedef typename std::enable_if_t<isCollection<T> && !std::is_lvalue_reference_v<T> >

Alias template for enabling overloads only for Collection r-values.

Definition at line 28 of file Frame.h.

◆ EnableIfRValue

template<typename T >
using podio::EnableIfRValue = typedef typename std::enable_if_t<!std ::is_lvalue_reference_v<T> >

Alias template for enabling overloads for r-values.

Definition at line 32 of file Frame.h.

◆ EnableIfSupportedUserType

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

Alias template to be used to enable template specializations only for the types listed in the SupportedUserDataTypes list

Definition at line 33 of file UserDataCollection.h.

◆ EnableIfValidGenericDataType

template<typename T >
using podio::EnableIfValidGenericDataType = typedef typename std::enable_if_t<isSupportedGenericDataType<T> >

Alias template to be used for enabling / disabling template overloads that should only be present for actually supported data types

Definition at line 29 of file GenericParameters.h.

◆ FloatVec

typedef std::vector<float> podio::FloatVec

Definition at line 61 of file GenericParameters.h.

◆ FunMap

typedef std::map<std::string, ColWriterBase*> podio::FunMap

Definition at line 32 of file ASCIIWriter.h.

◆ GenericDataReturnType

template<typename T >
using podio::GenericDataReturnType = typedef typename detail::GenericDataReturnTypeHelper<T>::type

Alias template for determining the appropriate return type for the passed in type

Definition at line 56 of file GenericParameters.h.

◆ IntVec

typedef std::vector<int> podio::IntVec

Definition at line 60 of file GenericParameters.h.

◆ RunMDMap

typedef std::map<int, GenericParameters> podio::RunMDMap

Definition at line 34 of file EventStore.h.

◆ StringVec

typedef std::vector<std::string> podio::StringVec

Definition at line 62 of file GenericParameters.h.

◆ SupportedGenericDataTypes

using podio::SupportedGenericDataTypes = typedef std::tuple<int, float, std::string, double>

The types which are supported in the GenericParameters.

Definition at line 20 of file GenericParameters.h.

◆ SupportedUserDataTypes

using podio::SupportedUserDataTypes = typedef 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

Definition at line 25 of file UserDataCollection.h.

◆ UVecPtr

template<typename T >
using podio::UVecPtr = typedef std::unique_ptr<std::vector<T> >

Definition at line 17 of file CollectionBuffers.h.

◆ VectorMembersInfo

using podio::VectorMembersInfo = typedef std::vector<std::pair<std::string, void*> >

Definition at line 20 of file CollectionBuffers.h.

Function Documentation

◆ createCollectionBranches()

std::tuple< std::vector< root_utils::CollectionBranches >, std::vector< std::pair< std::string, detail::CollectionInfo > > > podio::createCollectionBranches ( TChain *  chain,
const podio::CollectionIDTable idTable,
const std::vector< root_utils::CollectionInfoT > &  collInfo 
)

Definition at line 258 of file ROOTFrameReader.cc.

259 {
260
261 size_t collectionIndex{0};
262 std::vector<root_utils::CollectionBranches> collBranches;
263 collBranches.reserve(collInfo.size() + 1);
264 std::vector<std::pair<std::string, detail::CollectionInfo>> storedClasses;
265 storedClasses.reserve(collInfo.size());
266
267 for (const auto& [collID, collType, isSubsetColl] : collInfo) {
268 // We only write collections that are in the collectionIDTable, so no need
269 // to check here
270 const auto name = idTable.name(collID);
271
272 root_utils::CollectionBranches branches{};
273 const auto collectionClass = TClass::GetClass(collType.c_str());
274
275 // Need the collection here to setup all the branches. Have to manage the
276 // temporary collection ourselves
277 auto collection =
278 std::unique_ptr<podio::CollectionBase>(static_cast<podio::CollectionBase*>(collectionClass->New()));
279 collection->setSubsetCollection(isSubsetColl);
280
281 if (!isSubsetColl) {
282 // This branch is guaranteed to exist since only collections that are
283 // also written to file are in the info metadata that we work with here
284 branches.data = root_utils::getBranch(chain, name.c_str());
285 }
286
287 const auto buffers = collection->getBuffers();
288 for (size_t i = 0; i < buffers.references->size(); ++i) {
289 const auto brName = root_utils::refBranch(name, i);
290 branches.refs.push_back(root_utils::getBranch(chain, brName.c_str()));
291 }
292
293 for (size_t i = 0; i < buffers.vectorMembers->size(); ++i) {
294 const auto brName = root_utils::vecBranch(name, i);
295 branches.vecs.push_back(root_utils::getBranch(chain, brName.c_str()));
296 }
297
298 const std::string bufferClassName = "std::vector<" + collection->getDataTypeName() + ">";
299 const auto bufferClass = isSubsetColl ? nullptr : TClass::GetClass(bufferClassName.c_str());
300
301 storedClasses.emplace_back(name, std::make_tuple(bufferClass, collectionClass, collectionIndex++));
302 collBranches.push_back(branches);
303 }
304
305 return {collBranches, storedClasses};
306}
const std::string name(int collectionID) const
return name for given collection ID

◆ createReader()

std::unique_ptr< podio::IReader > podio::createReader ( const std::string &  filename)

Definition at line 10 of file IOHelpers.cc.

10 {
11 const auto fileEnding = [&filename]() -> std::string {
12 const auto n = filename.rfind('.');
13 if (n != std::string::npos) {
14 return filename.substr(n);
15 }
16 return "";
17 }();
18
19 if (fileEnding.empty()) {
20 return nullptr;
21 }
22
23 if (fileEnding == ".root") {
24 return std::make_unique<podio::ROOTReader>();
25 } else if (fileEnding == ".sio") {
26#if PODIO_ENABLE_SIO
27 return std::make_unique<podio::SIOReader>();
28#else
29 std::cerr << "PODIO: You are trying to open a .sio file but podio has not been built with SIO support\nMake sure "
30 "to build PODIO with SIO support to be able to read .sio files"
31 << std::endl;
32 return nullptr;
33#endif
34 } else {
35 return nullptr;
36 }
37}

Referenced by podio::PythonEventStore::PythonEventStore().

◆ getAvailableCategories()

std::vector< std::string > podio::getAvailableCategories ( TChain *  metaChain)

Definition at line 178 of file ROOTFrameReader.cc.

178 {
179 auto* branches = metaChain->GetListOfBranches();
180 std::vector<std::string> brNames;
181 brNames.reserve(branches->GetEntries());
182
183 for (int i = 0; i < branches->GetEntries(); ++i) {
184 const std::string name = branches->At(i)->GetName();
185 const auto fUnder = name.find("___");
186 if (fUnder != std::string::npos) {
187 brNames.emplace_back(name.substr(0, fUnder));
188 }
189 }
190
191 std::sort(brNames.begin(), brNames.end());
192 brNames.erase(std::unique(brNames.begin(), brNames.end()), brNames.end());
193 return brNames;
194}

Referenced by podio::ROOTFrameReader::openFiles().

◆ handlePODDataSIO()

template<typename devT , typename PODData >
void podio::handlePODDataSIO ( devT &  device,
PODData *  data,
size_t  size 
)

Definition at line 25 of file SIOBlock.h.

25 {
26 unsigned count = size * sizeof(PODData);
27 char* dataPtr = reinterpret_cast<char*>(data);
28 device.data(dataPtr, count);
29}

Referenced by podio::SIOBlockUserData< BasicType, typename >::read(), and podio::SIOBlockUserData< BasicType, typename >::write().

◆ operator<<() [1/2]

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
std::ostream & podio::operator<< ( std::ostream &  o,
const podio::UserDataCollection< BasicType > &  coll 
)

Definition at line 224 of file UserDataCollection.h.

224 {
225 coll.print(o);
226 return o;
227}
void print(std::ostream &os=std::cout, bool flush=true) const override
Print this collection to the passed stream.

◆ operator<<() [2/2]

template<typename T >
std::ostream & podio::operator<< ( std::ostream &  os,
const std::vector< T > &  values 
)

Definition at line 114 of file GenericParameters.cc.

114 {
115 os << "[";
116 if (!values.empty()) {
117 os << values[0];
118 for (size_t i = 1; i < values.size(); ++i) {
119 os << ", " << values[i];
120 }
121 }
122
123 return os << "]";
124}

◆ printMap()

template<typename MapType >
void podio::printMap ( const MapType &  map,
std::ostream &  os 
)

Definition at line 127 of file GenericParameters.cc.

127 {
128 os << std::left << std::setw(30) << "Key "
129 << "Value " << '\n';
130 os << "--------------------------------------------------------------------------------\n";
131 for (const auto& [key, value] : map) {
132 os << std::left << std::setw(30) << key << value << '\n';
133 }
134}

Referenced by podio::GenericParameters::print().

◆ readGenericParameters()

void podio::readGenericParameters ( sio::read_device &  device,
GenericParameters params,
sio::version_type  version 
)

Definition at line 59 of file SIOBlock.cc.

59 {
60 readMapLike(device, params.getIntMap());
61 readMapLike(device, params.getFloatMap());
62 readMapLike(device, params.getStringMap());
63 if (version >= sio::version::encode_version(0, 2)) {
64 readMapLike(device, params.getDoubleMap());
65 }
66}
const StringMap & getStringMap() const
const IntMap & getIntMap() const
const FloatMap & getFloatMap() const
const DoubleMap & getDoubleMap() const
void readMapLike(sio::read_device &device, MapLikeT &map)
Read anything that iterates like an std::map.
Definition: SIOBlock.h:43

Referenced by podio::SIOEventMetaDataBlock::read(), and podio::SIONumberedMetaDataBlock::read().

◆ readMapLike()

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

Read anything that iterates like an std::map.

Definition at line 43 of file SIOBlock.h.

43 {
44 int size;
45 device.data(size);
46 while (size--) {
48 device.data(key);
50 device.data(value);
51 if constexpr (podio::detail::isVector<MapLikeT>) {
52 map.emplace_back(std::move(key), std::move(value));
53 } else {
54 map.emplace(std::move(key), std::move(value));
55 }
56 }
57}
typename MapLikeTypeHelper< T >::mapped_type GetMappedType
Definition: TypeHelpers.h:159
typename MapLikeTypeHelper< T >::key_type GetKeyType
Definition: TypeHelpers.h:156

Referenced by podio::SIOMapBlock< KeyT, ValueT >::read(), and readGenericParameters().

◆ unpack()

template<typename FrameDataT >
std::optional< podio::CollectionReadBuffers > podio::unpack ( FrameDataT *  data,
const std::string &  name 
)

Definition at line 61 of file Frame.h.

61 {
62 return data->getCollectionBuffers(name);
63}

◆ userDataTypeName()

template<typename BasicType , typename = EnableIfSupportedUserType<BasicType>>
constexpr const char * podio::userDataTypeName ( )
constexpr

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

◆ writeGenericParameters()

void podio::writeGenericParameters ( sio::write_device &  device,
const GenericParameters params 
)

Definition at line 52 of file SIOBlock.cc.

52 {
53 writeMapLike(device, params.getIntMap());
54 writeMapLike(device, params.getFloatMap());
55 writeMapLike(device, params.getStringMap());
56 writeMapLike(device, params.getDoubleMap());
57}
void writeMapLike(sio::write_device &device, const MapLikeT &map)
Write anything that iterates like an std::map.
Definition: SIOBlock.h:33

Referenced by podio::SIOEventMetaDataBlock::write(), and podio::SIONumberedMetaDataBlock::write().

◆ writeMapLike()

template<typename MapLikeT >
void podio::writeMapLike ( sio::write_device &  device,
const MapLikeT &  map 
)

Write anything that iterates like an std::map.

Definition at line 33 of file SIOBlock.h.

33 {
34 device.data((int)map.size());
35 for (const auto& [key, value] : map) {
36 device.data(key);
37 device.data(value);
38 }
39}

Referenced by podio::SIOMapBlock< KeyT, ValueT >::write(), and writeGenericParameters().