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,
28 options.register(
'runUniqueKey',
30 VarParsing.VarParsing.multiplicity.singleton,
31 VarParsing.VarParsing.varType.string,
32 "Unique run key from RCMS for Frontier")
34 options.register(
'runNumber',
36 VarParsing.VarParsing.multiplicity.singleton,
37 VarParsing.VarParsing.varType.int,
38 "Run number. This run number has to be present in the dataset configured with the dataset option.")
40 options.register(
'dataset',
41 '/ExpressPhysics/Run2022B-Express-v1/FEVT',
42 VarParsing.VarParsing.multiplicity.singleton,
43 VarParsing.VarParsing.varType.string,
44 "Dataset name like '/ExpressCosmics/Commissioning2021-Express-v1/FEVT'")
46 options.register(
'maxLumi',
48 VarParsing.VarParsing.multiplicity.singleton,
49 VarParsing.VarParsing.varType.int,
50 "Only lumisections up to maxLumi are processed.")
52 options.register(
'minLumi',
54 VarParsing.VarParsing.multiplicity.singleton,
55 VarParsing.VarParsing.varType.int,
56 "Only lumisections starting from minLumi are processed.")
58 options.register(
'lumiPattern',
60 VarParsing.VarParsing.multiplicity.singleton,
61 VarParsing.VarParsing.varType.string,
62 "Only lumisections with numbers matching lumiPattern are processed.")
64 options.register(
'eventsPerLumi',
66 VarParsing.VarParsing.multiplicity.singleton,
67 VarParsing.VarParsing.varType.int,
68 "This number of last events in each lumisection will be processed.")
70 options.register(
'BeamSplashRun',
72 VarParsing.VarParsing.multiplicity.singleton,
73 VarParsing.VarParsing.varType.bool,
74 "Set client source settings for beam SPLASH run")
78 options.register(
'unitTest',
80 VarParsing.VarParsing.multiplicity.singleton,
81 VarParsing.VarParsing.varType.bool,
82 "Required to avoid the error.")
84 options.register(
'noDB',
86 VarParsing.VarParsing.multiplicity.singleton,
87 VarParsing.VarParsing.varType.bool,
88 "Don't upload the BeamSpot conditions to the DB")
90 options.parseArguments()
92 print(
"Querying DAS for files...")
93 readFiles = cms.untracked.vstring()
94 secFiles = cms.untracked.vstring()
98 for ls
in range(options.minLumi, options.maxLumi+1):
99 if fnmatch.fnmatch(
str(ls), options.lumiPattern):
100 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s lumi=%s" % (options.runNumber, options.dataset, ls))
101 readFiles.extend(read)
105 command =
"edmFileUtil --catalog file:/cvmfs/cms-ib.cern.ch/SITECONF/local/PhEDEx/storage.xml?protocol=ibeos --events %s | tail -n +9 | head -n -5 | awk '{ print $3 }'" % read[0]
107 events = subprocess.check_output(command, shell=
True)
108 events = events.split(b
'\n')
109 events =
filter(
lambda x: x != b
"", events)
110 events =
map(int, events)
111 events = sorted(events)
112 events = events[-options.eventsPerLumi:]
113 eventsToProcess.append(
"%s:%s:%s-%s:%s:%s" % (options.runNumber, ls, events[0], options.runNumber, ls, events[-1]))
115 eventRange = cms.untracked.VEventRange(eventsToProcess)
117 print(
"Got %d files." % len(readFiles))
119 source = cms.Source (
"PoolSource",
120 fileNames = readFiles,
121 secondaryFileNames = secFiles,
122 eventsToProcess = eventRange,
125 inputCommands = cms.untracked.vstring(
127 'keep FEDRawDataCollection_rawDataCollector_*_*',
128 'keep GlobalObjectMapRecord_hltGtStage2ObjectMap_*_*',
129 'keep edmTriggerResults_TriggerResults_*_*' 131 dropDescendantsOfDroppedBranches = cms.untracked.bool(
True)
133 maxEvents = cms.untracked.PSet(
134 input = cms.untracked.int32(-1)
138 if not options.runkey.strip():
139 options.runkey =
"pp_run" 141 runType.setRunType(options.runkey.strip())
def filesFromDASQuery(query, option="", s=None)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)