ATLAS Offline Software
Loading...
Searching...
No Matches
TBranchAuxDynWriter.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#ifndef TBRANCHAUXDYNWRITER_H
6#define TBRANCHAUXDYNWRITER_H
7
11#include "RootAuxDynIO.h"
12
13// Forward declarations
14class TFile;
15class TTree;
16class TBranch;
17class TClass;
18
19namespace RootAuxDynIO
20{
21
22 struct AuxInfo {
23 std::string name;
24 std::string type_name;
25 const std::type_info*typeinfo = nullptr;
26 std::string branch_name;
27 TBranch* branch = nullptr;
28 TClass* tclass = nullptr;
29 bool is_basic_type = false;
30 void* object = nullptr;
31 void* buffer = nullptr;
32 bool written = false;
33 size_t rows_written = 0;
34
35 // Dummy object instance; used when there was no request to write
36 // this branch but we need to write it anyway (for example,
37 // a dynamic variable that wasn't written on this event).
38 using dummy_ptr_t = std::unique_ptr<void, std::function<void(void*)> >;
40 void* dummy = 0;
41
42 void* setDummyAddr();
43
44 // get the right pointer to use with branch.setAddress() (different for objects and basic types)
45 void* objectAddr() { return is_basic_type? object : &object; }
46
47 ~AuxInfo();
48 };
49
50
52 {
53 public:
54 TBranchAuxDynWriter( TTree& tree, TClass& cls, int bufferSize, int splitLevel, int offsettab_len, bool branch_fill );
56
58 virtual void setBranchFillMode(bool mode) override final { m_branchFillMode = mode; }
59
60 // throws exceptions
61 void createAuxBranch( AuxInfo& info );
62
63 void setBranchOffsetTabLen(TBranch* b, int offsettab_len);
64
67 // throws exceptions
68 virtual int writeAuxAttributes( const std::string& base_branchname,
69 void *store,
70 size_t backfill_nrows ) override final;
71
72 virtual bool needsCommit() override final { return m_needsFill; }
73
74 virtual int commit() override final;
75
77 TFile* m_tfile = nullptr;
78 TTree* m_ttree = nullptr;
79 int m_bufferSize = 8192;
80 int m_splitLevel = 1;
82 bool m_branchFillMode = false;
83 bool m_needsFill = false;
84
87 };
88
89} // namespace
90#endif
An auxiliary data store that holds data internally.
#define protected
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Interface for an AuxDyn Writer - TTree based.
void setBranchOffsetTabLen(TBranch *b, int offsettab_len)
virtual int commit() override final
Call Fill() on the ROOT object used by this writer.
virtual bool needsCommit() override final
is there a need to call commit()?
virtual int writeAuxAttributes(const std::string &base_branchname, void *store, size_t backfill_nrows) override final
handle writing of dynamic xAOD attributes of an object called from RootTreeContainer::writeObject()
virtual void setBranchFillMode(bool mode) override final
set Filling mode (true/false) for branch containers
std::map< SG::auxid_t, AuxInfo > m_auxInfoMap
cached aux branches data by auxid
TBranchAuxDynWriter(TTree &tree, TClass &cls, int bufferSize, int splitLevel, int offsettab_len, bool branch_fill)
STL class.
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
Forward declaration.
STL namespace.
std::unique_ptr< void, std::function< void(void *)> > dummy_ptr_t
const std::type_info * typeinfo
TChain * tree