CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
lumiSumPlot Namespace Reference

Classes

class  constants
 

Functions

def getLumiInfoForRuns
 
def getLumiOrderByLS
 
def main
 

Variables

string VERSION = '1.00'
 

Function Documentation

def lumiSumPlot.getLumiInfoForRuns (   dbsession,
  c,
  runList,
  selectionDict,
  hltpath = '',
  beamstatus = None,
  beamenergy = None,
  beamfluctuation = 0.0 
)
input: runList[runnum], selectionDict{runnum:[ls]}
output:{runnumber:[delivered,recorded,recordedinpath] }

Definition at line 102 of file lumiSumPlot.py.

References hltTrgSeedMapper.findUniqueSeed(), lumiQueryAPI.hltBypathByrun(), lumiQueryAPI.hlttrgMappingByrun(), if(), lumiQueryAPI.lumisumByrun(), lumiQueryAPI.lumisummaryByrun(), lumiQueryAPI.lumisummarytrgbitzeroByrun(), max(), and lumiQueryAPI.trgBybitnameByrun().

Referenced by main().

103 def getLumiInfoForRuns(dbsession,c,runList,selectionDict,hltpath='',beamstatus=None,beamenergy=None,beamfluctuation=0.0):
104  '''
105  input: runList[runnum], selectionDict{runnum:[ls]}
106  output:{runnumber:[delivered,recorded,recordedinpath] }
107  '''
109  result={}#runnumber:[lumisumoverlumils,lumisumovercmsls-deadtimecorrected,lumisumovercmsls-deadtimecorrected*hltcorrection_hltpath]
110  #print 'selectionDict seen ',selectionDict
111  dbsession.transaction().start(True)
112  for runnum in runList:
113  totallumi=0.0
114  delivered=0.0
115  recorded=0.0
116  recordedinpath=0.0
117  if len(selectionDict)!=0 and not selectionDict.has_key(runnum):
118  if runnum<max(selectionDict.keys()):
119  result[runnum]=[0.0,0.0,0.0]
120  continue
121  #print 'looking for run ',runnum
122  q=dbsession.nominalSchema().newQuery()
123  totallumi=lumiQueryAPI.lumisumByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q1
124  del q
125  if not totallumi:
126  result[runnum]=[0.0,0.0,0.0]
127  if c.VERBOSE: print 'run ',runnum,' does not exist or has no lumi, skip'
128  continue
129  lumitrginfo={}
130  hltinfo={}
131  hlttrgmap={}
132  q=dbsession.nominalSchema().newQuery()
133  lumitrginfo=lumiQueryAPI.lumisummarytrgbitzeroByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q2
134  del q
135  if len(lumitrginfo)==0:
136  q=dbsession.nominalSchema().newQuery()
137  lumiinfobyrun=lumiQueryAPI.lumisummaryByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q3
138  del q
139  if len(lumiinfobyrun)!=0:
140  print 'warning request run ',runnum,' has no trigger data, calculate delivered only'
141  for perlsdata in lumiinfobyrun:
142  cmslsnum=perlsdata[0]
143  instlumi=perlsdata[1]
144  norbit=perlsdata[2]
145  lslength=t.bunchspace_s*t.nbx*norbit
146  delivered=instlumi*lslength
147  result[runnum]=[delivered,0.0,0.0]
148  #result[runnum]=[0.0,0.0,0.0]
149  #if c.VERBOSE: print 'request run ',runnum,' has no trigger, skip'
150  else:
151  norbits=lumitrginfo.values()[0][1]
152  lslength=t.bunchspace_s*t.nbx*norbits
153  delivered=totallumi*lslength
154  hlttrgmap={}
155  trgbitinfo={}
156  if len(hltpath)!=0 and hltpath!='all':
157  q=dbsession.nominalSchema().newQuery() #optional q3, initiated only if you ask for a hltpath
158  hlttrgmap=lumiQueryAPI.hlttrgMappingByrun(q,runnum)
159  del q
160  if hlttrgmap.has_key(hltpath):
161  l1bitname=hltTrgSeedMapper.findUniqueSeed(hltpath,hlttrgmap[hltpath])
162  q=dbsession.nominalSchema().newQuery() #optional q4, initiated only if you ask for a hltpath and it exists
163  hltinfo=lumiQueryAPI.hltBypathByrun(q,runnum,hltpath)
164  del q
165  q=dbsession.nominalSchema().newQuery()
166  trgbitinfo=lumiQueryAPI.trgBybitnameByrun(q,runnum,l1bitname) #optional q5, initiated only if you ask for a hltpath and it has a unique l1bit
167  del q
168  #done all possible queries. process result
169  for cmslsnum,valuelist in lumitrginfo.items():
170  if len(selectionDict)!=0 and not (cmslsnum in selectionDict[runnum]):
171  #if there's a selection list but cmslsnum is not selected,skip
172  continue
173  if valuelist[5]==0:#bitzero==0 means no beam,do nothing
174  continue
175  trgprescale=valuelist[8]
176  deadfrac=float(valuelist[6])/float(float(valuelist[5])*float(trgprescale))
177  if(deadfrac<1.0):
178  recorded=recorded+valuelist[0]*(1.0-deadfrac)*lslength
179  if hlttrgmap.has_key(hltpath) and hltinfo.has_key(cmslsnum):
180  hltprescale=hltinfo[cmslsnum][2]
181  trgprescale=trgbitinfo[cmslsnum][3]
182  recordedinpath=recordedinpath+valuelist[0]*(1.0-deadfrac)*lslength*hltprescale*trgprescale
183  else:
184  if deadfrac<0.0:
185  print 'warning deadfraction negative in run',runnum,' ls ',cmslsnum
186  if c.VERBOSE:
187  print runnum,cmslsnum,valuelist[0]*lslength,valuelist[0]*(1.0-deadfrac)*lslength,lslength,deadfrac
188  result[runnum]=[delivered,recorded,recordedinpath]
189  dbsession.transaction().commit()
190  #if c.VERBOSE:
191  # print result
192  return result
Definition: start.py:1
const T & max(const T &a, const T &b)
def lumisummarytrgbitzeroByrun
def hlttrgMappingByrun
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def getLumiInfoForRuns
Definition: lumiSumPlot.py:102
def lumiSumPlot.getLumiOrderByLS (   dbsession,
  c,
  runList,
  selectionDict,
  hltpath = '',
  beamstatus = None,
  beamenergy = None,
  beamfluctuation = None 
)
input:  runList[runnum], selectionDict{runnum:[ls]}
output: [[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded,recordedinpath]]

