#!/usr/bin/python import os,sys,glob from fpformat import fix def read_stats(): stats = {} f = file('nevts.txt') for l in f: if not l.startswith('#'): ls = l.split() stats[int(ls[0])] = float(ls[1]) return stats def unpack_list(l): new_l = [] for be in l.split(','): b,e = be.split('-') new_l.extend(range(int(b),int(e)+1)) return new_l def read_sets1(): sets = {} f = file('RunRangeInSet.new.list') for l in f: if not l.startswith('#'): ls = l.split() sets[int(ls[0])] = unpack_list(ls[1]) sets[91] = unpack_list('55588-55859') ##check again when Wiki fixed sets[92] = unpack_list('55952-56343') ##check again when Wiki fixed sets[93] = unpack_list('56472-57065') ##check again when Wiki fixed print 'WARNING: check s91/s92/s93 again when Wiki is working' print 'WARNING: check again when pass4 is replaced by newer treesum' return sets def read_goodlinks(ss,aa): sets = {} for s,a in zip(ss,aa): d = '/twist/tw00y/systematics/data/set'+str(s)+'/anal'+str(a)+'/goodlinks' if not os.path.isdir(d): print 'ERROR: cannot find',d,'; check your analysis number' sys.exit(-1) sets[s] = [] for gl in glob.glob(d+'/run*'): rn = int(gl.split('/')[-1][3:8]) sets[s].append(rn) return sets def co(rs,stats): t = 0. for r in rs: try: t += stats[r] except KeyError: pass return t if __name__=='__main__': good_sets = [68,70,71,72,74,75,76,83,84,86,87,91,92,93] good_ana = [3, 3, 3, 2, 4, 14,6, 4, 9, 3, 2, 2, 2, 2 ] stats = read_stats() sets1 = read_sets1() sets2 = read_goodlinks(good_sets,good_ana) for s in good_sets: print s,' & ',fix(1E-6*co(sets1[s],stats),0),' & ',fix(1E-6*co(sets2[s],stats),0) os.system('grep -A1 "Data: HistoDesc" pass4/sum*michel.log | grep Stat')