CMS 3D CMS Logo

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