Problem on reading files

Good evening everyone, sorry to bother but i have a question regarding reading ROOT files. Im trying to perform some analysis and help was already provided here so i was able to analyse data from a given file. It was a .root file and its format included the usually system for data storage in ROOT: a tree and inside many branches.

4

This time i want also to analyse the data from a .root file but that data is organized inside in folders for some reason.

5

I get this files from a acquisition software so i thought they were all be the same but that doesn’t happen. When i run my code i get the following error:

Because im trying to access this columns in the same way i acess a file with a tree and branch system in place.

Can someone help me solve my problem? Maybe there is a way to read the data on this kind of arrangement or i can somehow use TTree to organize the folders. I have a limited knowledge of ROOT so i welcom all the help i can get :slight_smile:

Best regards,
Andre Miranda

From your TBrowser image it seems that those “_R_Time…” objects are histograms, not trees or “variables”. You can do this on the terminal (outside ROOT):

 rootls -l yourfile.root

to see what they are, e.g.

  rootls -l hsimple.root
TProfile  Apr 12 17:27 2022 hprof;1  "Profile of pz versus px"
TH1F      Apr 12 17:27 2022 hpx;1    "This is the px distribution"
TH2F      Apr 12 17:27 2022 hpxpy;1  "py vs px"
TNtuple   Apr 12 17:27 2022 ntuple;1 "Demo ntuple"

You can get them with file.Get():

import ROOT
f = ROOT.TFile("hsimple.root","read")
h = f.Get("hpx")
h.Draw()

and so on.

1 Like

When there are directories, you can usually access those objects as:
“directory/Rnamexxx” with slashes.

Hello @dastudillo, im trying to implement your sugestion but im just able to get 0D arrays. Some of this collumns are supose to have columns of data so i was wondering is your sugestion is capable of storing those values in a array for instance.

Hello @ferhue i dont think i understand what you meant. Your sugestion is for me to do this navigation inside of ROOT?

I meant that instead of using f.Get(“hpx”) you can use f.Get(“mySubdir/hpx”) if that histogram is inside a particular subfolder.

1 Like