Transition from TTree to TH1

I was trying to move from an object of the TTree class to an object of the TH1 class (there is a branch inside the tree containing a histogram). But without success. How can this be implemented? I have already looked through some files from the TH1 class tutorial.

_ROOT Version: 6.26/10
_Platform: Ubuntu
_Compiler: pycharm community

What do you get from: your_tree.Print()


*Tree :FADCData 939: An event three for data storage *
*Entries : 1 : Total = 170657 bytes File Size = 54059 *

  •    :          : Tree compression factor =   3.11                       *
    

*Br 0 :SizeOfChannels : size/S *
*Entries : 1 : Total Size= 578 bytes File Size = 91 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *

*Br 1 :Channel0 : ch0[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 6982 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.94 *

*Br 2 :Channel1 : ch1[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 6889 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.98 *

*Br 3 :Channel2 : ch2[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 6179 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 3.33 *

*Br 4 :Channel3 : ch3[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 7187 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.86 *

*Br 5 :Channel4 : ch4[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 5948 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 3.46 *

*Br 6 :Channel5 : ch5[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 6920 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.97 *

*Br 7 :Channel6 : ch6[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 5739 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 3.58 *

*Br 8 :Channel7 : ch7[size]/s *
*Entries : 1 : Total Size= 21109 bytes File Size = 6783 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 3.03 *

*Br 9 :TriggerTimeData : trigger_time_data/i *
*Entries : 1 : Total Size= 625 bytes File Size = 94 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *

*Br 10 :SystemTimeData : sys_time_data/L *
*Entries : 1 : Total Size= 623 bytes File Size = 97 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *

So, your tree has no branch which contains a histogram.

h7 = ROOT.TCanvas()
myfile = ROOT.TFile.Open(“/home/erg/2022.12/2022.12.01/Dec01065533.root”)
tree = myfile.Get(“FADCData 939”)
tree.Draw(“Channel7”)

h = ROOT.TH1D("h", "histogram with channel 7", 100, 0., 0.) # automatic binning
tree.Draw("Channel7 >> h")
h.Print("all")

Thank you very much.
Can i print only maximum value of h?
I tried to use h.GetMaximum()

TH1::GetMaximum

1 Like

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