How can I save the scanned entries of a tree in text file

Hello experts, I want to scan three variables of my TTree “Events” which gives me 2233395 entries. as
and get all the entries in rows and columns. Now I want to save these entries in a text file like “output.txt”. How can I do this…???

You can read the values using TTreeReader (tutorial), and just write them to a text file using something like

myFile << *value1 << "\t" << *value2 << ...

with a std::fstream.

1 Like

Dear Stephan Hageboeck, thanks for your reply.
Can I make it possible in interactive root mode…??
[root] Events->SetScanField(0);
[root] Events->Scan(“run:luminosityBlock:event”);
[root] …???

You can indeed. To find it, I went to the documentation for TTree::Scan. It says that you should refer to TTreePlayer::Scan() for details.

There is a section that tells you how to dump the entire thing.

1 Like

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