10 from RecoLuminosity.LumiDB
import sessionManager,lumiTime,inputFilesetParser,csvSelectionParser,csvReporter,argparse,CommonUtil,lumiCalcAPI,lumiReport,RegexValidator,lumiTime,revisionDML
14 output ({run:[cmsls,cmsls,...]},[[resultlines]]) 19 runlsbyfile=p.runsandls()
20 selectedProcessedRuns=p.selectedRunsWithresult()
21 selectedNonProcessedRuns=p.selectedRunsWithoutresult()
22 resultlines=p.resultlines()
23 for runinfile
in selectedNonProcessedRuns:
24 selectedrunlsInDB[runinfile]=runlsbyfile[runinfile]
25 return (selectedrunlsInDB,resultlines)
35 if __name__ ==
'__main__':
36 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description =
"Additional information needed in the lumi calculation",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
37 allowedActions = [
'hltbyls',
'hltmenu',
'trgbyls',
'beambyls',
'runsummary']
38 amodetagChoices = [
"PROTPHYS",
"IONPHYS",
"PAPHYS" ]
39 beamModeChoices = [
"stable"]
48 parser.add_argument(
'action',choices=allowedActions,
49 help=
'command actions')
50 parser.add_argument(
'-c',dest=
'connect',action=
'store',
52 help=
'connect string to lumiDB,optional',
53 default=
'frontier://LumiCalc/CMS_LUMI_PROD')
54 parser.add_argument(
'-P',dest=
'authpath',action=
'store',
56 help=
'path to authentication file (optional)')
57 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',
60 help=
'run number (optional)')
61 parser.add_argument(
'-o',dest=
'outputfile',action=
'store',
63 help=
'output to csv file (optional)')
67 parser.add_argument(
'-i',dest=
'inputfile',action=
'store',
69 help=
'run/ls selection file (optional)')
70 parser.add_argument(
'--name',dest=
'name',action=
'store',
71 help=
'hltpath/l1bit name/pattern' 76 parser.add_argument(
'-b',dest=
'beammode',action=
'store',
77 choices=beamModeChoices,
79 help=
'beam mode choices [stable] (optional)')
80 parser.add_argument(
'-f',
'--fill',dest=
'fillnum',action=
'store',
81 default=
None,required=
False,
82 help=
'fill number (optional) ')
83 parser.add_argument(
'--amodetag',dest=
'amodetag',action=
'store',
84 choices=amodetagChoices,
86 help=
'specific accelerator mode choices [PROTOPHYS,IONPHYS] (optional)')
87 parser.add_argument(
'--beamenergy',dest=
'beamenergy',action=
'store',
90 help=
'nominal beam energy in GeV')
91 parser.add_argument(
'--beamfluctuation',dest=
'beamfluctuation',
92 type=float,action=
'store',
95 help=
'fluctuation in fraction allowed to nominal beam energy, default 0.2, to be used together with -beamenergy (optional)')
96 parser.add_argument(
'--minintensity',dest=
'minintensity',
97 type=float,action=
'store',
100 help=
'filter on beam intensity , effective with --with-beamintensity (optional)')
101 parser.add_argument(
'--begin',dest=
'begin',action=
'store',
105 help=
'min run start time, mm/dd/yy hh:mm:ss)' 107 parser.add_argument(
'--end',dest=
'end',action=
'store',
111 help=
'max run start time, mm/dd/yy hh:mm:ss' 116 parser.add_argument(
'--datatag',dest=
'datatag',action=
'store',
118 help=
'version of lumi/trg/hlt data' 123 parser.add_argument(
'--siteconfpath',dest=
'siteconfpath',action=
'store',
126 help=
'specific path to site-local-config.xml file, optional. If path undefined, fallback to cern proxy&server')
130 parser.add_argument(
'--with-beamintensity',
131 dest=
'withbeamintensity',
133 help=
'dump beam intensity' 135 parser.add_argument(
'--without-mask',
138 help=
'not considering trigger mask' 140 parser.add_argument(
'--verbose',
143 help=
'verbose mode for printing' )
144 parser.add_argument(
'--nowarning',
147 help=
'suppress bad for lumi warnings' 149 parser.add_argument(
'--debug',
154 options=parser.parse_args()
155 if not options.runnumber
and not options.inputfile
and not options.fillnum
and not options.begin:
156 raise RuntimeError(
'at least one run selection argument in [-r,-f,-i,--begin] is required')
163 timeFilter=[
None,
None]
168 if options.beammode==
'stable':
169 pbeammode =
'STABLE BEAMS' 170 if options.action==
'trgbyls':
172 if options.action==
'hltbyls':
174 if options.runnumber:
175 reqrunmax=options.runnumber
176 reqrunmin=options.runnumber
178 reqfillmin=options.fillnum
179 reqfillmax=options.fillnum
184 reqtimeminT=lute.StrToDatetime(reqtimemin,customfm=
'%m/%d/%y %H:%M:%S')
185 timeFilter[0]=reqtimeminT
190 reqtimemaxT=lute.StrToDatetime(reqtimemax,customfm=
'%m/%d/%y %H:%M:%S')
191 timeFilter[1]=reqtimemaxT
195 if sname
is not None:
197 if sname==
'*' or sname==
'all':
199 elif 1
in [c
in sname
for c
in '*?[]']:
202 if options.action ==
'beambyls' and options.withbeamintensity
and not options.outputfile:
203 print '[warning] --with-beamintensity must write data to a file, none specified using default "beamintensity.csv"' 204 options.outputfile=
'beamintensity.csv' 213 os.environ[
'CORAL_AUTH_PATH'] = options.authpath
216 authpath=options.authpath,
217 siteconfpath=options.siteconfpath,
218 debugON=options.debug)
219 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
227 session.transaction().
start(
True)
229 if options.inputfile:
231 filerunlist=irunlsdict.keys()
233 datatagname=options.datatag
239 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)
241 print '[INFO] No qualified run found, do nothing' 245 for irun,(lid,tid,hid)
in dataidmap.items():
247 print '[INFO] No qualified lumi data found for run, ',irun
248 if reqTrg
and not tid:
249 print '[INFO] No qualified trg data found for run ',irun
251 if reqHlt
and not hid:
252 print '[INFO] No qualified hlt data found for run ',irun
256 irunlsdict=
dict(
list(
zip(rruns,[
None]*len(rruns))))
258 for selectedrun
in irunlsdict.keys():
259 if selectedrun
not in rruns:
260 del irunlsdict[selectedrun]
262 print '[INFO] No qualified run found, do nothing' 265 session.transaction().commit()
269 if options.action ==
'trgbyls':
270 session.transaction().
start(
True)
271 result=
lumiCalcAPI.trgForIds(session.nominalSchema(),irunlsdict,dataidmap,trgbitname=sname,trgbitnamepattern=spattern,withL1Count=
True,withPrescale=
True)
272 session.transaction().commit()
273 if not options.outputfile:
274 lumiReport.toScreenLSTrg(result,iresults=iresults,irunlsdict=irunlsdict,noWarning=options.nowarning,withoutmask=options.withoutmask)
276 lumiReport.toScreenLSTrg(result,iresults=iresults,irunlsdict=irunlsdict,noWarning=options.nowarning,toFile=options.outputfile,withoutmask=options.withoutmask)
279 if options.action ==
'hltbyls':
281 print '[ERROR] --name option is required by hltbyls, do nothing' 285 session.transaction().
start(
True)
286 result=
lumiCalcAPI.hltForIds(session.nominalSchema(),irunlsdict,dataidmap,hltpathname=sname,hltpathpattern=spattern,withL1Pass=withL1Pass,withHLTAccept=withHLTAccept)
287 session.transaction().commit()
288 if not options.outputfile:
292 if options.action ==
'hltmenu':
293 session.transaction().
start(
True)
295 session.transaction().commit()
297 if not options.outputfile:
301 if options.action ==
'beambyls':
302 session.transaction().
start(
True)
303 dumpbeamintensity=
False 304 if options.outputfile
and options.verbose:
305 dumpbeamintensity=
True 306 result=
lumiCalcAPI.beamForIds(session.nominalSchema(),irunlsdict,dataidmap,withBeamIntensity=options.withbeamintensity,minIntensity=options.minintensity)
307 session.transaction().commit()
308 if not options.outputfile:
312 if options.action ==
'runsummary':
313 session.transaction().
start(
True)
315 session.transaction().commit()
322 starttime=c.StrToDatetime(r[7])
323 starttime=starttime.strftime(
'%m/%d/%y %H:%M:%S')
324 stoptime=c.StrToDatetime(r[8])
325 stoptime=stoptime.strftime(
'%m/%d/%y %H:%M:%S')
334 print 'Run ',
str(run),
' Fill ',fill,
' Amodetag ',amodetag,
' egev ',egev
335 print '\tStart '+starttime,
' ',
' Stop ',stoptime
336 print '\tL1key ',l1key,
' HLTkey ',hltkey
def parseInputFiles(inputfilename)
def toScreenLSHlt(hltdata, iresults=[], toFile=None)
def hltpathsForRange(schema, runlist, hltpathname=None, hltpathpattern=None)
def currentDataTag(schema, lumitype='HF')
def toScreenConfHlt(hltconfdata, iresults=[], toFile=None)
def toScreenLSTrg(trgdata, iresults=[], irunlsdict=None, noWarning=True, toFile=None, withoutmask=False)
def hltForIds(schema, irunlsdict, dataidmap, hltpathname=None, hltpathpattern=None, withL1Pass=False, withHLTAccept=False)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def beamForIds(schema, irunlsdict, dataidmap, withBeamIntensity=False, minIntensity=0.1)
def toScreenHeader(commandname, datatagname, normtag, worktag, updatetag, lumitype, toFile=None)
def trgForIds(schema, irunlsdict, dataidmap, trgbitname=None, trgbitnamepattern=None, withL1Count=False, withPrescale=False)
def toScreenLSBeam(beamdata, iresults=[], dumpIntensity=False, toFile=None)
def runsummary(schema, irunlsdict)
Lumi data management and calculation API # # Author: Zhen Xie #.
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')