|
[Rivet-svn] r2162 - in trunk: . bin pyextblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Dec 10 12:11:55 GMT 2009
Author: hoeth Date: Thu Dec 10 12:11:54 2009 New Revision: 2162 Log: propagate SPECIAL sections from .plot files through compare-histos Modified: trunk/ChangeLog trunk/bin/compare-histos trunk/pyext/lighthisto.py Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Thu Dec 10 11:52:08 2009 (r2161) +++ trunk/ChangeLog Thu Dec 10 12:11:54 2009 (r2162) @@ -1,3 +1,7 @@ +2009-12-10 Hendrik Hoeth <hendrik.hoeth at cern.ch> + + * propagate SPECIAL sections from .plot files through compare-histos + 2009-12-04 Andy Buckley <andy at insectnation.org> * Use scaling rather than normalising in DELPHI_1996: this is Modified: trunk/bin/compare-histos ============================================================================== --- trunk/bin/compare-histos Thu Dec 10 11:52:08 2009 (r2161) +++ trunk/bin/compare-histos Thu Dec 10 12:11:54 2009 (r2162) @@ -303,6 +303,14 @@ headstr += "%s=%s\n" % (key, val) headstr += "# END PLOT\n" + ## Special + special = plotparser.getSpecial(name) + if special: + headstr += "\n" + headstr += "# BEGIN SPECIAL %s\n" %name + headstr += special + headstr += "# END SPECIAL\n" + ## Write histos histstrs = [] i = 0 Modified: trunk/pyext/lighthisto.py ============================================================================== --- trunk/pyext/lighthisto.py Thu Dec 10 11:52:08 2009 (r2161) +++ trunk/pyext/lighthisto.py Thu Dec 10 12:11:54 2009 (r2162) @@ -449,8 +449,49 @@ if vm: prop, value = vm.group(1,2) headers[prop] = value + f.close() return headers + def getSpecial(self, hpath): + """Get a SPECIAL section for histogram hpath. + + hpath must have the form /AnalysisID/HistogramID + """ + # parts = os.path.split(hpath) + parts = hpath.split("/") + if len(parts) != 3: + raise ValueError("hpath has wrong number of parts (%i)" % + (len(parts))) + base = parts[1] + ".plot" + plotfile = None + for pidir in self.plotpaths: + if os.access(os.path.join(pidir, base), os.R_OK): + plotfile = os.path.join(pidir, base) + break + if plotfile is None: + raise ValueError("no plot file %s found in plotpaths %s" % + (base, self.plotpaths)) + special = None + startreading = False + f = open(plotfile) + for line in f: + m = self.pat_begin_block.match(line) + if m: + tag, pathpat = m.group(1,2) + if tag == 'SPECIAL' and re.match(pathpat, hpath) is not None: + startreading=True + special = '' + continue + if not startreading: + continue + if self.isEndMarker(line, 'SPECIAL'): + break + elif self.isComment(line): + continue + special += line + f.close() + return special + def isEndMarker(self, line, blockname): m = self.pat_end_block.match(line) return m and m.group(1) == blockname
More information about the Rivet-svn mailing list |