File indexing completed on 2024-10-19 04:58:37
0001 import FWCore.ParameterSet.Config as cms
0002
0003 from PhysicsTools.SelectorUtils.tools.vid_id_tools import *
0004
0005 from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
0006
0007 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
0008
0009 from PhysicsTools.PatUtils.tools.pfforTrkMET_cff import *
0010
0011 def miniAOD_customizeCommon(process):
0012 process.patMuons.isoDeposits = cms.PSet()
0013 process.patElectrons.isoDeposits = cms.PSet()
0014 process.patTaus.isoDeposits = cms.PSet()
0015 process.patPhotons.isoDeposits = cms.PSet()
0016
0017 process.patMuons.embedTrack = True
0018 process.patMuons.embedCombinedMuon = True
0019 process.patMuons.embedMuonBestTrack = True
0020 process.patMuons.embedStandAloneMuon = True
0021 process.patMuons.embedPickyMuon = False
0022 process.patMuons.embedTpfmsMuon = False
0023 process.patMuons.embedDytMuon = False
0024 process.patMuons.addPuppiIsolation = cms.bool(True)
0025 process.patMuons.puppiIsolationChargedHadrons = cms.InputTag("muonPUPPIIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
0026 process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag("muonPUPPIIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
0027 process.patMuons.puppiIsolationPhotons = cms.InputTag("muonPUPPIIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
0028 process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
0029 process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
0030 process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
0031
0032 process.patMuons.computeMiniIso = True
0033 process.patMuons.computeMuonIDMVA = True
0034 process.patMuons.computeSoftMuonMVA = True
0035
0036 process.patMuons.addTriggerMatching = True
0037 from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016
0038 from Configuration.Eras.Modifier_run2_muon_2017_cff import run2_muon_2017
0039 from Configuration.Eras.Modifier_run2_muon_2018_cff import run2_muon_2018
0040 from Configuration.Eras.Modifier_run3_muon_cff import run3_muon
0041 run2_muon_2016.toModify( process.patMuons, effectiveAreaVec = [0.0735,0.0619,0.0465,0.0433,0.0577])
0042 run2_muon_2017.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
0043 run2_muon_2018.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
0044 run3_muon.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
0045
0046 process.patMuons.computePuppiCombinedIso = True
0047
0048
0049 process.patElectrons.embedGsfElectronCore = False
0050 process.patElectrons.embedSuperCluster = False
0051 process.patElectrons.embedPflowSuperCluster = False
0052 process.patElectrons.embedSeedCluster = False
0053 process.patElectrons.embedBasicClusters = False
0054 process.patElectrons.embedPreshowerClusters = False
0055 process.patElectrons.embedPflowBasicClusters = False
0056 process.patElectrons.embedPflowPreshowerClusters = False
0057 process.patElectrons.embedRecHits = False
0058 process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0059 process.patElectrons.usePfCandidateMultiMap = True
0060 process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap")
0061 process.patElectrons.electronIDSources = cms.PSet()
0062
0063
0064 process.patElectrons.addPuppiIsolation = cms.bool(True)
0065 process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001")
0066 process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000")
0067 process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008")
0068 process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001")
0069 process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000")
0070 process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008")
0071
0072 process.patElectrons.computeMiniIso = cms.bool(True)
0073
0074 process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0075 process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0076 process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0077 process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0078 process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0079
0080 process.patPhotons.embedSuperCluster = False
0081 process.patPhotons.embedSeedCluster = False
0082 process.patPhotons.embedBasicClusters = False
0083 process.patPhotons.embedPreshowerClusters = False
0084 process.patPhotons.embedRecHits = False
0085
0086
0087 process.patPhotons.addPuppiIsolation = cms.bool(True)
0088 process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-")
0089 process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-")
0090 process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-")
0091
0092 process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
0093 process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0094
0095 process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
0096 process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
0097 process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
0098 process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
0099 process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
0100
0101 process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons")
0102 process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0103
0104 process.selectedPatJets.cut = cms.string("pt > 15")
0105 process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
0106
0107 from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
0108 phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )")
0109 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
0110 pp_on_AA.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 1.2 && (isGlobalMuon || isStandAloneMuon) )")
0111 from Configuration.Eras.Modifier_run3_upc_cff import run3_upc
0112 run3_upc.toModify(process.selectedPatMuons, cut = "")
0113 from Configuration.Eras.Modifier_ppRef_2024_cff import ppRef_2024
0114 ppRef_2024.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || isTrackerMuon || (pt > 1.2 && (isGlobalMuon || isStandAloneMuon))")
0115
0116 process.selectedPatElectrons.cut = cms.string("")
0117 process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5")
0118 process.selectedPatPhotons.cut = cms.string("")
0119
0120 _dummyPatJets = process.selectedPatJets.clone(cut = "pt < 0")
0121 task = getPatAlgosToolsTask(process)
0122
0123 def _applySubstructure(process):
0124 from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
0125
0126 from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
0127 applySubstructure( process )
0128 (~pp_on_AA).toModify(process, _applySubstructure)
0129
0130 pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJets', p.selectedPatJets.clone(), p, task))
0131 pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsAK8', _dummyPatJets.clone(), p, task))
0132
0133
0134 from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
0135 switchOnTriggerStandAlone( process, outputModule = '' )
0136 process.patTrigger.packTriggerPathNames = cms.bool(True)
0137
0138
0139
0140
0141 from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
0142 runMetCorAndUncForMiniAODProduction(process, metType="PF",
0143 jetCollUnskimmed="patJets")
0144
0145
0146 from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
0147 addMETCollection(process,
0148 labelName = "patCaloMet",
0149 metSource = "caloMetM"
0150 )
0151
0152
0153
0154 process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
0155 src=cms.InputTag("particleFlow"),
0156 cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
0157 )
0158 task.add(process.noHFCands)
0159
0160 runMetCorAndUncForMiniAODProduction(process,
0161 pfCandColl=cms.InputTag("noHFCands"),
0162 recoMetFromPFCs=True,
0163 jetSelection="pt>15 && abs(eta)<3.",
0164 postfix="NoHF"
0165 )
0166
0167 process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
0168 task.add(process.slimmedMETs)
0169 (~pp_on_AA).toModify(process.slimmedMETs, addDeepMETs = True)
0170
0171
0172
0173
0174 process.load("CommonTools.ParticleFlow.pfCHS_cff")
0175 task.add(process.pfCHS)
0176
0177 from RecoMET.METProducers.pfMet_cfi import pfMet
0178 process.pfMetCHS = pfMet.clone(src = 'pfCHS')
0179 task.add(process.pfMetCHS)
0180
0181 addMETCollection(process,
0182 labelName = "patCHSMet",
0183 metSource = "pfMetCHS"
0184 )
0185
0186 process.patCHSMet.computeMETSignificance = cms.bool(False)
0187
0188
0189
0190
0191 process.TrkCands = chargedPackedCandsForTkMet.clone()
0192 task.add(process.TrkCands)
0193
0194 process.pfMetTrk = pfMet.clone(src = 'TrkCands')
0195 task.add(process.pfMetTrk)
0196
0197 addMETCollection(process,
0198 labelName = "patTrkMet",
0199 metSource = "pfMetTrk"
0200 )
0201
0202 process.patTrkMet.computeMETSignificance = cms.bool(False)
0203
0204
0205
0206
0207 process.load('RecoJets.JetProducers.hfJetShowerShape_cfi')
0208 task.add(process.hfJetShowerShape)
0209
0210 process.patJets.userData.userFloats.src += [ 'hfJetShowerShape:sigmaEtaEta', 'hfJetShowerShape:sigmaPhiPhi']
0211 process.patJets.userData.userInts.src += [ 'hfJetShowerShape:centralEtaStripSize', 'hfJetShowerShape:adjacentEtaStripsSize']
0212
0213
0214 def _add_deepFlavour(process):
0215 process.load('RecoBTag.Combined.deepFlavour_cff')
0216 task.add(process.pfDeepCSVDiscriminatorsJetTags)
0217 process.patJets.discriminatorSources.extend([
0218 'pfDeepCSVDiscriminatorsJetTags:BvsAll',
0219 'pfDeepCSVDiscriminatorsJetTags:CvsB',
0220 'pfDeepCSVDiscriminatorsJetTags:CvsL',
0221 ])
0222
0223
0224 process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
0225 src = process.patJets.jetSource,
0226 matched = cms.InputTag("ak4CaloJets"),
0227 distMax = cms.double(0.4),
0228 values = cms.vstring('pt','emEnergyFraction'),
0229 valueLabels = cms.vstring('pt','emEnergyFraction'),
0230 lazyParser = cms.bool(True) )
0231 task.add(process.caloJetMap)
0232 process.patJets.userData.userFloats.src += [ 'caloJetMap:pt', 'caloJetMap:emEnergyFraction' ]
0233
0234 pp_on_AA.toModify(process.patJets.userData.userInts, src = [] )
0235 pp_on_AA.toModify(process.patJets.userData.userFloats, src = [] )
0236
0237
0238 from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
0239 makeInputForPUPPIIsolationMuon(process)
0240
0241
0242 from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
0243 makeInputForPUPPIIsolationEgm(process)
0244 from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
0245 process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
0246 process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
0247
0248
0249 process.patElectrons.addElectronID = cms.bool(True)
0250 electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
0251 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV71_cff',
0252 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
0253 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
0254 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Winter22_122X_V1_cff',
0255 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
0256 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
0257 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
0258 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
0259 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
0260 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
0261 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
0262 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer16UL_ID_ISO_cff',
0263 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer17UL_ID_ISO_cff',
0264 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff',
0265 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_noIso_V1_cff',
0266 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_iso_V1_cff',
0267 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Winter22_HZZ_V1_cff'
0268 ]
0269 switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
0270 process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0271 process.electronMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
0272
0273
0274
0275
0276 process.load("RecoEgamma.EgammaTools.gedGsfElectronsTo106X_cff")
0277 from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
0278 pp_on_AA_2018.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
0279 pp_on_AA_2018.toModify(process.electronMVAValueMapProducer,
0280 keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
0281 src = "gedGsfElectronsFrom94XTo106X")
0282
0283 for idmod in electron_ids:
0284 setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
0285
0286
0287 process.patPhotons.addPhotonID = cms.bool(True)
0288 photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
0289 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
0290 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
0291 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
0292 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
0293 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff',
0294 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Winter22_122X_V1_cff',
0295 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_RunIIIWinter22_122X_V1_cff']
0296
0297 switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
0298 process.egmPhotonIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedPhotons")
0299 process.photonMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedPhotons')
0300 for idmod in photon_ids:
0301 setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)
0302
0303
0304 from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier
0305 egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs"))
0306
0307
0308 from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
0309 addBoostedTaus(process)
0310
0311 import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
0312 _updatedBoostedTauName = 'slimmedTausBoostedDeepIDs'
0313 _noUpdatedBoostedTauName = 'slimmedTausBoostedNoDeepIDs'
0314 boostedTauIdEmbedder = tauIdConfig.TauIDEmbedder(
0315 process, debug = False,
0316 originalTauName = _noUpdatedBoostedTauName,
0317 updatedTauName = _updatedBoostedTauName,
0318 postfix = 'BoostedForMini',
0319 toKeep = ['boostedDeepTauRunIIv2p0']
0320 )
0321 boostedTauIdEmbedder.runTauID()
0322 addToProcessAndTask(_noUpdatedBoostedTauName, process.slimmedTausBoosted.clone(),process,task)
0323 delattr(process, 'slimmedTausBoosted')
0324 process.slimmedTausBoosted = getattr(process, _updatedBoostedTauName).clone()
0325 process.rerunMvaIsolationTaskBoostedForMini.add(process.slimmedTausBoosted)
0326 task.add(process.rerunMvaIsolationTaskBoostedForMini)
0327 process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
0328 process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
0329
0330 _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
0331 _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauBasicDiscriminatorsTask,
0332 process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask,
0333 process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask,
0334 process.hpsPFTauBasicDiscriminatorsdR03Task,
0335 process.hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTTask,
0336 process.hpsPFTauDiscriminationByMVA6rawElectronRejection,
0337 process.hpsPFTauDiscriminationByMVA6ElectronRejection,
0338 process.hpsPFTauDiscriminationByMuonRejection3)
0339 from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
0340 (run2_miniAOD_UL).toReplaceWith(
0341 process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
0342 )
0343
0344 _updatedTauName = 'slimmedTausDeepIDs'
0345 _noUpdatedTauName = 'slimmedTausNoDeepIDs'
0346 tauIdEmbedder = tauIdConfig.TauIDEmbedder(
0347 process, debug = False,
0348 originalTauName = _noUpdatedTauName,
0349 updatedTauName = _updatedTauName,
0350 postfix = 'ForMini',
0351 toKeep = ['deepTau2018v2p5']
0352 )
0353 from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
0354 _tauIds_phase2 = ['deepTau2026v2p5']
0355 phase2_common.toModify(tauIdEmbedder.toKeep, func=lambda t:t.extend(_tauIds_phase2))
0356 tauIdEmbedder.runTauID()
0357 addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(),process,task)
0358 delattr(process, 'slimmedTaus')
0359 process.slimmedTaus = getattr(process, _updatedTauName).clone()
0360 process.rerunMvaIsolationTaskForMini.add(process.slimmedTaus)
0361 task.add(process.rerunMvaIsolationTaskForMini)
0362
0363
0364
0365 _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy()
0366 _makePatTausTaskWithDeadECalVeto.add(
0367 process.hpsPFTauDiscriminationByDeadECALElectronRejection
0368 )
0369 _run2_miniAOD_ANY = (run2_miniAOD_UL)
0370 _run2_miniAOD_ANY.toReplaceWith(
0371 process.makePatTausTask, _makePatTausTaskWithDeadECalVeto
0372 )
0373
0374
0375 _makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
0376 _makePatTausTaskWithTauReReco.add(process.PFTauTask)
0377 (pp_on_AA).toReplaceWith(
0378 process.makePatTausTask, _makePatTausTaskWithTauReReco
0379 )
0380
0381
0382 process.load('CommonTools.PileupAlgos.Puppi_cff')
0383 process.load('RecoJets.JetProducers.ak4PFJets_cfi')
0384 from Configuration.Eras.Modifier_pA_2016_cff import pA_2016
0385 _rerun_puppijets_task = task.copy()
0386 _rerun_puppijets_task.add(process.puppi, process.ak4PFJetsPuppi)
0387 (_run2_miniAOD_ANY | pA_2016 | pp_on_AA).toReplaceWith(task, _rerun_puppijets_task)
0388
0389 from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
0390 process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
0391 j2tParametersVX,
0392 jets = cms.InputTag("ak4PFJetsPuppi")
0393 )
0394 task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
0395 process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
0396 src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
0397 var = cms.string('Pt'),
0398 exp = cms.double(1.0)
0399 )
0400 task.add(process.patJetPuppiCharge)
0401
0402
0403 process.load("RecoJets.JetProducers.PileupJetID_cfi")
0404 task.add(process.pileUpJetIDPuppiTask)
0405
0406 def _add_jetsPuppi(process):
0407 from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
0408 noDeepFlavourDiscriminators = [x.value() if isinstance(x, cms.InputTag) else x for x in process.patJets.discriminatorSources
0409 if (not "DeepFlavour" in str(x) and not "Transformer" in str(x))]
0410 addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
0411 jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
0412 pfCandidates = cms.InputTag("particleFlow"),
0413 algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
0414 )
0415
0416 process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
0417
0418 process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
0419
0420
0421 process.patJetsPuppi.userData.userFloats.src += [cms.InputTag("pileupJetIdPuppi:fullDiscriminant")]
0422 process.patJetsPuppi.userData.userInts.src += [cms.InputTag("pileupJetIdPuppi:fullId")]
0423
0424 process.selectedPatJetsPuppi.cut = cms.string("pt > 10")
0425
0426 from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging
0427 applyDeepBtagging( process )
0428
0429 process.slimmedJetsNoDeepFlavour.dropTagInfos = '0'
0430 process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.addTagInfos = True
0431 process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.tagInfoSources = ["pixelClusterTagInfos"]
0432 _run2_miniAOD_ANY.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = False )
0433 (~pp_on_AA).toModify(process, _add_jetsPuppi)
0434
0435 pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsPuppi', _dummyPatJets.clone(), p, task))
0436
0437
0438 process.patJets.addTagInfos = True
0439 process.patJets.tagInfoSources = ["pixelClusterTagInfos"]
0440
0441 _run2_miniAOD_ANY.toModify(process.patJets, addTagInfos = False )
0442
0443 from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
0444 pp_on_AA_2018.toModify(process.patJets, tagInfoSources = cms.VInputTag(["impactParameterTagInfos","secondaryVertexTagInfos"]) )
0445
0446
0447 def _add_metPuppi(process):
0448 process.load('RecoMET.METProducers.pfMetPuppi_cfi')
0449 _rerun_puppimet_task = task.copy()
0450 _rerun_puppimet_task.add(process.puppiNoLep, process.pfMetPuppi)
0451 (_run2_miniAOD_ANY | pA_2016 | pp_on_AA ).toReplaceWith(task, _rerun_puppimet_task)
0452
0453 runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
0454 jetCollUnskimmed="slimmedJetsPuppi",
0455 recoMetFromPFCs=True,
0456 jetFlavor="AK4PFPuppi",
0457 postfix="Puppi"
0458 )
0459 (~pp_on_AA).toModify(process, _add_metPuppi)
0460
0461 process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
0462 task.add(process.slimmedMETs)
0463
0464 def _add_slimmedMETsPuppi(process):
0465 addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
0466 process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
0467 process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
0468 process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
0469 process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
0470 process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
0471 process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
0472 process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
0473 process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
0474 process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
0475 process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
0476 del process.slimmedMETsPuppi.caloMET
0477 (~pp_on_AA).toModify(process, _add_slimmedMETsPuppi)
0478
0479 def _add_deepMET(process):
0480 from RecoMET.METPUSubtraction.deepMETProducer_cff import deepMETsResolutionTune, deepMETsResponseTune
0481
0482 addToProcessAndTask('deepMETsResolutionTune', deepMETsResolutionTune, process, task)
0483 addToProcessAndTask('deepMETsResponseTune', deepMETsResponseTune, process, task)
0484 (~pp_on_AA).toModify(process, _add_deepMET)
0485
0486
0487 process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
0488
0489
0490
0491 from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
0492 process.load("RecoEgamma.EgammaTools.slimmedEgammaHGC_cff")
0493 phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaHGCTask))
0494
0495
0496
0497 def _addUTagToTaus(process, task,
0498 storePNetCHSjets = False,
0499 storeUParTPUPPIjets = False,
0500 addGenJet = False):
0501 if not (storePNetCHSjets or storeUParTPUPPIjets): return process
0502 noUpdatedTauName = 'slimmedTausNoUTag'
0503 updatedTauName = ''
0504 addToProcessAndTask(noUpdatedTauName, process.slimmedTaus.clone(), process, task)
0505 process.pfParticleNetFromMiniAODAK4CHSCentralTagInfosSlimmedDeepFlavour.taus = noUpdatedTauName
0506 process.pfParticleNetFromMiniAODAK4PuppiCentralTagInfosSlimmedPuppiWithDeepTags.taus = noUpdatedTauName
0507 process.pfParticleNetFromMiniAODAK4PuppiForwardTagInfosSlimmedPuppiWithDeepTags.taus = noUpdatedTauName
0508 from PhysicsTools.PatAlgos.patTauHybridProducer_cfi import patTauHybridProducer
0509 if storePNetCHSjets:
0510 jetCollection = 'slimmedJets'
0511 TagName = 'pfParticleNetFromMiniAODAK4CHSCentralJetTags'
0512 tag_prefix = 'byUTagCHS'
0513 updatedTauName = 'slimmedTausWithUTagCHS'
0514
0515 from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import pfParticleNetFromMiniAODAK4CHSCentralJetTags
0516 Discriminators = [TagName+":"+tag for tag in pfParticleNetFromMiniAODAK4CHSCentralJetTags.flav_names.value()]
0517
0518 setattr(process, updatedTauName,
0519 patTauHybridProducer.clone(
0520 src = noUpdatedTauName,
0521 jetSource = jetCollection,
0522 dRMax = 0.4,
0523 jetPtMin = 15,
0524 jetEtaMax = 2.5,
0525 UTagLabel = TagName,
0526 UTagScoreNames = Discriminators,
0527 tagPrefix = tag_prefix,
0528 tauScoreMin = -1,
0529 vsJetMin = 0.05,
0530 checkTauScoreIsBest = False,
0531 chargeAssignmentProbMin = 0.2,
0532 addGenJetMatch = addGenJet,
0533 genJetMatch = ''
0534 ))
0535 if addGenJet:
0536 addToProcessAndTask('tauGenJetMatchCHSJet',
0537 process.tauGenJetMatch.clone(src = jetCollection),
0538 process, task)
0539 getattr(process,updatedTauName).genJetMatch = 'tauGenJetMatchCHSJet'
0540 if storeUParTPUPPIjets: task.add(getattr(process,updatedTauName))
0541 if storeUParTPUPPIjets:
0542 jetCollection = 'slimmedJetsPuppi'
0543 TagName = 'pfUnifiedParticleTransformerAK4JetTags'
0544 tag_prefix = 'byUTagPUPPI'
0545 updatedTauName = 'slimmedTausWithUTagPUPPI' if not storePNetCHSjets else 'slimmedTausWithUTagCHSAndUTagPUPPI'
0546
0547 from RecoBTag.ONNXRuntime.pfUnifiedParticleTransformerAK4JetTags_cfi import pfUnifiedParticleTransformerAK4JetTags
0548 Discriminators = [TagName+":"+tag for tag in pfUnifiedParticleTransformerAK4JetTags.flav_names.value()]
0549
0550 setattr(process, updatedTauName,
0551 patTauHybridProducer.clone(
0552 src = noUpdatedTauName if not storePNetCHSjets else 'slimmedTausWithUTagCHS',
0553 jetSource = jetCollection,
0554 dRMax = 0.4,
0555 jetPtMin = 15,
0556 jetEtaMax = 2.5,
0557 UTagLabel = TagName,
0558 UTagScoreNames = Discriminators,
0559 tagPrefix = tag_prefix,
0560 tauScoreMin = -1,
0561 vsJetMin = 0.05,
0562 checkTauScoreIsBest = False,
0563 chargeAssignmentProbMin = 0.2,
0564 addGenJetMatch = addGenJet,
0565 genJetMatch = ''
0566 ))
0567 if addGenJet:
0568 addToProcessAndTask('tauGenJetMatchPUPPIJet',
0569 process.tauGenJetMatch.clone(src = jetCollection),
0570 process, task)
0571 getattr(process,updatedTauName).genJetMatch = 'tauGenJetMatchPUPPIJet'
0572
0573 delattr(process, 'slimmedTaus')
0574 process.slimmedTaus = getattr(process, updatedTauName).clone()
0575 task.add(process.slimmedTaus)
0576 return process
0577
0578 _uTagToTaus_switches = cms.PSet(
0579 storePNetCHSjets = cms.bool(True),
0580 storeUParTPUPPIjets = cms.bool(True),
0581 addGenJet = cms.bool(True)
0582 )
0583 pp_on_AA.toModify(_uTagToTaus_switches, storePNetCHSjets=False, storeUParTPUPPIjets=False)
0584 _addUTagToTaus(process, task,
0585 storePNetCHSjets = _uTagToTaus_switches.storePNetCHSjets.value(),
0586 storeUParTPUPPIjets = _uTagToTaus_switches.storePNetCHSjets.value(),
0587 addGenJet = _uTagToTaus_switches.addGenJet.value()
0588 )
0589
0590
0591 from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring
0592 from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
0593 from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
0594 from Configuration.Eras.Modifier_stage2L1Trigger_2018_cff import stage2L1Trigger_2018
0595 from Configuration.Eras.Modifier_tracker_apv_vfp30_2016_cff import tracker_apv_vfp30_2016
0596 if not hasattr(process,'prefiringweight'):
0597 process.load("PhysicsTools.PatUtils.L1PrefiringWeightProducer_cff")
0598 (stage2L1Trigger & tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016preVFP", DataEraMuon = "2016preVFP" )
0599 (stage2L1Trigger & ~tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016postVFP", DataEraMuon = "2016postVFP" )
0600 stage2L1Trigger_2017.toModify(process.prefiringweight, DataEraECAL = "UL2017BtoF", DataEraMuon = "20172018")
0601 stage2L1Trigger_2018.toModify(process.prefiringweight, DataEraECAL = "None", DataEraMuon = "20172018")
0602 run2_L1prefiring.toModify(task, func=lambda t: t.add(process.prefiringweight))
0603
0604 from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeL1FastJetJECs
0605 pp_on_AA.toModify(process, removeL1FastJetJECs)
0606
0607 def miniAOD_customizeMC(process):
0608 task = getPatAlgosToolsTask(process)
0609
0610 process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
0611 task.add(process.selectedHadronsAndPartons)
0612 task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
0613
0614 process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
0615 task.add(process.ak4GenJetFlavourInfos)
0616
0617 process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
0618 task.add(process.slimmedGenJetsFlavourInfos)
0619
0620
0621 process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
0622 task.add(process.slimmedAddPileupInfo)
0623
0624 process.muonMatch.matched = "prunedGenParticles"
0625 process.electronMatch.matched = "prunedGenParticles"
0626 process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
0627 process.photonMatch.matched = "prunedGenParticles"
0628 process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
0629 process.ootPhotonMatch.matched = "prunedGenParticles"
0630 process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
0631 process.tauMatch.matched = "prunedGenParticles"
0632 process.tauGenJets.GenParticles = "prunedGenParticles"
0633
0634 process.tauMatchBoosted.matched = "prunedGenParticles"
0635 process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
0636 process.patJetPartons.particles = "genParticles"
0637 process.patJetPartonMatch.matched = "prunedGenParticles"
0638 pp_on_AA.toModify(process.patJetPartonMatch, matched = "hiSignalGenParticles")
0639 from Configuration.ProcessModifiers.genJetSubEvent_cff import genJetSubEvent
0640 genJetSubEvent.toModify(process.patJetPartonMatch, matched = "cleanedPartons")
0641 process.patJetPartonMatch.mcStatus = [ 3, 23 ]
0642 process.patJetGenJetMatch.matched = "slimmedGenJets"
0643 (~pp_on_AA).toModify(process, patJetGenJetMatchAK8Puppi = dict(matched = "slimmedGenJetsAK8"))
0644 process.patMuons.embedGenMatch = False
0645 process.patElectrons.embedGenMatch = False
0646 process.patPhotons.embedGenMatch = False
0647 process.patOOTPhotons.embedGenMatch = False
0648 process.patTaus.embedGenMatch = False
0649 process.patTausBoosted.embedGenMatch = False
0650 process.patJets.embedGenPartonMatch = False
0651
0652 process.patJetFlavourAssociation.rParam = 0.4
0653
0654 from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeJECsForMC
0655 pp_on_AA.toModify(process, removeJECsForMC)
0656 pp_on_AA.toReplaceWith(task,task.copyAndExclude([process.slimmedGenJetsFlavourInfos]))
0657
0658
0659 def miniAOD_customizeOutput(out):
0660 from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
0661 out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
0662 out.splitLevel = cms.untracked.int32(0)
0663 out.dropMetaData = cms.untracked.string('ALL')
0664 out.fastCloning= cms.untracked.bool(False)
0665 out.overrideInputFileSplitLevels = cms.untracked.bool(True)
0666 out.compressionAlgorithm = cms.untracked.string('LZMA')
0667
0668 def miniAOD_customizeData(process):
0669 from PhysicsTools.PatAlgos.tools.coreTools import runOnData
0670 runOnData( process, outputModules = [] )
0671
0672 print('removing MC dependencies for hybrid taus')
0673 modulesToDel = []
0674 for postfix in ['','WithUTagCHS','WithUTagPUPPI','WithUTagCHSAndUTagPUPPI']:
0675 if hasattr(process,'slimmedTaus'+postfix):
0676 hybridTau = getattr(process,'slimmedTaus'+postfix)
0677 if hasattr(hybridTau,'addGenJetMatch'):
0678 hybridTau.addGenJetMatch = False
0679 genJetModule = hybridTau.genJetMatch.getModuleLabel()
0680 if not genJetModule in modulesToDel:
0681 modulesToDel.append(genJetModule)
0682 hybridTau.genJetMatch = ''
0683 for module in modulesToDel:
0684 if hasattr(process,module): delattr(process,module)
0685
0686 process.load("RecoPPS.Local.ctppsLocalTrackLiteProducer_cff")
0687 process.load("RecoPPS.ProtonReconstruction.ctppsProtons_cff")
0688 process.load("Geometry.VeryForwardGeometry.geometryRPFromDB_cfi")
0689 process.load('L1Trigger.L1TGlobal.simGtExtFakeProd_cfi')
0690 task = getPatAlgosToolsTask(process)
0691 task.add(process.simGtExtUnprefireable)
0692 from Configuration.Eras.Modifier_ctpps_cff import ctpps
0693 ctpps.toModify(task, func=lambda t: t.add(process.ctppsLocalTrackLiteProducer))
0694 ctpps.toModify(task, func=lambda t: t.add(process.ctppsProtons))
0695 from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
0696 run2_miniAOD_UL.toModify(task, func=lambda t: t.add(process.simGtExtUnprefireable))
0697
0698 def miniAOD_customizeAllData(process):
0699 miniAOD_customizeCommon(process)
0700 miniAOD_customizeData(process)
0701 return process
0702
0703 def miniAOD_customizeAllMC(process):
0704 miniAOD_customizeCommon(process)
0705 miniAOD_customizeMC(process)
0706 return process
0707
0708 def miniAOD_customizeAllMCFastSim(process):
0709 miniAOD_customizeCommon(process)
0710 miniAOD_customizeMC(process)
0711 from PhysicsTools.PatAlgos.slimming.metFilterPaths_cff import miniAOD_customizeMETFiltersFastSim
0712 process = miniAOD_customizeMETFiltersFastSim(process)
0713 from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
0714 process = miniAOD_customizeIsolatedTracksFastSim(process)
0715 process.patMuons.addTriggerMatching = False
0716
0717 from Configuration.Eras.Modifier_fastSim_cff import fastSim
0718 fastSim.toModify(process.patJets, addTagInfos = cms.bool(False) )
0719 fastSim.toModify(process.slimmedJetsNoDeepFlavour, dropTagInfos = cms.string('1') )
0720 fastSim.toModify(process.updatedPatJetsSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
0721 fastSim.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
0722
0723 return process