1 import sys,os,os.path,glob,csv,math,datetime
6 plotreader=csv.reader(fileobj,delimiter=
',')
10 [run,fill]=row[0].
split(
':')
11 [lumils,cmsls]=row[1].
split(
':')
12 if int(fill)
not in range(fillmin,fillmax+1):
14 delivered=float(row[5])
15 if not result.has_key(int(fill)):
17 if result[int(fill)].has_key(int(run)):
18 result[int(fill)][int(run)]+=delivered
20 result[int(fill)][int(run)]=delivered
27 lpcfilldir=[f
for f
in glob.glob(cachedir+
'/????')
if os.path.isdir(f) ]
28 lpcfills=[os.path.split(f)[1]
for f
in lpcfilldir]
30 result=[int(f)
for f
in lpcfills
if int(f)>=fillmin]
33 if __name__ ==
"__main__" :
34 ofile=open(
'checklumi.log',
'w')
35 lpcdir=
'/afs/cern.ch/cms/CAF/CMSCOMM/COMM_GLOBAL/LHCFILES/'
36 plotcachedir=
'/afs/cern.ch/cms/lumi/www/publicplots/public_lumi_plots_cache/pp_all'
37 plotfiles=[f
for f
in glob.glob(os.path.join(plotcachedir,
'lumicalc_cache_2012-??-??.csv'))
if os.path.getsize(f)>0]
46 ofile.write(
'checking fills %s\n'%str(lpcfill2012))
47 ofile.write(
"-----------------------------------------------------------------------------------\n")
48 ofile.write(
'on %s\n'%str(datetime.datetime.now()) )
49 ofile.write(
"-----------------------------------------------------------------------------------\n")
55 for fill
in lpcfill2012:
62 lpcfile=os.path.join(lpcdir,str(fill),str(fill)+
'_summary_CMS.txt')
63 if not os.path.exists(lpcfile):
66 for line
in l.readlines():
68 rundataline=line.split()
69 if len(rundataline)!=4:
continue
70 lpcdelperrun=float(rundataline[3])
71 lpcresult.setdefault(fill,[]).
append(lpcdelperrun)
73 lumi_lpc+=lpcdelperrun
76 if plotfilldata.has_key(fill):
77 runs=plotfilldata[fill].
keys()
80 tot_nrunpplot+=nruns_pplot
83 lumi_pplot+=plotfilldata[fill][run]
84 tot_lumipplot+=lumi_pplot
86 delta=lumi_pplot-lumi_lpc
88 dellumi=1.-math.fabs(lumi_pplot/lumi_lpc)
89 if nruns_pplot!=nrun_lpc:
90 ofile.write(
'fill: %d plot=%.2f plotrun=%d lpc=%.2f lpcrun=%d diff=%.2f rel=%.3f *\n'%(fill,lumi_pplot,nruns_pplot,lumi_lpc,nrun_lpc,delta,dellumi))
92 ofile.write(
'fill: %d plot=%.2f plotrun=%d lpc=%.2f lpcrun=%d diff=%.2f rel=%.3f \n'%(fill,lumi_pplot,nruns_pplot,lumi_lpc,nrun_lpc,delta,dellumi))
93 tot_diff=tot_lumipplot-tot_lumilpc
96 tot_rel=1.-tot_lumipplot/tot_lumilpc
98 ofile.write(
"-----------------------------------------------------------------------------------\n")
99 ofile.write(
"tot : plot=%.2f lpc=%.2f diff=%.2f rel=%.3f\n" % (tot_lumipplot,tot_lumilpc,tot_diff,tot_rel))
100 ofile.write(
"tot : plotnrun=%d lpcnrun=%d\n"%(tot_nrunpplot,tot_nrunlpc))