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 '/ExpressCosmics/Commissioning2021-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.")
72 options.register(
'unitTest',
74 VarParsing.VarParsing.multiplicity.singleton,
75 VarParsing.VarParsing.varType.bool,
76 "Required to avoid the error.")
78 options.register(
'noDB',
80 VarParsing.VarParsing.multiplicity.singleton,
81 VarParsing.VarParsing.varType.bool,
82 "Don't upload the BeamSpot conditions to the DB")
84 options.parseArguments()
86 print(
"Querying DAS for files...")
87 readFiles = cms.untracked.vstring()
88 secFiles = cms.untracked.vstring()
92 for ls
in range(options.minLumi, options.maxLumi+1):
93 if fnmatch.fnmatch(
str(ls), options.lumiPattern):
94 read, sec =
filesFromDASQuery(
"file run=%d dataset=%s lumi=%s" % (options.runNumber, options.dataset, ls))
95 readFiles.extend(read)
99 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]
101 events = subprocess.check_output(command, shell=
True)
102 events = events.split(b
'\n')
103 events =
filter(
lambda x: x != b
"", events)
104 events = map(int, events)
105 events = sorted(events)
106 events = events[-options.eventsPerLumi:]
107 eventsToProcess.append(
"%s:%s:%s-%s:%s:%s" % (options.runNumber, ls, events[0], options.runNumber, ls, events[-1]))
109 eventRange = cms.untracked.VEventRange(eventsToProcess)
111 print(
"Got %d files." % len(readFiles))
113 source = cms.Source (
"PoolSource",
114 fileNames = readFiles,
115 secondaryFileNames = secFiles,
116 eventsToProcess = eventRange,
119 inputCommands = cms.untracked.vstring(
121 'keep FEDRawDataCollection_rawDataCollector_*_*',
122 'keep GlobalObjectMapRecord_hltGtStage2ObjectMap_*_*',
123 'keep edmTriggerResults_TriggerResults_*_*'
125 dropDescendantsOfDroppedBranches = cms.untracked.bool(
True)
127 maxEvents = cms.untracked.PSet(
128 input = cms.untracked.int32(-1)
132 if not options.runkey.strip():
133 options.runkey =
"pp_run"
135 runType.setRunType(options.runkey.strip())
const uint16_t range(const Frame &aFrame)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)