Definition at line 16 of file lumiSumPlot.py.

References if(), lumiQueryAPI.lumisummaryByrun(), lumiQueryAPI.lumisummarytrgbitzeroByrun(), max(), lumiQueryAPI.runsummaryByrun(), and CommonUtil.transposed().

Referenced by main().

16 
17 def getLumiOrderByLS(dbsession,c,runList,selectionDict,hltpath='',beamstatus=None,beamenergy=None,beamfluctuation=None):
18  '''
19  input: runList[runnum], selectionDict{runnum:[ls]}
20  output: [[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded,recordedinpath]]
21  '''
22  #print 'getLumiOrderByLS selectionDict seen ',selectionDict
24  result=[]#[[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded]]
25  dbsession.transaction().start(True)
26  sortedresult=[]
27  #print 'runlist ',runList
28  for runnum in runList:
29  delivered=0.0
30  recorded=0.0
31  #print 'looking for run ',runnum
32  q=dbsession.nominalSchema().newQuery()
33  runsummary=lumiQueryAPI.runsummaryByrun(q,runnum)
34  del q
35  runstarttimeStr=runsummary[3]
36  if len(runstarttimeStr)==0:
37  if c.VERBOSE: print 'warning request run ',runnum,' has no runsummary, skip'
38  continue
39  if len(selectionDict)!=0 and not selectionDict.has_key(runnum):
40  if runnum<max(selectionDict.keys()):
41  result.append([runnum,runstarttimeStr,1,t.StrToDatetime(runstarttimeStr),0.0,0.0])
42  continue
43  #print 'runsummary ',runsummary
44  lumitrginfo={}
45  q=dbsession.nominalSchema().newQuery()
46  lumitrginfo=lumiQueryAPI.lumisummarytrgbitzeroByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q2
47  del q
48  #print 'lumitrginfo ',lumitrginfo
49  if len(lumitrginfo)==0: #if no qualified cross lumi-trg found, try lumionly
50  #result.append([runnum,runstarttimeStr,1,t.StrToDatetime(runstarttimeStr),0.0,0.0])
51  q=dbsession.nominalSchema().newQuery()
52  lumiinfobyrun=lumiQueryAPI.lumisummaryByrun(q,runnum,c.LUMIVERSION,beamstatus,beamenergy,beamfluctuation) #q3
53  del q
54  if len(lumiinfobyrun)!=0: #if lumionly has qualified data means trg has no data
55  print 'warning request run ',runnum,' has no trigger data, calculate delivered only'
56  for perlsdata in lumiinfobyrun:
57  cmslsnum=perlsdata[0]
58  instlumi=perlsdata[1]
59  norbit=perlsdata[2]
60  startorbit=perlsdata[3]
61  lsstarttime=t.OrbitToTime(runstarttimeStr,startorbit)
62  lslength=t.bunchspace_s*t.nbx*norbit
63  delivered=instlumi*lslength
64  result.append([runnum,runstarttimeStr,cmslsnum,lsstarttime,delivered,0.0])
65  else:
66  #print 'run '+str(runnum)+' has no qualified data '
67  lsstarttime=t.OrbitToTime(runstarttimeStr,0)
68  result.append([runnum,runstarttimeStr,1,lsstarttime,0.0,0.0])
69  else:
70  norbits=lumitrginfo.values()[0][1]
71  lslength=t.bunchspace_s*t.nbx*norbits
72  trgbitinfo={}
73  for cmslsnum,valuelist in lumitrginfo.items():
74  instlumi=valuelist[0]
75  startorbit=valuelist[2]
76  bitzero=valuelist[5]
77  deadcount=valuelist[6]
78  prescale=valuelist[-1]
79  lsstarttime=t.OrbitToTime(runstarttimeStr,startorbit)
80  if len(selectionDict)!=0 and not (cmslsnum in selectionDict[runnum]):
81  #if there's a selection list but cmslsnum is not selected,set to 0
82  result.append([runnum,runstarttimeStr,cmslsnum,lsstarttime,0.0,0.0])
83  continue
84  delivered=instlumi*lslength
85  if valuelist[5]==0:#bitzero==0 means no beam,do nothing
86  recorded=0.0
87  else:
88  deadfrac=float(deadcount)/float(float(bitzero)*float(prescale))
89  if(deadfrac<1.0):
90  recorded=delivered*(1.0-deadfrac)
91  result.append([runnum,runstarttimeStr,cmslsnum,lsstarttime,delivered,recorded])
92  #print 'result : ',result
93  dbsession.transaction().commit()
94  transposedResult=CommonUtil.transposed(result)
95  lstimes=transposedResult[3]
96  lstimes.sort()
97  for idx,lstime in enumerate(lstimes):
98  sortedresult.append(result[idx])
99  if c.VERBOSE:
100  print sortedresult
101  return sortedresult
Definition: start.py:1
def transposed
Definition: CommonUtil.py:52
const T & max(const T &a, const T &b)
def lumisummarytrgbitzeroByrun
def getLumiOrderByLS
Definition: lumiSumPlot.py:16
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def lumiSumPlot.main ( )

