Hey all,
I am using a root file to read values from it, the file is called main.root. The root file consists of a tree “myvalues” and several branches like “Energy”, “Momentum”, “Event”.
Now I would like to separate my main.root file in two different root files main1.root and main2.root depending on the Event Variable that can either be 0 or 1. In the case of 0, I would like to save all the values from this line in the table (Energy, Momentum, Event) in the file main1.root. When the Event Variable is 1, I would like to save all values (Energy, Momentum, Event) in the main2.root file.
I searched that this can be possible with the TTreeReaderValue.
TFile file(“main.root”);
TTree* tree = (TTree*) file.Get(“myvalues”);
TTreeReaderValue var_event(reader, “Event”);
TTreeReaderValue var_energy(reader, “Energy”);
while (reader.Next()) {
std::cout<< "Eventvalue: "<<*var_event<< std::endl;
}
Unfortunately I dont know how to save these values. Is this done with a chain?
_ROOT Version: 6.20.04
_Platform: Ubuntu 18.04.5 LTS (Bionic Beaver)
_Compiler: gcc -v 7.5.0