I want to access the graph from the root file to then get the maximum value on the Y axis. After digging in the forum, I managed to write this code. What should be added or removed here?
c = ROOT.TCanvas()
myfile = ROOT.TFile.Open(“/home/erg/2022.12/2022.12.01/Dec01031235.root”)
tree = myfile.Get(“FADCData 939”)
tree.Draw(“Channel1”)
g = ROOT.TGraph()
g = g.gPad.GetPrimitive(“Graph”)
print(ROOT.TMath.MaxElement(10230, g.GetY()))
ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided
I tried something new. But it gives an empty canvas.
c = ROOT.TCanvas()
f = ROOT.TFile(“/home/erg/2022.12/2022.12.01/Dec01031235.root”)
tree = f.Get(“FADCData 939”)
g = ROOT.TGraph()
g = tree.GetBranch(“Channel1”)
g.Draw()
I used to think I was working with histograms too. I even made a code that allows you to get their maximums. But some of the values were different from the true ones. Recently I realized that I am dealing with graphs with time on the X axis. However, tree.Draw() produces the same images as when calling rootbrowse. Now I need to write a program that will output all the correct values of the maxima. I attach a file here. Dec01031235.root (120.3 KB)
c = ROOT.TCanvas()
f = ROOT.TFile("Dec01031235.root")
tree = f.Get("FADCData 939")
tree.Draw("Channel1")
myh = ROOT.gPad.GetPrimitive("htemp");
print "Maximum of the histogram is", myh.GetMaximum()