1 from array
import array
5 fName =
'MyOutput.yoda.gz'
6 yodaAOs = yoda.read(fName)
7 rtFile = rt.TFile(fName[:fName.find(
'.yoda')] +
'.root',
'recreate')
9 for name_slashes
in yodaAOs:
10 name = name_slashes.replace(
"/",
"_")
11 yodaAO = yodaAOs[name_slashes]
14 if 'Histo1D' in str(yodaAO):
15 rtAO = rt.TH1D(name,
'', yodaAO.numBins(),
array(
'd', yodaAO.xEdges()))
19 rtErrs = rtAO.GetSumw2()
21 for i
in range(rtAO.GetNbinsX()):
23 rtAO.SetBinContent(i + 1, yodaAO.bin(i).sumW())
24 rtErrs.AddAt(yodaAO.bin(i).sumW2(), i+1)
26 elif 'Scatter2D' in str(yodaAO):
27 rtAO = rt.TGraphAsymmErrors(yodaAO.numPoints())
30 for i
in range(yodaAO.numPoints()):
31 x = yodaAO.point(i).
x(); y = yodaAO.point(i).y()
32 xLo, xHi = yodaAO.point(i).xErrs()
33 yLo, yHi = yodaAO.point(i).yErrs()
34 rtAO.SetPoint(i, x, y)
35 rtAO.SetPointError(i, xLo, xHi, yLo, yHi)