ATLAS Offline Software
RootAuxDynIO.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 #ifndef ROOTAUXDYN_IO_H
6 #define ROOTAUXDYN_IO_H
7 
8 #include "RVersion.h"
9 
10 #include <string>
11 #include <memory>
12 #include <vector>
13 #include <mutex>
14 #include <tuple>
16 
17 class TBranch;
18 class TTree;
19 class TFile;
20 class TClass;
21 
22 namespace ROOT::Experimental {
23  class RNTupleReader;
24  class RFieldBase;
25 }
26 namespace SG { class IAuxStoreIO; class auxid_set_t; }
27 
28 
29 namespace RootAuxDynIO
30 {
33  class IRootAuxDynReader;
34  class IRootAuxDynWriter;
35  class IRNTupleAuxDynWriter;
36  class IRNTupleWriter;
37 
39  bool hasAuxStore(std::string_view fieldname, TClass *tc);
40 
45  bool isAuxDynBranch(TBranch *branch);
46 
51  std::string getKeyFromBranch(TBranch* branch);
52 
53  std::unique_ptr<IRootAuxDynReader> getBranchAuxDynReader(TTree*, TBranch*);
54  std::unique_ptr<IRootAuxDynWriter> getBranchAuxDynWriter(TTree*, int bufferSize, int splitLevel,
55  int offsettab_len, bool do_branch_fill);
56 
57  std::unique_ptr<IRootAuxDynReader> getNTupleAuxDynReader(const std::string& field_name, const std::string& field_type, RNTupleReader* reader);
58  std::unique_ptr<IRNTupleAuxDynWriter> getNTupleAuxDynWriter();
59  std::unique_ptr<IRNTupleWriter> getNTupleWriter(TFile*, const std::string& ntupleName, bool enableBufferedWrite, bool enableMetrics);
60 
61  // The convention for the tuple is <name, type, data>
62  typedef std::tuple<std::string, std::string, void*> attrDataTuple;
63 
65  {
66  public :
75  virtual void addReaderToObject(void* object, size_t row, std::recursive_mutex* iomtx = nullptr) = 0;
76 
77  virtual const SG::auxid_set_t& auxIDs() const = 0;
78 
79  virtual size_t getBytesRead() const = 0;
80 
81  virtual void resetBytesRead() = 0;
82 
83  virtual ~IRootAuxDynReader() {}
84  };
85 
86 
89  public:
90  virtual ~IRootAuxDynWriter() {}
91 
94  // may throw exceptions
95  virtual int writeAuxAttributes(const std::string& base_branch, SG::IAuxStoreIO* store, size_t rows_written ) = 0;
96 
98  virtual bool needsCommit() = 0;
99 
101  virtual int commit() = 0;
102 
104  virtual void setBranchFillMode(bool) = 0;
105  };
106 
110  public:
112  virtual ~IRNTupleAuxDynWriter() = default;
113 
115  virtual std::vector<attrDataTuple> collectAuxAttributes( const std::string& base_branch, SG::IAuxStoreIO* store ) = 0;
116  };
117 
118 } // namespace
119 
120 #endif
query_example.row
row
Definition: query_example.py:24
SGTest::store
TestStore store
Definition: TestStore.cxx:23
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
RootAuxDynIO::getNTupleAuxDynWriter
std::unique_ptr< IRNTupleAuxDynWriter > getNTupleAuxDynWriter()
Definition: RootAuxDynIO.cxx:100
RootAuxDynIO::IRootAuxDynWriter::writeAuxAttributes
virtual int writeAuxAttributes(const std::string &base_branch, SG::IAuxStoreIO *store, size_t rows_written)=0
handle writing of dynamic xAOD attributes of an AuxContainer - called from RootTreeContainer::writeOb...
RootAuxDynIO::IRootAuxDynWriter
Interface for an AuxDyn Writer - TTree based.
Definition: RootAuxDynIO.h:88
RootAuxDynIO::attrDataTuple
std::tuple< std::string, std::string, void * > attrDataTuple
Definition: RootAuxDynIO.h:62
RootAuxDynIO::getNTupleWriter
std::unique_ptr< IRNTupleWriter > getNTupleWriter(TFile *, const std::string &ntupleName, bool enableBufferedWrite, bool enableMetrics)
RootAuxDynIO::IRootAuxDynReader::auxIDs
virtual const SG::auxid_set_t & auxIDs() const =0
RootAuxDynIO::IRootAuxDynReader::resetBytesRead
virtual void resetBytesRead()=0
RootAuxDynIO::IRootAuxDynWriter::~IRootAuxDynWriter
virtual ~IRootAuxDynWriter()
Definition: RootAuxDynIO.h:90
RootAuxDynIO::IRootAuxDynWriter::commit
virtual int commit()=0
Call Fill() on the ROOT object used by this writer.
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
RootAuxDynIO::IRNTupleAuxDynWriter::~IRNTupleAuxDynWriter
virtual ~IRNTupleAuxDynWriter()=default
Default Destructor.
RootAuxDynIO::IRNTupleAuxDynWriter::collectAuxAttributes
virtual std::vector< attrDataTuple > collectAuxAttributes(const std::string &base_branch, SG::IAuxStoreIO *store)=0
Collect Aux data information to be writting out.
RootAuxDynIO::IRootAuxDynWriter::setBranchFillMode
virtual void setBranchFillMode(bool)=0
set per-branch independent commit/fill mode
RootStorageSvc::RFieldBase
ROOT::Experimental::RFieldBase RFieldBase
Definition: RNTupleWriterHelper.h:22
RootAuxDynIO::IRNTupleAuxDynWriter
Interface for a RNTuple-based Writer that handles AuxDyn attributes Works in conjuction with the gene...
Definition: RootAuxDynIO.h:109
RootAuxDynIO::getNTupleAuxDynReader
std::unique_ptr< IRootAuxDynReader > getNTupleAuxDynReader(const std::string &field_name, const std::string &field_type, RNTupleReader *reader)
Definition: RootAuxDynIO.cxx:85
RootAuxDynDefs.h
RNTupleReader
ROOT::Experimental::RNTupleReader RNTupleReader
Definition: RNTCollectionSchemaEditor.h:21
RootAuxDynIO::getKeyFromBranch
std::string getKeyFromBranch(TBranch *branch)
Exctract the Aux object SG Key from the branch name.
Definition: RootAuxDynIO.cxx:40
RootAuxDynIO::getBranchAuxDynReader
std::unique_ptr< IRootAuxDynReader > getBranchAuxDynReader(TTree *, TBranch *)
Definition: RootAuxDynIO.cxx:80
RootAuxDynIO::IRootAuxDynReader::addReaderToObject
virtual void addReaderToObject(void *object, size_t row, std::recursive_mutex *iomtx=nullptr)=0
Attach specialized AuxStore for reading dynamic attributes.
RootAuxDynIO::IRootAuxDynReader::~IRootAuxDynReader
virtual ~IRootAuxDynReader()
Definition: RootAuxDynIO.h:83
RootAuxDynIO::hasAuxStore
bool hasAuxStore(std::string_view fieldname, TClass *tc)
check if a field/branch with fieldname and type tc has IAuxStore interface
Definition: RootAuxDynIO.cxx:30
RootAuxDynIO::IRootAuxDynReader
Definition: RootAuxDynIO.h:65
RootAuxDynIO
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
Definition: RNTupleContainer.h:26
RootAuxDynIO::isAuxDynBranch
bool isAuxDynBranch(TBranch *branch)
Check is a branch holds AuxStore objects.
Definition: RootAuxDynIO.cxx:60
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
RootAuxDynIO::getBranchAuxDynWriter
std::unique_ptr< IRootAuxDynWriter > getBranchAuxDynWriter(TTree *, int bufferSize, int splitLevel, int offsettab_len, bool do_branch_fill)
generate TBranchAuxDynWriter tree -> destination tree do_branch_fill -> flag telling to Fill each TBr...
Definition: RootAuxDynIO.cxx:95
RootAuxDynIO::IRootAuxDynWriter::needsCommit
virtual bool needsCommit()=0
is there a need to call commit()?
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
ROOT::Experimental
Definition: RNTCollection.h:28
collisions.reader
reader
read the goodrunslist xml file(s)
Definition: collisions.py:22
RootAuxDynIO::IRootAuxDynReader::getBytesRead
virtual size_t getBytesRead() const =0
xAOD::Utils::RNTupleReader
ROOT::Experimental::RNTupleReader RNTupleReader
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Utils.h:33