ATLAS Offline Software
RootTreeContainer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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
17 #include "StorageSvc/DbDatabase.h"
19 
20 #include <map>
21 #include <vector>
22 #include <set>
23 #include <functional>
24 
25 // Forward declarations
26 class TBranch;
27 class TTree;
28 class TLeaf;
29 class TClass;
30 
31 namespace SG { class IAuxStoreIO; }
32 namespace RootAuxDynIO {
33  class IRootAuxDynWriter;
34  class IRootAuxDynReader;
35 }
36 
37 
38 /*
39  * POOL namespace declaration
40  */
41 namespace pool {
42 
43  // Forward declaration
44  class DbColumn;
45  class RootDatabase;
46 
60  {
61  protected:
62 
64  struct BranchDesc {
65  TClass* clazz = nullptr;
66  TBranch* branch = nullptr;
67  TLeaf* leaf = nullptr;
68  void* object = nullptr;
69  void* buffer = nullptr;
70  const DbColumn* column = nullptr;
71 
72  // ---- extra variables used for AuxDyn attributes
73  // number of rows written to this branch so far
74  size_t rows_written = 0;
75 
78  // AuxDyn writer and the reader for this branch (object type)
79  std::unique_ptr<RootAuxDynIO::IRootAuxDynWriter> auxdyn_writer;
80  std::unique_ptr<RootAuxDynIO::IRootAuxDynReader> auxdyn_reader;
81 
82 
83  BranchDesc() = default;
84  BranchDesc(TClass* cl, TBranch* b, TLeaf* l, void* o, const DbColumn* c);
85  BranchDesc(BranchDesc && other) = default;
86  BranchDesc(BranchDesc const& other) = delete;
87 
88  BranchDesc& operator=(BranchDesc const& other) = delete;
91  };
92 
94  typedef std::vector<BranchDesc> Branches;
95 
97  TTree* m_tree;
107  std::string m_branchName;
113  bool m_isDirty;
114 
115  private:
116 
119  BranchDesc& dsc,
120  const std::string& desc);
121 
124  const DbColumn* col,
125  BranchDesc& dsc,
126  const std::string& desc,
127  int splitLevel,
128  int bufferSize,
129  int branchOffsetTabLen);
130 
132  DbStatus selectRow( const DataCallBack* call,
133  const Token::OID_t& linkH,
135 
136  // Routine needed for TRANSACT_FLUSH, if branch is specified by user.
138 
140  TBranch* branch(const std::string& nam) const;
141 
143  void setBranchOffsetTabLen(TBranch* b, int offsettab_len);
144 
145  public:
148 
151 
153  virtual DbStatus close() override;
154 
156  virtual DbStatus open(DbDatabase& dbH,
157  const std::string& nam,
158  const DbTypeInfo* info,
159  DbAccessMode mod) override;
160 
162 
166  virtual DbStatus getOption(DbOption& opt) override;
167 
169 
173  virtual DbStatus setOption(const DbOption& opt) override;
174 
176  virtual DbStatus isShapeSupported(const DbTypeInfo* typ) const override;
177 
179  virtual DbStatus select(DbSelect& criteria) override;
180 
182  virtual uint64_t size() override;
183 
185  TTree* getTTree() { return m_tree; }
186 
188  const std::string& getName() const { return m_name; }
189 
191  bool isBranchContainer() const { return !m_branchName.empty(); }
192 
194  void setTreeFillMode(bool mode);
195 
197  bool usingTreeFillMode() const { return m_treeFillMode; }
198 
200  bool isDirty() const { return m_isDirty; }
201 
203  void clearDirty() { m_isDirty = false; }
204 
206  virtual DbStatus fetch(DbSelect& sel) override;
207 
209  virtual DbStatus fetch(const Token::OID_t& linkH, Token::OID_t& stmt) override;
210 
212 
218  virtual DbStatus loadObject( void** ptr, ShapeH shape,
219  Token::OID_t& oid) override;
220 
222  virtual DbStatus writeObject(ActionList::value_type&) override;
223 
226  };
227 }
228 #endif //POOL_ROOTTREECONTAINER_H
grepfile.info
info
Definition: grepfile.py:38
pool::RootTreeContainer::setBranchOffsetTabLen
void setBranchOffsetTabLen(TBranch *b, int offsettab_len)
Recursively set Offset Table length for a branch and it's subbranches.
pool::DbAccessMode
int DbAccessMode
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:47
pool::RootTreeContainer::BranchDesc::auxdyn_reader
std::unique_ptr< RootAuxDynIO::IRootAuxDynReader > auxdyn_reader
Definition: RootTreeContainer.h:80
createCoolChannelIdFile.stmt
stmt
Definition: createCoolChannelIdFile.py:42
pool::RootTreeContainer::BranchDesc::branch
TBranch * branch
Definition: RootTreeContainer.h:66
pool::RootTreeContainer::BranchDesc::BranchDesc
BranchDesc(TClass *cl, TBranch *b, TLeaf *l, void *o, const DbColumn *c)
pool::DbStatus
Definition: DbStatus.h:67
pool::RootTreeContainer::m_branches
Branches m_branches
Branch map.
Definition: RootTreeContainer.h:101
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
pool::RootTreeContainer::m_treeFillMode
bool m_treeFillMode
if True, branch container will not use Branch->Fill() but will be filled with its Tree by the databas...
Definition: RootTreeContainer.h:111
make_coralServer_rep.opt
opt
Definition: make_coralServer_rep.py:19
pool::RootTreeContainer::close
virtual DbStatus close() override
Close the container and deallocate resources.
pool::RootTreeContainer::m_branchName
std::string m_branchName
Branch name, if branch is specified by user.
Definition: RootTreeContainer.h:107
pool::RootTreeContainer::getTTree
TTree * getTTree()
return the TTree in which this container is stored
Definition: RootTreeContainer.h:185
pool::RootTreeContainer::addBranch
DbStatus addBranch(const DbColumn *col, BranchDesc &dsc, const std::string &desc)
Add item branch.
pool::RootTreeContainer::BranchDesc::column
const DbColumn * column
Definition: RootTreeContainer.h:70
pool::RootTreeContainer::selectRow
DbStatus selectRow(const DataCallBack *call, const Token::OID_t &linkH, DbAccessMode mode)
Find entry identified by his number (=primary key) in the Database.
pool
pool namespace
Definition: libname.h:15
pool::RootTreeContainer::getName
const std::string & getName() const
return the name of the container
Definition: RootTreeContainer.h:188
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
pool::RootTreeContainer::RootTreeContainer
RootTreeContainer()
Standard constructor.
pool::DbContainerImp::m_name
std::string m_name
Container name.
Definition: DbContainerImp.h:76
pool::RootTreeContainer::usingTreeFillMode
bool usingTreeFillMode() const
return true if this branch container is using TTree Filling mode
Definition: RootTreeContainer.h:197
pool::RootTreeContainer::BranchDesc::rows_written
size_t rows_written
Definition: RootTreeContainer.h:74
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
pool::RootTreeContainer::~RootTreeContainer
virtual ~RootTreeContainer()
Standard destructor.
pool::RootTreeContainer::BranchDesc::getIOStorePtr
SG::IAuxStoreIO * getIOStorePtr()
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
DbDatabase.h
pool::RootTreeContainer::BranchDesc::operator=
BranchDesc & operator=(BranchDesc &&other)=default
pool::RootTreeContainer::m_tree
TTree * m_tree
Reference to the root tree object.
Definition: RootTreeContainer.h:97
Token::OID_t
Definition: Token.h:24
pool::RootTreeContainer::m_ioBytes
int m_ioBytes
Number of bytes written/read during last operation. Set to -1 if it failed.
Definition: RootTreeContainer.h:109
pool::RootTreeContainer::finishTransAct
DbStatus finishTransAct()
pool::ShapeH
const class Shape * ShapeH
Definition: DbContainerObj.h:27
pool::RootTreeContainer::getOption
virtual DbStatus getOption(DbOption &opt) override
Access options.
python.trfUtils.call
def call(args, bufsize=0, executable=None, stdin=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, message="", logger=msg, loglevel=None, timeout=None, retry=2, timefactor=1.5, sleeptime=10)
Definition: trfUtils.py:155
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
pool::RootTreeContainer::BranchDesc::BranchDesc
BranchDesc(BranchDesc &&other)=default
pool::RootTreeContainer::BranchDesc::auxdyn_writer
std::unique_ptr< RootAuxDynIO::IRootAuxDynWriter > auxdyn_writer
Definition: RootTreeContainer.h:79
pool::RootTreeContainer::BranchDesc
Definiton of a branch descriptor.
Definition: RootTreeContainer.h:64
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
pool::RootTreeContainer::branch
TBranch * branch(const std::string &nam) const
Access branch by name.
pool::DbOption
Definition: DbOption.h:36
sel
sel
Definition: SUSYToolsTester.cxx:97
pool::RootTreeContainer::open
virtual DbStatus open(DbDatabase &dbH, const std::string &nam, const DbTypeInfo *info, DbAccessMode mod) override
Open the container for object access.
pool::DbSelect
Definition: DbSelect.h:44
pool::RootTreeContainer::isBranchContainer
bool isBranchContainer() const
is this a container in a TBranch? (regular ones take the whole TTree)
Definition: RootTreeContainer.h:191
pool::RootTreeContainer::m_type
const DbTypeInfo * m_type
reference to exact type description
Definition: RootTreeContainer.h:99
pool::RootTreeContainer::m_rootDb
RootDatabase * m_rootDb
Root database file reference.
Definition: RootTreeContainer.h:105
pool::RootTreeContainer::Branches
std::vector< BranchDesc > Branches
Definition of the branch container.
Definition: RootTreeContainer.h:94
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
Preparation.mode
mode
Definition: Preparation.py:94
pool::RootTreeContainer
Definition: RootTreeContainer.h:60
pool::RootTreeContainer::transAct
virtual DbStatus transAct(Transaction::Action action) override
Execute Transaction action.
pool::RootTreeContainer::fetch
virtual DbStatus fetch(DbSelect &sel) override
Fetch next object address of the selection to set token.
pool::RootTreeContainer::isShapeSupported
virtual DbStatus isShapeSupported(const DbTypeInfo *typ) const override
Ask if a given shape is supported.
pool::RootTreeContainer::BranchDesc::aux_iostore_IFoffset
int aux_iostore_IFoffset
IOStore interface offset for object type in this branch (for casting)
Definition: RootTreeContainer.h:77
pool::RootTreeContainer::m_dbH
DbDatabase m_dbH
Parent Database handle.
Definition: RootTreeContainer.h:103
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
pool::Transaction::Action
Action
Definition: Transaction.h:34
pool::RootTreeContainer::writeObject
virtual DbStatus writeObject(ActionList::value_type &) override
Commit single entry to container.
query_example.col
col
Definition: query_example.py:7
RootAuxDynIO
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
Definition: RNTupleContainer.h:26
pool::DbColumn
Definition: DbColumn.h:35
pool::RootTreeContainer::select
virtual DbStatus select(DbSelect &criteria) override
Define selection criteria.
pool::RootTreeContainer::BranchDesc::buffer
void * buffer
Definition: RootTreeContainer.h:69
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
pool::RootDatabase
Definition: RootDatabase.h:59
pool::RootTreeContainer::BranchDesc::leaf
TLeaf * leaf
Definition: RootTreeContainer.h:67
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
DbContainerImp.h
pool::RootTreeContainer::m_isDirty
bool m_isDirty
flag set when a branch container was updated (but the branch was not Filled)
Definition: RootTreeContainer.h:113
pool::RootTreeContainer::size
virtual uint64_t size() override
Number of entries within the container.
pool::RootTreeContainer::loadObject
virtual DbStatus loadObject(void **ptr, ShapeH shape, Token::OID_t &oid) override
Find object by object identifier and load it into memory.
pool::RootTreeContainer::BranchDesc::operator=
BranchDesc & operator=(BranchDesc const &other)=delete
pool::RootTreeContainer::isDirty
bool isDirty() const
return true if this branch container was updated and it's TTree needs to be Filled
Definition: RootTreeContainer.h:200
pool::RootTreeContainer::BranchDesc::BranchDesc
BranchDesc()=default
pool::RootTreeContainer::clearDirty
void clearDirty()
clear the dirty status (used after containing TTree was Filled)
Definition: RootTreeContainer.h:203
pool::RootTreeContainer::BranchDesc::BranchDesc
BranchDesc(BranchDesc const &other)=delete
pool::RootTreeContainer::BranchDesc::clazz
TClass * clazz
Definition: RootTreeContainer.h:65
pool::DbContainerImp
Definition: DbContainerImp.h:44
pool::DbDatabase
Definition: DbDatabase.h:53
pool::RootTreeContainer::fetch
virtual DbStatus fetch(const Token::OID_t &linkH, Token::OID_t &stmt) override
Fetch refined object address. Default implementation returns identity.
python.compressB64.c
def c
Definition: compressB64.py:93
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
pool::RootTreeContainer::addObject
DbStatus addObject(DbDatabase &dbH, const DbColumn *col, BranchDesc &dsc, const std::string &desc, int splitLevel, int bufferSize, int branchOffsetTabLen)
Add BLOB.
pool::DbTypeInfo
Definition: DbTypeInfo.h:47
pool::RootTreeContainer::setOption
virtual DbStatus setOption(const DbOption &opt) override
Set options.
pool::RootTreeContainer::setTreeFillMode
void setTreeFillMode(bool mode)
set Tree Filling mode (true/false) for branch containers