Read data from a .root file

Hi. I have a problem reading data from my lines2.root file.
I need to read it to do a project.
I tried to solve it doing a similar process to run it, but I fail.
lines2.root (8.9 KB)
Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.22/00


I’m not quite sure I understand. Please attach a minimal example of the code you are running and let us know which part of the code is unclear to you.



Thanks for your help. I have no problem with the code. I uploaded my .root file so you can help me read it. I can’t get the data from the file, I need to get it to modify and work with it.

I tried doing this:

void dump(const char *fname = "lines2.root",
          const char *nname = "ntuple")
  if (!fname || !(*fname) || !nname || !(*nname)) return; 
  TFile *f = TFile::Open(fname, "READ");
  if ((!f) || f->IsZombie()) { delete f; return; } 
  TTree *t; f->GetObject(nname, t);
  if (!t) { delete f; return; } // just a precaution
  delete f; 

I tried to do it like this, but it didn’t work. The .txt file that was created in my folder does not have the data.
This was the file created:
lines2.txt (78 Bytes)

The code is trying to read a TTree named “ntuple” from the file but such an tree does not exist. The file contains five histograms. You can check the contents of a ROOT file with a TBrowser.

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