Hello
I’m trying to create a tree with its branch determined by reading input, here is a example if the map contain 3 different module, but in the end, when I look at the out put file, the tree “t1” is empty, does anyone could help? Thanks.
sorry I miss a line when I copy and paste from my code, it is there but not work, the line is :
t1->Branch(Form("%s",map_it->first.c_str()),map_it->second);
inside the while loop, so the original code will be this :
TTree *t1 =new TTree(“t1”,"tree with ");
auto map_it = timingPerModule_.cbegin();
while (map_it != timingPerModule_.cend()){
cout<<“name = “<first<first.c_str()),map_it->second);
t1->Branch(Form(”%s”,map_it->first.c_str()),map_it->second);
map_it++;
}
t1->Fill();
I think that what you mean associate a branch to the tree, but it does not work, the tree is empty after fill and file write.
That’s what I also had tryied , by using &map_it->second, but it will return error before running and stop . error shows :
TTree.h:336:14: error: no matching member function for call to ‘BranchImpRef’
this looks like a problem linked to the fact that the addresses are temporary and not a root issue. A way in which you can overcome this hurdle if the keys of your map are always identical is to create for the N keys N fp numbers associated to N branches which you will update for every entry.