Hello,
I am wondering if it is possible to scan a TTree into a text file, similar to:
tree->Scan(“*”); or tree->Scan(“var1:var2”);
, but the output is dumped into a text file rather than the terminal.
Thank you!
Hello,
I am wondering if it is possible to scan a TTree into a text file, similar to:
tree->Scan(“*”); or tree->Scan(“var1:var2”);
, but the output is dumped into a text file rather than the terminal.
Thank you!
Hi Deyan,
here is an exact same question (solved): Saving output as .txt file
Apologies, I don’t get it. I am running a code, which first undergoes a compilation. Can it be done from within the code?
Of course, I can program my own output stream, but I wonder if this is implemented already.
You mean you do things like
tree->Scan("*");
tree->Scan("var1:var2");
from within a compiled executable? You mentioned the terminal, so I assumed you do it like
$ root -l
root [0] tree->Scan("*");
root [1] tree->Scan("var1:var2");
From compile code, you can redirect the output to a text file by calling RedirectOutput
on gSystem
. See ROOT: TSystem Class Reference
Could you try
tree->SetScanField(0);
auto logname = TString(tree->GetName())+".log";
auto player = static_cast<TTreePlayer *>(tree->GetPlayer());
player->SetScanFileName(logname);
player->SetScanRedirect(true);
tree->Scan();
Thank you!