How to extract a data from dna.root file?

Fix missing ;
No dump.cxx is:

// Name this file “dump.cxx” and use as:
//
// root [0] .x dump.cxx("dump.txt")
//
// Produces “dump.txt” and “dump.xml” files.
//

void dump(const char *outputname = "dump.txt", const char *fname = "dna.root",
const char *nname = "ntuple")
{
if (!fname || !(*fname) || !nname || !(*nname)) return; // just a precaution

TFile *f = TFile::Open(fname, "READ");
if (!f) return; // just a precaution

TTree *t; f->GetObject(nname, t);
if (!t) { delete f; return; } // just a precaution

t->SetScanField(0);
 ((TTreePlayer *)t->GetPlayer())->SetScanRedirect(kTRUE)
 ((TTreePlayer *)t->GetPlayer())->SetScanFileName(outputname);
t->Scan("*");
t->SaveAs("dump.xml");

delete f; // no longer needed (automatically deletes "t")
}

No no errors, but no output files…

PS dna.root - https://www.file-up.org/9ofsmxb1dmqn

I can not download the file from this link. It ‘just’ bring to what seems like scams/fake-download etc…

The file ‘diump.txt’ is not even created?

Try to download root.dna from here - https://yadi.sk/d/8fN-s6zXz1gyKQ

Yes, dump.txt and dump.xml is not created. Nothing…

Note that there is no “ntuple” TTree in your “dna.root” TFile.

1 Like

Thanks!

const char *nname = "dna")

Solve the problem!

Sorry, works, but gives an error on a long tracks:

Error in <TBranch::TBranch::WriteBasketImpl>: basket's WriteBuffer failed.

What does it means?

Most likely the amount of data in that single entry for that single branch is reaching 1Gb (other less likely possibility included disk error). If this is the case, you will need to ask the branch to be split further. If it is already non-splittable but let us know the class layout and semantic content to see if we can come up with an alternative storage strategy.

Dear All, I also want to convert root file into text file, I tried the above code shared by # Wile_E_Coyote and still getting the below error;

,

My root file is attached.SPECT.root (551.2 KB)

Any help is highly appreciated
Thanks in advance

Thank you for your quick response;
I am using root 6 and entered the command in same ordered as you advised, you can see in the screenshot but still error; please see the screenshot below;

Please see where I am wrong;

Thank you

Dear #Wile_E_Coyote, I tired almost all the way mentioned in above threads but still unable to convert .root to .txt ,

I tried [ .> dump.txt
.x dump.cxx
.> ]
and another way [ .x dump.cxx(“dump.txt”) ]
annother way [ .> dump.txt
.x dump.cxx
root -l -q dump.cxx > dump.txt ]

Thanks for your cooperation.

Have a look inside the dump.cxx file. It needs you to provide 3 arguments (or change the defaults in the macro itself!), according to your files and trees:

root[] .x dump.cxx("myoutput.txt","myrootfile.root","mytreename")

and it creates “myoutput.txt” and “dump.xml” (the latter name is not in the arguments but obviously you can change the code).

Dear # Dastudillo thank you for your reply.

I already set the default arguments to my desired file names, moreover same arguments was also given while executing dump.cxx. image I wonder to see that the .x dump.cxx(“spect.txt”, “SPECT.root”,“mytree”) does nothing , text file only created after executing .> dump.txt file created ]

Still there is nothing in output please guide,

Note that there is no “mytreename” nor “mytree” TTree in your “SPECT.root” TFile.
Try:
[...]$ rootls -l SPECT.root

BTW. You can also try the latest “groot/cmd/root-ls”, “groot/cmd/root-dump” and another “groot/cmd/root2*” standalone utilities from the Go-HEP project.

BTW, I’ve put (thanks to Wile’s suggestion) a /dist/latest link that should always point to the latest release of Go-HEP binaries (ie: including binaries from groot, a pure-Go implementation of (a subset of) ROOT)

here: