23 using std::placeholders::_1;
24 void(TClass::*dxtor)(
void*, Bool_t) = &TClass::Destructor;
25 std::function<void(
void*)> del = std::bind(dxtor,
tclass, _1,
false);
43 int offsettab_len,
bool branch_fill ) :
55 if( offsettab_len > 0 ) {
56 if( b->GetEntryOffsetLen() > 0 )
57 b->SetEntryOffsetLen( offsettab_len );
58 TIter biter( b->GetListOfBranches() );
59 TBranch* subbranch(
nullptr);
60 while( (subbranch = (TBranch*)biter.Next()) ) {
69 std::string error_type(
"is unknown");
70 const std::type_info& ti = *info.typeinfo;
72 auto createBasicAuxBranch = [&](
const char* typeopt) {
73 info.is_basic_type =
true;
74 info.branch =
m_ttree->Branch(info.branch_name.c_str(), info.buffer, (info.name+typeopt).c_str(), 2048);
75 ATH_MSG_VERBOSE(
"Created branch with name=" << info.branch_name <<
" type: " << info.name+typeopt);
77 if ( ti ==
typeid(UInt_t) ) createBasicAuxBranch(
"/i");
78 else if( ti ==
typeid(Int_t) ) createBasicAuxBranch(
"/I");
79 else if( ti ==
typeid(Double_t) ) createBasicAuxBranch(
"/D");
80 else if( ti ==
typeid(Float_t) ) createBasicAuxBranch(
"/F");
81 else if( ti ==
typeid(Long64_t) or ti ==
typeid(std::int64_t) ) createBasicAuxBranch(
"/L");
82 else if( ti ==
typeid(ULong64_t) or ti ==
typeid(std::uint64_t) ) createBasicAuxBranch(
"/l");
83 else if( ti ==
typeid(Short_t) ) createBasicAuxBranch(
"/S");
84 else if( ti ==
typeid(UShort_t) ) createBasicAuxBranch(
"/s");
85 else if( ti ==
typeid(Char_t) ) createBasicAuxBranch(
"/B");
86 else if( ti ==
typeid(UChar_t) ) createBasicAuxBranch(
"/b");
87 else if( ti ==
typeid(
bool) ) createBasicAuxBranch(
"/O");
88 else if( ti ==
typeid(
char*) || ti ==
typeid(
unsigned char*) ) createBasicAuxBranch(
"/C");
90 TClass* cl = TClass::GetClass(info.type_name.c_str());
92 error_type =
" has no TClass";
93 }
else if( !cl->GetStreamerInfo() ) {
94 error_type =
" has no streamer";
95 }
else if( !cl->HasDictionary() ) {
96 error_type =
" has no dictionary";
100 info.branch =
m_ttree->Branch( info.branch_name.c_str(),
105 ATH_MSG_VERBOSE(
"Created branch with name=" << info.branch_name <<
" type: " << cl->GetName());
108 }
catch(
const std::exception& e ) {
109 error_type += std::string(
" Exception msg: ") + e.what();
112 error_type +=
" Unknown exception.";
116 throw std::runtime_error( std::string(
"Failed to create Auxiliary branch '") + info.branch_name
117 +
"'. Class: " + info.type_name + error_type );
120 info.branch->SetAutoDelete(kFALSE);
130 size_t backfill_nrows )
133 int bytes_written = 0;
138 for(
auto& aux_info_entry :
m_auxInfoMap ) aux_info_entry.second.written =
false;
145 attrInfo.
typeinfo = store->getIOType(
id);
154 if( backfill_nrows ) {
156 ATH_MSG_DEBUG(
" Backfilling " << backfill_nrows <<
" entries for " << attrInfo.
name);
161 for(
size_t r=0;
r<backfill_nrows; ++
r ) {
162 bytes_written += attrInfo.
branch->BackFill();
164 " Tree size=" <<
m_ttree->GetEntries()
165 <<
" branch size:" << attrInfo.
branch->GetEntries() );
176 AuxInfo& attrInfo = aux_info_entry.second;
184 bytes_written += attrInfo.
branch->Fill();
189 return bytes_written;
194 ATH_MSG_WARNING(
"Commit for TBranchAuxDynWriter should be handled on the DB level");
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Handle mappings between names and auxid_t.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
AuxDynAttrAccess(TClass &tc)
SG::IAuxStoreIO * castIOStore(void *object)
void setBranchOffsetTabLen(TBranch *b, int offsettab_len)
virtual int commit() override final
Call Fill() on the ROOT object used by this writer.
void createAuxBranch(AuxInfo &info)
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()
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)
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Interface providing I/O for a generic auxiliary store.
A set of aux data identifiers.
const std::string selection
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
std::string auxBranchName(const std::string &attr_name, const std::string &baseBranchName)
Construct branch name for a given dynamic attribute.
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
size_t auxid_t
Identifier for a particular aux data item.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
std::unique_ptr< void, std::function< void(void *)> > dummy_ptr_t
const std::type_info * typeinfo