Making Tree using TSelector

I am using TSelector to analyze some nuclear data.
For this I firstly chain all root files having same Tree using TChain class and then analyse data using TSelector (do various operations with histograms).
Then I write the results (modified histograms) in another root file. I write using the Write() function and it writes the histograms as branches in the root file. I need these branches to be written in a new Tree in the output root file.
I tried it using Branch() function but it didn’t work for me.
ROOT Version: 6.14
Platform: Ubuntu 18.04LTS
Compiler: Not Provided


Do you need to write the histograms as branches of the output tree or just as regular objects?

In other words, do you need histograms per event or just once after the event loop finishes?


This tutorial might be helpful:

Yes yes, I need histograms as branches of the output tree.


Then I guess that in Begin you need to create the output tree and its histogram branches, and in Process (which runs for every entry) you have to Fill those branches.

How can I get total entries of tree after adding files using TChain
I am using the code:
TChain ch(“Tree1”);
Thank you.

std::cout << ch.GetEntries() << std::endl;

Using this I can get entries of TChain.
But my motto is to get entries in Process() function of TSelector so that I can fill histograms in a new tree there.

I do not understand what you are trying to achieve.

See various “selector” related links in this old post.

BTW. From inside of your “Bool_t Process(Long64_t entry)” method, you can access the “fReader” (and / or the “fChain”) data member.

You can access the data in the C-style branches from C++ interface classes. After initial setup, using these classes incurs almost no overhead. With these classes, data can be easily passed into external functions, unlike the hard-coded-in-your-header-file TSelector data members.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.