ATLAS Offline Software
Loading...
Searching...
No Matches
RootTreeContainer.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//====================================================================
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 <string>
22#include <string_view>
23#include <vector>
24#include <memory>
25
26// Forward declarations
27class StatucCode;
28class TBranch;
29class TTree;
30class TLeaf;
31class TClass;
32
33namespace RootAuxDynIO {
36 class IFactoryTool;
37}
38
39
40/*
41 * POOL namespace declaration
42 */
43namespace pool {
44
45 // Forward declaration
46 class DbColumn;
47 class RootDatabase;
48
62 {
63 protected:
64
66 struct BranchDesc {
67 TClass* clazz = nullptr;
68 TBranch* branch = nullptr;
69 TLeaf* leaf = nullptr;
70 void* object = nullptr;
71 void* buffer = nullptr;
72 const DbColumn* column = nullptr;
73
74 // ---- extra variables used for AuxDyn attributes
75 // number of rows written to this branch so far
76 size_t rows_written = 0;
77
80 // AuxDyn writer and the reader for this branch (object type)
81 std::unique_ptr<RootAuxDynIO::IRootAuxDynWriter> auxdyn_writer;
82 std::unique_ptr<RootAuxDynIO::IRootAuxDynReader> auxdyn_reader;
83
84
85 BranchDesc() = default;
86 BranchDesc(TClass* cl, TBranch* b, TLeaf* l, void* o, const DbColumn* c);
87 BranchDesc(BranchDesc && other) = default;
88 BranchDesc(BranchDesc const& other) = delete;
89
90 BranchDesc& operator=(BranchDesc const& other) = delete;
91 BranchDesc& operator=(BranchDesc && other) = default;
92 };
93
95 typedef std::vector<BranchDesc> Branches;
96
98 TTree* m_tree;
108 std::string m_branchName;
115
117 std::unique_ptr<RootAuxDynIO::IFactoryTool> m_auxDynTool;
118
119 private:
120
122 StatusCode addBranch( const DbColumn* col,
123 BranchDesc& dsc,
124 std::string_view desc);
125
127 StatusCode addObject( DbDatabase& dbH,
128 const DbColumn* col,
129 BranchDesc& dsc,
130 const std::string& desc,
131 int splitLevel,
132 int bufferSize,
133 int branchOffsetTabLen);
134
135 // Routine needed for TRANSACT_FLUSH, if branch is specified by user.
136 StatusCode finishTransAct();
137
139 TBranch* branch(const std::string& nam) const;
140
142 void setBranchOffsetTabLen(TBranch* b, int offsettab_len);
143
144 public:
145 explicit RootTreeContainer(const std::string& name);
147
149 virtual StatusCode close() override;
150
152 virtual StatusCode open(DbDatabase& dbH,
153 const std::string& nam,
154 const DbTypeInfo* info,
155 DbAccessMode mod) override;
156
158 virtual StatusCode checkAccess(DbDatabase& dbH,
159 const std::string& nam) const override final;
160
162
166 virtual StatusCode getOption(DbOption& opt) override;
167
169
173 virtual StatusCode setOption(const DbOption& opt) override;
174
176 virtual uint64_t size() override;
177
179 TTree* getTTree() { return m_tree; }
180
182 const std::string& getName() const { return m_name; }
183
185 bool isBranchContainer() const { return !m_branchName.empty(); }
186
188 void setTreeFillMode(bool mode);
189
191 bool usingTreeFillMode() const { return m_treeFillMode; }
192
194 bool isDirty() const { return m_isDirty; }
195
197 void clearDirty() { m_isDirty = false; }
198
200
206 virtual StatusCode loadObject( void** ptr, ShapeH shape,
207 Token::OID_t& oid) override;
208
210 virtual StatusCode writeObject(ActionList::value_type&) override;
211
213 virtual StatusCode transAct(Transaction::Action action) override;
214 };
215}
216#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:54
Description: Definition an option to be supplied to database objects.
Definition DbOption.h:36
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.
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.
StatusCode addBranch(const DbColumn *col, BranchDesc &dsc, std::string_view desc)
Add item branch.
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.
Framework include files.
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