17 #include "TClassEdit.h"
18 #include "TVirtualCollectionProxy.h"
21 #include "ROOT/RNTuple.hxx"
22 #include "ROOT/RNTupleReader.hxx"
23 #include "ROOT/RField.hxx"
27 #if ROOT_VERSION_CODE >= ROOT_VERSION( 6, 35, 0 )
28 using ROOT::RNTupleDescriptor;
29 using ROOT::RFieldDescriptor;
30 using ROOT::DescriptorId_t;
31 using ROOT::kInvalidDescriptorId;
33 using ROOT::Experimental::RNTupleDescriptor;
34 using ROOT::Experimental::RFieldDescriptor;
35 using ROOT::Experimental::DescriptorId_t;
36 using ROOT::Experimental::kInvalidDescriptorId;
55 getAuxElementType(
bool standalone, std::string& elementTypeName,
const std::string& storageTypeName)
58 elementTypeName = storageTypeName;
60 if( elementTypeName ==
"std::uint64_t")
return &
typeid(
unsigned long long);
65 if( storageTypeName.rfind(
"vector<", 0) == 0
66 || storageTypeName.rfind(
"std::vector<", 0) == 0 ) {
68 if( !tclass )
return nullptr;
69 TVirtualCollectionProxy*
proxy = tclass->GetCollectionProxy();
70 if( !
proxy )
return nullptr;
71 if(
proxy->GetValueClass() ) {
72 elementTypeName =
proxy->GetValueClass()->GetName();
73 return proxy->GetValueClass()->GetTypeInfo();
76 elementTypeName = elemtype.getTypeName();
77 return elemtype.getTypeInfo();
80 if( storageTypeName.rfind(
"SG::PackedContainer<", 0) == 0) {
81 elementTypeName.clear();
86 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
87 TClassEdit::TSplitType
split( storageTypeName.c_str() );
88 if(
split.fElements.size() > 1 ) {
89 elementTypeName =
split.fElements[1];
92 if( !elementTypeName.empty() ) {
102 const RNTupleDescriptor&
desc,
103 const std::string& field_prefix,
105 const std::string& attr_type,
111 const RNTupleDescriptor&
desc,
112 const std::string& field_prefix,
114 const std::string& attr_type,
120 DescriptorId_t did =
desc.FindFieldId (field_prefix + linked_attr);
121 if (did != kInvalidDescriptorId) {
122 const RFieldDescriptor& linked_f =
desc.GetFieldDescriptor (did);
123 linked_auxid = getAuxIdForAttribute (
r,
desc, field_prefix,
124 linked_attr, linked_f.GetTypeName(),
standalone);
126 if (linked_auxid == SG::null_auxid) {
128 msg <<
"Could not find linked variable for " <<
attr_name
129 <<
" type: " << attr_type;
138 const RNTupleDescriptor&
desc,
139 const std::string& field_prefix,
141 const std::string& attr_type,
145 if(auxid != SG::null_auxid)
149 const std::type_info* ti = getAuxElementType(
standalone, element_type, attr_type);
166 const std::string& field_type,
168 :
AthMessaging( std::string(
"RNTupleAuxDynReader[")+field_name+
"]" ),
169 m_storeFieldName( field_name ),
172 const std::string field_prefix = field_type +
"_";
180 TClass *tc = TClass::GetClass( field_type.c_str() );
182 TClass *storeTC = tc->GetBaseClass(
"SG::IAuxStoreHolder");
186 throw std::runtime_error(
string(
"Class ") + tc->GetName() +
" does not implement SG::IAuxStoreHolder");
189 throw std::runtime_error(
string(
"Class ") + field_type +
" could not be found");
203 for(
const auto &
f :
desc.GetTopLevelFields() ) {
204 const string field_name =
f.GetFieldName();
205 if( field_name.rfind(field_prefix,0) == 0 ) {
206 const string attr_infile = field_name.substr(field_prefix.size());
208 const string field_type =
f.GetTypeName();
214 if( auxid != SG::null_auxid ) {
220 msg <<
"Could not find auxid for " << attr_infile <<
" type: " << field_type
237 fieldInfo.
auxid = auxid;
259 if( !
store.standalone() and fieldInfo.
fieldName.rfind(
"SG::PackedContainer<", 0) == 0 )