1 import FWCore.ParameterSet.Config
as cms
4 import FWCore.ParameterSet.VarParsing
as VarParsing
7 from dqmPythonTypes
import *
10 from Configuration.Applications.ConfigBuilder
import filesFromDASQuery
17 VarParsing.VarParsing.multiplicity.singleton,
18 VarParsing.VarParsing.varType.string,
22 options.register(
'runNumber',
24 VarParsing.VarParsing.multiplicity.singleton,
25 VarParsing.VarParsing.varType.int,
26 "Run number. This run number has to be present in the dataset configured with the dataset option.")
28 options.register(
'maxLumi',
30 VarParsing.VarParsing.multiplicity.singleton,
31 VarParsing.VarParsing.varType.int,
32 "Only lumisections up to maxLumi are processed.")
34 options.register(
'minLumi',
36 VarParsing.VarParsing.multiplicity.singleton,
37 VarParsing.VarParsing.varType.int,
38 "Only lumisections starting from minLumi are processed.")
40 options.register(
'lumiPattern',
42 VarParsing.VarParsing.multiplicity.singleton,
43 VarParsing.VarParsing.varType.string,
44 "Only lumisections with numbers matching lumiPattern are processed.")
46 options.register(
'dataset',
48 VarParsing.VarParsing.multiplicity.singleton,
49 VarParsing.VarParsing.varType.string,
50 "Dataset name like '/ExpressPhysicsPA/PARun2016D-Express-v1/FEVT', or 'auto' to guess it with a DAS query. A dataset_cfi.py that defines 'readFiles' and 'secFiles' (like a DAS Python snippet) will override this, to avoid DAS queries.")
52 options.parseArguments()
56 from dataset_cfi
import readFiles, secFiles
57 print "Using filenames from dataset_cfi.py." 59 if options.dataset ==
'auto':
60 print "Querying DAS for a dataset..." 62 out = subprocess.check_output(
"dasgoclient --query 'dataset run=%d dataset=/*Express*/*/*FEVT*'" % options.runNumber, shell=
True)
63 dataset = out.splitlines()[-1]
64 print "Using dataset=%s." % dataset
66 dataset = options.dataset
68 print "Querying DAS for files..." 69 readFiles = cms.untracked.vstring()
70 secFiles = cms.untracked.vstring()
72 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s" % (options.runNumber, dataset), option=
" --limit 10000 ")
73 readFiles.extend(read)
76 print "Got %d files." % len(readFiles)
78 runstr =
str(options.runNumber)
79 runpattern =
"*" + runstr[0:3] +
"/" + runstr[3:] +
"*" 80 readFiles = cms.untracked.vstring([f
for f
in readFiles
if fnmatch.fnmatch(f, runpattern)])
81 secFiles = cms.untracked.vstring([f
for f
in secFiles
if fnmatch.fnmatch(f, runpattern)])
82 lumirange = cms.untracked.VLuminosityBlockRange(
83 [
str(options.runNumber) +
":" +
str(ls)
84 for ls
in range(options.minLumi, options.maxLumi+1)
85 if fnmatch.fnmatch(
str(ls), options.lumiPattern)
89 print "Selected %d files and %d LS." % (len(readFiles), len(lumirange))
91 source = cms.Source (
"PoolSource",fileNames = readFiles, secondaryFileNames = secFiles, lumisToProcess = lumirange)
92 maxEvents = cms.untracked.PSet(
93 input = cms.untracked.int32(100)
101 if not options.runkey.strip():
102 options.runkey =
"pp_run" 104 runType.setRunType(options.runkey.strip())
def filesFromDASQuery(query, option="", s=None)