Storing data in TTree

Hello, Dear rooters.
How I can write data to tree from text file? I plot histogram from text file, but how to do with TTree.
Thanks in advance

60Co_0cm.txt (66.8 KB)
hist.C (223 Bytes)

TTree::ReadFile
${ROOTSYS}/tutorials/tree/basic2.C
${ROOTSYS}/tutorials/tree/temperature.C

1 Like

Your file has only one column. You can simply do:

root [0] auto t = new TTree()
root [1] t->ReadFile("60Co_0cm.txt","x");
root [2] t->Print()
******************************************************************************
*Tree    :          :                                                        *
*Entries :    16384 : Total =           66708 bytes  File  Size =          0 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :x         : x/F                                                    *
*Entries :    16384 : Total  Size=      66421 bytes  All baskets in memory   *
*Baskets :        2 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
root [3] t->Draw("x")
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [4] 
1 Like

Thank you. but I am unable to plot the correct histogram from the tree, as attached


[image]

t->Draw("x : Entry$", "", "L");

1 Like