Hi, I have a root file with some tuples. when I open open with TBrowser, it shows values at for example 4 in the figure below.
but when I use a code, or simply Draw it via terminal:
TFile f("f0_output_eventsfivetev35.root"); TList *l = (TList*)f.Get("htupList"); TNtuple *t = (TNtuple*)l->FindObject("FqTuple0_ptbin1_cbin0"); t->Draw("Mb");
I get the following with so many values at zero.
What might be the reason??
ROOT Version: 6.36.000
Built for macosxarm64
From tags/6-36-000@6-36-000
yus
July 2, 2025, 6:38pm
2
Hi,
could you please share your ROOT file?
1 Like
This is an unusual way to store the TTree
and you may or may not be retrieving what you need/want. What is the result of
f.ls();
Thanks.
1 Like
thanks for the reply. I am attaching the root file cernbox link: CERNBox
thanks for the reply. this is how they are stored in the file. I have attached the file
If I draw a second time, it works fine
root [0] TFile f("f0_output_eventsfivetev35.root"); TList *l = (TList*)f.Get("htupList"); TNtuple *t = (TNtuple*)l->FindObject("FqTuple0_ptbin1_cbin0");
root [1] t->Draw("Mb"); # shows points at zero
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [2] t->Draw("Mb"); # all points at 4
It looks like something (pointer?) is not being properly initialised before the first draw.
If I do t->Print()
before drawing, the result is even crazier:
root [0] TFile f("f0_output_eventsfivetev35.root"); TList *l = (TList*)f.Get("htupList"); TNtuple *t = (TNtuple*)l->FindObject("FqTuple0_ptbin1_cbin0");
root [1] t->Print()
******************************************************************************
*Tree :FqTuple0_ptbin1_cbin0: etaphitup0_1_0 *
*Entries : 19851 : Total = 481869 bytes File Size = 47899 *
* : : Tree compression factor = 8.02 *
******************************************************************************
*Br 0 :Mb : Float_t *
*Entries : 19851 : Total Size= 80243 bytes File Size = 558 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 114.69 *
*............................................................................*
*Br 1 :Av_bcon : Float_t *
*Entries : 19851 : Total Size= 80283 bytes File Size = 8569 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 7.47 *
*............................................................................*
*Br 2 :fq2e : Float_t *
*Entries : 19851 : Total Size= 80259 bytes File Size = 9792 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 6.54 *
*............................................................................*
*Br 3 :fq3e : Float_t *
*Entries : 19851 : Total Size= 80259 bytes File Size = 9674 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 6.61 *
*............................................................................*
*Br 4 :fq4e : Float_t *
*Entries : 19851 : Total Size= 80259 bytes File Size = 9652 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 6.63 *
*............................................................................*
*Br 5 :fq5e : Float_t *
*Entries : 19851 : Total Size= 80259 bytes File Size = 9654 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 6.63 *
*............................................................................*
root [2] t->Draw("Mb");
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [3]
But drawing a second time, the issue goes away again.
1 Like
Try:
cout << t->GetEntry(0) << endl;
cout << t->GetEntry(15955) << endl;
cout << t->GetEntry(15956) << endl;
cout << t->GetEntry(19850) << endl;
cout << t->GetEntry(19851) << endl;
@pcanal Maybe TTree:Draw
(and similar) should be protected against “I/O errors”.
@Marooz_Malik For saving multiple trees, instead of a TList
, use a TDirectoryFile
(i.e., a disk resident TDirectory
).
1 Like