10 from RecoLuminosity.LumiDB
import sessionManager,lumiTime,inputFilesetParser,csvSelectionParser,selectionParser,csvReporter,argparse,CommonUtil,revisionDML,lumiCalcAPI,lumiReport,RegexValidator,normDML
12 beamChoices=[
'PROTPHYS',
'IONPHYS',
'PAPHYS']
16 output ({run:[cmsls,cmsls,...]},[[resultlines]]) 21 runlsbyfile=p.runsandls()
22 selectedProcessedRuns=p.selectedRunsWithresult()
23 selectedNonProcessedRuns=p.selectedRunsWithoutresult()
24 resultlines=p.resultlines()
25 for runinfile
in selectedNonProcessedRuns:
26 selectedrunlsInDB[runinfile]=runlsbyfile[runinfile]
27 return (selectedrunlsInDB,resultlines)
37 if __name__ ==
'__main__':
39 allowedActions = [
'overview',
'delivered',
'recorded',
'lumibyls',
'lumibylsXing']
40 beamModeChoices = [
"stable"]
41 amodetagChoices = [
"PROTPHYS",
"IONPHYS",
'PAPHYS' ]
42 xingAlgoChoices =[
"OCC1",
"OCC2",
"ET"]
50 parser.add_argument(
'action',choices=allowedActions,
51 help=
'command actions')
52 parser.add_argument(
'-c',dest=
'connect',action=
'store',
54 help=
'connect string to lumiDB,optional',
55 default=
'frontier://LumiCalc/CMS_LUMI_PROD')
56 parser.add_argument(
'-P',dest=
'authpath',action=
'store',
58 help=
'path to authentication file')
59 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',
63 parser.add_argument(
'-o',dest=
'outputfile',action=
'store',
65 help=
'output to csv file' )
70 parser.add_argument(
'-i',dest=
'inputfile',action=
'store',
72 help=
'lumi range selection file')
76 parser.add_argument(
'--hltpath',dest=
'hltpath',action=
'store',
77 default=
None,required=
False,
78 help=
'specific hltpath or hltpath pattern to calculate the effectived luminosity')
82 parser.add_argument(
'--normtag',dest=
'normtag',action=
'store',
84 help=
'version of lumi norm/correction')
85 parser.add_argument(
'--datatag',dest=
'datatag',action=
'store',
87 help=
'version of lumi/trg/hlt data')
92 parser.add_argument(
'-f',
'--fill',dest=
'fillnum',action=
'store',
93 default=
None,required=
False,
94 help=
'fill number (optional) ')
95 parser.add_argument(
'--amodetag',dest=
'amodetag',action=
'store',
96 choices=amodetagChoices,
98 help=
'specific accelerator mode choices [PROTOPHYS,IONPHYS,PAPHYS] (optional)')
99 parser.add_argument(
'--beamenergy',dest=
'beamenergy',action=
'store',
102 help=
'nominal beam energy in GeV')
103 parser.add_argument(
'--beamfluctuation',dest=
'beamfluctuation',
104 type=float,action=
'store',
107 help=
'fluctuation in fraction allowed to nominal beam energy, default 0.2, to be used together with -beamenergy (optional)')
109 parser.add_argument(
'--begin',dest=
'begin',action=
'store',
113 help=
'min run start time (mm/dd/yy hh:mm:ss),min fill or min run' 115 parser.add_argument(
'--end',dest=
'end',action=
'store',
119 help=
'max run start time (mm/dd/yy hh:mm:ss),max fill or max run' 121 parser.add_argument(
'--minBiasXsec',dest=
'minbiasxsec',action=
'store',
125 help=
'minbias cross-section in ub' 130 parser.add_argument(
'-b',dest=
'beammode',action=
'store',
131 choices=beamModeChoices,
133 help=
'beam mode choices [stable]')
135 parser.add_argument(
'--xingMinLum', dest =
'xingMinLum',
139 help=
'Minimum perbunch luminosity to print, default=1e-03/ub')
141 parser.add_argument(
'--xingAlgo', dest =
'xingAlgo',
144 help=
'algorithm name for per-bunch lumi ')
149 parser.add_argument(
'-n',dest=
'scalefactor',action=
'store',
153 help=
'user defined global scaling factor on displayed lumi values,optional')
158 parser.add_argument(
'--siteconfpath',dest=
'siteconfpath',action=
'store',
161 help=
'specific path to site-local-config.xml file, optional. If path undefined, fallback to cern proxy&server')
163 parser.add_argument(
'--headerfile',dest=
'headerfile',action=
'store',
166 help=
'write command header output to specified file' 171 parser.add_argument(
'--without-correction',
174 help=
'without any correction/calibration' 176 parser.add_argument(
'--without-checkforupdate',
177 dest=
'withoutCheckforupdate',
179 help=
'without check for update' 186 parser.add_argument(
'--nowarning',
189 help=
'suppress bad for lumi warnings' 191 parser.add_argument(
'--debug',
196 options=parser.parse_args()
197 if not options.runnumber
and not options.inputfile
and not options.fillnum
and not options.begin:
198 raise RuntimeError(
'at least one run selection argument in [-r,-f,-i,--begin] is required')
205 timeFilter=[
None,
None]
206 noWarning=options.nowarning
208 if options.beammode==
'stable':
209 pbeammode =
'STABLE BEAMS' 213 if options.action==
'overview' or options.action==
'lumibyls' or options.action==
'lumibylsXing':
215 if options.action==
'lumibyls' and options.hltpath:
217 if options.action==
'recorded':
220 if options.runnumber:
221 reqrunmax=options.runnumber
222 reqrunmin=options.runnumber
224 reqfillmin=options.fillnum
225 reqfillmax=options.fillnum
240 reqtimeminT=lute.StrToDatetime(reqtimemin,customfm=
'%m/%d/%y %H:%M:%S')
241 timeFilter[0]=reqtimeminT
254 reqtimemaxT=lute.StrToDatetime(reqtimemax,customfm=
'%m/%d/%y %H:%M:%S')
255 timeFilter[1]=reqtimemaxT
256 if options.inputfile
and (reqtimemax
or reqtimemin):
263 workingversion=
'UNKNOWN' 266 if not options.withoutCheckforupdate:
267 from RecoLuminosity.LumiDB
import checkforupdate
268 cmsswWorkingBase=os.environ[
'CMSSW_BASE']
269 if not cmsswWorkingBase:
270 print 'Please check out RecoLuminosity/LumiDB from CVS,scram b,cmsenv' 273 workingversion=c.runningVersion(cmsswWorkingBase,
'lumiCalc2.py',isverbose=
False)
275 updateversionList=c.checkforupdate(workingversion,isverbose=
False)
276 if updateversionList:
277 updateversion=updateversionList[-1][0]
282 os.environ[
'CORAL_AUTH_PATH'] = options.authpath
288 if options.action==
'recorded':
289 if not options.hltpath:
290 raise RuntimeError(
'argument --hltpath pathname is required for recorded action')
293 authpath=options.authpath,
294 siteconfpath=options.siteconfpath,
295 debugON=options.debug)
296 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
303 session.transaction().
start(
True)
305 if options.inputfile:
307 filerunlist=irunlsdict.keys()
320 datatagname=options.datatag
326 dataidmap=
lumiCalcAPI.runList(session.nominalSchema(),datatagid,runmin=reqrunmin,runmax=reqrunmax,fillmin=reqfillmin,fillmax=reqfillmax,startT=reqtimemin,stopT=reqtimemax,l1keyPattern=
None,hltkeyPattern=
None,amodetag=options.amodetag,nominalEnergy=options.beamenergy,energyFlut=options.beamfluctuation,requiretrg=reqTrg,requirehlt=reqHlt,preselectedruns=filerunlist)
328 print '[INFO] No qualified run found, do nothing' 332 for irun,(lid,tid,hid)
in dataidmap.items():
334 print '[INFO] No qualified lumi data found for run, ',irun
335 if reqTrg
and not tid:
336 print '[INFO] No qualified trg data found for run ',irun
338 if reqHlt
and not hid:
339 print '[INFO] No qualified hlt data found for run ',irun
343 irunlsdict=
dict(
list(
zip(rruns,[
None]*len(rruns))))
345 for selectedrun
in irunlsdict.keys():
346 if selectedrun
not in rruns:
347 del irunlsdict[selectedrun]
349 print '[INFO] No qualified run found, do nothing' 358 if not options.withoutNorm:
359 normname=options.normtag
363 normname=normmap.keys()[0]
364 normid=normmap[normname]
368 raise RuntimeError(
'[ERROR] cannot resolve norm/correction')
371 session.transaction().commit()
378 session.transaction().
start(
True)
381 if options.action ==
'delivered':
382 result=
lumiCalcAPI.deliveredLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype=
'HF')
384 if options.action ==
'overview':
385 result=
lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype=
'HF')
386 lumiReport.toScreenOverview(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
387 if options.action ==
'lumibyls':
388 if not options.hltpath:
389 result=
lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype=
'HF',minbiasXsec=options.minbiasxsec)
390 lumiReport.toScreenLumiByLS(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
392 hltname=options.hltpath
394 if hltname==
'*' or hltname==
'all':
396 elif 1
in [c
in hltname
for c
in '*?[]']:
399 result=
lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=
False,bxAlgo=
None,xingMinLum=options.xingMinLum,withBeamIntensity=
False,lumitype=
'HF')
401 if options.action ==
'recorded':
402 hltname=options.hltpath
404 if hltname
is not None:
405 if hltname==
'*' or hltname==
'all':
407 elif 1
in [c
in hltname
for c
in '*?[]']:
410 result=
lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=
False,bxAlgo=
None,xingMinLum=options.xingMinLum,withBeamIntensity=
False,lumitype=
'HF')
412 if options.action ==
'lumibylsXing':
413 result=
lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,withBXInfo=
True,bxAlgo=options.xingAlgo,xingMinLum=options.xingMinLum,withBeamIntensity=
False,lumitype=
'HF')
414 outfile=options.outputfile
416 print '[WARNING] no output file given. lumibylsXing writes per-bunch lumi only to default file lumibylsXing.csv' 417 outfile=
'lumibylsXing.csv' 419 session.transaction().commit()
def toScreenOverview(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def effectiveLumiForIds(schema, irunlsdict, dataidmap, runsummaryMap=None, beamstatusfilter=None, timeFilter=None, normmap=None, hltpathname=None, hltpathpattern=None, withBXInfo=False, bxAlgo=None, xingMinLum=None, withBeamIntensity=False, lumitype='HF', minbiasXsec=None)
def normIdByName(schema, normname)
def currentDataTag(schema, lumitype='HF')
def toScreenLumiByLS(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def parseInputFiles(inputfilename)
def normIdByType(schema, lumitype='HF', defaultonly=True)
def runsummaryMap(schema, irunlsdict, dataidmap, lumitype='HF')
def toScreenTotDelivered(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def lumiForIds(schema, irunlsdict, dataidmap, runsummaryMap, beamstatusfilter=None, timeFilter=None, normmap=None, withBXInfo=False, bxAlgo=None, xingMinLum=None, withBeamIntensity=False, lumitype='HF', minbiasXsec=None)
def toCSVLumiByLSXing(lumidata, scalefactor, filename, irunlsdict=None, noWarning=True)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def toScreenHeader(commandname, datatagname, normtag, worktag, updatetag, lumitype, toFile=None)
def normValueById(schema, normid)
def toScreenTotEffective(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def toScreenLSEffective(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def deliveredLumiForIds(schema, irunlsdict, dataidmap, runsummaryMap, beamstatusfilter=None, timeFilter=None, normmap=None, withBXInfo=False, bxAlgo=None, xingMinLum=None, withBeamIntensity=False, lumitype='HF', minbiasXsec=None)
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
def getDataTagId(schema, tagname, lumitype='HF')
def runList(schema, datatagid, runmin=None, runmax=None, fillmin=None, fillmax=None, startT=None, stopT=None, l1keyPattern=None, hltkeyPattern=None, amodetag=None, nominalEnergy=None, energyFlut=0.2, requiretrg=True, requirehlt=True, preselectedruns=None, lumitype='HF')