1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
5 import FWCore.ParameterSet.VarParsing
as VarParsing
8 from dqmPythonTypes
import *
11 from Configuration.Applications.ConfigBuilder
import filesFromDASQuery
18 VarParsing.VarParsing.multiplicity.singleton,
19 VarParsing.VarParsing.varType.string,
23 options.register(
'runNumber',
25 VarParsing.VarParsing.multiplicity.singleton,
26 VarParsing.VarParsing.varType.int,
27 "Run number. This run number has to be present in the dataset configured with the dataset option.")
29 options.register(
'maxLumi',
31 VarParsing.VarParsing.multiplicity.singleton,
32 VarParsing.VarParsing.varType.int,
33 "Only lumisections up to maxLumi are processed.")
35 options.register(
'minLumi',
37 VarParsing.VarParsing.multiplicity.singleton,
38 VarParsing.VarParsing.varType.int,
39 "Only lumisections starting from minLumi are processed.")
41 options.register(
'lumiPattern',
43 VarParsing.VarParsing.multiplicity.singleton,
44 VarParsing.VarParsing.varType.string,
45 "Only lumisections with numbers matching lumiPattern are processed.")
47 options.register(
'dataset',
49 VarParsing.VarParsing.multiplicity.singleton,
50 VarParsing.VarParsing.varType.string,
51 "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.")
53 options.parseArguments()
57 from dataset_cfi
import readFiles, secFiles
58 print(
"Using filenames from dataset_cfi.py.")
60 if options.dataset ==
'auto':
61 print(
"Querying DAS for a dataset...")
63 out = subprocess.check_output(
"dasgoclient --query 'dataset run=%d dataset=/*Express*/*/*FEVT*'" % options.runNumber, shell=
True)
64 dataset = out.splitlines()[-1]
65 print(
"Using dataset=%s." % dataset)
67 dataset = options.dataset
69 print(
"Querying DAS for files...")
70 readFiles = cms.untracked.vstring()
71 secFiles = cms.untracked.vstring()
73 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s" % (options.runNumber, dataset), option=
" --limit 10000 ")
74 readFiles.extend(read)
77 print(
"Got %d files." % len(readFiles))
79 runstr =
str(options.runNumber)
80 runpattern =
"*" + runstr[0:3] +
"/" + runstr[3:] +
"*" 81 readFiles = cms.untracked.vstring([f
for f
in readFiles
if fnmatch.fnmatch(f, runpattern)])
82 secFiles = cms.untracked.vstring([f
for f
in secFiles
if fnmatch.fnmatch(f, runpattern)])
83 lumirange = cms.untracked.VLuminosityBlockRange(
84 [
str(options.runNumber) +
":" +
str(ls)
85 for ls
in range(options.minLumi, options.maxLumi+1)
86 if fnmatch.fnmatch(
str(ls), options.lumiPattern)
90 print(
"Selected %d files and %d LS." % (len(readFiles), len(lumirange)))
92 source = cms.Source (
"PoolSource",fileNames = readFiles, secondaryFileNames = secFiles, lumisToProcess = lumirange)
93 maxEvents = cms.untracked.PSet(
94 input = cms.untracked.int32(-1)
102 if not options.runkey.strip():
103 options.runkey =
"pp_run" 105 runType.setRunType(options.runkey.strip())
S & print(S &os, JobReport::InputFile const &f)
def filesFromDASQuery(query, option="", s=None)