ATLAS Offline Software
Loading...
Searching...
No Matches
RootTreeContainer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//====================================================================
6// Root Database implementation
7//--------------------------------------------------------------------
8//
9// Package : APR RootStorageSvc (former POOL project)
10//
11// Author : M.Frank M.Nowak S.Snyder
12//====================================================================
13#ifndef POOL_ROOTTREECONTAINER_H
14#define POOL_ROOTTREECONTAINER_H 1
15
16// Framework include files
19
20#include <map>
21#include <vector>
22#include <set>
23#include <functional>
24
25// Forward declarations
26class StatucCode;
27class TBranch;
28class TTree;
29class TLeaf;
30class TClass;
31
32namespace RootAuxDynIO {
35 class IFactoryTool;
36}
37
38
39/*
40 * POOL namespace declaration
41 */
42namespace pool {
43
44 // Forward declaration
45 class DbColumn;
46 class RootDatabase;
47
61 {
62 protected:
63
65 struct BranchDesc {
66 TClass* clazz = nullptr;
67 TBranch* branch = nullptr;
68 TLeaf* leaf = nullptr;
69 void* object = nullptr;
70 void* buffer = nullptr;
71 const DbColumn* column = nullptr;
72
73 // ---- extra variables used for AuxDyn attributes
74 // number of rows written to this branch so far
75 size_t rows_written = 0;
76
79 // AuxDyn writer and the reader for this branch (object type)
80 std::unique_ptr<RootAuxDynIO::IRootAuxDynWriter> auxdyn_writer;
81 std::unique_ptr<RootAuxDynIO::IRootAuxDynReader> auxdyn_reader;
82
83
84 BranchDesc() = default;
85 BranchDesc(TClass* cl, TBranch* b, TLeaf* l, void* o, const DbColumn* c);
86 BranchDesc(BranchDesc && other) = default;
87 BranchDesc(BranchDesc const& other) = delete;
88
89 BranchDesc& operator=(BranchDesc const& other) = delete;
90 BranchDesc& operator=(BranchDesc && other) = default;
91 };
92
94 typedef std::vector<BranchDesc> Branches;
95
97 TTree* m_tree;
107 std::string m_branchName;
114
116 std::unique_ptr<RootAuxDynIO::IFactoryTool> m_auxDynTool;
117
118 private:
119
121 StatusCode addBranch( const DbColumn* col,
122 BranchDesc& dsc,
123 const std::string& desc);
124
126 StatusCode addObject( DbDatabase& dbH,
127 const DbColumn* col,
128 BranchDesc& dsc,
129 const std::string& desc,
130 int splitLevel,
131 int bufferSize,
132 int branchOffsetTabLen);
133
134 // Routine needed for TRANSACT_FLUSH, if branch is specified by user.
135 StatusCode finishTransAct();
136
138 TBranch* branch(const std::string& nam) const;
139
141 void setBranchOffsetTabLen(TBranch* b, int offsettab_len);
142
143 public:
144 explicit RootTreeContainer(const std::string& name);
146
148 virtual StatusCode close() override;
149
151 virtual StatusCode open(DbDatabase& dbH,
152 const std::string& nam,
153 const DbTypeInfo* info,
154 DbAccessMode mod) override;
155
157 virtual StatusCode checkAccess(DbDatabase& dbH,
158 const std::string& nam) const override final;
159
161
165 virtual StatusCode getOption(DbOption& opt) override;
166
168
172 virtual StatusCode setOption(const DbOption& opt) override;
173
175 virtual uint64_t size() override;
176
178 TTree* getTTree() { return m_tree; }
179
181 const std::string& getName() const { return m_name; }
182
184 bool isBranchContainer() const { return !m_branchName.empty(); }
185
187 void setTreeFillMode(bool mode);
188
190 bool usingTreeFillMode() const { return m_treeFillMode; }
191
193 bool isDirty() const { return m_isDirty; }
194
196 void clearDirty() { m_isDirty = false; }
197
199
205 virtual StatusCode loadObject( void** ptr, ShapeH shape,
206 Token::OID_t& oid) override;
207
209 virtual StatusCode writeObject(ActionList::value_type&) override;
210
212 virtual StatusCode transAct(Transaction::Action action) override;
213 };
214}
215#endif //POOL_ROOTTREECONTAINER_H
Interface for an AuxDyn Writer - TTree based.
Description: Definition of the generic column in a (relational) Database.
Definition DbColumn.h:34
std::string m_name
Container name.
virtual std::string name() const override
Get container name.
DbContainerImp(const std::string &name)
Description: Handle managing a DbDatabaseObj, a generic Database object.
Definition DbDatabase.h:55
Description: Definition an option to be supplied to database objects.
Definition DbOption.h:37
Definition of class DbTypeInfo.
Definition DbTypeInfo.h:49
Description: ROOT specific implementation of Database file.
StatusCode addObject(DbDatabase &dbH, const DbColumn *col, BranchDesc &dsc, const std::string &desc, int splitLevel, int bufferSize, int branchOffsetTabLen)
Add BLOB.
std::string m_branchName
Branch name, if branch is specified by user.
const std::string & getName() const
return the name of the container
virtual StatusCode getOption(DbOption &opt) override
Access options.
DbDatabase m_dbH
Parent Database handle.
StatusCode addBranch(const DbColumn *col, BranchDesc &dsc, const std::string &desc)
Add item branch.
const DbTypeInfo * m_type
reference to exact type description
TBranch * branch(const std::string &nam) const
Access branch by name.
bool m_treeFillMode
if True, branch container will not use Branch->Fill() but will be filled with its Tree by the databas...
std::vector< BranchDesc > Branches
Definition of the branch container.
Branches m_branches
Branch map.
bool m_isDirty
flag set when a branch container was updated (but the branch was not Filled)
virtual StatusCode close() override
Close the container and deallocate resources.
RootTreeContainer(const std::string &name)
int m_ioBytes
Number of bytes written/read during last operation. Set to -1 if it failed.
TTree * getTTree()
return the TTree in which this container is stored
RootDatabase * m_rootDb
Root database file reference.
virtual uint64_t size() override
Number of entries within the container.
void clearDirty()
clear the dirty status (used after containing TTree was Filled)
virtual StatusCode loadObject(void **ptr, ShapeH shape, Token::OID_t &oid) override
Find object by object identifier and load it into memory.
void setTreeFillMode(bool mode)
set Tree Filling mode (true/false) for branch containers
TTree * m_tree
Reference to the root tree object.
void setBranchOffsetTabLen(TBranch *b, int offsettab_len)
Recursively set Offset Table length for a branch and it's subbranches.
bool isBranchContainer() const
is this a container in a TBranch? (regular ones take the whole TTree)
bool isDirty() const
return true if this branch container was updated and it's TTree needs to be Filled
virtual StatusCode writeObject(ActionList::value_type &) override
Commit single entry to container.
bool usingTreeFillMode() const
return true if this branch container is using TTree Filling mode
virtual StatusCode open(DbDatabase &dbH, const std::string &nam, const DbTypeInfo *info, DbAccessMode mod) override
Open the container for object access.
std::unique_ptr< RootAuxDynIO::IFactoryTool > m_auxDynTool
Factory object from AuxDynIO plugin that creates AuxDyn readers and writers.
virtual StatusCode transAct(Transaction::Action action) override
Execute Transaction action.
virtual StatusCode checkAccess(DbDatabase &dbH, const std::string &nam) const override final
Check if we can access the container for reading with the given type.
StatusCode finishTransAct()
virtual StatusCode setOption(const DbOption &opt) override
Set options.
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
pool namespace
Definition libname.h:15
const class Shape * ShapeH
Definiton of a branch descriptor.
BranchDesc & operator=(BranchDesc &&other)=default
BranchDesc(BranchDesc const &other)=delete
std::unique_ptr< RootAuxDynIO::IRootAuxDynWriter > auxdyn_writer
int aux_iostore_IFoffset
IOStore interface offset for object type in this branch (for casting)
std::unique_ptr< RootAuxDynIO::IRootAuxDynReader > auxdyn_reader
BranchDesc(TClass *cl, TBranch *b, TLeaf *l, void *o, const DbColumn *c)
BranchDesc & operator=(BranchDesc const &other)=delete
BranchDesc(BranchDesc &&other)=default