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
19 options.register(
"runkey",
21 VarParsing.VarParsing.multiplicity.singleton,
22 VarParsing.VarParsing.varType.string,
26 options.register(
'runUniqueKey',
28 VarParsing.VarParsing.multiplicity.singleton,
29 VarParsing.VarParsing.varType.string,
30 "Unique run key from RCMS for Frontier")
32 options.register(
'runNumber',
34 VarParsing.VarParsing.multiplicity.singleton,
35 VarParsing.VarParsing.varType.int,
36 "Run number. This run number has to be present in the dataset configured with the dataset option.")
38 options.register(
'dataset',
39 '/ExpressPhysics/Run2022B-Express-v1/FEVT',
40 VarParsing.VarParsing.multiplicity.singleton,
41 VarParsing.VarParsing.varType.string,
42 "Dataset name like '/ExpressCosmics/Commissioning2021-Express-v1/FEVT'")
44 options.register(
'maxLumi',
46 VarParsing.VarParsing.multiplicity.singleton,
47 VarParsing.VarParsing.varType.int,
48 "Only lumisections up to maxLumi are processed.")
50 options.register(
'minLumi',
52 VarParsing.VarParsing.multiplicity.singleton,
53 VarParsing.VarParsing.varType.int,
54 "Only lumisections starting from minLumi are processed.")
56 options.register(
'lumiPattern',
58 VarParsing.VarParsing.multiplicity.singleton,
59 VarParsing.VarParsing.varType.string,
60 "Only lumisections with numbers matching lumiPattern are processed.")
62 options.register(
'eventsPerLumi',
64 VarParsing.VarParsing.multiplicity.singleton,
65 VarParsing.VarParsing.varType.int,
66 "This number of last events in each lumisection will be processed.")
68 options.register(
'BeamSplashRun',
70 VarParsing.VarParsing.multiplicity.singleton,
71 VarParsing.VarParsing.varType.bool,
72 "Set client source settings for beam SPLASH run")
76 options.register(
'unitTest',
78 VarParsing.VarParsing.multiplicity.singleton,
79 VarParsing.VarParsing.varType.bool,
80 "Required to avoid the error.")
82 options.register(
'noDB',
84 VarParsing.VarParsing.multiplicity.singleton,
85 VarParsing.VarParsing.varType.bool,
86 "Don't upload the BeamSpot conditions to the DB")
88 options.parseArguments()
90 print(
"Querying DAS for files...")
91 readFiles = cms.untracked.vstring()
92 secFiles = cms.untracked.vstring()
96 for ls
in range(options.minLumi, options.maxLumi+1):
97 if fnmatch.fnmatch(
str(ls), options.lumiPattern):
98 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s lumi=%s" % (options.runNumber, options.dataset, ls))
99 readFiles.extend(read)
103 command =
"edmFileUtil --events %s | tail -n +9 | head -n -5 | awk '{ print $3 }'" % read[0]
105 events = subprocess.check_output(command, shell=
True)
106 events = events.split(b
'\n')
107 events =
filter(
lambda x: x != b
"", events)
108 events =
map(int, events)
109 events = sorted(events)
110 events = events[-options.eventsPerLumi:]
111 eventsToProcess.append(
"%s:%s:%s-%s:%s:%s" % (options.runNumber, ls, events[0], options.runNumber, ls, events[-1]))
113 eventRange = cms.untracked.VEventRange(eventsToProcess)
115 print(
"Got %d files." % len(readFiles))
117 source = cms.Source (
"PoolSource",
118 fileNames = readFiles,
119 secondaryFileNames = secFiles,
120 eventsToProcess = eventRange,
123 inputCommands = cms.untracked.vstring(
125 'keep FEDRawDataCollection_rawDataCollector_*_*',
126 'keep GlobalObjectMapRecord_hltGtStage2ObjectMap_*_*',
127 'keep edmTriggerResults_TriggerResults_*_*' 129 dropDescendantsOfDroppedBranches = cms.untracked.bool(
True)
131 maxEvents = cms.untracked.PSet(
132 input = cms.untracked.int32(-1)
136 if not options.runkey.strip():
137 options.runkey =
"pp_run" 139 runType.setRunType(options.runkey.strip())
def filesFromDASQuery(query, option="", s=None)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)