本文整理汇总了Python中FWCore.PythonUtilities.LumiList.LumiList.getLumis方法的典型用法代码示例。如果您正苦于以下问题:Python LumiList.getLumis方法的具体用法?Python LumiList.getLumis怎么用?Python LumiList.getLumis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWCore.PythonUtilities.LumiList.LumiList
的用法示例。
在下文中一共展示了LumiList.getLumis方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LumiListForRunPeriod
# 需要导入模块: from FWCore.PythonUtilities.LumiList import LumiList [as 别名]
# 或者: from FWCore.PythonUtilities.LumiList.LumiList import getLumis [as 别名]
def LumiListForRunPeriod(rp, MIN_LUMIS=0):
ll = LumiList(filename = rp.json)
runs = [ run for run in map(int,ll.getRuns()) if run >= rp.firstRun and run <= rp.lastRun]
lumis = ll.getLumis()
nlumis = defaultdict(int)
for r,l in lumis:
nlumis[r]+=1
select_runs = [run for run in runs if nlumis[run] > MIN_LUMIS]
ll.selectRuns(select_runs)
return ll
示例2: len
# 需要导入模块: from FWCore.PythonUtilities.LumiList import LumiList [as 别名]
# 或者: from FWCore.PythonUtilities.LumiList.LumiList import getLumis [as 别名]
from FWCore.PythonUtilities.LumiList import LumiList
# Bomb if args not specified.
if len(sys.argv) < 3 or not os.path.isfile(sys.argv[1]):
print 'usage: prescales.py lumis.json pathsubstr'
sys.exit(1)
json = sys.argv[1]
path = sys.argv[2]
ll = LumiList(json)
# Why doesn't LumiList have a getRunsAndLumis method? It can be
# constructed from a dict of runsAndLumis... Anyway we'll use sets for
# faster searching later.
runs_and_lumis = defaultdict(set)
for r,l in ll.getLumis():
runs_and_lumis[r].add(l)
runs = runs_and_lumis.keys()
runs.sort()
# The path to look for: e.g. HLT_Mu30_v*. Should only find one per
# run, i.e. v4 and v5 do not exist simultaneously.
path_re = re.compile(r'HLT_%s_v\d+' % path)
# Magic.
parameters = lumiQueryAPI.ParametersObject()
session, svc = lumiQueryAPI.setupSession('frontier://LumiCalc/CMS_LUMI_PROD', None, parameters, False)
session.transaction().start(True)
schema = session.nominalSchema()
# Loop over all the requested runs, using the selected lumis, and get
示例3: getLumiFromLL
# 需要导入模块: from FWCore.PythonUtilities.LumiList import LumiList [as 别名]
# 或者: from FWCore.PythonUtilities.LumiList.LumiList import getLumis [as 别名]
inGoldenButNotCMS3 = goldenLumis - cms3Lumis
inGoldenButNotCMS3IntLumi = getLumiFromLL(inGoldenButNotCMS3)
# cms3LumisIntLumi = getLumiFromLL(cms3Lumis - (cms3Lumis - goldenLumis))
cms3LumisIntLumi = getLumiFromLL(cms3Lumis & goldenLumis)
print "We have %.2f/pb in CMS3" % (getLumiFromLL(cms3Lumis))
print "We have %.2f/pb in Golden&CMS3 (%.1f%% of golden)" % (cms3LumisIntLumi, 100.0*cms3LumisIntLumi/goldenIntLumi)
print "This is what is in the Golden JSON, but not the CMS3 merged (%.2f/pb):" % getLumiFromLL(inGoldenButNotCMS3)
print inGoldenButNotCMS3
print
for file in fileLumis.keys():
fileLumi = LumiList(compactList=fileLumis[file])
# Only care about stuff in the file that is in the golden JSON
fileLumi = fileLumi - (fileLumi - goldenLumis)
nLumisInFile = len(fileLumi.getLumis())
lumisWeDontHave = fileLumi - cms3Lumis
nLumisWeDontHave = len(lumisWeDontHave.getLumis())
# If we don't have ANY of the lumis in a file, it could be that we didn't run over the file
# (I am thus implicitly assuming that if we have any lumis in cms3 corresponding to a file
# that we actually ran over the whole file and maybe didn't store some lumis due to triggers)
if nLumisInFile == nLumisWeDontHave and nLumisInFile > 0:
# maybe we didn't run over this file
print " "*5,file
print " "*10,"File has lumis ", fileLumi,"and CMS3 is missing all of them"
print "\n"*2
示例4: LumiList
# 需要导入模块: from FWCore.PythonUtilities.LumiList import LumiList [as 别名]
# 或者: from FWCore.PythonUtilities.LumiList.LumiList import getLumis [as 别名]
#!/usr/bin/env python
import sys
from FWCore.PythonUtilities.LumiList import LumiList
ll = LumiList(filename=sys.argv[1])
print len(ll.getLumis())
示例5: len
# 需要导入模块: from FWCore.PythonUtilities.LumiList import LumiList [as 别名]
# 或者: from FWCore.PythonUtilities.LumiList.LumiList import getLumis [as 别名]
help='base for output filenames')
parser.add_option ('--outend', dest='outend', type='string', default = [],
help='ending for output filenames')
# required parameters
(options, args) = parser.parse_args()
if len (args) != 1:
raise RuntimeError, "Must provide exactly one input file"
if options.sec < 2:
raise RuntimeError, "Need at least 2 sections."
commaRE = re.compile (r',')
alphaList = LumiList (filename = args[0]) # Read in first JSON file
allLumis = alphaList.getLumis()
count_lumis = 0
for (run, lumi) in allLumis:
count_lumis += 1
lumis_per_sec = count_lumis/options.sec
print 'Found %s lumis in file.' % count_lumis
print 'Splitting into %s sections with %s lumis each.' % (options.sec, lumis_per_sec)
count_lumis = 0
for sec in range(options.sec):
ibegin = sec*lumis_per_sec
iend = ibegin + lumis_per_sec
if sec == options.sec - 1:
示例6: LumiList
# 需要导入模块: from FWCore.PythonUtilities.LumiList import LumiList [as 别名]
# 或者: from FWCore.PythonUtilities.LumiList.LumiList import getLumis [as 别名]
from FWCore.PythonUtilities.LumiList import LumiList
import sys
ll = LumiList(filename=sys.argv[1])
lumis = ll.getLumis()
nblock = 0
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in xrange(0, len(l), n):
yield l[i:i+n]
for lumiblock in chunks(lumis, 5):
print lumiblock
nblock += 1
ll2 = LumiList(lumis=lumiblock)
of = open(sys.argv[2] + "/block_{0}.json".format(nblock), "w")
of.write(str(ll2))
of.close()