Skip to content

Commit 8fd36f3

Browse files
authored
Merge pull request #47525 from LinaresToine/repack-raw-skims
Repack raw skims
2 parents d7c08e7 + 680de4a commit 8fd36f3

File tree

3 files changed

+72
-28
lines changed

3 files changed

+72
-28
lines changed

Configuration/DataProcessing/python/Repack.py

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"""
88
import copy
99
import FWCore.ParameterSet.Config as cms
10-
10+
import HLTrigger.HLTfilters.hltHighLevel_cfi as hlt
11+
import Configuration.Skimming.RAWSkims_cff as RawSkims
12+
from Configuration.AlCa.GlobalTag import GlobalTag
1113

1214
def repackProcess(**args):
1315
"""
@@ -18,31 +20,37 @@ def repackProcess(**args):
1820
supported options:
1921
2022
- outputs : defines output modules
23+
- globalTag : contains trigger paths for the selected raw skims in outputs
24+
25+
Additional comments:
26+
27+
The selectEvents parameter within the outputs option is of type list, provided by T0.
28+
The paths in the list have an added ":HLT" to the string, which needs to be removed for propper use of the raw skim machinery.
2129
2230
"""
2331
from Configuration.EventContent.EventContent_cff import RAWEventContent
2432
from Configuration.EventContent.EventContent_cff import HLTSCOUTEventContent
2533
from Configuration.EventContent.EventContent_cff import L1SCOUTEventContent
2634
process = cms.Process("REPACK")
2735
process.load("FWCore.MessageLogger.MessageLogger_cfi")
28-
29-
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
36+
37+
process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))
3038

3139
process.configurationMetadata = cms.untracked.PSet(
32-
name = cms.untracked.string("repack-config"),
33-
version = cms.untracked.string("none"),
34-
annotation = cms.untracked.string("auto generated configuration")
35-
)
40+
name=cms.untracked.string("repack-config"),
41+
version=cms.untracked.string("none"),
42+
annotation=cms.untracked.string("auto generated configuration")
43+
)
3644

3745
process.options = cms.untracked.PSet(
38-
Rethrow = cms.untracked.vstring("ProductNotFound","TooManyProducts","TooFewProducts"),
39-
wantSummary = cms.untracked.bool(False)
40-
)
46+
Rethrow=cms.untracked.vstring("ProductNotFound", "TooManyProducts", "TooFewProducts"),
47+
wantSummary=cms.untracked.bool(False)
48+
)
4149

4250
process.source = cms.Source(
4351
"NewEventStreamFileReader",
44-
fileNames = cms.untracked.vstring()
45-
)
52+
fileNames=cms.untracked.vstring()
53+
)
4654

4755
defaultDataTier = "RAW"
4856

@@ -58,36 +66,56 @@ def repackProcess(**args):
5866

5967
if len(outputs) > 0:
6068
process.outputPath = cms.EndPath()
61-
69+
70+
globalTag = args.get('globalTag', None)
71+
if globalTag:
72+
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
73+
process.GlobalTag = GlobalTag(process.GlobalTag, globalTag, '')
74+
6275
for output in outputs:
6376

77+
selectEventsBase = output.get('selectEvents', None)
78+
rawSkim = output.get('rawSkim', None)
79+
80+
if rawSkim:
81+
82+
selectEventsBase = [item.replace(":HLT", "") for item in selectEventsBase]
83+
84+
process.baseSelection = hlt.hltHighLevel.clone(
85+
TriggerResultsTag = "TriggerResults::HLT",
86+
HLTPaths = cms.vstring(selectEventsBase)
87+
)
88+
skim = getattr(RawSkims, rawSkim)
89+
setattr(process, rawSkim, skim)
90+
path = cms.Path(skim + process.baseSelection)
91+
selectEvents = f"{rawSkim}Path"
92+
setattr(process, selectEvents, path)
93+
94+
else:
95+
selectEvents = selectEventsBase
96+
6497
moduleLabel = output['moduleLabel']
65-
selectEvents = output.get('selectEvents', None)
6698
maxSize = output.get('maxSize', None)
6799

68100
outputModule = cms.OutputModule(
69101
"PoolOutputModule",
70102
compressionAlgorithm=copy.copy(eventContent.compressionAlgorithm),
71103
compressionLevel=copy.copy(eventContent.compressionLevel),
72-
fileName = cms.untracked.string("%s.root" % moduleLabel)
73-
)
74-
104+
fileName=cms.untracked.string("%s.root" % moduleLabel)
105+
)
75106

76-
outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string(dataTier))
107+
outputModule.dataset = cms.untracked.PSet(dataTier=cms.untracked.string(dataTier))
77108

78-
if maxSize != None:
109+
if maxSize is not None:
79110
outputModule.maxSize = cms.untracked.int32(maxSize)
80111

81-
if selectEvents != None:
112+
if selectEvents is not None:
82113
outputModule.SelectEvents = cms.untracked.PSet(
83-
SelectEvents = cms.vstring(selectEvents)
84-
)
114+
SelectEvents=cms.vstring(selectEvents)
115+
)
85116

86117
setattr(process, moduleLabel, outputModule)
87118

88119
process.outputPath += outputModule
89120

90121
return process
91-
92-
93-

Configuration/DataProcessing/test/RunRepack.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def __init__(self):
1818
self.selectEvents = None
1919
self.inputLFN = None
2020
self.dataTier = None
21+
self.rawSkim = None
22+
self.globalTag= None
2123

2224
def __call__(self):
2325
if self.inputLFN == None:
@@ -36,9 +38,11 @@ def __call__(self):
3638
if self.selectEvents != None:
3739
outputs[0]['selectEvents'] = self.selectEvents.split(',')
3840
outputs[1]['selectEvents'] = self.selectEvents.split(',')
39-
41+
if self.rawSkim != None:
42+
outputs[0]['rawSkim'] = self.rawSkim
43+
outputs[1]['rawSkim'] = None
4044
try:
41-
process = repackProcess(outputs = outputs, dataTier = self.dataTier)
45+
process = repackProcess(outputs = outputs, globalTag = self.globalTag, dataTier = self.dataTier)
4246
except Exception as ex:
4347
msg = "Error creating process for Repack:\n"
4448
msg += str(ex)
@@ -60,7 +64,7 @@ def __call__(self):
6064

6165

6266
if __name__ == '__main__':
63-
valid = ["select-events=", "lfn=", "data-tier="]
67+
valid = ["select-events=", "lfn=", "data-tier=", "raw-skim=", "global-tag="]
6468

6569
usage = \
6670
"""
@@ -92,6 +96,10 @@ def __call__(self):
9296
repackinator.inputLFN = arg
9397
if opt == "--data-tier" :
9498
repackinator.dataTier = arg
99+
if opt == "--raw-skim":
100+
repackinator.rawSkim = arg
101+
if opt == "--global-tag":
102+
repackinator.globalTag = arg
95103

96104
repackinator()
97105

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import FWCore.ParameterSet.Config as cms
2+
import HLTrigger.HLTfilters.hltHighLevel_cfi as hlt
3+
4+
# ReserveDMu raw skim already exists, so we import it
5+
from Configuration.Skimming.PDWG_ReserveDMu_SD_cff import ReserveDMu
6+
7+
# Define here another raw skim if desired
8+

0 commit comments

Comments
 (0)