Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RNTupleContainer.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 // Root Database Container RNTuple implementation
6 //--------------------------------------------------------------------
7 // Author : M.Nowak
8 //====================================================================
9 #ifndef POOL_RNTUPLECONTAINER_H
10 #define POOL_RNTUPLECONTAINER_H 1
11 
12 // Framework include files
13 #include "StorageSvc/DbColumn.h"
15 #include "StorageSvc/DbDatabase.h"
16 
18 
19 #include "ROOT/RNTupleView.hxx"
20 
21 #include <memory>
22 #include <optional>
23 #include <string>
24 #include <vector>
25 
26 // Forward declarations
27 class TClass;
29 namespace RootStorageSvc { class RNTupleWriterHelper; }
30 
31 #if ROOT_VERSION_CODE < ROOT_VERSION( 6, 35, 0 )
32 namespace ROOT { using ROOT::Experimental::RNTupleView; }
33 namespace ROOT::Experimental { class RNTupleReader; }
34 namespace ROOT { using ROOT::Experimental::RNTupleReader; }
35 #else
36 namespace ROOT { class RNTupleReader; }
37 #endif
38 
39 /*
40  * POOL namespace declaration
41  */
42 namespace pool {
43 
44 // Forward declaration
45 class DbColumn;
46 class RootDatabase;
47 
55 {
57 
59  struct FieldDesc : public DbColumn
60  {
61  std::string fieldname;
62  std::optional< ROOT::RNTupleView<void> > view;
63  std::string sgkey;
64  TClass* clazz = nullptr;
65  void* object = nullptr;
66 
67  // if writing char* keep a copy here as an std::string
68  std::string str;
69 
70  // ---- extra variables used for AuxDyn attributes
71  // number of rows written to this branch so far
72  size_t rows_written = 0;
73 
74  // AuxDyn RNTuple reader (managed by the Database)
75  std::unique_ptr<RootAuxDynIO::IRootAuxDynReader> auxdyn_reader;
76 
77  // AuxDyn RNTuple writer
78  std::unique_ptr<RootAuxDynIO::IRNTupleAuxDynWriter> auxdyn_writer;
79 
80  FieldDesc(const DbColumn& c);
81  FieldDesc(FieldDesc const& other) = delete;
82  FieldDesc(FieldDesc&& other) = default;
83  ~FieldDesc() = default;
84 
85  FieldDesc& operator=(FieldDesc const& other) = delete;
87 
88  const std::string typeName();
89  };
90 
91  protected:
93  const DbTypeInfo* m_type{};
95  std::vector<FieldDesc> m_fieldDescs;
103  bool m_isDirty;
104 
107  int64_t m_indexBump;
109 
112 
114  ROOT::RNTupleReader* m_ntupleReader{};
115 
117  std::unique_ptr<RootAuxDynIO::IFactoryTool> m_auxDynTool;
118 
119  public:
122 
123  virtual ~RNTupleContainer();
124 
126  virtual DbStatus close() override final;
127 
129  virtual DbStatus open(DbDatabase& dbH, const std::string& nam,
131  DbAccessMode mod) override final;
132 
135  const std::string& nam) const override final;
136 
138 
142  virtual DbStatus getOption(DbOption& opt) override final;
143 
145 
149  virtual DbStatus setOption(const DbOption& opt) override final;
150 
152  virtual DbStatus isShapeSupported(const DbTypeInfo* typ) const override final;
153 
155  virtual uint64_t size() override final;
156 
158  const std::string& getName() const { return m_name; }
159 
162  bool isDirty() const { return m_isDirty; }
163 
165  void clearDirty() { m_isDirty = false; }
166 
168 
174  virtual DbStatus loadObject(void** ptr, ShapeH shape,
175  Token::OID_t& oid) override final;
176 
178  virtual DbStatus writeObject(ActionList::value_type&) override final;
179 
180  virtual uint64_t nextRecordId() override final;
181 
182  virtual void useNextRecordId(uint64_t nextID) override final;
183 
185  virtual DbStatus select(DbSelect& criteria) override final;
186 
188  using DbContainerImp::fetch;
189  virtual DbStatus fetch(DbSelect& sel) override final;
190 
192  virtual DbStatus transAct(Transaction::Action action) override final;
193 
195  virtual DbStatus save(DbObjectHandle<DbObject>& objH) override final;
196 
197  private:
200 };
201 
202 } // namespace pool
203 #endif
grepfile.info
info
Definition: grepfile.py:38
pool::RNTupleContainer::useNextRecordId
virtual void useNextRecordId(uint64_t nextID) override final
Suggest next Record ID for tbe next object written - used only with synced indexes.
pool::RNTupleContainer::FieldDesc
Definition of a field info structure.
Definition: RNTupleContainer.h:60
pool::DbAccessMode
int DbAccessMode
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:47
pool::RNTupleContainer::m_rootDb
RootDatabase * m_rootDb
Root database file reference.
Definition: RNTupleContainer.h:99
pool::RNTupleContainer::FieldDesc::auxdyn_writer
std::unique_ptr< RootAuxDynIO::IRNTupleAuxDynWriter > auxdyn_writer
Definition: RNTupleContainer.h:78
pool::DbObject
void DbObject
Definition: Database/APR/StorageSvc/StorageSvc/pool.h:35
pool::DbStatus
Definition: DbStatus.h:67
pool::RNTupleContainer::save
virtual DbStatus save(DbObjectHandle< DbObject > &objH) override final
Add single entry to container.
pool::RNTupleContainer::nextRecordId
virtual uint64_t nextRecordId() override final
Number of next record in the container (=size if no delete is allowed)
pool::RNTupleContainer::select
virtual DbStatus select(DbSelect &criteria) override final
Define selection criteria.
make_coralServer_rep.opt
opt
Definition: make_coralServer_rep.py:19
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
pool::RNTupleContainer::FieldDesc::sgkey
std::string sgkey
Definition: RNTupleContainer.h:63
pool::RNTupleContainer::loadObject
virtual DbStatus loadObject(void **ptr, ShapeH shape, Token::OID_t &oid) override final
Find object by object identifier and load it into memory.
pool
pool namespace
Definition: libname.h:15
pool::RNTupleContainer::isDirty
bool isDirty() const
Return true if this branch container was updated and it's TTree needs to be Filled.
Definition: RNTupleContainer.h:162
pool::RNTupleContainer::size
virtual uint64_t size() override final
Number of entries within the container.
pool::DbContainerImp::save
virtual DbStatus save(DbObjectHandle< DbObject > &objH) override
Add single entry to container.
pool::RNTupleContainer::m_type
const DbTypeInfo * m_type
reference to exact type description
Definition: RNTupleContainer.h:93
pool::RNTupleContainer::writeObject
virtual DbStatus writeObject(ActionList::value_type &) override final
Commit single entry to container.
pool::DbObjectHandle
Definition: DbContainer.h:37
pool::RNTupleContainer::m_isDirty
bool m_isDirty
flag set on writing to prevent double writes in the same commit
Definition: RNTupleContainer.h:103
pool::DbContainerImp::m_name
std::string m_name
Container name.
Definition: DbContainerImp.h:76
pool::RNTupleContainer::m_dbH
DbDatabase m_dbH
Parent Database handle.
Definition: RNTupleContainer.h:97
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
pool::RNTupleContainer::FieldDesc::fieldname
std::string fieldname
Definition: RNTupleContainer.h:61
pool::RNTupleContainer::getName
const std::string & getName() const
Return the name of the container.
Definition: RNTupleContainer.h:158
pool::RNTupleContainer::RNTupleContainer
RNTupleContainer()
Standard constructor.
DbColumn.h
pool::RNTupleContainer::FieldDesc::auxdyn_reader
std::unique_ptr< RootAuxDynIO::IRootAuxDynReader > auxdyn_reader
Definition: RNTupleContainer.h:75
pool::RNTupleContainer::open
virtual DbStatus open(DbDatabase &dbH, const std::string &nam, const DbTypeInfo *info, DbAccessMode mod) override final
Open the container for object access.
DbDatabase.h
pool::RNTupleContainer::FieldDesc::~FieldDesc
~FieldDesc()=default
pool::RNTupleContainer::setOption
virtual DbStatus setOption(const DbOption &opt) override final
Set options.
Token::OID_t
Definition: Token.h:24
pool::RNTupleContainer::m_indexMulti
const uint32_t m_indexMulti
Definition: RNTupleContainer.h:108
pool::ShapeH
const class Shape * ShapeH
Definition: DbContainerObj.h:27
pool::RNTupleContainer::m_fieldDescs
std::vector< FieldDesc > m_fieldDescs
List of field descriptors.
Definition: RNTupleContainer.h:95
RootAuxDynIO::IRNTupleAuxDynWriter
Interface for a RNTuple-based Writer that handles AuxDyn attributes Works in conjuction with the gene...
Definition: IRootAuxDynIO.h:78
pool::RNTupleContainer::m_indexSize
uint64_t m_indexSize
Definition: RNTupleContainer.h:106
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
pool::RNTupleContainer::getOption
virtual DbStatus getOption(DbOption &opt) override final
Access options.
pool::RNTupleContainer::close
virtual DbStatus close() override final
Close the container and deallocate resources.
pool::RNTupleContainer::FieldDesc::FieldDesc
FieldDesc(const DbColumn &c)
pool::DbOption
Definition: DbOption.h:36
pool::RNTupleContainer::m_ntupleReader
ROOT::RNTupleReader * m_ntupleReader
Internal cache of the native RNTupleReader.
Definition: RNTupleContainer.h:114
sel
sel
Definition: SUSYToolsTester.cxx:97
pool::RNTupleContainer::m_indexBump
int64_t m_indexBump
Definition: RNTupleContainer.h:107
pool::DbSelect
Definition: DbSelect.h:44
pool::RNTupleContainer
Definition: RNTupleContainer.h:55
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
pool::RNTupleContainer::isShapeSupported
virtual DbStatus isShapeSupported(const DbTypeInfo *typ) const override final
Ask if a given shape is supported.
pool::RNTupleContainer::m_ntupleWriter
RootStorageSvc::RNTupleWriterHelper * m_ntupleWriter
Internal cache of the RNTupleWriterHelper.
Definition: RNTupleContainer.h:111
pool::RNTupleContainer::m_index
uint64_t m_index
Definition: RNTupleContainer.h:105
pool::RNTupleContainer::FieldDesc::clazz
TClass * clazz
Definition: RNTupleContainer.h:64
pool::RNTupleContainer::FieldDesc::rows_written
size_t rows_written
Definition: RNTupleContainer.h:72
pool::RNTupleContainer::fetch
virtual DbStatus fetch(DbSelect &sel) override final
Fetch next object address of the selection to set token.
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
pool::RNTupleContainer::FieldDesc::operator=
FieldDesc & operator=(FieldDesc const &other)=delete
pool::Transaction
Definition: Transaction.h:26
pool::RNTupleContainer::initObjectFieldDesc
DbStatus initObjectFieldDesc(FieldDesc &dsc)
Init a field description for an object (i.e. find TClass etc.)
pool::RNTupleContainer::FieldDesc::typeName
const std::string typeName()
RootAuxDynIO::IRootAuxDynReader
Definition: IRootAuxDynIO.h:36
pool::RNTupleContainer::checkAccess
virtual DbStatus checkAccess(DbDatabase &dbH, const std::string &nam) const override final
Check if we can access the container for reading with the given type.
pool::RNTupleContainer::FieldDesc::view
std::optional< ROOT::RNTupleView< void > > view
Definition: RNTupleContainer.h:62
pool::RNTupleContainer::m_ioBytes
int m_ioBytes
Number of bytes written/read during last operation. Set to -1 if it failed.
Definition: RNTupleContainer.h:101
RootAuxDynIO
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
Definition: RNTupleContainer.h:28
pool::RNTupleContainer::FieldDesc::FieldDesc
FieldDesc(FieldDesc const &other)=delete
pool::DbColumn
Definition: DbColumn.h:35
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
RootStorageSvc::RNTupleWriterHelper
Definition: RNTupleWriterHelper.h:30
pool::RootDatabase
Definition: RootDatabase.h:59
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
DbContainerImp.h
pool::RNTupleContainer::~RNTupleContainer
virtual ~RNTupleContainer()
pool::RNTupleContainer::transAct
virtual DbStatus transAct(Transaction::Action action) override final
Execute transaction action.
pool::RNTupleContainer::clearDirty
void clearDirty()
Clear the dirty status (used after containing TTree was Filled)
Definition: RNTupleContainer.h:165
pool::DbContainerImp
Definition: DbContainerImp.h:44
pool::RNTupleContainer::FieldDesc::FieldDesc
FieldDesc(FieldDesc &&other)=default
pool::DbDatabase
Definition: DbDatabase.h:53
python.compressB64.c
def c
Definition: compressB64.py:93
pool::RNTupleContainer::m_auxDynTool
std::unique_ptr< RootAuxDynIO::IFactoryTool > m_auxDynTool
Factory object from AuxDynIO plugin that creates AuxDyn readers and writers.
Definition: RNTupleContainer.h:117
RootStorageSvc
Definition: RNTupleContainer.h:29
ROOT
Selection rules: declare transient members.
Definition: DataVector.h:580
pool::DbTypeInfo
Definition: DbTypeInfo.h:47
IRootAuxDynIO.h
pool::RNTupleContainer::FieldDesc::str
std::string str
Definition: RNTupleContainer.h:68
pool::RNTupleContainer::FieldDesc::operator=
FieldDesc & operator=(FieldDesc &&other)=default