CMS 3D CMS Logo

checklumidiff.py
Go to the documentation of this file.
1 from builtins import range
2 import sys,os,os.path,glob,csv,math,datetime
3 def parseplotcache(filelist,fillmin,fillmax):
4  result={}#{fill:{run:delivered}}
5  for f in filelist:
6  fileobj=open(f,'rb')
7  plotreader=csv.reader(fileobj,delimiter=',')
8  idx=0
9  for row in plotreader:
10  if idx!=0:
11  [run,fill]=row[0].split(':')
12  [lumils,cmsls]=row[1].split(':')
13  if int(fill) not in list(range(fillmin,fillmax+1)):
14  continue
15  delivered=float(row[5])
16  if int(fill) not in result:
17  result[int(fill)]={}
18  if int(run) in result[int(fill)]:
19  result[int(fill)][int(run)]+=delivered
20  else:
21  result[int(fill)][int(run)]=delivered
22  idx+=1
23  fileobj.close()
24  return result
25 def findlpcdir(lpcdir,fillmin):
26  result=[]
27  cachedir=lpcdir
28  lpcfilldir=[f for f in glob.glob(cachedir+'/????') if os.path.isdir(f) ]
29  lpcfills=[os.path.split(f)[1] for f in lpcfilldir]
30  #print lpcfills
31  result=[int(f) for f in lpcfills if int(f)>=fillmin]
32  return result
33 
34 if __name__ == "__main__" :
35  ofile=open('checklumi.log','w')
36  lpcdir='/afs/cern.ch/cms/CAF/CMSCOMM/COMM_GLOBAL/LHCFILES/'
37  plotcachedir='/afs/cern.ch/cms/lumi/www/publicplots/public_lumi_plots_cache/pp_all'
38  plotfiles=[f for f in glob.glob(os.path.join(plotcachedir,'lumicalc_cache_2012-??-??.csv')) if os.path.getsize(f)>0]
39  fillmin=2450
40  lpcfill2012=sorted(findlpcdir(lpcdir,fillmin))
41  lpcresult={}#{fill:[delivered]}
42 
43  plotfilldata={}#{fill:{run:delivered}}
44  plotfilldata=parseplotcache(plotfiles,min(lpcfill2012),max(lpcfill2012))
45 
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")
50  tot_lumipplot=0.
51  tot_nrunpplot=0
52  tot_lumilpc=0.
53  tot_nrunlpc=0
54 
55  for fill in lpcfill2012:
56  nruns_pplot=0
57  nrun_lpc=0
58  lumi_pplot=0.
59  lumi_lpc=0.
60  dellumi=0.
61  delta=0.
62  lpcfile=os.path.join(lpcdir,str(fill),str(fill)+'_summary_CMS.txt')
63  if not os.path.exists(lpcfile):
64  continue
65  l=open(lpcfile,'rb')
66  for line in l.readlines():
67  line=line.strip()
68  rundataline=line.split()
69  if len(rundataline)!=4: continue
70  lpcdelperrun=float(rundataline[3])
71  lpcresult.setdefault(fill,[]).append(lpcdelperrun)
72  nrun_lpc+=1
73  lumi_lpc+=lpcdelperrun
74  tot_nrunlpc+=1
75  l.close()
76  if fill in plotfilldata:
77  runs=plotfilldata[fill].keys()
78  if not runs: continue
79  nruns_pplot=len(runs)
80  tot_nrunpplot+=nruns_pplot
81  runs.sort()
82  for run in runs:
83  lumi_pplot+=plotfilldata[fill][run]
84  tot_lumipplot+=lumi_pplot
85  tot_lumilpc+=lumi_lpc
86  delta=lumi_pplot-lumi_lpc
87  if 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))
91  else:
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
94  tot_rel=0.
95  if tot_lumilpc!=0:
96  tot_rel=1.-tot_lumipplot/tot_lumilpc
97 
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))
T min(T a, T b)
Definition: MathUtil.h:58
def parseplotcache(filelist, fillmin, fillmax)
Definition: checklumidiff.py:3
def findlpcdir(lpcdir, fillmin)
#define str(s)
double split
Definition: MVATrainer.cc:139
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run