|
[yoda-svn] yoda: Preserve path information in root2yoda. Thanks to Dmitry K...YODA Mercurial yoda at projects.hepforge.orgMon Apr 3 14:30:01 BST 2017
details: https://yoda.hepforge.org/hg/yoda/rev/669c2be582ef branches: release-1-6 changeset: 1334:669c2be582ef user: David Grellscheid <david.grellscheid at durham.ac.uk> date: Mon Apr 03 14:17:52 2017 +0100 description: Preserve path information in root2yoda. Thanks to Dmitry Kalinkin for the patch! diffs (30 lines): --- a/bin/root2yoda Thu Feb 23 13:16:38 2017 +0000 +++ b/bin/root2yoda Mon Apr 03 14:17:52 2017 +0100 @@ -24,16 +24,21 @@ import ROOT for i, o in in_out: rf = ROOT.TFile(i) - rootobjects_raw = [obj for (path, obj) in yoda.root.getall(rf)] - rootobjects = [x for x in rootobjects_raw if not isinstance(x, ROOT.TH1F)] - th1f = [x for x in rootobjects_raw if isinstance(x, ROOT.TH1F)] + rootobjects_raw = yoda.root.getall(rf) + rootobjects = [(path, ro) for (path, ro) in rootobjects_raw if not isinstance(ro, ROOT.TH1F)] + th1f = [(path, ro) for (path, ro) in rootobjects_raw if isinstance(ro, ROOT.TH1F)] # Conversion of TH1F into TH1D - for ro in th1f: + for path, ro in th1f: temp = ROOT.TH1D() ro.Copy(temp) - rootobjects.append(temp) + rootobjects.append((path, temp)) - analysisobjects = [yoda.root.to_yoda(ro) for ro in rootobjects] + def to_yoda(path, ro): + ao = yoda.root.to_yoda(ro) + ao.path = path + return ao + + analysisobjects = [to_yoda(path, ro) for (path, ro) in rootobjects] rf.Close() analysisobjects = [ao for ao in analysisobjects if ao is not None]
More information about the yoda-svn mailing list |