binning = RoundLog(0.1, 1) keyComposer = GenericKeyComposer(('met_pt', ), (binning, )) eventBuilder = EventBuilder(analyzerName, fileName, treeName, args.nevents) outFile = open(outPath, 'w') columnnames = ("component", "met", "n", "nvar") print >> outFile, "{:>22s} {:>12s} {:>6s} {:>6s}".format(*columnnames) heppyResult = HeppyResult(args.heppydir) for component in heppyResult.components(): counts = Counts() events = eventBuilder.build(component) for event in events: keys = keyComposer(event) for key in keys: counts.count(key) results = counts.results() keys = results.keys() keys.sort() for k in keys: row = (component.name, k[0], results[k]['n'], results[k]['nvar']) print >> outFile, "{:>22s} {:12.6f} {:6.0f} {:6.0f}".format(*row) ##__________________________________________________________________||
treeName = 'tree' outPath = os.path.join(args.outdir, 'tbl_met.txt') eventBuilder = EventBuilder(analyzerName, fileName, treeName, args.nevents) outFile = open(outPath, 'w') columnnames = ("component", "met", "n", "nvar") print >>outFile, "{:>22s} {:>12s} {:>6s} {:>6s}".format(*columnnames) heppyResult = HeppyResult(args.heppydir) for component in heppyResult.components(): binning = RoundLog(0.1, 1) counts = Counts() events = eventBuilder.build(component) for event in events: met = event.met_pt met_bin = binning(met) counts.count(met_bin) results = counts.results() keys = results.keys() keys.sort() for k in keys: row = (component.name, k, results[k]['n'], results[k]['nvar']) print >>outFile, "{:>22s} {:12.6f} {:6.0f} {:6.0f}".format(*row) ##__________________________________________________________________||