本文整理汇总了Python中WMCore.Lexicon.slicedIterator方法的典型用法代码示例。如果您正苦于以下问题:Python Lexicon.slicedIterator方法的具体用法?Python Lexicon.slicedIterator怎么用?Python Lexicon.slicedIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Lexicon
的用法示例。
在下文中一共展示了Lexicon.slicedIterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getMaskedBlocks
# 需要导入模块: from WMCore import Lexicon [as 别名]
# 或者: from WMCore.Lexicon import slicedIterator [as 别名]
def getMaskedBlocks(self, task, dbs, datasetPath):
""" Get the blocks which pass the lumi mask restrictions. For each block return the list of lumis
which were ok (given the lumi mask). The data structure returned is the following:
{
"block1" : {"file1" : LumiList(), "file5" : LumiList(), ...}
"block2" : {"file2" : LumiList(), "file7" : LumiList(), ...}
}
"""
# Get mask and convert to LumiList to make operations easier
maskedBlocks = {}
lumiMask = task.getLumiMask()
taskMask = LumiList(compactList = lumiMask)
# Find all the files that have runs and lumis we are interested in,
# fill block lfn part of maskedBlocks
for run, lumis in lumiMask.items():
files = []
for slumis in Lexicon.slicedIterator(lumis, 50):
slicedFiles = dbs.dbs.listFileArray(dataset=datasetPath, run_num=run,
lumi_list=slumis, detail=True)
files.extend(slicedFiles)
for file in files:
blockName = file['block_name']
fileName = file['logical_file_name']
if blockName not in maskedBlocks:
maskedBlocks[blockName] = {}
if fileName not in maskedBlocks[blockName]:
maskedBlocks[blockName][fileName] = LumiList()
# Fill maskedLumis part of maskedBlocks
for block in maskedBlocks:
fileLumis = dbs.dbs.listFileLumis(block_name=block, validFileOnly = 1)
for fileLumi in fileLumis:
lfn = fileLumi['logical_file_name']
# For each run : [lumis] mask by needed lumis, append to maskedBlocks
if maskedBlocks[block].get(lfn, None) is not None:
lumiList = LumiList(runsAndLumis = {fileLumi['run_num']: fileLumi['lumi_section_num']})
maskedBlocks[block][lfn] += (lumiList & taskMask)
return maskedBlocks