Convert .root file to .tex file

i try to use the following program to convert a .root file to a .tex file

// 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 *fname = “dna.root”,
const char *nname = "ntuple”) // <—- If needed, change this line.
{
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);
t->Scan("*");

t->SaveAs(“dump.xml”);
// t->SaveAs(TString::Format("%s.xml", nname));
delete f; // no longer needed (automatically deletes “t”)
}

my situation is shown in the following picture

what should i replace the"dna.root"and"ntuple" in the program shown ablve with?

There are no TTree objects in your “outputES134mm.root” file (there are only 5 histograms), so you cannot use the “dump.cxx” macro at all.

Thank you! But if there are some appropriate approaches to convert the histogram(such as the “edepHisto;1” in the “outputES134mm.root” shown in the picture above)?

Try to experiment with:
edepHisto->SaveAs(“histo.cxx”)
edepHisto->SaveAs(“histo.xml”)
edepHisto->Print(“range”);
edepHisto->Print(“all”);

Thank you! Truly grateful for your help.

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