Hi all.
I have a function, buildTree, that takes a tree and analyses the branches. It loops over the branches in the tree, analyses their type via the GetExpectedType function from TBranchSTL and then does something with it, which doesn’t really matter for now. The problem I have is, that GetExpectedType(ctype, t) sets ctype to 0 for every branch in the tree and I do not really understand why.
Here’s the function:
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <TROOT.h>
#include <TLorentzVector.h>
#include <TBranch.h>
#include <TBranchSTL.h>
#include <TClass.h>
#include <TObjArray.h>
#include <TTree.h>
#include <TBits.h>
#include <TChain.h>
// [...]
void myClass::buildTree(TTree* tree) {
TObjArray* branches = tree -> GetListOfBranches();
string name;
EDataType t;
TClass* cc;
string type;
for(int ib = 0; ib < branches -> GetEntries(); ++ib) {
name = (string)( ((*branches)[ib]) -> GetName());
((TBranchSTL*)((*branches)[ib])) -> GetExpectedType(cc,t);
// vector or container
if( t == -1 )
type = (string)(cc -> GetName());
std::cout << "for " << name << " we find the type " << cc << " (" << type << ") " << std::endl;
// here we start doing something with it
// [...]
}
}
// [...]
This returns the full list of all branches in the tree, but at the place of cc it returns “0” and for type it returns nothing.
You have any idea on why this is?
Thank you in advance,
heico