Previously, I handled root files as histograms. But it turned out that these are not histograms, but graphs. Perhaps the TGraph class. Therefore, I ask you to help in the following:
How to read and draw such a graph?
How to get the maximum value on the Y axis?
I attach one of the files as a sample.
Dec01031235.root (120.3 KB)
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
If you do on the terminal:
rootls -l yourfile.root
you’ll see that the file contains trees, not graphs. There are several ways to plot trees / branches, try searching the forum or read the ROOT primer.
Data Analysis Framework
As for the “maximum on y”, maybe that’s not what you really want; if you plot a branch, the maximum “y” will depend on the binning; if you want the highest value in a branch (which is not the same!) (e.g. “ch0” in tree “mytree”) you can use
Thank you. But mytree->GetMaximum(“ch0”) give maximum “x”.
I have a code to get the maximum if we treat objects as histograms. Now we need a similar code, but in relation to TGraph.
c = ROOT.TCanvas()
myfile = ROOT.TFile.Open("/home/erg/2022.12/2022.12.01/Dec01031235.root")
tree = myfile.Get("FADCData 939")
h = ROOT.TH1D("h", "histogram with channel 1", 16500, 0., 16500.)
tree.Draw("Channel1 >> h")
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.