ATLAS Offline Software
Loading...
Searching...
No Matches
RootCollection.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ROOTCOLLECTION_ROOTCOLLECTION_H
6#define ROOTCOLLECTION_ROOTCOLLECTION_H
7
11#include "StorageSvc/DbPrint.h"
12
13#include "GaudiKernel/IFileMgr.h"
14#include "GaudiKernel/SmartIF.h"
15#include "Gaudi/PluginService.h"
16
17#include <string>
18#include <memory>
19
20class TTree;
21class TFile;
22class IFileMgr;
23namespace ROOT {
24 class RNTupleModel;
25 class RNTupleWriter;
26 class RNTupleReader;
27}
28
29namespace pool {
30
31 namespace PersistencySvc { class ISession; }
32
33 namespace RootCollection {
34
35 class Attribute;
36
37 // Create and Overwrite is only option, we'll never update
38 constexpr const char* const poolOptToRootOpt[] = {"UPDATE", "READ"};
39 // Io flags are not constexpr
40 inline const Io::IoFlags poolOptToFileMgrOpt[] = { Io::WRITE|Io::APPEND, Io::READ };
41
51 class RootCollection : public ICollection, public APRMessaging {
52
53 public:
54 typedef Gaudi::PluginService::Factory<ICollection*( const CollectionDescription*, ICollection::OpenMode, PersistencySvc::ISession*)> Factory;
55
63
66
67
69 virtual void open() final override;
70
72 virtual void insertRow( const pool::CollectionRowBuffer& inputRowBuffer ) final override;
73
75 virtual void commit( bool restartTransaction = false ) final override;
76
78 virtual void close() final override;
79
81 virtual const CollectionDescription& description() const final override;
82
84 virtual std::unique_ptr<ICollectionCursor> cursor() final override;
85
86 private:
87
90 RootCollection& operator = (const RootCollection &) = delete;
91
93 virtual void addTreeBranch( const std::string& name, const std::string& type_name );
94 void addField(ROOT::RNTupleModel* model, const std::string& field_name, const std::string& field_type);
95
96 void cleanup();
97
99
100 std::string m_name;
103 TFile* m_file;
104 TTree* m_tree;
105 std::unique_ptr<ROOT::RNTupleReader> m_reader;
107
109 bool m_open;
110
111 SmartIF<IFileMgr> m_fileMgr;
112 };
113 }
114}
115#endif
APRMessaging(const std::string &name)
An implementation used to define the properties of a collection to be constructed and to retrieve the...
A class representing a row of a collection.
An interface used to navigate the result of a query on a collection.
An interface to a storage technology specific collection of event references and attributes.
Definition ICollection.h:24
OpenMode
Enumeration of the possible open modes of the collection.
Definition ICollection.h:27
ISession is the interface class for user (macroscopic) sessions Every transaction and connection to a...
Definition ISession.h:40
virtual void open() final override
Explicitly re-opens the collection after it has been closed.
virtual void close() final override
Explicitly closes the collection.
virtual void insertRow(const pool::CollectionRowBuffer &inputRowBuffer) final override
Adds a new row of data to the collection.
virtual void addTreeBranch(const std::string &name, const std::string &type_name)
void addField(ROOT::RNTupleModel *model, const std::string &field_name, const std::string &field_type)
virtual const CollectionDescription & description() const final override
Returns an object used to describe the collection properties.
RootCollection(const pool::CollectionDescription *description, pool::ICollection::OpenMode mode, pool::PersistencySvc::ISession *session)
Constructor.
virtual void commit(bool restartTransaction=false) final override
Commits the last changes made to the collection.
PersistencySvc::ISession * m_session
std::unique_ptr< ROOT::RNTupleReader > m_reader
Gaudi::PluginService::Factory< ICollection *(const CollectionDescription *, ICollection::OpenMode, PersistencySvc::ISession *)> Factory
virtual std::unique_ptr< ICollectionCursor > cursor() final override
Returns a cursor for the collection.
std::unique_ptr< ROOT::RNTupleWriter > m_rntupleWriter
STL class.
Selection rules: declare transient members.
Definition DataVector.h:581
const Io::IoFlags poolOptToFileMgrOpt[]
constexpr const char *const poolOptToRootOpt[]
Framework include files.
Definition libname.h:15
STL namespace.
#define private