19 #include "TClassTable.h"
20 #include "TClassEdit.h"
21 #include "TVirtualCollectionProxy.h"
23 #include "TDictAttributeMap.h"
29 const std::type_info* dataTypeToTypeInfo (EDataType
type, std::string&
typeName)
33 return typ.getTypeInfo();
53 getAuxElementType( TClass *expectedClass, EDataType expectedType,
bool standalone,
54 std::string& elementTypeName, std::string& storageTypeName)
58 elementTypeName = expectedClass->GetName();
59 storageTypeName = elementTypeName;
60 return expectedClass->GetTypeInfo();
62 const std::type_info* ret = dataTypeToTypeInfo(expectedType, elementTypeName);
63 storageTypeName = elementTypeName;
68 if (!expectedClass)
return 0;
70 storageTypeName = expectedClass->GetName();
71 if (strncmp (expectedClass->GetName(),
"vector<", 7) == 0) {
72 TVirtualCollectionProxy* prox = expectedClass->GetCollectionProxy();
74 if (prox->GetValueClass()) {
75 elementTypeName = prox->GetValueClass()->GetName();
76 return prox->GetValueClass()->GetTypeInfo();
78 return dataTypeToTypeInfo (prox->GetType(), elementTypeName);
80 else if (strncmp (expectedClass->GetName(),
"SG::PackedContainer<", 20) == 0){
81 elementTypeName.clear();
86 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
87 TClassEdit::TSplitType
split (expectedClass->GetName());
88 if (
split.fElements.size() > 1) {
89 elementTypeName =
split.fElements[1];
92 if (!elementTypeName.empty()) {
94 return typ.getTypeInfo();
103 getAuxIdForAttribute(
const std::string& attr, TClass *tclass, EDataType edt,
bool standalone,
109 if(auxid != SG::null_auxid)
112 string elemen_type_name;
113 string branch_type_name;
114 const std::type_info* ti = getAuxElementType(tclass, edt,
standalone, elemen_type_name, branch_type_name);
130 sizeof(Long_t) ==
sizeof(Long64_t) ) {
139 std::ostringstream
msg;
140 msg <<
"SetBranchAddress() failed for " <<
branch->GetName() <<
" error=" << rc;
159 TClass *tc =
nullptr, *storeTC =
nullptr;
161 base_branch->GetExpectedType(tc,
type);
162 if( tc ) storeTC = tc->GetBaseClass(
"SG::IAuxStoreHolder");
167 msg <<
"IAuxStoreHolder interface not found in " <<
name <<
" - will not read dynamic attributes";
172 TObjArray *all_branches =
m_tree->GetListOfBranches();
173 for(
int i=0;
i<all_branches->GetEntriesFast();
i++ ) {
174 const char *bname = (*all_branches)[
i]->GetName();
175 if( strncmp(bname, branch_prefix.c_str(), branch_prefix.size()) == 0 ) {
176 const string attr_inFile = bname+branch_prefix.size();
177 const string attr =
r.inputRename (
m_key, attr_inFile);
185 const std::string& attr,
188 TClass* expectedClass = 0;
189 EDataType expectedType = kOther_t;
190 if(
branch->GetExpectedType(expectedClass, expectedType) != 0) {
196 std::string
className = expectedClass->GetName();
203 if (linked_auxid == SG::null_auxid) {
205 msg <<
"Could not find linked variable for " <<
branch->GetName()
206 <<
" type: " << expectedClass->GetName();
216 if (auxid != SG::null_auxid) {
220 msg <<
"Could not find auxid for " <<
branch->GetName()
221 <<
" type: " << expectedClass->GetName();
248 brInfo.
auxid = auxid;
270 brInfo.
branch =
m_tree->GetBranch( aux_branch_name.c_str() );
280 throw string(
"Error getting branch type for ") + brInfo.
branch->GetName();
283 if( !
store.standalone() )
284 if( brInfo.
tclass && strncmp( brInfo.
tclass->GetName(),
"SG::PackedContainer<", 20) == 0)
287 string elem_tname, branch_tname;
289 const std::type_info* ti = getAuxElementType( brInfo.
tclass, brInfo.
edtyp,
store.standalone(),
290 elem_tname, branch_tname );
291 const std::type_info* reg_ti =
r.getType(auxid);
293 const std::type_info *io_tinf =
store.getIOType(auxid);
294 const std::type_info *tcls_tinf = brInfo.
tclass ? brInfo.
tclass->GetTypeInfo() : ti;
298 throw string(
"Error getting IO type for AUX branch ") + brInfo.
branch->GetName();
303 io_tinf != tcls_tinf && (!tcls_tinf || strcmp(io_tinf->name(), tcls_tinf->name()) != 0)
304 : ti && ti != reg_ti && strcmp(ti->name(), reg_ti->name()) != 0;
309 msg <<
"attribute '" << brInfo.
attribName <<
"' (id=" << auxid
311 <<
") has different type than the branch: " << branch_tname;
312 msg <<
" Marking for schema evolution.";
314 brInfo.
SE_tclass = TClass::GetClass(*io_tinf);
317 brInfo.
SE_edt = TDataType::GetType(*io_tinf);
320 throw string(
"Error getting ROOT type for AUX branch ") + brInfo.
branch->GetName()
321 +
" typeinfo=" + io_tinf->name();