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
12#include "POOLCore/DbPrint.h"
13
14#include "GaudiKernel/IFileMgr.h"
15#include "GaudiKernel/SmartIF.h"
16#include "Gaudi/PluginService.h"
17
18#include <string>
19#include <memory>
20
21class TTree;
22class TFile;
23class IFileMgr;
24namespace ROOT {
25 class RNTupleModel;
26 class RNTupleWriter;
27 class RNTupleReader;
28}
29
30namespace pool {
31
32 class ISession;
33
34 namespace RootCollection {
35
36 class Attribute;
37
38 // Create and Overwrite is only option, we'll never update
39 constexpr const char* const poolOptToRootOpt[] = {"UPDATE", "READ"};
40 // Io flags are not constexpr
41 inline const Io::IoFlags poolOptToFileMgrOpt[] = { Io::WRITE|Io::APPEND, Io::READ };
42
52 class RootCollection : public ICollection, public APRMessaging {
53
54 public:
55 typedef Gaudi::PluginService::Factory<ICollection*( const CollectionDescription*, ICollection::OpenMode, ISession*)> Factory;
56
64
67
68
70 virtual void open() final override;
71
73 virtual void insertRow( const pool::CollectionRowBuffer& inputRowBuffer ) final override;
74
76 virtual void commit( bool restartTransaction = false ) final override;
77
79 virtual void close() final override;
80
82 virtual const CollectionDescription& description() const final override;
83
85 virtual ICollectionCursor& cursor() final override;
86
87 private:
88
91 RootCollection& operator = (const RootCollection &) = delete;
92
94 virtual void addTreeBranch( const std::string& name, const std::string& type_name );
95 void addField(ROOT::RNTupleModel* model, const std::string& field_name, const std::string& field_type);
96
97 void cleanup();
98
100
101 std::string m_name;
104 TFile* m_file;
105 TTree* m_tree;
106 std::unique_ptr<ROOT::RNTupleReader> m_reader;
108
110 bool m_open;
111
112 SmartIF<IFileMgr> m_fileMgr;
113 };
114 }
115}
116#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:23
OpenMode
Enumeration of the possible open modes of the collection.
Definition ICollection.h:26
ISession is the interface class for user (macroscopic) sessions Every transaction and connection to a...
Definition ISession.h:31
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.
Gaudi::PluginService::Factory< ICollection *(const CollectionDescription *, ICollection::OpenMode, ISession *)> Factory
virtual void commit(bool restartTransaction=false) final override
Commits the last changes made to the collection.
virtual ICollectionCursor & cursor() final override
Returns a cursor for the collection.
std::unique_ptr< ROOT::RNTupleReader > m_reader
RootCollection(const pool::CollectionDescription *description, pool::ICollection::OpenMode mode, pool::ISession *)
Constructor.
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[]
pool namespace
Definition libname.h:15
STL namespace.
#define private