9 from __future__
import print_function
11 from RecoLuminosity.LumiDB
import sessionManager,lumiTime,inputFilesetParser,csvSelectionParser,selectionParser,csvReporter,argparse,CommonUtil,lumiCalcAPI,revisionDML,normDML,lumiReport,lumiCorrections,RegexValidator
15 output ({run:[cmsls,cmsls,...]},[[resultlines]]) 20 runlsbyfile=p.runsandls()
21 selectedProcessedRuns=p.selectedRunsWithresult()
22 selectedNonProcessedRuns=p.selectedRunsWithoutresult()
23 resultlines=p.resultlines()
24 for runinfile
in selectedNonProcessedRuns:
25 selectedrunlsInDB[runinfile]=runlsbyfile[runinfile]
26 return (selectedrunlsInDB,resultlines)
36 if __name__ ==
'__main__':
37 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description =
"Lumi Calculation Based on Pixel",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
38 allowedActions = [
'overview',
'recorded',
'lumibyls']
45 parser.add_argument(
'action',choices=allowedActions,
46 help=
'command actions')
47 parser.add_argument(
'-c',dest=
'connect',action=
'store',
49 help=
'connect string to lumiDB,optional',
50 default=
'frontier://LumiCalc/CMS_LUMI_PROD')
51 parser.add_argument(
'-P',dest=
'authpath',action=
'store',
53 help=
'path to authentication file (optional)')
54 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',
57 help=
'run number (optional)')
58 parser.add_argument(
'-o',dest=
'outputfile',action=
'store',
60 help=
'output to csv file (optional)')
64 parser.add_argument(
'-i',dest=
'inputfile',action=
'store',
66 help=
'lumi range selection file (optional)')
70 parser.add_argument(
'--hltpath',dest=
'hltpath',action=
'store',
71 default=
None,required=
False,
72 help=
'specific hltpath or hltpath pattern to calculate the effectived luminosity (optional)')
76 parser.add_argument(
'--normtag',dest=
'normtag',action=
'store',
78 help=
'version of lumi norm/correction')
79 parser.add_argument(
'--datatag',dest=
'datatag',action=
'store',
81 help=
'version of lumi/trg/hlt data')
85 parser.add_argument(
'-f',
'--fill',dest=
'fillnum',action=
'store',
86 default=
None,required=
False,
87 help=
'fill number (optional) ')
89 parser.add_argument(
'--begin',dest=
'begin',action=
'store',
93 help=
'min run start time (mm/dd/yy hh:mm:ss),min fill or min run' 95 parser.add_argument(
'--end',dest=
'end',action=
'store',
98 help=
'max run start time (mm/dd/yy hh:mm:ss),max fill or max run' 100 parser.add_argument(
'--minBiasXsec',dest=
'minbiasxsec',action=
'store',
104 help=
'minbias cross-section in ub' 109 parser.add_argument(
'-n',dest=
'scalefactor',action=
'store',
113 help=
'user defined global scaling factor on displayed lumi values,optional')
117 parser.add_argument(
'--siteconfpath',dest=
'siteconfpath',action=
'store',
120 help=
'specific path to site-local-config.xml file, optional. If path undefined, fallback to cern proxy&server')
122 parser.add_argument(
'--headerfile',dest=
'headerfile',action=
'store',
125 help=
'write command header output to specified file' 131 parser.add_argument(
'--without-correction',
134 help=
'without afterglow correction' 136 parser.add_argument(
'--without-checkforupdate',
137 dest=
'withoutCheckforupdate',
139 help=
'without check for update' 144 parser.add_argument(
'--nowarning',
147 help=
'suppress bad for lumi warnings' )
148 parser.add_argument(
'--debug',dest=
'debug',
152 options=parser.parse_args()
153 if not options.runnumber
and not options.inputfile
and not options.fillnum
and not options.begin:
154 raise RuntimeError(
'at least one run selection argument in [-r,-f,-i,--begin] is required')
164 timeFilter=[
None,
None]
165 noWarning=options.nowarning
169 if options.action==
'overview' or options.action==
'lumibyls':
171 if options.action==
'lumibyls' and options.hltpath:
173 if options.action==
'recorded':
176 if options.runnumber:
177 reqrunmax=options.runnumber
178 reqrunmin=options.runnumber
180 reqfillmin=options.fillnum
181 reqfillmax=options.fillnum
195 reqtimeminT=lute.StrToDatetime(reqtimemin,customfm=
'%m/%d/%y %H:%M:%S')
196 timeFilter[0]=reqtimeminT
209 reqtimemaxT=lute.StrToDatetime(reqtimemax,customfm=
'%m/%d/%y %H:%M:%S')
210 timeFilter[1]=reqtimemaxT
211 if options.inputfile
and (reqtimemax
or reqtimemin):
218 workingversion=
'UNKNOWN' 221 if not options.withoutCheckforupdate:
222 from RecoLuminosity.LumiDB
import checkforupdate
223 cmsswWorkingBase=os.environ[
'CMSSW_BASE']
224 if not cmsswWorkingBase:
225 print(
'Please check out RecoLuminosity/LumiDB from CVS,scram b,cmsenv')
228 workingversion=c.runningVersion(cmsswWorkingBase,
'pixelLumiCalc.py',isverbose=
False)
230 updateversionList=c.checkforupdate(workingversion,isverbose=
False)
231 if updateversionList:
232 updateversion=updateversionList[-1][0]
237 os.environ[
'CORAL_AUTH_PATH'] = options.authpath
241 if options.action==
'recorded':
242 if not options.hltpath:
243 raise RuntimeError(
'argument --hltpath pathname is required for recorded action')
245 authpath=options.authpath,
246 siteconfpath=options.siteconfpath,
247 debugON=options.debug)
249 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
255 session.transaction().
start(
True)
257 if options.inputfile:
259 filerunlist=irunlsdict.keys()
263 datatagname=options.datatag
269 dataidmap=
lumiCalcAPI.runList(session.nominalSchema(),datatagid,runmin=reqrunmin,runmax=reqrunmax,fillmin=reqfillmin,fillmax=reqfillmax,startT=reqtimemin,stopT=reqtimemax,l1keyPattern=
None,hltkeyPattern=
None,amodetag=
None,nominalEnergy=
None,energyFlut=
None,requiretrg=reqTrg,requirehlt=reqHlt,preselectedruns=filerunlist,lumitype=
'PIXEL')
271 print(
'[INFO] No qualified run found, do nothing')
274 for irun,(lid,tid,hid)
in dataidmap.items():
276 print(
'[INFO] No qualified lumi data found for run, ',irun)
277 if reqTrg
and not tid:
278 print(
'[INFO] No qualified trg data found for run ',irun)
280 if reqHlt
and not hid:
281 print(
'[INFO] No qualified hlt data found for run ',irun)
285 irunlsdict=
dict(
list(
zip(rruns,[
None]*len(rruns))))
287 for selectedrun
in irunlsdict.keys():
288 if selectedrun
not in rruns:
289 del irunlsdict[selectedrun]
291 print(
'[INFO] No qualified run found, do nothing')
299 if not options.withoutNorm:
300 normname=options.normtag
304 normname=normmap.keys()[0]
305 normid=normmap[normname]
309 raise RuntimeError(
'[ERROR] cannot resolve norm/correction')
312 session.transaction().commit()
318 session.transaction().
start(
True)
320 if options.action ==
'overview':
321 result=
lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=
None,timeFilter=timeFilter,normmap=normvalueDict,lumitype=
'PIXEL')
323 if options.action ==
'lumibyls':
324 if not options.hltpath:
325 result=
lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=
None,timeFilter=timeFilter,normmap=normvalueDict,lumitype=
'PIXEL',minbiasXsec=options.minbiasxsec)
326 lumiReport.toScreenLumiByLS(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
328 hltname=options.hltpath
330 if hltname==
'*' or hltname==
'all':
332 elif 1
in [c
in hltname
for c
in '*?[]']:
335 result=
lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=
None,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=
False,bxAlgo=
None,withBeamIntensity=
False,lumitype=
'PIXEL')
337 if options.action ==
'recorded':
338 hltname=options.hltpath
340 if hltname
is not None:
341 if hltname==
'*' or hltname==
'all':
343 elif 1
in [c
in hltname
for c
in '*?[]']:
346 result=
lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=
None,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=
False,bxAlgo=
None,withBeamIntensity=
False,lumitype=
'PIXEL')
348 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)
S & print(S &os, JobReport::InputFile const &f)
def normIdByType(schema, lumitype='HF', defaultonly=True)
def runsummaryMap(schema, irunlsdict, dataidmap, lumitype='HF')
def lumiForIds(schema, irunlsdict, dataidmap, runsummaryMap, beamstatusfilter=None, timeFilter=None, normmap=None, withBXInfo=False, bxAlgo=None, xingMinLum=None, withBeamIntensity=False, lumitype='HF', minbiasXsec=None)
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 parseInputFiles(inputfilename)
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')