I have a root file from Geant4 but I do no know how to extract the data from it in text form or anything.
ROOT Version: v6.18.04
OS : Windows 10
I have a root file from Geant4 but I do no know how to extract the data from it in text form or anything.
ROOT Version: v6.18.04
OS : Windows 10
There is way too much information on there for it to be able to help me. I am able to access root files using TBrowser but I cannot seem to draw any plots using that data.
I have this code:
root -l human_phantom_t3.root
TBrowser b
.ls
TFile** human_phantom_t3.root
TFile* human_phantom_t3.root
TDirectoryFile* human_phantom_ntuple human_phantom_ntuple
OBJ: TTree 1 3Dedep : 0 at: 0x7fcc40a08670
OBJ: TTree 1 3Dedep : 0 at: 0x7fcc408a8f90
OBJ: TTree 1 3Dedep : 0 at: 0x7fcc409c8590
OBJ: TTree 1 3Dedep : 0 at: 0x7fcc37740570
OBJ: TTree 1 3Dedep : 0 at: 0x7fcc37753260
OBJ: TTree 1 3Dedep : 0 at: 0x7fcc408f1350KEY: TTree 1;1 3Dedep
KEY: TDirectoryFile human_phantom_ntuple;1 human_phantom_ntuple
root [12] human_phantom_ntuple->Draw(“edep”)
root [13] human_phantom_ntuple->Draw(“organID”)
root [14] human_phantom_ntuple->Draw(“organID:edep”)
I don’t get this
KEY: TDirectoryFile human_phantom_ntuple;1 human_phantom_ntuple
Neither can I seem to run the last three lines of code
Hi @esh187,
human_phantom_ntuple
is a TDirectoryFile
, i.e. a sub-directory in the file. In the ROOT prompt, you can do _file0->cd("human_phantom_ntuple"); _file0->ls();
to see the contents of that sub-directory.
Hope this helps!
Enrico
I see you also opened a TBrowser. The window opened by this command allows you to navigate easily in the file human_phantom_t3.root
and therefore understand its structure.
you can also get a tree(1)
like view of your file with groot
's root-ls
:
$> root-ls -t ../testdata/dirs-6.14.00.root ../testdata/B2HHH.root
=== [../testdata/dirs-6.14.00.root] ===
version: 61400
TDirectoryFile dir1 dir1 (cycle=1)
TDirectoryFile dir11 dir11 (cycle=1)
TH1F h1 h1 (cycle=1)
TDirectoryFile dir2 dir2 (cycle=1)
TDirectoryFile dir3 dir3 (cycle=1)
=== [../testdata/B2HHH.root] ===
version: 60806
TTree DecayTree (entries=8556118)
B_FlightDistance "B_FlightDistance/D" TBranch
B_VertexChi2 "B_VertexChi2/D" TBranch
H1_PX "H1_PX/D" TBranch
H1_PY "H1_PY/D" TBranch
H1_PZ "H1_PZ/D" TBranch
H1_ProbK "H1_ProbK/D" TBranch
H1_ProbPi "H1_ProbPi/D" TBranch
H1_Charge "H1_Charge/I" TBranch
H1_isMuon "H1_isMuon/I" TBranch
H1_IpChi2 "H1_IpChi2/D" TBranch
H2_PX "H2_PX/D" TBranch
H2_PY "H2_PY/D" TBranch
H2_PZ "H2_PZ/D" TBranch
H2_ProbK "H2_ProbK/D" TBranch
H2_ProbPi "H2_ProbPi/D" TBranch
H2_Charge "H2_Charge/I" TBranch
H2_isMuon "H2_isMuon/I" TBranch
H2_IpChi2 "H2_IpChi2/D" TBranch
H3_PX "H3_PX/D" TBranch
H3_PY "H3_PY/D" TBranch
H3_PZ "H3_PZ/D" TBranch
H3_ProbK "H3_ProbK/D" TBranch
H3_ProbPi "H3_ProbPi/D" TBranch
H3_Charge "H3_Charge/I" TBranch
H3_isMuon "H3_isMuon/I" TBranch
H3_IpChi2 "H3_IpChi2/D" TBranch
TTree DecayTree (entries=8506680)
B_FlightDistance "B_FlightDistance/D" TBranch
B_VertexChi2 "B_VertexChi2/D" TBranch
H1_PX "H1_PX/D" TBranch
H1_PY "H1_PY/D" TBranch
H1_PZ "H1_PZ/D" TBranch
H1_ProbK "H1_ProbK/D" TBranch
H1_ProbPi "H1_ProbPi/D" TBranch
H1_Charge "H1_Charge/I" TBranch
H1_isMuon "H1_isMuon/I" TBranch
H1_IpChi2 "H1_IpChi2/D" TBranch
H2_PX "H2_PX/D" TBranch
H2_PY "H2_PY/D" TBranch
H2_PZ "H2_PZ/D" TBranch
H2_ProbK "H2_ProbK/D" TBranch
H2_ProbPi "H2_ProbPi/D" TBranch
H2_Charge "H2_Charge/I" TBranch
H2_isMuon "H2_isMuon/I" TBranch
H2_IpChi2 "H2_IpChi2/D" TBranch
H3_PX "H3_PX/D" TBranch
H3_PY "H3_PY/D" TBranch
H3_PZ "H3_PZ/D" TBranch
H3_ProbK "H3_ProbK/D" TBranch
H3_ProbPi "H3_ProbPi/D" TBranch
H3_Charge "H3_Charge/I" TBranch
H3_isMuon "H3_isMuon/I" TBranch
H3_IpChi2 "H3_IpChi2/D" TBranch