ATLAS Offline Software
TBranchAuxDynWriter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TBRANCHAUXDYNWRITER_H
6 #define TBRANCHAUXDYNWRITER_H
7 
11 
12 // Forward declarations
13 class TFile;
14 class TTree;
15 class TBranch;
16 class TClass;
17 
18 namespace RootAuxDynIO
19 {
20 
21  struct AuxInfo {
22  std::string name;
23  std::string type_name;
24  const std::type_info*typeinfo = nullptr;
25  std::string branch_name;
26  TBranch* branch = nullptr;
27  TClass* tclass = nullptr;
28  bool is_basic_type = false;
29  void* object = nullptr;
30  void* buffer = nullptr;
31  bool written = false;
32  size_t rows_written = 0;
33 
34  // Dummy object instance; used when there was no request to write
35  // this branch but we need to write it anyway (for example,
36  // a dynamic variable that wasn't written on this event).
37  using dummy_ptr_t = std::unique_ptr<void, std::function<void(void*)> >;
39  void* dummy = 0;
40 
41  void* setDummyAddr();
42 
43  // get the right pointer to use with branch.setAddress() (different for objects and basic types)
44  void* objectAddr() { return is_basic_type? object : &object; }
45 
46  ~AuxInfo();
47  };
48 
49 
51  {
52  public:
53  TBranchAuxDynWriter( TTree* tree, int bufferSize, int splitLevel, int offsettab_len, bool branch_fill );
54  virtual ~TBranchAuxDynWriter() { }
55 
57  virtual void setBranchFillMode(bool mode) override final { m_branchFillMode = mode; }
58 
59  // throws exceptions
60  void createAuxBranch( AuxInfo& info );
61 
62  void setBranchOffsetTabLen(TBranch* b, int offsettab_len);
63 
66  // throws exceptions
67  virtual int writeAuxAttributes( const std::string& base_branchname,
69  size_t backfill_nrows ) override final;
70 
71  virtual bool needsCommit() override final { return m_needsFill; }
72 
73  virtual int commit() override final;
74 
75  protected:
76  TFile* m_tfile = nullptr;
77  TTree* m_ttree = nullptr;
78  int m_bufferSize = 8192;
79  int m_splitLevel = 1;
81  bool m_branchFillMode = false;
82  bool m_needsFill = false;
83 
86  };
87 
88 } // namespace
89 #endif
grepfile.info
info
Definition: grepfile.py:38
RootAuxDynIO::AuxInfo
Definition: TBranchAuxDynWriter.h:21
SGTest::store
TestStore store
Definition: TestStore.cxx:23
RootAuxDynIO::TBranchAuxDynWriter::setBranchFillMode
virtual void setBranchFillMode(bool mode) override final
set Filling mode (true/false) for branch containers
Definition: TBranchAuxDynWriter.h:57
RootAuxDynIO::TBranchAuxDynWriter::m_tfile
TFile * m_tfile
Definition: TBranchAuxDynWriter.h:76
RootAuxDynIO::TBranchAuxDynWriter::createAuxBranch
void createAuxBranch(AuxInfo &info)
Definition: TBranchAuxDynWriter.cxx:67
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
RootAuxDynIO::TBranchAuxDynWriter
Definition: TBranchAuxDynWriter.h:51
RootAuxDynIO::AuxInfo::written
bool written
Definition: TBranchAuxDynWriter.h:31
RootAuxDynIO::AuxInfo::tclass
TClass * tclass
Definition: TBranchAuxDynWriter.h:27
RootAuxDynIO::IRootAuxDynWriter
Interface for an AuxDyn Writer - TTree based.
Definition: RootAuxDynIO.h:88
RootAuxDynIO::TBranchAuxDynWriter::m_ttree
TTree * m_ttree
Definition: TBranchAuxDynWriter.h:77
RootAuxDynIO::AuxInfo::setDummyAddr
void * setDummyAddr()
Definition: TBranchAuxDynWriter.cxx:19
tree
TChain * tree
Definition: tile_monitor.h:30
RootAuxDynIO::AuxInfo::name
std::string name
Definition: TBranchAuxDynWriter.h:22
RootAuxDynIO::AuxInfo::branch
TBranch * branch
Definition: TBranchAuxDynWriter.h:26
RootAuxDynIO::AuxInfo::type_name
std::string type_name
Definition: TBranchAuxDynWriter.h:23
RootAuxDynIO::AuxInfo::is_basic_type
bool is_basic_type
Definition: TBranchAuxDynWriter.h:28
protected
#define protected
Definition: DetDescrConditionsDict_dict_fixes.cxx:14
RootAuxDynIO::TBranchAuxDynWriter::setBranchOffsetTabLen
void setBranchOffsetTabLen(TBranch *b, int offsettab_len)
Definition: TBranchAuxDynWriter.cxx:53
RootAuxDynIO::TBranchAuxDynWriter::writeAuxAttributes
virtual int writeAuxAttributes(const std::string &base_branchname, SG::IAuxStoreIO *store, size_t backfill_nrows) override final
handle writing of dynamic xAOD attributes of an object called from RootTreeContainer::writeObject()
Definition: TBranchAuxDynWriter.cxx:127
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
RootAuxDynIO::AuxInfo::~AuxInfo
~AuxInfo()
Definition: TBranchAuxDynWriter.cxx:35
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
RootAuxDynIO::TBranchAuxDynWriter::m_branchFillMode
bool m_branchFillMode
Definition: TBranchAuxDynWriter.h:81
RootAuxDynIO::TBranchAuxDynWriter::commit
virtual int commit() override final
Call Fill() on the ROOT object used by this writer.
Definition: TBranchAuxDynWriter.cxx:203
RootAuxDynIO::AuxInfo::dummy
void * dummy
Definition: TBranchAuxDynWriter.h:39
RootAuxDynIO::TBranchAuxDynWriter::~TBranchAuxDynWriter
virtual ~TBranchAuxDynWriter()
Definition: TBranchAuxDynWriter.h:54
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
RootAuxDynIO::TBranchAuxDynWriter::m_needsFill
bool m_needsFill
Definition: TBranchAuxDynWriter.h:82
Preparation.mode
mode
Definition: Preparation.py:94
RootAuxDynIO::AuxInfo::typeinfo
const std::type_info * typeinfo
Definition: TBranchAuxDynWriter.h:24
RootAuxDynIO::AuxInfo::dummyptr
dummy_ptr_t dummyptr
Definition: TBranchAuxDynWriter.h:38
RootAuxDynIO::AuxInfo::object
void * object
Definition: TBranchAuxDynWriter.h:29
RootAuxDynIO::AuxInfo::rows_written
size_t rows_written
Definition: TBranchAuxDynWriter.h:32
RootAuxDynIO::TBranchAuxDynWriter::needsCommit
virtual bool needsCommit() override final
is there a need to call commit()?
Definition: TBranchAuxDynWriter.h:71
RootAuxDynIO::TBranchAuxDynWriter::m_splitLevel
int m_splitLevel
Definition: TBranchAuxDynWriter.h:79
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
RootAuxDynIO::AuxInfo::dummy_ptr_t
std::unique_ptr< void, std::function< void(void *)> > dummy_ptr_t
Definition: TBranchAuxDynWriter.h:37
RootAuxDynIO
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
Definition: RNTupleContainer.h:26
RootAuxDynIO::AuxInfo::objectAddr
void * objectAddr()
Definition: TBranchAuxDynWriter.h:44
AthMessaging.h
RootAuxDynIO.h
RootAuxDynIO::TBranchAuxDynWriter::TBranchAuxDynWriter
TBranchAuxDynWriter(TTree *tree, int bufferSize, int splitLevel, int offsettab_len, bool branch_fill)
Definition: TBranchAuxDynWriter.cxx:42
AuxStoreInternal.h
An auxiliary data store that holds data internally.
RootAuxDynIO::TBranchAuxDynWriter::m_auxInfoMap
std::map< SG::auxid_t, AuxInfo > m_auxInfoMap
cached aux branches data by auxid
Definition: TBranchAuxDynWriter.h:85
RootAuxDynIO::AuxInfo::branch_name
std::string branch_name
Definition: TBranchAuxDynWriter.h:25
RootAuxDynIO::TBranchAuxDynWriter::m_bufferSize
int m_bufferSize
Definition: TBranchAuxDynWriter.h:78
RootAuxDynIO::AuxInfo::buffer
void * buffer
Definition: TBranchAuxDynWriter.h:30
RootAuxDynIO::TBranchAuxDynWriter::m_branchOffsetTabLen
int m_branchOffsetTabLen
Definition: TBranchAuxDynWriter.h:80