Definition at line 193 of file lumiSumPlot.py.

References lumiQueryAPI.allfills(), lumiQueryAPI.allruns(), python.multivaluedict.append(), getLumiInfoForRuns(), getLumiOrderByLS(), max(), lumiQueryAPI.runsByfillrange(), lumiQueryAPI.runsByTimerange(), and CommonUtil.transposed().

194 def main():
195  allowedscales=['linear','log','both']
196  c=constants()
197  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Plot integrated luminosity as function of the time variable of choice",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
198  # add required arguments
199  parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
200  # add optional arguments
201  parser.add_argument('-P',dest='authpath',action='store',help='path to authentication file')
202  parser.add_argument('-n',dest='normfactor',action='store',help='normalization factor (optional, default to 1.0)')
203  parser.add_argument('-i',dest='inputfile',action='store',help='lumi range selection file (optional)')
204  parser.add_argument('-o',dest='outputfile',action='store',help='csv outputfile name (optional)')
205  parser.add_argument('-lumiversion',dest='lumiversion',default='0001',action='store',required=False,help='lumi data version')
206  parser.add_argument('-begin',dest='begin',action='store',help='begin value of x-axi (required)')
207  parser.add_argument('-end',dest='end',action='store',help='end value of x-axi (optional). Default to the maximum exists DB')
208  parser.add_argument('-beamenergy',dest='beamenergy',action='store',type=float,required=False,help='beamenergy (in GeV) selection criteria,e.g. 3.5e3')
209  parser.add_argument('-beamfluctuation',dest='beamfluctuation',action='store',type=float,required=False,help='allowed fraction of beamenergy to fluctuate, e.g. 0.1')
210  parser.add_argument('-beamstatus',dest='beamstatus',action='store',required=False,help='selection criteria beam status,e.g. STABLE BEAMS')
211  parser.add_argument('-yscale',dest='yscale',action='store',required=False,default='linear',help='y_scale')
212  parser.add_argument('-hltpath',dest='hltpath',action='store',help='specific hltpath to calculate the recorded luminosity. If specified aoverlays the recorded luminosity for the hltpath on the plot')
213  parser.add_argument('-batch',dest='batch',action='store',help='graphical mode to produce PNG file. Specify graphical file here. Default to lumiSum.png')
214  parser.add_argument('--annotateboundary',dest='annotateboundary',action='store_true',help='annotate boundary run numbers')
215  parser.add_argument('--interactive',dest='interactive',action='store_true',help='graphical mode to draw plot in a TK pannel.')
216  parser.add_argument('-timeformat',dest='timeformat',action='store',help='specific python timeformat string (optional). Default mm/dd/yy hh:min:ss.00')
217  parser.add_argument('-siteconfpath',dest='siteconfpath',action='store',help='specific path to site-local-config.xml file, default to $CMS_PATH/SITECONF/local/JobConfig, if path undefined, fallback to cern proxy&server')
218  parser.add_argument('action',choices=['run','fill','time','perday'],help='x-axis data type of choice')
219  #graphical mode options
220  parser.add_argument('--verbose',dest='verbose',action='store_true',help='verbose mode, print result also to screen')
221  parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
222  # parse arguments
223  batchmode=True
224  args=parser.parse_args()
225  connectstring=args.connect
226  begvalue=args.begin
227  endvalue=args.end
228  beamstatus=args.beamstatus
229  beamenergy=args.beamenergy
230  beamfluctuation=args.beamfluctuation
231  xaxitype='run'
232  connectparser=connectstrParser.connectstrParser(connectstring)
233  connectparser.parse()
234  usedefaultfrontierconfig=False
235  cacheconfigpath=''
236  if connectparser.needsitelocalinfo():
237  if not args.siteconfpath:
238  cacheconfigpath=os.environ['CMS_PATH']
239  if cacheconfigpath:
240  cacheconfigpath=os.path.join(cacheconfigpath,'SITECONF','local','JobConfig','site-local-config.xml')
241  else:
242  usedefaultfrontierconfig=True
243  else:
244  cacheconfigpath=args.siteconfpath
245  cacheconfigpath=os.path.join(cacheconfigpath,'site-local-config.xml')
247  if usedefaultfrontierconfig:
248  p.parseString(c.defaultfrontierConfigString)
249  else:
250  p.parse(cacheconfigpath)
251  connectstring=connectparser.fullfrontierStr(connectparser.schemaname(),p.parameterdict())
252  #print 'connectstring',connectstring
253  runnumber=0
254  svc = coral.ConnectionService()
255  hltpath=''
256  if args.hltpath:
257  hltpath=args.hltpath
258  if args.debug :
259  msg=coral.MessageStream('')
260  msg.setMsgVerbosity(coral.message_Level_Debug)
261  ifilename=''
262  ofilename='integratedlumi.png'
263  timeformat=''
264  if args.authpath and len(args.authpath)!=0:
265  os.environ['CORAL_AUTH_PATH']=args.authpath
266  if args.normfactor:
267  c.NORM=float(args.normfactor)
268  if args.lumiversion:
269  c.LUMIVERSION=args.lumiversion
270  if args.verbose:
271  c.VERBOSE=True
272  if args.inputfile:
273  ifilename=args.inputfile
274  if args.batch:
275  opicname=args.batch
276  if args.outputfile:
277  ofilename=args.outputfile
278  if args.timeformat:
279  timeformat=args.timeformat
280  session=svc.connect(connectstring,accessMode=coral.access_Update)
281  session.typeConverter().setCppTypeForSqlType("unsigned int","NUMBER(10)")
282  session.typeConverter().setCppTypeForSqlType("unsigned long long","NUMBER(20)")
283  inputfilecontent=''
284  fileparsingResult=''
285  runList=[]
286  runDict={}
287  fillDict={}
288  selectionDict={}
289  minTime=''
290  maxTime=''
291 
292  #if len(ifilename)!=0 :
293  # f=open(ifilename,'r')
294  # inputfilecontent=f.read()
295  # sparser=selectionParser.selectionParser(inputfilecontent)
296  # runsandls=sparser.runsandls()
297  # keylist=runsandls.keys()
298  # keylist.sort()
299  # for run in keylist:
300  # if selectionDict.has_key(run):
301  # lslist=runsandls[run]
302  # lslist.sort()
303  # selectionDict[run]=lslist
304  if len(ifilename)!=0:
305  ifparser=inputFilesetParser.inputFilesetParser(ifilename)
306  runsandls=ifparser.runsandls()
307  keylist=runsandls.keys()
308  keylist.sort()
309  for run in keylist:
310  if not selectionDict.has_key(run):
311  lslist=runsandls[run]
312  lslist.sort()
313  selectionDict[run]=lslist
314  if args.action == 'run':
315  if not args.end:
316  session.transaction().start(True)
317  schema=session.nominalSchema()
318  lastrun=max(lumiQueryAPI.allruns(schema,requireRunsummary=True,requireLumisummary=True,requireTrg=True,requireHlt=True))
319  session.transaction().commit()
320  else:
321  lastrun=int(args.end)
322  for r in range(int(args.begin),lastrun+1):
323  runList.append(r)
324  elif args.action == 'fill':
325  session.transaction().start(True)
326  maxfill=None
327  if not args.end:
328  qHandle=session.nominalSchema().newQuery()
329  maxfill=max(lumiQueryAPI.allfills(qHandle,filtercrazy=True))
330  del qHandle
331  else:
332  maxfill=int(args.end)
333  qHandle=session.nominalSchema().newQuery()
334  fillDict=lumiQueryAPI.runsByfillrange(qHandle,int(args.begin),maxfill)
335  del qHandle
336  session.transaction().commit()
337  #print 'fillDict ',fillDict
338  for fill in range(int(args.begin),maxfill+1):
339  if fillDict.has_key(fill): #fill exists
340  for run in fillDict[fill]:
341  runList.append(run)
342  elif args.action == 'time' or args.action == 'perday':
343  session.transaction().start(True)
345  minTime=t.StrToDatetime(args.begin,timeformat)
346  if not args.end:
347  maxTime=datetime.datetime.utcnow() #to now
348  else:
349  maxTime=t.StrToDatetime(args.end,timeformat)
350  #print minTime,maxTime
351  qHandle=session.nominalSchema().newQuery()
352  runDict=lumiQueryAPI.runsByTimerange(qHandle,minTime,maxTime)#xrawdata
353  session.transaction().commit()
354  runList=runDict.keys()
355  del qHandle
356  #print runDict
357  else:
358  print 'unsupported action ',args.action
359  exit
360  runList.sort()
361  #print 'runList ',runList
362  #print 'runDict ', runDict
363 
364  fig=Figure(figsize=(6,4.5),dpi=100)
366 
367  logfig=Figure(figsize=(6.8,4.5),dpi=100)
368  mlog=matplotRender.matplotRender(logfig)
369 
370  if args.action == 'run':
371  result={}
372  result=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
373  xdata=[]
374  ydata={}
375  ydata['Delivered']=[]
376  ydata['Recorded']=[]
377  keylist=result.keys()
378  keylist.sort() #must be sorted in order
379  if args.outputfile:
380  reporter=csvReporter.csvReporter(ofilename)
381  fieldnames=['run','delivered','recorded']
382  reporter.writeRow(fieldnames)
383  for run in keylist:
384  xdata.append(run)
385  delivered=result[run][0]
386  recorded=result[run][1]
387  ydata['Delivered'].append(delivered)
388  ydata['Recorded'].append(recorded)
389  if args.outputfile and (delivered!=0 or recorded!=0):
390  reporter.writeRow([run,result[run][0],result[run][1]])
391  m.plotSumX_Run(xdata,ydata,yscale='linear')
392  mlog.plotSumX_Run(xdata,ydata,yscale='log')
393  elif args.action == 'fill':
394  lumiDict={}
395  lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
396  xdata=[]
397  ydata={}
398  ydata['Delivered']=[]
399  ydata['Recorded']=[]
400  #keylist=lumiDict.keys()
401  #keylist.sort()
402  if args.outputfile:
403  reporter=csvReporter.csvReporter(ofilename)
404  fieldnames=['fill','run','delivered','recorded']
405  reporter.writeRow(fieldnames)
406  fills=fillDict.keys()
407  fills.sort()
408  for fill in fills:
409  runs=fillDict[fill]
410  runs.sort()
411  for run in runs:
412  xdata.append(run)
413  ydata['Delivered'].append(lumiDict[run][0])
414  ydata['Recorded'].append(lumiDict[run][1])
415  if args.outputfile :
416  reporter.writeRow([fill,run,lumiDict[run][0],lumiDict[run][1]])
417  #print 'input fillDict ',len(fillDict.keys()),fillDict
418  m.plotSumX_Fill(xdata,ydata,fillDict,yscale='linear')
419  mlog.plotSumX_Fill(xdata,ydata,fillDict,yscale='log')
420  elif args.action == 'time' :
421  lumiDict={}
422  lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
423  #lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus='STABLE BEAMS')
424  xdata={}#{run:[starttime,stoptime]}
425  ydata={}
426  ydata['Delivered']=[]
427  ydata['Recorded']=[]
428  keylist=lumiDict.keys()
429  keylist.sort()
430  if args.outputfile:
431  reporter=csvReporter.csvReporter(ofilename)
432  fieldnames=['run','starttime','stoptime','delivered','recorded']
433  reporter.writeRow(fieldnames)
434  for run in keylist:
435  ydata['Delivered'].append(lumiDict[run][0])
436  ydata['Recorded'].append(lumiDict[run][1])
437  starttime=runDict[run][0]
438  stoptime=runDict[run][1]
439  xdata[run]=[starttime,stoptime]
440  if args.outputfile :
441  reporter.writeRow([run,starttime,stoptime,lumiDict[run][0],lumiDict[run][1]])
442  m.plotSumX_Time(xdata,ydata,minTime,maxTime,hltpath=hltpath,annotateBoundaryRunnum=args.annotateboundary,yscale='linear')
443  mlog.plotSumX_Time(xdata,ydata,minTime,maxTime,hltpath=hltpath,annotateBoundaryRunnum=args.annotateboundary,yscale='log')
444  elif args.action == 'perday':
445  daydict={}#{day:[[run,cmslsnum,lsstarttime,delivered,recorded]]}
446  lumibyls=getLumiOrderByLS(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation)
447  #print 'lumibyls ',lumibyls
448  #lumibyls [[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded,recordedinpath]]
449  if args.outputfile:
450  reporter=csvReporter.csvReporter(ofilename)
451  fieldnames=['day','begrunls','endrunls','delivered','recorded']
452  reporter.writeRow(fieldnames)
453  beginfo=[lumibyls[0][3],str(lumibyls[0][0])+':'+str(lumibyls[0][2])]
454  endinfo=[lumibyls[-1][3],str(lumibyls[-1][0])+':'+str(lumibyls[-1][2])]
455  for perlsdata in lumibyls:
456  lsstarttime=perlsdata[3]
457  delivered=perlsdata[4]
458  recorded=perlsdata[5]
459  day=lsstarttime.toordinal()
460  if not daydict.has_key(day):
461  daydict[day]=[]
462  daydict[day].append([delivered,recorded])
463  days=daydict.keys()
464  days.sort()
465  daymin=days[0]
466  daymax=days[-1]
467  #alldays=range(daymin,daymax+1)
468  resultbyday={}
469  resultbyday['Delivered']=[]
470  resultbyday['Recorded']=[]
471  #for day in days:
472  #print 'day min ',daymin
473  #print 'day max ',daymax
474  for day in range(daymin,daymax+1):
475  if not daydict.has_key(day):
476  delivered=0.0
477  recorded=0.0
478  else:
479  daydata=daydict[day]
480  mytransposed=CommonUtil.transposed(daydata,defaultval=0.0)
481  delivered=sum(mytransposed[0])
482  recorded=sum(mytransposed[1])
483  resultbyday['Delivered'].append(delivered)
484  resultbyday['Recorded'].append(recorded)
485  if args.outputfile:
486  reporter.writeRow([day,beginfo[1],endinfo[1],delivered,recorded])
487  #print 'beginfo ',beginfo
488  #print 'endinfo ',endinfo
489  #print resultbyday
490  m.plotPerdayX_Time( range(daymin,daymax+1) ,resultbyday,minTime,maxTime,boundaryInfo=[beginfo,endinfo],annotateBoundaryRunnum=args.annotateboundary,yscale='linear')
491  mlog.plotPerdayX_Time( range(daymin,daymax+1),resultbyday,minTime,maxTime,boundaryInfo=[beginfo,endinfo],annotateBoundaryRunnum=args.annotateboundary,yscale='log')
492  else:
493  raise Exception,'must specify the type of x-axi'
494 
495  del session
496  del svc
497 
498  if args.batch and args.yscale=='linear':
499  m.drawPNG(args.batch)
500  elif args.batch and args.yscale=='log':
501  mlog.drawPNG(args.batch)
502  elif args.batch and args.yscale=='both':
503  m.drawPNG(args.batch)
504  basename,extension=os.path.splitext(args.batch)
505  logfilename=basename+'_log'+extension
506  mlog.drawPNG(logfilename)
507  else:
508  raise Exception('unsupported yscale for batch mode : '+args.yscale)
509  if not args.interactive:
510  return
511  if args.interactive is True and args.yscale=='linear':
512  m.drawInteractive()
513  elif args.interactive is True and args.yscale=='log':
514  mlog.drawInteractive()
515  else:
raise Exception('unsupported yscale for interactive mode : '+args.yscale)
Definition: start.py:1
def allruns
==============real api=====###
def transposed
Definition: CommonUtil.py:52
const T & max(const T &a, const T &b)
def getLumiOrderByLS
Definition: lumiSumPlot.py:16
def getLumiInfoForRuns
Definition: lumiSumPlot.py:102

Variable Documentation

string lumiSumPlot.VERSION = '1.00'

Definition at line 2 of file lumiSumPlot.py.