Root to ascii format

Dear all,

I would like to know if there is a way to convert root files to ascii.
I have not found until now clear indications on this issue.

Thank you,
Ana.

A root file can contain many things such as histograms and trees. You need to be more specific in what data you want to have in ascii format.

You also need to specify what you mean by “ascii format”.

ROOT already allows creating TFiles in XML format (which might actually be
UTF-8), which can I think save pretty much any ROOT object, e.g.

TFile* f = TFile::Open("f.xml", "recreate");
TH1* h = new TH1D("h","", 100,-10,10);
h.Draw();
gPad->Write();

but that might not be what you wanted.

Just my snarky 2¢.

Thanks for your replies.

I have two sets of ROOT files: file1 containing a Tree with corresponding Branches and file2 containing only histograms.

Indeed converting my ROOT files to XML format would already help. Could you be more specific on how to do that for my file1.root and file2.root?

Thanks,
Ana.

If you simply want to merge the two files, ROOT’s hadd should already do all you want.

$ hadd merged.xml file1.root file2.root

I wasn’t trying to be serious when mentioning XML output since it can be a pain to parse.

Hi Ana,

[quote]Indeed converting my ROOT files to XML format would already help. Could you be more specific on how to do that for my file1.root and file2.root?[/quote]What is goal are you trying to reach by writing a ROOT file in ASCII? [In the general case ROOT file contain a lot of data and wading through them visually and/or in a unstructured file format can be a pain]. Are you trying to be able to directly/visually read the data? Are you trying to convert to a format readable for some other software (which one)?

The XML format written by ROOT does not support TTree at the moment.

Cheers,
Philippe.