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
9 from future.moves
import subprocess
10 from .dqmPythonTypes
import *
13 from Configuration.Applications.ConfigBuilder
import filesFromDASQuery
22 VarParsing.VarParsing.multiplicity.singleton,
23 VarParsing.VarParsing.varType.string,
27 options.register(
'runNumber',
29 VarParsing.VarParsing.multiplicity.singleton,
30 VarParsing.VarParsing.varType.int,
31 "Run number. This run number has to be present in the dataset configured with the dataset option.")
33 options.register(
'dataset',
34 '/ExpressCosmics/Commissioning2019-Express-v1/FEVT',
35 VarParsing.VarParsing.multiplicity.singleton,
36 VarParsing.VarParsing.varType.string,
37 "Dataset name like '/ExpressCosmics/Commissioning2019-Express-v1/FEVT'")
39 options.register(
'maxLumi',
41 VarParsing.VarParsing.multiplicity.singleton,
42 VarParsing.VarParsing.varType.int,
43 "Only lumisections up to maxLumi are processed.")
45 options.register(
'minLumi',
47 VarParsing.VarParsing.multiplicity.singleton,
48 VarParsing.VarParsing.varType.int,
49 "Only lumisections starting from minLumi are processed.")
51 options.register(
'lumiPattern',
53 VarParsing.VarParsing.multiplicity.singleton,
54 VarParsing.VarParsing.varType.string,
55 "Only lumisections with numbers matching lumiPattern are processed.")
57 options.register(
'eventsPerLumi',
59 VarParsing.VarParsing.multiplicity.singleton,
60 VarParsing.VarParsing.varType.int,
61 "This number of last events in each lumisection will be processed.")
63 options.register(
'transDelay',
65 VarParsing.VarParsing.multiplicity.singleton,
66 VarParsing.VarParsing.varType.int,
67 "delay in seconds for the commit of the db transaction")
71 options.register(
'unitTest',
73 VarParsing.VarParsing.multiplicity.singleton,
74 VarParsing.VarParsing.varType.bool,
75 "Required to avoid the error.")
77 options.register(
'noDB',
79 VarParsing.VarParsing.multiplicity.singleton,
80 VarParsing.VarParsing.varType.bool,
81 "Don't upload the BeamSpot conditions to the DB")
83 options.parseArguments()
85 print(
"Querying DAS for files...")
86 readFiles = cms.untracked.vstring()
87 secFiles = cms.untracked.vstring()
91 for ls
in range(options.minLumi, options.maxLumi+1):
92 if fnmatch.fnmatch(
str(ls), options.lumiPattern):
93 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s lumi=%s" % (options.runNumber, options.dataset, ls))
94 readFiles.extend(read)
98 command =
"edmFileUtil --catalog file:/cvmfs/cms-ib.cern.ch/SITECONF/local/PhEDEx/storage.xml?protocol=xrootd --events %s | tail -n +9 | head -n -5 | awk '{ print $3 }'" % read[0]
100 events = subprocess.check_output(command, shell=
True)
101 events = events.split(b
'\n')
102 events =
filter(
lambda x: x != b
"", events)
103 events =
map(int, events)
104 events = sorted(events)
105 events = events[-options.eventsPerLumi:]
106 eventsToProcess.append(
"%s:%s:%s-%s:%s:%s" % (options.runNumber, ls, events[0], options.runNumber, ls, events[-1]))
108 eventRange = cms.untracked.VEventRange(eventsToProcess)
110 print(
"Got %d files." % len(readFiles))
112 source = cms.Source (
"PoolSource", fileNames = readFiles, secondaryFileNames = secFiles, eventsToProcess = eventRange)
113 maxEvents = cms.untracked.PSet(
114 input = cms.untracked.int32(-1)
118 if not options.runkey.strip():
119 options.runkey =
"pp_run"
121 runType.setRunType(options.runkey.strip())