Warning, file /include/k4FWCore/PodioDataSvc.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef FWCORE_PODIODATASVC_H
0020 #define FWCORE_PODIODATASVC_H
0021
0022 #include "GaudiKernel/DataSvc.h"
0023 #include "GaudiKernel/IConversionSvc.h"
0024
0025 #include <utility>
0026 #include "podio/CollectionBase.h"
0027 #include "podio/CollectionIDTable.h"
0028 #include "podio/Frame.h"
0029 #include "podio/ROOTFrameReader.h"
0030
0031 #include "k4FWCore/DataWrapper.h"
0032 class DataWrapperBase;
0033 class PodioOutput;
0034 template <typename T> class MetaDataHandle;
0035
0036
0037
0038
0039
0040
0041
0042 class PodioDataSvc : public DataSvc {
0043 template <typename T> friend class MetaDataHandle;
0044 friend class PodioOutput;
0045
0046 public:
0047 typedef std::vector<std::pair<std::string, podio::CollectionBase*>> CollRegistry;
0048
0049 StatusCode initialize() final;
0050 StatusCode reinitialize() final;
0051 StatusCode finalize() final;
0052 StatusCode clearStore() final;
0053 StatusCode i_setRoot(std::string root_path, IOpaqueAddress* pRootAddr) final;
0054 StatusCode i_setRoot(std::string root_path, DataObject* pRootObj) final;
0055
0056
0057 PodioDataSvc(const std::string& name, ISvcLocator* svc);
0058
0059
0060 virtual ~PodioDataSvc();
0061
0062
0063 using DataSvc::registerObject;
0064
0065
0066 virtual StatusCode registerObject(std::string_view parentPath, std::string_view fullPath,
0067 DataObject* pObject) override final;
0068
0069 const std::string_view getCollectionType(const std::string& collName);
0070
0071 template <typename T> StatusCode readCollection(const std::string& collName) {
0072 DataObject* objectPtr = nullptr;
0073 if (DataSvc::findObject("/Event", "/" + collName, objectPtr)) {
0074 debug() << "Collection " << collName << " already read, not reading it again" << endmsg;
0075 return StatusCode::SUCCESS;
0076 }
0077 const T* collection(nullptr);
0078 collection = static_cast<const T*>(m_eventframe.get(collName));
0079 if (collection == nullptr) {
0080 error() << "Collection " << collName << " does not exist." << endmsg;
0081 }
0082 auto wrapper = new DataWrapper<T>;
0083 wrapper->setData(collection);
0084 m_podio_datawrappers.push_back(wrapper);
0085 return DataSvc::registerObject("/Event", "/" + collName, wrapper);
0086 }
0087
0088 const podio::Frame& getEventFrame() const { return m_eventframe; }
0089
0090
0091 void endOfRead();
0092
0093
0094 podio::Frame& getMetaDataFrame() { return m_metadataframe; }
0095
0096 private:
0097
0098 podio::ROOTFrameReader m_reader;
0099
0100 podio::Frame m_eventframe;
0101
0102 podio::Frame m_metadataframe;
0103
0104 int m_eventNum{0};
0105
0106 int m_numAvailableEvents{-1};
0107 int m_requestedEventMax{-1};
0108
0109 bool m_reading_from_file{false};
0110
0111 SmartIF<IConversionSvc> m_cnvSvc;
0112
0113
0114 std::vector<DataWrapperBase*> m_podio_datawrappers;
0115
0116 protected:
0117
0118 std::vector<std::string> m_filenames;
0119 std::string m_filename;
0120
0121
0122 unsigned m_1stEvtEntry{0};
0123 bool m_bounds_check_needed{true};
0124 };
0125 #endif