quinnb
June 6, 2019, 10:02pm
1
I am reading from my input file:
TFile* file = TFile::Open(argv[1], “READ”);
myTree myInfo = myTree::ReadFrom(“myTree”, *file);
myTreeReader tree(*file);
I would like to print some information from a sub-sub branch of myTree. How would I do that? I know that to read “Information” from my top tree, I would do something like:
cout << Form(“Some Information”, myInfo.Information) << endl;
but I want to read from a sub-sub branch of this tree. How would I modify this print statement to do so?
Pnine
June 7, 2019, 9:32am
2
Hi,
RDataFrame might help:
ROOT::RDataFrame r("myTree",argv[1]);
r.Foreach([](typeOfInfo &i){cout << Form(“Some Information”, myInfo.Information) << endl;},{"myInfo.Information"});
Cheers
Cheers
Hi, thanks for your help! In my root file, my tree structure is:
myTree1
—myBranch1
------mySubBranch1
---------mySubSubBranch1
------------myInfo1
------------myInfo2
------------…
myTree2
…
How do I access myInfo1, myInfo2, etc.? I just need to print them using cout. I’m not sure I understand how your reply reaches into those sub sub branches.
Pnine
June 8, 2019, 11:19am
5
Hi,
I think you can access the nested data using dots. If you have dictionaries around for your classes, in the C++ code:
r.Foreach([](typeOfBranch &branch){cout << Form(“Some Information”, branch.subbranch1.myInfo1) << endl;},{"branch"});
if you do not, you can access them via the branch name:
r.Foreach([](typeOfInfo1 &i){cout << Form(“Some Information”, i) << endl;},{"branch.subbranch1.myInfo1"});
Cheers
system
Closed
June 22, 2019, 11:19am
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.