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.register(
'transDelay',
57 VarParsing.VarParsing.multiplicity.singleton,
58 VarParsing.VarParsing.varType.int,
59 "delay in seconds for the commit of the db transaction")
61 options.register(
'noDB',
63 VarParsing.VarParsing.multiplicity.singleton,
64 VarParsing.VarParsing.varType.bool,
65 "Don't upload the BeamSpot conditions to the DB")
67 options.parseArguments()
71 from dataset_cfi
import readFiles, secFiles
72 print(
"Using filenames from dataset_cfi.py.")
74 if options.dataset ==
'auto':
75 print(
"Querying DAS for a dataset...")
77 out = subprocess.check_output(
"dasgoclient --query 'dataset run=%d dataset=/*Express*/*/*FEVT*'" % options.runNumber, shell=
True)
78 dataset = out.splitlines()[-1]
79 print(
"Using dataset=%s." % dataset)
81 dataset = options.dataset
83 print(
"Querying DAS for files...")
84 readFiles = cms.untracked.vstring()
85 secFiles = cms.untracked.vstring()
87 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s" % (options.runNumber, dataset), option=
" --limit 10000 ")
88 readFiles.extend(read)
91 print(
"Got %d files." % len(readFiles))
93 runstr =
str(options.runNumber)
94 runpattern =
"*" + runstr[0:3] +
"/" + runstr[3:] +
"*"
95 readFiles = cms.untracked.vstring([f
for f
in readFiles
if fnmatch.fnmatch(f, runpattern)])
96 secFiles = cms.untracked.vstring([f
for f
in secFiles
if fnmatch.fnmatch(f, runpattern)])
97 lumirange = cms.untracked.VLuminosityBlockRange(
98 [
str(options.runNumber) +
":" +
str(ls)
99 for ls
in range(options.minLumi, options.maxLumi+1)
100 if fnmatch.fnmatch(
str(ls), options.lumiPattern)
104 print(
"Selected %d files and %d LS." % (len(readFiles), len(lumirange)))
106 source = cms.Source (
"PoolSource",fileNames = readFiles, secondaryFileNames = secFiles, lumisToProcess = lumirange)
107 maxEvents = cms.untracked.PSet(
108 input = cms.untracked.int32(-1)
116 if not options.runkey.strip():
117 options.runkey =
"pp_run"
119 runType.setRunType(options.runkey.strip())