17#include "TClassEdit.h"
18#include "TVirtualCollectionProxy.h"
20#include "ROOT/RNTuple.hxx"
21#include "ROOT/RNTupleReader.hxx"
22#include "ROOT/RField.hxx"
42getAuxElementType(
bool standalone, std::string& elementTypeName,
const std::string& storageTypeName)
45 elementTypeName = storageTypeName;
47 if( elementTypeName ==
"std::uint64_t")
return &
typeid(
unsigned long long);
52 if( storageTypeName.rfind(
"vector<", 0) == 0
53 || storageTypeName.rfind(
"std::vector<", 0) == 0 ) {
55 if( !tclass )
return nullptr;
56 TVirtualCollectionProxy*
proxy = tclass->GetCollectionProxy();
57 if( !proxy )
return nullptr;
58 if(
proxy->GetValueClass() ) {
59 elementTypeName =
proxy->GetValueClass()->GetName();
60 return proxy->GetValueClass()->GetTypeInfo();
63 elementTypeName = elemtype.getTypeName();
64 return elemtype.getTypeInfo();
67 if( storageTypeName.rfind(
"SG::PackedContainer<", 0) == 0) {
68 elementTypeName.clear();
73 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
74 TClassEdit::TSplitType
split( storageTypeName.c_str() );
75 if(
split.fElements.size() > 1 ) {
76 elementTypeName =
split.fElements[1];
79 if( !elementTypeName.empty() ) {
89 const ROOT::RNTupleDescriptor& desc,
90 const std::string& field_prefix,
91 const std::string& attr_name,
92 const std::string& attr_type,
98 const ROOT::RNTupleDescriptor& desc,
99 const std::string& field_prefix,
100 const std::string& attr_name,
101 const std::string& attr_type,
107 ROOT::DescriptorId_t did =
desc.FindFieldId (field_prefix + linked_attr);
108 if (did != ROOT::kInvalidDescriptorId) {
109 const ROOT::RFieldDescriptor& linked_f =
desc.GetFieldDescriptor (did);
110 linked_auxid = getAuxIdForAttribute (
r, desc, field_prefix,
111 linked_attr, linked_f.GetTypeName(), standalone);
115 msg <<
"Could not find linked variable for " << attr_name
116 <<
" type: " << attr_type;
125 const ROOT::RNTupleDescriptor& desc,
126 const std::string& field_prefix,
127 const std::string& attr_name,
128 const std::string& attr_type,
136 const std::type_info* ti = getAuxElementType(standalone, element_type, attr_type);
140 SG::auxid_t linked_auxid = getLinkedAuxId (
r, desc, field_prefix, attr_name, attr_type, standalone);
142 return SG::getDynamicAuxID (*ti, attr_name, element_type, attr_type, standalone, linked_auxid);
153 const std::string& field_type,
154 ROOT::RNTupleReader* reader)
159 const std::string field_prefix = field_type +
"_";
161 m_key = m_storeFieldName.substr( field_type.size()+1 );
164 m_key = m_storeFieldName.substr( 0, m_storeFieldName.size() - 4 );
167 TClass *
tc = TClass::GetClass( field_type.c_str() );
169 TClass *storeTC =
tc->GetBaseClass(
"SG::IAuxStoreHolder");
173 throw std::runtime_error(
string(
"Class ") +
tc->GetName() +
" does not implement SG::IAuxStoreHolder");
176 throw std::runtime_error(
string(
"Class ") + field_type +
" could not be found");
190 for(
const auto &f : desc.GetTopLevelFields() ) {
191 const string field_name = f.GetFieldName();
192 if( field_name.starts_with(field_prefix) ) {
193 const string attr_infile = field_name.substr(field_prefix.size());
194 const string attr_name = reg.inputRename(
m_key, attr_infile);
195 const string field_type = f.GetTypeName();
197 SG::auxid_t auxid = getAuxIdForAttribute(reg, desc, field_prefix,
198 attr_name, field_type, standalone);
205 const std::string& tiname = (standalone and !reg.isLinked(auxid))? reg.getTypeName(auxid) : reg.getVecTypeName(auxid);
209 msg <<
"Could not find auxid for " << attr_infile <<
" type: " << field_type
210 <<
" standalone=" << standalone;
226 fieldInfo.
auxid = auxid;
248 if( !store.standalone() and fieldInfo.
fieldName.rfind(
"SG::PackedContainer<", 0) == 0 )
#define ATH_MSG_VERBOSE(x)
Hold information about an option setting request.
Handle mappings between names and auxid_t.
Exceptions that can be thrown from AthContainers.
MsgStream & msg() const
The standard message stream.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
void init(bool standalone)
initialize once the mode of the Aux store is known
FieldInfo & getFieldInfo(const SG::auxid_t &auxid, const SG::AuxStoreInternal &store)
get field informatino for auxid
std::string m_storeFieldName
ROOT::RNTupleReader * m_ntupleReader
RNTupleAuxDynReader(const std::string &field_name, const std::string &field_type, ROOT::RNTupleReader *reader)
create Reader for Aux attributes of an AuxContainer object stored in a given field
virtual void addReaderToObject(void *object, size_t row, std::recursive_mutex *iomtx=nullptr) override final
attach RNTupleAuxStore to the current Aux container @object
std::map< SG::auxid_t, FieldInfo > m_fieldInfos
bool addAuxID(const SG::auxid_t &id)
const std::type_info * getTypeInfo() const
Return the type_info for the described type.
const TClass * getClass() const
Return the ROOT class for the described type.
An auxiliary data store that holds data internally.
Handle mappings between names and auxid_t.
static std::string linkedName(const std::string &name)
Given a variable name, return the name of the corresponding linked variable.
static bool classNameHasLink(const std::string &className)
Test to see if a class name corresponds to a class with a linked variable.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Interface for objects taking part in direct ROOT I/O.
@ AST_ObjectStore
The store describes a single object.
Helper class to use to report a message.
Helper for emitting error messages.
Find the auxid for a dynamic branch.
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 auxFieldName(const std::string &attr_name, const std::string &baseName)
Construct field name for a given dynamic attribute.
static const auxid_t null_auxid
To signal no aux data item.
SG::auxid_t getDynamicAuxID(const std::type_info &ti, const std::string &name, const std::string &elementTypeName, const std::string &branch_type_name, bool standalone, SG::auxid_t linked_auxid)
Find the auxid for a dynamic branch.
size_t auxid_t
Identifier for a particular aux data item.