Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-12 23:01:45

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 # helper functions
0004 from HLTrigger.Configuration.common import *
0005 
0006 # add one customisation function per PR
0007 # - put the PR number into the name of the function
0008 # - add a short comment
0009 # for example:
0010 
0011 # CCCTF tuning
0012 # def customiseFor12718(process):
0013 #     for pset in process._Process__psets.values():
0014 #         if hasattr(pset,'ComponentType'):
0015 #             if (pset.ComponentType == 'CkfBaseTrajectoryFilter'):
0016 #                 if not hasattr(pset,'minGoodStripCharge'):
0017 #                     pset.minGoodStripCharge = cms.PSet(refToPSet_ = cms.string('HLTSiStripClusterChargeCutNone'))
0018 #     return process
0019 
0020 def customiseHCALFor2018Input(process):
0021     """Customise the HLT to run on Run 2 data/MC using the old readout for the HCAL barel"""
0022 
0023     for producer in producers_by_type(process, "HBHEPhase1Reconstructor"):
0024         # switch on the QI8 processing for 2018 HCAL barrel
0025         producer.processQIE8 = True
0026 
0027     # adapt CaloTowers threshold for 2018 HCAL barrel with only one depth
0028     for producer in producers_by_type(process, "CaloTowersCreator"):
0029         producer.HBThreshold1  = 0.7
0030         producer.HBThreshold2  = 0.7
0031         producer.HBThreshold   = 0.7
0032 
0033     # adapt Particle Flow threshold for 2018 HCAL barrel with only one depth
0034     from RecoParticleFlow.PFClusterProducer.particleFlowClusterHBHE_cfi import _thresholdsHB, _thresholdsHEphase1, _seedingThresholdsHB
0035 
0036     logWeightDenominatorHCAL2018 = cms.VPSet(
0037         cms.PSet(
0038             depths = cms.vint32(1, 2, 3, 4),
0039             detector = cms.string('HCAL_BARREL1'),
0040             logWeightDenominator = _thresholdsHB
0041         ),
0042         cms.PSet(
0043             depths = cms.vint32(1, 2, 3, 4, 5, 6, 7),
0044             detector = cms.string('HCAL_ENDCAP'),
0045             logWeightDenominator = _thresholdsHEphase1
0046         )
0047     )
0048 
0049     for producer in producers_by_type(process, "PFRecHitProducer"):
0050         if producer.producers[0].name.value() == 'PFHBHERecHitCreator':
0051             producer.producers[0].qualityTests[0].cuts[0].threshold = _thresholdsHB
0052 
0053     for producer in producers_by_type(process, "PFClusterProducer"):
0054         if producer.seedFinder.thresholdsByDetector[0].detector.value() == 'HCAL_BARREL1':
0055             producer.seedFinder.thresholdsByDetector[0].seedingThreshold = _seedingThresholdsHB
0056             producer.initialClusteringStep.thresholdsByDetector[0].gatheringThreshold = _thresholdsHB
0057             producer.pfClusterBuilder.recHitEnergyNorms[0].recHitEnergyNorm = _thresholdsHB
0058             producer.pfClusterBuilder.positionCalc.logWeightDenominatorByDetector = logWeightDenominatorHCAL2018
0059             producer.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector = logWeightDenominatorHCAL2018
0060 
0061     for producer in producers_by_type(process, "PFMultiDepthClusterProducer"):
0062         producer.pfClusterBuilder.allCellsPositionCalc.logWeightDenominatorByDetector = logWeightDenominatorHCAL2018
0063 
0064     # done
0065     return process
0066 
0067 def customiseFor2017DtUnpacking(process):
0068     """Adapt the HLT to run the legacy DT unpacking
0069     for pre2018 data/MC workflows as the default"""
0070 
0071     if hasattr(process,'hltMuonDTDigis'):
0072         process.hltMuonDTDigis = cms.EDProducer( "DTUnpackingModule",
0073             useStandardFEDid = cms.bool( True ),
0074             maxFEDid = cms.untracked.int32( 779 ),
0075             inputLabel = cms.InputTag( "rawDataCollector" ),
0076             minFEDid = cms.untracked.int32( 770 ),
0077             dataType = cms.string( "DDU" ),
0078             readOutParameters = cms.PSet(
0079                 localDAQ = cms.untracked.bool( False ),
0080                 debug = cms.untracked.bool( False ),
0081                 rosParameters = cms.PSet(
0082                     localDAQ = cms.untracked.bool( False ),
0083                     debug = cms.untracked.bool( False ),
0084                     writeSC = cms.untracked.bool( True ),
0085                     readDDUIDfromDDU = cms.untracked.bool( True ),
0086                     readingDDU = cms.untracked.bool( True ),
0087                     performDataIntegrityMonitor = cms.untracked.bool( False )
0088                     ),
0089                 performDataIntegrityMonitor = cms.untracked.bool( False )
0090                 ),
0091             dqmOnly = cms.bool( False )
0092         )
0093 
0094     return process
0095 
0096 def customisePixelGainForRun2Input(process):
0097     """Customise the HLT to run on Run 2 data/MC using the old definition of the pixel calibrations
0098 
0099     Up to 11.0.x, the pixel calibarations were fully specified in the configuration:
0100         VCaltoElectronGain      =   47
0101         VCaltoElectronGain_L1   =   50
0102         VCaltoElectronOffset    =  -60
0103         VCaltoElectronOffset_L1 = -670
0104 
0105     Starting with 11.1.x, the calibrations for Run 3 were moved to the conditions, leaving in the configuration only:
0106         VCaltoElectronGain      =    1
0107         VCaltoElectronGain_L1   =    1
0108         VCaltoElectronOffset    =    0
0109         VCaltoElectronOffset_L1 =    0
0110 
0111     Since the conditions for Run 2 have not been updated to the new scheme, the HLT configuration needs to be reverted.
0112     """
0113     # revert the Pixel parameters to be compatible with the Run 2 conditions
0114     for producer in producers_by_type(process, "SiPixelClusterProducer"):
0115         producer.VCaltoElectronGain = 47
0116         producer.VCaltoElectronGain_L1 = 50
0117         producer.VCaltoElectronOffset = -60
0118         producer.VCaltoElectronOffset_L1 = -670
0119 
0120     for pluginType in ["SiPixelRawToClusterCUDA", "SiPixelRawToClusterCUDAPhase1", "SiPixelRawToClusterCUDAHIonPhase1"]:
0121         for producer in producers_by_type(process, pluginType):
0122             producer.VCaltoElectronGain = 47
0123             producer.VCaltoElectronGain_L1 = 50
0124             producer.VCaltoElectronOffset = -60
0125             producer.VCaltoElectronOffset_L1 = -670
0126 
0127     return process
0128 
0129 def customisePixelL1ClusterThresholdForRun2Input(process):
0130     # revert the pixel Layer 1 cluster threshold to be compatible with Run2:
0131     for producer in producers_by_type(process, "SiPixelClusterProducer"):
0132         if hasattr(producer,"ClusterThreshold_L1"):
0133             producer.ClusterThreshold_L1 = 2000
0134     for pluginType in ["SiPixelRawToClusterCUDA", "SiPixelRawToClusterCUDAPhase1", "SiPixelRawToClusterCUDAHIonPhase1"]:
0135         for producer in producers_by_type(process, pluginType):
0136             if hasattr(producer,"clusterThreshold_layer1"):
0137                 producer.clusterThreshold_layer1 = 2000
0138     for producer in producers_by_type(process, "SiPixelDigisClustersFromSoA"):
0139         if hasattr(producer,"clusterThreshold_layer1"):
0140             producer.clusterThreshold_layer1 = 2000
0141 
0142     return process
0143 
0144 def customiseCTPPSFor2018Input(process):
0145     for prod in producers_by_type(process, 'CTPPSGeometryESModule'):
0146         prod.isRun2 = True
0147     for prod in producers_by_type(process, 'CTPPSPixelRawToDigi'):
0148         prod.isRun3 = False
0149 
0150     return process
0151 
0152 def customiseEGammaRecoFor2018Input(process):
0153     for prod in producers_by_type(process, 'PFECALSuperClusterProducer'):
0154         if hasattr(prod, 'regressionConfig'):
0155             prod.regressionConfig.regTrainedWithPS = cms.bool(False)
0156 
0157     return process
0158 
0159 def customiseBeamSpotFor2018Input(process):
0160     """Customisation for the HLT BeamSpot when running on Run-2 (2018) data:
0161        - For Run-2 data, disable the use of the BS transient record, in order to read the BS record from SCAL.
0162        - Additionally, remove all instances of OnlineBeamSpotESProducer (not needed if useTransientRecord=False).
0163        - See CMSHLT-2271 and CMSHLT-2300 for further details.
0164     """
0165     for prod in producers_by_type(process, 'BeamSpotOnlineProducer'):
0166         prod.useTransientRecord = False
0167     onlineBeamSpotESPLabels = [prod.label_() for prod in esproducers_by_type(process, 'OnlineBeamSpotESProducer')]
0168     for espLabel in onlineBeamSpotESPLabels:
0169         delattr(process, espLabel)
0170 
0171     # re-introduce SCAL digis, if missing
0172     if not hasattr(process, 'hltScalersRawToDigi') and hasattr(process, 'HLTBeamSpot') and isinstance(process.HLTBeamSpot, cms.Sequence):
0173 
0174         if hasattr(process, 'hltOnlineBeamSpot'):
0175             process.hltOnlineBeamSpot.src = 'hltScalersRawToDigi'
0176 
0177         if hasattr(process, 'hltPixelTrackerHVOn'):
0178             process.hltPixelTrackerHVOn.DcsStatusLabel = 'hltScalersRawToDigi'
0179 
0180         if hasattr(process, 'hltStripTrackerHVOn'):
0181             process.hltStripTrackerHVOn.DcsStatusLabel = 'hltScalersRawToDigi'
0182 
0183         process.hltScalersRawToDigi = cms.EDProducer( "ScalersRawToDigi",
0184             scalersInputTag = cms.InputTag( "rawDataCollector" )
0185         )
0186 
0187         process.HLTBeamSpot.insert(0, process.hltScalersRawToDigi)
0188 
0189     return process
0190 
0191 def customiseECALCalibrationsFor2018Input(process):
0192     """Customisation to apply the ECAL Run-2 Ultra-Legacy calibrations (CMSHLT-2339)"""
0193     if hasattr(process, 'GlobalTag'):
0194       if not hasattr(process.GlobalTag, 'toGet'):
0195         process.GlobalTag.toGet = cms.VPSet()
0196       process.GlobalTag.toGet += [
0197         cms.PSet(
0198           record = cms.string('EcalLaserAlphasRcd'),
0199           tag = cms.string('EcalLaserAlphas_UL_Run1_Run2_2018_lastIOV_movedTo1')
0200         ),
0201         cms.PSet(
0202           record = cms.string('EcalIntercalibConstantsRcd'),
0203           tag = cms.string('EcalIntercalibConstants_UL_Run1_Run2_2018_lastIOV_movedTo1')
0204         )
0205       ]
0206     else:
0207       print('# customiseECALCalibrationsFor2018Input -- the process.GlobalTag ESSource does not exist: no customisation applied.')
0208 
0209     return process
0210 
0211 def customiseFor2018Input(process):
0212     """Customise the HLT to run on Run 2 data/MC"""
0213     process = customisePixelGainForRun2Input(process)
0214     process = customisePixelL1ClusterThresholdForRun2Input(process)
0215     process = customiseHCALFor2018Input(process)
0216     process = customiseCTPPSFor2018Input(process)
0217     process = customiseEGammaRecoFor2018Input(process)
0218     process = customiseBeamSpotFor2018Input(process)
0219     process = customiseECALCalibrationsFor2018Input(process)
0220 
0221     return process
0222 
0223 
0224 def customiseForOffline(process):
0225     # For running HLT offline on Run-3 Data, use "(OnlineBeamSpotESProducer).timeThreshold = 1e6",
0226     # in order to pick the beamspot that was actually used by the HLT (instead of a "fake" beamspot).
0227     # These same settings can be used offline for Run-3 Data and Run-3 MC alike.
0228     # Note: the products of the OnlineBeamSpotESProducer are used only
0229     #       if the configuration uses "(BeamSpotOnlineProducer).useTransientRecord = True".
0230     # See CMSHLT-2271 and CMSHLT-2300 for further details.
0231     for prod in esproducers_by_type(process, 'OnlineBeamSpotESProducer'):
0232         prod.timeThreshold = int(1e6)
0233 
0234     # For running HLT offline and relieve the strain on Frontier so it will no longer inject a
0235     # transaction id which tells Frontier to add a unique "&freshkey" to many query URLs.
0236     # That was intended as a feature to only be used by the Online HLT, to guarantee that fresh conditions
0237     # from the database were loaded at each Lumi section
0238     # Seee CMSHLT-3123 for further details
0239     if hasattr(process, 'GlobalTag'):
0240         # Set ReconnectEachRun and RefreshEachRun to False
0241         process.GlobalTag.ReconnectEachRun = cms.untracked.bool(False)
0242         process.GlobalTag.RefreshEachRun = cms.untracked.bool(False)
0243 
0244         if hasattr(process.GlobalTag, 'toGet'):
0245             # Filter out PSet objects containing only 'record' and 'refreshTime'
0246             process.GlobalTag.toGet = [
0247                 pset for pset in process.GlobalTag.toGet
0248                 if set(pset.parameterNames_()) != {'record', 'refreshTime'}
0249             ]
0250 
0251     return process
0252 
0253 def checkHLTfor43774(process):
0254     filt_types = ["HLTEgammaGenericFilter","HLTEgammaGenericQuadraticEtaFilter","HLTEgammaGenericQuadraticFilter","HLTElectronGenericFilter"]
0255     absAbleVar = ["DEta","deta","DetaSeed","Dphi","OneOESuperMinusOneOP","OneOESeedMinusOneOP"]
0256     for filt_type in filt_types:
0257         for filt in filters_by_type(process, filt_type):
0258             if filt.varTag.productInstanceLabel in absAbleVar:
0259                 if (filt.useAbs != cms.bool(True)):
0260                     print('# TSG WARNING: check value of parameter "useAbs" in',filt,'(expect True but is False)!')
0261 
0262     return process
0263     
0264 # CMSSW version specific customizations
0265 def customizeHLTforCMSSW(process, menuType="GRun"):
0266 
0267     process = customiseForOffline(process)
0268 
0269     # add call to action function in proper order: newest last!
0270     # process = customiseFor12718(process)
0271 
0272     process = checkHLTfor43774(process)
0273 
0274     return process