Hi,
I’m looking to determine the storage type of some TLeaf(s) (which are contained within a TTree). I don’t want to open the file using ROOT script (I would rather just make the appropriate calls to the various libraries and determine the storage type within my own executable).
I do the following:
TKey * current_key = nullptr;
TTree * a_tree = nullptr;
TIter key_iterator(m_root_file_handle->GetListOfKeys());
while ((current_key = static_cast<TKey *> (key_iterator())))
{
TClass * current_key_class = gROOT->GetClass(current_key->GetClassName());
if (current_key_class->InheritsFrom(TTree::Class()))
{
a_tree = static_cast<TTree *> (current_key->ReadObj());
break;// get a hold of first TTree found in the file.
}
}
TObjArray * leaves_array = static_cast<TObjArray *> (a_tree->GetListOfLeaves());
const size_t leaves_array_size = leaves_array->GetEntriesFast();
for (size_t i_iter = 0; i_iter < leaves_array_size; ++i_iter)
{
TLeaf * leaf = static_cast<TLeaf *> (leaves_array->At(i_iter));
if (leaf->InheritsFrom(TLeafF::Class()))
{
//TLeafF or an array held by TLeafF
}
else if (leaf->InheritsFrom(TLeafI::Class()))
{
//TLeafI or an array held by TLeafI
}
//....
}
I’ve handled the primitive types that I’m interested in; However I was wondering what is the best way to detect if a TLeaf actually stores a std::vector<int>, std::vector<double>, std::vector<float>
?