forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomizeHLTforCMSSW.py
251 lines (203 loc) · 10.6 KB
/
customizeHLTforCMSSW.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import FWCore.ParameterSet.Config as cms
# helper functions
from HLTrigger.Configuration.common import *
# add one customisation function per PR
# - put the PR number into the name of the function
# - add a short comment
# for example:
# CCCTF tuning
# def customiseFor12718(process):
# for pset in process._Process__psets.values():
# if hasattr(pset,'ComponentType'):
# if (pset.ComponentType == 'CkfBaseTrajectoryFilter'):
# if not hasattr(pset,'minGoodStripCharge'):
# pset.minGoodStripCharge = cms.PSet(refToPSet_ = cms.string('HLTSiStripClusterChargeCutNone'))
# return process
def customiseHCALFor2018Input(process):
"""Customise the HLT to run on Run 2 data/MC using the old readout for the HCAL barel"""
for producer in producers_by_type(process, "HBHEPhase1Reconstructor"):
# switch on the QI8 processing for 2018 HCAL barrel
producer.processQIE8 = True
# adapt CaloTowers threshold for 2018 HCAL barrel with only one depth
for producer in producers_by_type(process, "CaloTowersCreator"):
producer.HBThreshold1 = 0.7
producer.HBThreshold2 = 0.7
producer.HBThreshold = 0.7
# adapt Particle Flow threshold for 2018 HCAL barrel with only one depth
from RecoParticleFlow.PFClusterProducer.particleFlowClusterHBHE_cfi import _thresholdsHB, _thresholdsHEphase1, _seedingThresholdsHB
logWeightDenominatorHCAL2018 = cms.VPSet(
cms.PSet(
depths = cms.vint32(1, 2, 3, 4),
detector = cms.string('HCAL_BARREL1'),
logWeightDenominator = _thresholdsHB
),
cms.PSet(
depths = cms.vint32(1, 2, 3, 4, 5, 6, 7),
detector = cms.string('HCAL_ENDCAP'),
logWeightDenominator = _thresholdsHEphase1
)
)
for producer in producers_by_type(process, "PFRecHitProducer"):
if producer.producers[0].name.value() == 'PFHBHERecHitCreator':
producer.producers[0].qualityTests[0].cuts[0].threshold = _thresholdsHB
for producer in producers_by_type(process, "PFClusterProducer"):
if producer.seedFinder.thresholdsByDetector[0].detector.value() == 'HCAL_BARREL1':
producer.seedFinder.thresholdsByDetector[0].seedingThreshold = _seedingThresholdsHB
producer.initialClusteringStep.thresholdsByDetector[0].gatheringThreshold = _thresholdsHB
producer.pfClusterBuilder.recHitEnergyNorms[0].recHitEnergyNorm = _thresholdsHB
producer.pfClusterBuilder.positionCalc.logWeightDenominatorByDetector = logWeightDenominatorHCAL2018
producer.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector = logWeightDenominatorHCAL2018
for producer in producers_by_type(process, "PFMultiDepthClusterProducer"):
producer.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector = logWeightDenominatorHCAL2018
# done
return process
def customiseFor2017DtUnpacking(process):
"""Adapt the HLT to run the legacy DT unpacking
for pre2018 data/MC workflows as the default"""
if hasattr(process,'hltMuonDTDigis'):
process.hltMuonDTDigis = cms.EDProducer( "DTUnpackingModule",
useStandardFEDid = cms.bool( True ),
maxFEDid = cms.untracked.int32( 779 ),
inputLabel = cms.InputTag( "rawDataCollector" ),
minFEDid = cms.untracked.int32( 770 ),
dataType = cms.string( "DDU" ),
readOutParameters = cms.PSet(
localDAQ = cms.untracked.bool( False ),
debug = cms.untracked.bool( False ),
rosParameters = cms.PSet(
localDAQ = cms.untracked.bool( False ),
debug = cms.untracked.bool( False ),
writeSC = cms.untracked.bool( True ),
readDDUIDfromDDU = cms.untracked.bool( True ),
readingDDU = cms.untracked.bool( True ),
performDataIntegrityMonitor = cms.untracked.bool( False )
),
performDataIntegrityMonitor = cms.untracked.bool( False )
),
dqmOnly = cms.bool( False )
)
return process
def customisePixelGainForRun2Input(process):
"""Customise the HLT to run on Run 2 data/MC using the old definition of the pixel calibrations
Up to 11.0.x, the pixel calibarations were fully specified in the configuration:
VCaltoElectronGain = 47
VCaltoElectronGain_L1 = 50
VCaltoElectronOffset = -60
VCaltoElectronOffset_L1 = -670
Starting with 11.1.x, the calibrations for Run 3 were moved to the conditions, leaving in the configuration only:
VCaltoElectronGain = 1
VCaltoElectronGain_L1 = 1
VCaltoElectronOffset = 0
VCaltoElectronOffset_L1 = 0
Since the conditions for Run 2 have not been updated to the new scheme, the HLT configuration needs to be reverted.
"""
# revert the Pixel parameters to be compatible with the Run 2 conditions
for producer in producers_by_type(process, "SiPixelClusterProducer"):
producer.VCaltoElectronGain = 47
producer.VCaltoElectronGain_L1 = 50
producer.VCaltoElectronOffset = -60
producer.VCaltoElectronOffset_L1 = -670
for producer in producers_by_type(process, "SiPixelRawToClusterCUDA"):
producer.isRun2 = True
return process
def customisePixelL1ClusterThresholdForRun2Input(process):
# revert the pixel Layer 1 cluster threshold to be compatible with Run2:
for producer in producers_by_type(process, "SiPixelClusterProducer"):
if hasattr(producer,"ClusterThreshold_L1"):
producer.ClusterThreshold_L1 = 2000
for producer in producers_by_type(process, "SiPixelRawToClusterCUDA"):
if hasattr(producer,"clusterThreshold_layer1"):
producer.clusterThreshold_layer1 = 2000
for producer in producers_by_type(process, "SiPixelDigisClustersFromSoA"):
if hasattr(producer,"clusterThreshold_layer1"):
producer.clusterThreshold_layer1 = 2000
return process
def customiseCTPPSFor2018Input(process):
for prod in producers_by_type(process, 'CTPPSGeometryESModule'):
prod.isRun2 = True
for prod in producers_by_type(process, 'CTPPSPixelRawToDigi'):
prod.isRun3 = False
return process
def customiseEGammaRecoFor2018Input(process):
for prod in producers_by_type(process, 'PFECALSuperClusterProducer'):
if hasattr(prod, 'regressionConfig'):
prod.regressionConfig.regTrainedWithPS = cms.bool(False)
return process
def customiseBeamSpotFor2018Input(process):
"""Customisation for the HLT BeamSpot when running on Run-2 (2018) data:
- For Run-2 data, disable the use of the BS transient record, in order to read the BS record from SCAL.
- Additionally, remove all instances of OnlineBeamSpotESProducer (not needed if useTransientRecord=False).
- See CMSHLT-2271 and CMSHLT-2300 for further details.
"""
for prod in producers_by_type(process, 'BeamSpotOnlineProducer'):
prod.useTransientRecord = False
onlineBeamSpotESPLabels = [prod.label_() for prod in esproducers_by_type(process, 'OnlineBeamSpotESProducer')]
for espLabel in onlineBeamSpotESPLabels:
delattr(process, espLabel)
return process
def customiseECALCalibrationsFor2018Input(process):
"""Customisation to apply the ECAL Run-2 Ultra-Legacy calibrations (CMSHLT-2339)"""
if hasattr(process, 'GlobalTag'):
if not hasattr(process.GlobalTag, 'toGet'):
process.GlobalTag.toGet = cms.VPSet()
process.GlobalTag.toGet += [
cms.PSet(
record = cms.string('EcalLaserAlphasRcd'),
tag = cms.string('EcalLaserAlphas_UL_Run1_Run2_2018_lastIOV_movedTo1')
),
cms.PSet(
record = cms.string('EcalIntercalibConstantsRcd'),
tag = cms.string('EcalIntercalibConstants_UL_Run1_Run2_2018_lastIOV_movedTo1')
)
]
else:
print('# customiseECALCalibrationsFor2018Input -- the process.GlobalTag ESSource does not exist: no customisation applied.')
return process
def customiseFor2018Input(process):
"""Customise the HLT to run on Run 2 data/MC"""
process = customisePixelGainForRun2Input(process)
process = customisePixelL1ClusterThresholdForRun2Input(process)
process = customiseHCALFor2018Input(process)
process = customiseCTPPSFor2018Input(process)
process = customiseEGammaRecoFor2018Input(process)
process = customiseBeamSpotFor2018Input(process)
process = customiseECALCalibrationsFor2018Input(process)
return process
def customiseForOffline(process):
# For running HLT offline on Run-3 Data, use "(OnlineBeamSpotESProducer).timeThreshold = 1e6",
# in order to pick the beamspot that was actually used by the HLT (instead of a "fake" beamspot).
# These same settings can be used offline for Run-3 Data and Run-3 MC alike.
# Note: the products of the OnlineBeamSpotESProducer are used only
# if the configuration uses "(BeamSpotOnlineProducer).useTransientRecord = True".
# See CMSHLT-2271 and CMSHLT-2300 for further details.
for prod in esproducers_by_type(process, 'OnlineBeamSpotESProducer'):
prod.timeThreshold = int(1e6)
return process
def customizeHLTfor41058(process):
for prod in esproducers_by_type(process, 'ClusterShapeHitFilterESProducer'):
prod.PixelShapeFile = "RecoTracker/PixelLowPtUtilities/data/pixelShapePhase1_noL1.par"
prod.PixelShapeFileL1 = "RecoTracker/PixelLowPtUtilities/data/pixelShapePhase1_loose.par"
return process
def customizeHLTfor41495(process):
for producer in filters_by_type(process, 'HLTPixelIsolTrackL1TFilter'):
if hasattr(producer, 'L1GTSeedLabel'):
del producer.L1GTSeedLabel
if hasattr(producer, 'MinDeltaPtL1Jet'):
del producer.MinDeltaPtL1Jet
return process
def customizeHLTfor41815(process):
# use hlt online BeamSpot for SiStripClusters2ApproxClusters
for producer in producers_by_type(process, 'SiStripClusters2ApproxClusters'):
producer.beamSpot = cms.InputTag('hltOnlineBeamSpot')
if hasattr(process, 'HLT_HIRandom_v4'):
getattr(process,'HLT_HIRandom_v4').insert(2,process.HLTBeamSpot)
return process
# CMSSW version specific customizations
def customizeHLTforCMSSW(process, menuType="GRun"):
process = customiseForOffline(process)
# add call to action function in proper order: newest last!
# process = customiseFor12718(process)
process = customizeHLTfor41058(process)
process = customizeHLTfor41495(process)
process = customizeHLTfor41815(process)
return process