17 #include "TClassEdit.h"
18 #include "TVirtualCollectionProxy.h"
20 #include "ROOT/RNTuple.hxx"
21 #include "ROOT/RNTupleReader.hxx"
22 #include "ROOT/RField.hxx"
26 #if ROOT_VERSION_CODE < ROOT_VERSION( 6, 35, 0 )
28 using ROOT::Experimental::RNTupleDescriptor;
29 using ROOT::Experimental::RFieldDescriptor;
30 using ROOT::Experimental::DescriptorId_t;
31 using ROOT::Experimental::kInvalidDescriptorId;
51 getAuxElementType(
bool standalone, std::string& elementTypeName,
const std::string& storageTypeName)
54 elementTypeName = storageTypeName;
56 if( elementTypeName ==
"std::uint64_t")
return &
typeid(
unsigned long long);
61 if( storageTypeName.rfind(
"vector<", 0) == 0
62 || storageTypeName.rfind(
"std::vector<", 0) == 0 ) {
64 if( !tclass )
return nullptr;
65 TVirtualCollectionProxy*
proxy = tclass->GetCollectionProxy();
66 if( !
proxy )
return nullptr;
67 if(
proxy->GetValueClass() ) {
68 elementTypeName =
proxy->GetValueClass()->GetName();
69 return proxy->GetValueClass()->GetTypeInfo();
72 elementTypeName = elemtype.getTypeName();
73 return elemtype.getTypeInfo();
76 if( storageTypeName.rfind(
"SG::PackedContainer<", 0) == 0) {
77 elementTypeName.clear();
82 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
83 TClassEdit::TSplitType
split( storageTypeName.c_str() );
84 if(
split.fElements.size() > 1 ) {
85 elementTypeName =
split.fElements[1];
88 if( !elementTypeName.empty() ) {
98 const ROOT::RNTupleDescriptor&
desc,
99 const std::string& field_prefix,
100 const std::string& attr_name,
101 const std::string& attr_type,
107 const ROOT::RNTupleDescriptor&
desc,
108 const std::string& field_prefix,
109 const std::string& attr_name,
110 const std::string& attr_type,
116 ROOT::DescriptorId_t did =
desc.FindFieldId (field_prefix + linked_attr);
117 if (did != ROOT::kInvalidDescriptorId) {
118 const ROOT::RFieldDescriptor& linked_f =
desc.GetFieldDescriptor (did);
119 linked_auxid = getAuxIdForAttribute (
r,
desc, field_prefix,
120 linked_attr, linked_f.GetTypeName(),
standalone);
122 if (linked_auxid == SG::null_auxid) {
124 msg <<
"Could not find linked variable for " << attr_name
125 <<
" type: " << attr_type;
134 const ROOT::RNTupleDescriptor&
desc,
135 const std::string& field_prefix,
136 const std::string& attr_name,
137 const std::string& attr_type,
141 if(auxid != SG::null_auxid)
145 const std::type_info* ti = getAuxElementType(
standalone, element_type, attr_type);
162 const std::string& field_type,
163 ROOT::RNTupleReader*
reader)
164 :
AthMessaging( std::string(
"RNTupleAuxDynReader[")+field_name+
"]" ),
165 m_storeFieldName( field_name ),
168 const std::string field_prefix = field_type +
"_";
176 TClass *tc = TClass::GetClass( field_type.c_str() );
178 TClass *storeTC = tc->GetBaseClass(
"SG::IAuxStoreHolder");
182 throw std::runtime_error(
string(
"Class ") + tc->GetName() +
" does not implement SG::IAuxStoreHolder");
185 throw std::runtime_error(
string(
"Class ") + field_type +
" could not be found");
199 for(
const auto &
f :
desc.GetTopLevelFields() ) {
200 const string field_name =
f.GetFieldName();
201 if( field_name.starts_with(field_prefix) ) {
202 const string attr_infile = field_name.substr(field_prefix.size());
204 const string field_type =
f.GetTypeName();
210 if( auxid != SG::null_auxid ) {
213 #if ROOT_VERSION_CODE < ROOT_VERSION( 6, 35, 0 )
222 msg <<
"Could not find auxid for " << attr_infile <<
" type: " << field_type
239 fieldInfo.
auxid = auxid;
261 if( !
store.standalone() and fieldInfo.
fieldName.rfind(
"SG::PackedContainer<", 0) == 0 )