ROOT file -> txt format

Thank you for your guidance,
The root files that are generated at the end of the execution are 3 files:

output.root
output_t0.root
output_t1.root

The following command for the output.root file
Runs properly:

root -b -l -q ‘dump.cxx (“dump.txt”, “output.root”, “ntuple / ntuple_1”)’

The dump.txt and dump.xml files are created and display the following message in the terminal:

+++++++++++++++++++++++++
Processing dump.cxx (“dump.txt”, “output.root”, “ntuple / ntuple_1”) …
File <dump.txt> created
Info in : ROOT file dump.xml has been created

+++++++++++++++++++++++++

But for files:

output_t0.root
output_t1.root

Displays the following error:

++++++++++++++++++++++++++++

Processing dump.cxx(“dump.txt”, “output_t1.root”, “ntuple/ntuple_1”)…
File <dump.txt> created
Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Info in TTree::SaveAs: ROOT file dump.xml has been created

++++++++++++++++++++++++++++++

See https://github.com/root-project/root/issues/10024 for TTree::SaveAs explicit disabling request.

@pcanal Note that, at least in some cases, it can work without reporting any errors, e.g., try ntuple->SaveAs("dump.xml") for the “hsimple.root” (from the “tutorials”).

Note that, at least in some cases, it can work without reporting any errors,

I see that too … However the xml file only contains the TTree object (meta-data) and none of the data. (i.e. unlikely to be the intended content)

Thank you for your valuable help, please help with the root file in the following format:

ttaching file output.root as _file0 …
(TFile *) 0x5556a033ddc0
TFile ** output.root
TFile * output.root
KEY: TH1D 1; 1 edep
KEY: TH1D 2; 1 cl size
KEY: TH1D 3; 1 Nsb
KEY: TH1D 4; 1 Ndb
KEY: TH1D 5; 1 Cdb

The .txt file will not be generated when I run the following command in the terminal:

root -b -l -q ‘dump.cxx (“dump.txt”, “output.root”, “1/ 1”)’

With respect ,
Spring_127

root -b -l -q output.root -e 'TH1 *h; gFile->GetObject("1", h); h->Print("all");' > h.out.txt

you could definitely use root2yoda for that:

which can be downloaded from:

Dear Wile_E_Coyote,

Thank you very much for your help.

dear sbinet,
Thank you for your help.

$ ./root2yoda-linux_amd64.exe output.root out.yoda


root2yoda: processing output.root
BEGIN YODA_HISTO1D_V2 /2
Path: /2
.
.
.
.
.
root2yoda: processing out.yoda
root2yoda: failed to open [out.yoda]: riofs: unable to open “out.yoda”: riofs: no ROOT plugin to open [out.yoda] (scheme=)


The output file was not created, only displayed on the terminal.

With respect,
zj

./root2yoda-linux_amd64.exe output.root > out.yoda
./root2yoda-linux_amd64.exe -o out.yoda output.root

Dear Wile_E_Coyote,

Thank you very much for your help.

With respect,
zj

did it work for what you wanted to achieve (at least for the histograms part)?

for the TTree part, root2csv could be an option (if the TTree is simple enough: just scalars, not std::vector<T> nor arrays or structs.)

(root2npy could be an option as well, but…)
it all depends on what you want to do with those ASCII files.

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