17 #include "TClassEdit.h"
18 #include "TVirtualCollectionProxy.h"
21 #include "ROOT/RNTuple.hxx"
22 #include "ROOT/RNTupleReader.hxx"
23 #include "ROOT/RField.hxx"
43 getAuxElementType(
bool standalone, std::string& elementTypeName,
const std::string& storageTypeName)
46 elementTypeName = storageTypeName;
48 if( elementTypeName ==
"std::uint64_t")
return &
typeid(
unsigned long long);
53 if( storageTypeName.rfind(
"vector<", 0) == 0
54 || storageTypeName.rfind(
"std::vector<", 0) == 0 ) {
56 if( !tclass )
return nullptr;
57 TVirtualCollectionProxy*
proxy = tclass->GetCollectionProxy();
58 if( !
proxy )
return nullptr;
59 if(
proxy->GetValueClass() ) {
60 elementTypeName =
proxy->GetValueClass()->GetName();
61 return proxy->GetValueClass()->GetTypeInfo();
64 elementTypeName = elemtype.getTypeName();
65 return elemtype.getTypeInfo();
68 if( storageTypeName.rfind(
"SG::PackedContainer<", 0) == 0) {
69 elementTypeName.clear();
74 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
75 TClassEdit::TSplitType
split( storageTypeName.c_str() );
76 if(
split.fElements.size() > 1 ) {
77 elementTypeName =
split.fElements[1];
80 if( !elementTypeName.empty() ) {
90 const ROOT::Experimental::RNTupleDescriptor&
desc,
91 const std::string& field_prefix,
93 const std::string& attr_type,
99 const ROOT::Experimental::RNTupleDescriptor&
desc,
100 const std::string& field_prefix,
102 const std::string& attr_type,
107 using ROOT::Experimental::DescriptorId_t;
108 using ROOT::Experimental::RFieldDescriptor;
109 using ROOT::Experimental::RNTupleDescriptor;
110 using ROOT::Experimental::kInvalidDescriptorId;
112 DescriptorId_t did =
desc.FindFieldId (field_prefix + linked_attr);
113 if (did != kInvalidDescriptorId) {
114 const RFieldDescriptor& linked_f =
desc.GetFieldDescriptor (did);
115 linked_auxid = getAuxIdForAttribute (
r,
desc, field_prefix,
116 linked_attr, linked_f.GetTypeName(),
standalone);
118 if (linked_auxid == SG::null_auxid) {
120 msg <<
"Could not find linked variable for " <<
attr_name
121 <<
" type: " << attr_type;
130 const ROOT::Experimental::RNTupleDescriptor&
desc,
131 const std::string& field_prefix,
133 const std::string& attr_type,
137 if(auxid != SG::null_auxid)
141 const std::type_info* ti = getAuxElementType(
standalone, element_type, attr_type);
158 const std::string& field_type,
160 :
AthMessaging( std::string(
"RNTupleAuxDynReader[")+field_name+
"]" ),
161 m_storeFieldName( field_name ),
164 const std::string field_prefix = field_type +
"_";
172 TClass *tc = TClass::GetClass( field_type.c_str() );
174 TClass *storeTC = tc->GetBaseClass(
"SG::IAuxStoreHolder");
178 throw std::runtime_error(
string(
"Class ") + tc->GetName() +
" does not implement SG::IAuxStoreHolder");
181 throw std::runtime_error(
string(
"Class ") + field_type +
" could not be found");
195 for(
const auto &
f :
desc.GetTopLevelFields() ) {
196 const string field_name =
f.GetFieldName();
197 if( field_name.rfind(field_prefix,0) == 0 ) {
198 const string attr_infile = field_name.substr(field_prefix.size());
200 const string field_type =
f.GetTypeName();
206 if( auxid != SG::null_auxid ) {
209 #if ROOT_VERSION_CODE >= ROOT_VERSION( 6, 33, 0 )
210 m_fieldInfos[auxid].view_p = std::make_unique<RNTupleView<void>>(
212 m_fieldInfos[auxid].view_p = std::make_unique<RNTupleView<void,true>>(
217 msg <<
"Could not find auxid for " << attr_infile <<
" type: " << field_type
234 fieldInfo.
auxid = auxid;
256 if( !
store.standalone() and fieldInfo.
fieldName.rfind(
"SG::PackedContainer<", 0) == 0 )