1 from __future__
import print_function
2 from __future__
import absolute_import
3 from builtins
import range
4 import FWCore.ParameterSet.Config
as cms
7 import FWCore.ParameterSet.VarParsing
as VarParsing
10 from .dqmPythonTypes
import *
13 from Configuration.Applications.ConfigBuilder
import filesFromDASQuery
20 VarParsing.VarParsing.multiplicity.singleton,
21 VarParsing.VarParsing.varType.string,
25 options.register(
'runNumber',
27 VarParsing.VarParsing.multiplicity.singleton,
28 VarParsing.VarParsing.varType.int,
29 "Run number. This run number has to be present in the dataset configured with the dataset option.")
31 options.register(
'maxLumi',
33 VarParsing.VarParsing.multiplicity.singleton,
34 VarParsing.VarParsing.varType.int,
35 "Only lumisections up to maxLumi are processed.")
37 options.register(
'minLumi',
39 VarParsing.VarParsing.multiplicity.singleton,
40 VarParsing.VarParsing.varType.int,
41 "Only lumisections starting from minLumi are processed.")
43 options.register(
'lumiPattern',
45 VarParsing.VarParsing.multiplicity.singleton,
46 VarParsing.VarParsing.varType.string,
47 "Only lumisections with numbers matching lumiPattern are processed.")
49 options.register(
'dataset',
51 VarParsing.VarParsing.multiplicity.singleton,
52 VarParsing.VarParsing.varType.string,
53 "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.")
55 options.parseArguments()
59 from dataset_cfi
import readFiles, secFiles
60 print(
"Using filenames from dataset_cfi.py.")
62 if options.dataset ==
'auto':
63 print(
"Querying DAS for a dataset...")
65 out = subprocess.check_output(
"dasgoclient --query 'dataset run=%d dataset=/*Express*/*/*FEVT*'" % options.runNumber, shell=
True)
66 dataset = out.splitlines()[-1]
67 print(
"Using dataset=%s." % dataset)
69 dataset = options.dataset
71 print(
"Querying DAS for files...")
72 readFiles = cms.untracked.vstring()
73 secFiles = cms.untracked.vstring()
75 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s" % (options.runNumber, dataset), option=
" --limit 10000 ")
76 readFiles.extend(read)
79 print(
"Got %d files." % len(readFiles))
81 runstr =
str(options.runNumber)
82 runpattern =
"*" + runstr[0:3] +
"/" + runstr[3:] +
"*" 83 readFiles = cms.untracked.vstring([f
for f
in readFiles
if fnmatch.fnmatch(f, runpattern)])
84 secFiles = cms.untracked.vstring([f
for f
in secFiles
if fnmatch.fnmatch(f, runpattern)])
85 lumirange = cms.untracked.VLuminosityBlockRange(
86 [
str(options.runNumber) +
":" +
str(ls)
87 for ls
in range(options.minLumi, options.maxLumi+1)
88 if fnmatch.fnmatch(
str(ls), options.lumiPattern)
92 print(
"Selected %d files and %d LS." % (len(readFiles), len(lumirange)))
94 source = cms.Source (
"PoolSource",fileNames = readFiles, secondaryFileNames = secFiles, lumisToProcess = lumirange)
95 maxEvents = cms.untracked.PSet(
96 input = cms.untracked.int32(-1)
104 if not options.runkey.strip():
105 options.runkey =
"pp_run" 107 runType.setRunType(options.runkey.strip())
S & print(S &os, JobReport::InputFile const &f)
def filesFromDASQuery(query, option="", s=None)