XML data from TH3F

Hi, I’m a beginner in ROOT and I’m having trouble to interpret a .xml data from a TH3F ROOT file.
Here is the macro

void dump(const char *fname = "resultwaterboneEdep.root",
          const char *nname = "histo")
  if (!fname || !(*fname) || !nname || !(*nname)) return; // just a precaution
  TFile *f = TFile::Open(fname, "READ");
  if (!f) return; // just a precaution
  TH3F *t; f->GetObject(nname, t);
  if (!t) { delete f; return; } // just a precaution
  // See:
  // http://root.cern.ch/root/html/TTreePlayer.html#TTreePlayer:Scan
  // http://root.cern.ch/root/html/TTree.html#TTree:Scan
  TAxis *xaxis = t->GetXaxis();

  // See:
  // http://root.cern.ch/root/html/TObject.html#TObject:SaveAs
  // t->SaveAs(TString::Format("%s.xml", nname));
  delete f; // no longer needed (automatically deletes "t")

This code gives me a .xml file

          <Int_t v="778688"/>
            <Float_t v="0.000000e+00" cnt="194811"/>
            <Float_t v="2.422105e-03"/>
            <Float_t v="0.000000e+00" cnt="261"/>
            <Float_t v="4.438538e-03"/>
            <Float_t v="0.000000e+00" cnt="5"/>
            <Float_t v="3.366382e-02"/>

What is v? and cnt? and why there is a zero and a number in sequence (for the most part)?


Here attribute v contains values of array elements.
And then cnt attribute present, means there are as many similar consecutive elements. Minimal possible value is 2.


Hi linev,

Thank you so much! But do you think these Float_t are only ‘v’ values for X coordinate?


In the array bins content is stored.
For 3-dimensional histogram with NxMxK bins total number of
elements in such array is (N+2)*(M+2)*(K+2),
while it also includes overflow/underflow bins.

Probably, you should start with 1-dim histogram to understand better
which values corresponds to which histogram bins. In 1 dimensional histogram
it is only two additional values - underflow bin in the beginning and overflow bin at the end.

More info about direct access of bins content you will find here:


search a paragraph “Convention for numbering bins”


1 Like

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