CMS 3D CMS Logo

miniAOD_tools.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 
5 from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
6 
7 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
8 
10 
12  process.patMuons.isoDeposits = cms.PSet()
13  process.patElectrons.isoDeposits = cms.PSet()
14  process.patTaus.isoDeposits = cms.PSet()
15  process.patPhotons.isoDeposits = cms.PSet()
16  #
17  process.patMuons.embedTrack = True # used for IDs
18  process.patMuons.embedCombinedMuon = True # used for IDs
19  process.patMuons.embedMuonBestTrack = True # used for IDs
20  process.patMuons.embedStandAloneMuon = True # maybe?
21  process.patMuons.embedPickyMuon = False # no, use best track
22  process.patMuons.embedTpfmsMuon = False # no, use best track
23  process.patMuons.embedDytMuon = False # no, use best track
24  process.patMuons.addPuppiIsolation = cms.bool(True)
25  process.patMuons.puppiIsolationChargedHadrons = cms.InputTag("muonPUPPIIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
26  process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag("muonPUPPIIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
27  process.patMuons.puppiIsolationPhotons = cms.InputTag("muonPUPPIIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
28  process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
29  process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
30  process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
31 
32  process.patMuons.computeMiniIso = True
33  process.patMuons.computeMuonIDMVA = True
34  process.patMuons.computeSoftMuonMVA = True
35 
36  process.patMuons.addTriggerMatching = True
37  from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016
38  from Configuration.Eras.Modifier_run2_muon_2017_cff import run2_muon_2017
39  from Configuration.Eras.Modifier_run2_muon_2018_cff import run2_muon_2018
40  from Configuration.Eras.Modifier_run3_muon_cff import run3_muon
41  run2_muon_2016.toModify( process.patMuons, effectiveAreaVec = [0.0735,0.0619,0.0465,0.0433,0.0577])
42  run2_muon_2017.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
43  run2_muon_2018.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
44  run3_muon.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
45 
46  process.patMuons.computePuppiCombinedIso = True
47  #
48  # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer
49  process.patElectrons.embedGsfElectronCore = False
50  process.patElectrons.embedSuperCluster = False
51  process.patElectrons.embedPflowSuperCluster = False
52  process.patElectrons.embedSeedCluster = False
53  process.patElectrons.embedBasicClusters = False
54  process.patElectrons.embedPreshowerClusters = False
55  process.patElectrons.embedPflowBasicClusters = False
56  process.patElectrons.embedPflowPreshowerClusters = False
57  process.patElectrons.embedRecHits = False
58  process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
59  process.patElectrons.usePfCandidateMultiMap = True
60  process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap")
61  process.patElectrons.electronIDSources = cms.PSet()
62 
63  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
64  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
65  (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify(process.patElectrons,
66  addPFClusterIso = True,
67  ecalPFClusterIsoMap = "reducedEgamma:eleEcalPFClusIso",
68  hcalPFClusterIsoMap = "reducedEgamma:eleHcalPFClusIso")
69 
70  #add puppi isolation in miniAOD
71  process.patElectrons.addPuppiIsolation = cms.bool(True)
72  process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001")
73  process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000")
74  process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008")
75  process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001")
76  process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000")
77  process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008")
78 
79  process.patElectrons.computeMiniIso = cms.bool(True)
80 
81  process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
82  process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
83  process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
84  process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
85  process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
86  #
87  process.patPhotons.embedSuperCluster = False
88  process.patPhotons.embedSeedCluster = False
89  process.patPhotons.embedBasicClusters = False
90  process.patPhotons.embedPreshowerClusters = False
91  process.patPhotons.embedRecHits = False
92 
93  #add puppi isolation in miniAOD
94  process.patPhotons.addPuppiIsolation = cms.bool(True)
95  process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-")
96  process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-")
97  process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-")
98 
99  (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify(process.patPhotons,
100  addPFClusterIso = True,
101  ecalPFClusterIsoMap = "reducedEgamma:phoEcalPFClusIso",
102  hcalPFClusterIsoMap = "reducedEgamma:phoHcalPFClusIso")
103  #the 80X legacy customsations are done in ootPhotonProducer for OOT photons
104  run2_miniAOD_94XFall17.toModify(process.patOOTPhotons,
105  addPFClusterIso = True,
106  ecalPFClusterIsoMap = "reducedEgamma:ootPhoEcalPFClusIso",
107  hcalPFClusterIsoMap = "reducedEgamma:ootPhoHcalPFClusIso")
108 
109 
110  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
111  process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
112 
113  process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
114  process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
115  process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
116  process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
117  process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
118  #
119  process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons")
120  process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
121  #
122  process.selectedPatJets.cut = cms.string("pt > 15")
123  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
124 
125  from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
126  phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )")
127  from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
128  pp_on_AA.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 1.2 && (isGlobalMuon || isStandAloneMuon) )")
129  from Configuration.Eras.Modifier_run3_upc_cff import run3_upc
130  run3_upc.toModify(process.selectedPatMuons, cut = "")
131  from Configuration.Eras.Modifier_ppRef_2024_cff import ppRef_2024
132  ppRef_2024.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || isTrackerMuon || (pt > 1.2 && (isGlobalMuon || isStandAloneMuon))")
133 
134  process.selectedPatElectrons.cut = cms.string("")
135  process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5")
136  process.selectedPatPhotons.cut = cms.string("")
137 
138  _dummyPatJets = process.selectedPatJets.clone(cut = "pt < 0")
139  task = getPatAlgosToolsTask(process)
140 
141  def _applySubstructure(process):
142  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
143 
144  from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
145  applySubstructure( process )
146  (~pp_on_AA).toModify(process, _applySubstructure)
147 
148  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJets', p.selectedPatJets.clone(), p, task))
149  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsAK8', _dummyPatJets.clone(), p, task))
150 
151  #
152  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
153  switchOnTriggerStandAlone( process, outputModule = '' )
154  process.patTrigger.packTriggerPathNames = cms.bool(True)
155  #
156  # apply type I + other PFMEt corrections to pat::MET object
157  # and estimate systematic uncertainties on MET
158 
159  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
160  runMetCorAndUncForMiniAODProduction(process, metType="PF",
161  jetCollUnskimmed="patJets")
162 
163  #caloMET computation
164  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
165  addMETCollection(process,
166  labelName = "patCaloMet",
167  metSource = "caloMetM"
168  )
169 
170  #noHF pfMET =========
171 
172  process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
173  src=cms.InputTag("particleFlow"),
174  cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
175  )
176  task.add(process.noHFCands)
177 
179  pfCandColl=cms.InputTag("noHFCands"),
180  recoMetFromPFCs=True, #needed for HF removal
181  jetSelection="pt>15 && abs(eta)<3.",
182  postfix="NoHF"
183  )
184 
185  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
186  task.add(process.slimmedMETs)
187  (~pp_on_AA).toModify(process.slimmedMETs, addDeepMETs = True)
188 
189  # ================== NoHF pfMET
190 
191  # ================== CHSMET
192  process.load("CommonTools.ParticleFlow.pfCHS_cff")
193  task.add(process.pfCHS)
194 
195  from RecoMET.METProducers.pfMet_cfi import pfMet
196  process.pfMetCHS = pfMet.clone(src = 'pfCHS')
197  task.add(process.pfMetCHS)
198 
199  addMETCollection(process,
200  labelName = "patCHSMet",
201  metSource = "pfMetCHS"
202  )
203 
204  process.patCHSMet.computeMETSignificance = cms.bool(False)
205 
206  # ================== CHSMET
207 
208  # ================== TrkMET
209  process.TrkCands = chargedPackedCandsForTkMet.clone()
210  task.add(process.TrkCands)
211 
212  process.pfMetTrk = pfMet.clone(src = 'TrkCands')
213  task.add(process.pfMetTrk)
214 
215  addMETCollection(process,
216  labelName = "patTrkMet",
217  metSource = "pfMetTrk"
218  )
219 
220  process.patTrkMet.computeMETSignificance = cms.bool(False)
221 
222  # ================== TrkMET
223 
224  #HF jet shower shape
225  process.load('RecoJets.JetProducers.hfJetShowerShape_cfi')
226  task.add(process.hfJetShowerShape)
227 
228  process.patJets.userData.userFloats.src += [ 'hfJetShowerShape:sigmaEtaEta', 'hfJetShowerShape:sigmaPhiPhi']
229  process.patJets.userData.userInts.src += [ 'hfJetShowerShape:centralEtaStripSize', 'hfJetShowerShape:adjacentEtaStripsSize']
230 
231 
232  def _add_deepFlavour(process):
233  process.load('RecoBTag.Combined.deepFlavour_cff')
234  task.add(process.pfDeepCSVDiscriminatorsJetTags)
235  process.patJets.discriminatorSources.extend([
236  'pfDeepCSVDiscriminatorsJetTags:BvsAll',
237  'pfDeepCSVDiscriminatorsJetTags:CvsB',
238  'pfDeepCSVDiscriminatorsJetTags:CvsL',
239  ])
240 
241 
242  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
243  src = process.patJets.jetSource,
244  matched = cms.InputTag("ak4CaloJets"),
245  distMax = cms.double(0.4),
246  values = cms.vstring('pt','emEnergyFraction'),
247  valueLabels = cms.vstring('pt','emEnergyFraction'),
248  lazyParser = cms.bool(True) )
249  task.add(process.caloJetMap)
250  process.patJets.userData.userFloats.src += [ 'caloJetMap:pt', 'caloJetMap:emEnergyFraction' ]
251 
252  pp_on_AA.toModify(process.patJets.userData.userInts, src = [] )
253  pp_on_AA.toModify(process.patJets.userData.userFloats, src = [] )
254 
255  #Muon object modifications
256  from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
258 
259  #EGM object modifications
260  from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
262  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
263  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
264  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
265 
266  #VID Electron IDs
267  process.patElectrons.addElectronID = cms.bool(True)
268  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
269  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV71_cff',
270  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
271  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
272  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Winter22_122X_V1_cff',
273  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
274  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
275  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
276  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
277  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
278  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
279  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
280  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer16UL_ID_ISO_cff',
281  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer17UL_ID_ISO_cff',
282  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff',
283  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_noIso_V1_cff',
284  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_iso_V1_cff',
285  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Winter22_HZZ_V1_cff'
286  ]
287  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
288  process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
289  process.electronMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
290 
291  # To use older DataFormats, the electronMVAValueMapProducer MUST take a updated electron collection
292  # such that the conversion variables are filled correctly.
293  process.load("RecoEgamma.EgammaTools.gedGsfElectronsTo106X_cff")
294  run2_miniAOD_80XLegacy.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom80XTo106XTask))
295  run2_miniAOD_80XLegacy.toModify(process.electronMVAValueMapProducer,
296  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
297  src = cms.InputTag("gedGsfElectronsFrom80XTo106X"))
298 
299  run2_miniAOD_94XFall17.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
300  run2_miniAOD_94XFall17.toModify(process.electronMVAValueMapProducer,
301  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
302  src = cms.InputTag("gedGsfElectronsFrom94XTo106X"))
303 
304  from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
305  pp_on_AA_2018.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
306  pp_on_AA_2018.toModify(process.electronMVAValueMapProducer,
307  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
308  src = "gedGsfElectronsFrom94XTo106X")
309 
310  for idmod in electron_ids:
311  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
312 
313  #VID Photon IDs
314  process.patPhotons.addPhotonID = cms.bool(True)
315  photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
316  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
317  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
318  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
319  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
320  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff',
321  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Winter22_122X_V1_cff',
322  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_RunIIIWinter22_122X_V1_cff']
323 
324  switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
325  process.egmPhotonIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedPhotons")
326  process.photonMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedPhotons')
327  for idmod in photon_ids:
328  setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)
329 
330  #add the cut base IDs bitmaps of which cuts passed
331  from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier
332  egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs"))
333 
334  #-- Adding boosted taus
335  from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
336  addBoostedTaus(process)
337  process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
338  process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
339  #-- Adding customization for 94X 2017 legacy reMniAOD
340  _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
341  _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauBasicDiscriminatorsTask,
342  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask,
343  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask,
344  process.hpsPFTauBasicDiscriminatorsdR03Task,
345  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTTask,
346  process.hpsPFTauDiscriminationByMVA6rawElectronRejection,
347  process.hpsPFTauDiscriminationByMVA6ElectronRejection,
348  process.hpsPFTauDiscriminationByMuonRejection3)
349  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
350  (run2_miniAOD_94XFall17 | run2_miniAOD_UL).toReplaceWith(
351  process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
352  )
353  #-- Adding DeepTauID
354  # deepTau v2p1 and v2p5
355  _updatedTauName = 'slimmedTausDeepIDsv2p1'
356  _noUpdatedTauName = 'slimmedTausNoDeepIDs'
357  import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
358  tauIdEmbedder = tauIdConfig.TauIDEmbedder(
359  process, debug = False,
360  originalTauName = _noUpdatedTauName,
361  updatedTauName = _updatedTauName,
362  postfix = 'ForMini',
363  toKeep = ['deepTau2017v2p1','deepTau2018v2p5']
364  )
365  from Configuration.Eras.Modifier_phase2_common_cff import phase2_common #Phase2 Tau MVA
366  _tauIds_phase2 = ['deepTau2026v2p5']
367  phase2_common.toModify(tauIdEmbedder.toKeep, func=lambda t:t.extend(_tauIds_phase2))
368  tauIdEmbedder.runTauID()
369  addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(),process,task)
370  delattr(process, 'slimmedTaus')
371  process.slimmedTaus = getattr(process, _updatedTauName).clone()
372  process.rerunMvaIsolationTaskForMini.add(process.slimmedTaus)
373  task.add(process.rerunMvaIsolationTaskForMini)
374 
375  #-- Rerun tauID against dead ECal towers to taus for the various re-MiniAOD eras
376  # to enable default behoviour with leading track extrapolation to ECAL
377  _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy()
378  _makePatTausTaskWithDeadECalVeto.add(
379  process.hpsPFTauDiscriminationByDeadECALElectronRejection
380  )
381  _run2_miniAOD_ANY = (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17 | run2_miniAOD_UL)
382  _run2_miniAOD_ANY.toReplaceWith(
383  process.makePatTausTask, _makePatTausTaskWithDeadECalVeto
384  )
385 
386  #-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions
387  _makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
388  _makePatTausTaskWithTauReReco.add(process.PFTauTask)
389  (run2_miniAOD_80XLegacy | pp_on_AA).toReplaceWith(
390  process.makePatTausTask, _makePatTausTaskWithTauReReco
391  )
392 
393  # Adding puppi jets
394  process.load('CommonTools.PileupAlgos.Puppi_cff')
395  process.load('RecoJets.JetProducers.ak4PFJets_cfi')
396  from Configuration.Eras.Modifier_pA_2016_cff import pA_2016
397  from Configuration.Eras.Modifier_run3_miniAOD_12X_cff import run3_miniAOD_12X
398  _rerun_puppijets_task = task.copy()
399  _rerun_puppijets_task.add(process.puppi, process.ak4PFJetsPuppi)
400  (_run2_miniAOD_ANY | pA_2016 | pp_on_AA | run3_miniAOD_12X).toReplaceWith(task, _rerun_puppijets_task)
401 
402  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
403  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
404  j2tParametersVX,
405  jets = cms.InputTag("ak4PFJetsPuppi")
406  )
407  task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
408  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
409  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
410  var = cms.string('Pt'),
411  exp = cms.double(1.0)
412  )
413  task.add(process.patJetPuppiCharge)
414 
415  def _add_jetsPuppi(process):
416  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
417  noDeepFlavourDiscriminators = [x.value() if isinstance(x, cms.InputTag) else x for x in process.patJets.discriminatorSources
418  if (not "DeepFlavour" in str(x) and not "Transformer" in str(x))]
419  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
420  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
421  pfCandidates = cms.InputTag("particleFlow"),
422  algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
423  )
424 
425  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
426 
427  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
428 
429  process.selectedPatJetsPuppi.cut = cms.string("pt > 10")
430 
431  from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging
432  applyDeepBtagging( process )
433 
434  process.slimmedJetsNoDeepFlavour.dropTagInfos = '0'
435  process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.addTagInfos = True
436  process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.tagInfoSources = ["pixelClusterTagInfos"]
437  _run2_miniAOD_ANY.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = False )
438  (~pp_on_AA).toModify(process, _add_jetsPuppi)
439 
440  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsPuppi', _dummyPatJets.clone(), p, task))
441 
442  # Embed pixelClusterTagInfos in slimmedJets
443  process.patJets.addTagInfos = True
444  process.patJets.tagInfoSources = ["pixelClusterTagInfos"]
445 
446  _run2_miniAOD_ANY.toModify(process.patJets, addTagInfos = False )
447 
448  from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
449  pp_on_AA_2018.toModify(process.patJets, tagInfoSources = cms.VInputTag(["impactParameterTagInfos","secondaryVertexTagInfos"]) )
450 
451 
452  def _add_metPuppi(process):
453  process.load('RecoMET.METProducers.pfMetPuppi_cfi')
454  _rerun_puppimet_task = task.copy()
455  _rerun_puppimet_task.add(process.puppiNoLep, process.pfMetPuppi)
456  (_run2_miniAOD_ANY | pA_2016 | pp_on_AA | run3_miniAOD_12X).toReplaceWith(task, _rerun_puppimet_task)
457 
458  runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
459  jetCollUnskimmed="slimmedJetsPuppi",
460  recoMetFromPFCs=True,
461  jetFlavor="AK4PFPuppi",
462  postfix="Puppi"
463  )
464  (~pp_on_AA).toModify(process, _add_metPuppi)
465 
466  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
467  task.add(process.slimmedMETs)
468 
469  def _add_slimmedMETsPuppi(process):
470  addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
471  process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
472  process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
473  process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
474  process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
475  process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
476  process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
477  process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
478  process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
479  process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
480  process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
481  del process.slimmedMETsPuppi.caloMET
482  (~pp_on_AA).toModify(process, _add_slimmedMETsPuppi)
483 
484  def _add_deepMET(process):
485  from RecoMET.METPUSubtraction.deepMETProducer_cff import deepMETsResolutionTune, deepMETsResponseTune
486 
487  addToProcessAndTask('deepMETsResolutionTune', deepMETsResolutionTune, process, task)
488  addToProcessAndTask('deepMETsResponseTune', deepMETsResponseTune, process, task)
489  (~pp_on_AA).toModify(process, _add_deepMET)
490 
491  # add DetIdAssociatorRecords to EventSetup (for isolatedTracks)
492  process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
493 
494  # EGamma objects from HGCal are not yet in GED
495  # so add companion collections for Phase-II MiniAOD production
496  from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
497  process.load("RecoEgamma.EgammaTools.slimmedEgammaHGC_cff")
498  phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaHGCTask))
499 
500  # L1 pre-firing weights for 2016, 2017, and 2018
501  from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring
502  from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
503  from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
504  from Configuration.Eras.Modifier_stage2L1Trigger_2018_cff import stage2L1Trigger_2018
505  from Configuration.Eras.Modifier_tracker_apv_vfp30_2016_cff import tracker_apv_vfp30_2016
506  if not hasattr(process,'prefiringweight'):
507  process.load("PhysicsTools.PatUtils.L1PrefiringWeightProducer_cff")
508  (stage2L1Trigger & tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016preVFP", DataEraMuon = "2016preVFP" )
509  (stage2L1Trigger & ~tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016postVFP", DataEraMuon = "2016postVFP" )
510  stage2L1Trigger_2017.toModify(process.prefiringweight, DataEraECAL = "UL2017BtoF", DataEraMuon = "20172018")
511  stage2L1Trigger_2018.toModify(process.prefiringweight, DataEraECAL = "None", DataEraMuon = "20172018")
512  run2_L1prefiring.toModify(task, func=lambda t: t.add(process.prefiringweight))
513 
514  from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeL1FastJetJECs
515  pp_on_AA.toModify(process, removeL1FastJetJECs)
516 
517 def miniAOD_customizeMC(process):
518  task = getPatAlgosToolsTask(process)
519  #GenJetFlavourInfos
520  process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
521  task.add(process.selectedHadronsAndPartons)
522  task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
523 
524  process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
525  task.add(process.ak4GenJetFlavourInfos)
526 
527  process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
528  task.add(process.slimmedGenJetsFlavourInfos)
529 
530  #slimmed pileup information
531  process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
532  task.add(process.slimmedAddPileupInfo)
533 
534  process.muonMatch.matched = "prunedGenParticles"
535  process.electronMatch.matched = "prunedGenParticles"
536  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
537  process.photonMatch.matched = "prunedGenParticles"
538  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
539  process.ootPhotonMatch.matched = "prunedGenParticles"
540  process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
541  process.tauMatch.matched = "prunedGenParticles"
542  process.tauGenJets.GenParticles = "prunedGenParticles"
543  #Boosted taus
544  process.tauMatchBoosted.matched = "prunedGenParticles"
545  process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
546  process.patJetPartons.particles = "genParticles"
547  process.patJetPartonMatch.matched = "prunedGenParticles"
548  pp_on_AA.toModify(process.patJetPartonMatch, matched = "hiSignalGenParticles")
549  from Configuration.ProcessModifiers.genJetSubEvent_cff import genJetSubEvent
550  genJetSubEvent.toModify(process.patJetPartonMatch, matched = "cleanedPartons")
551  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
552  process.patJetGenJetMatch.matched = "slimmedGenJets"
553  (~pp_on_AA).toModify(process, patJetGenJetMatchAK8Puppi = dict(matched = "slimmedGenJetsAK8"))
554  process.patMuons.embedGenMatch = False
555  process.patElectrons.embedGenMatch = False
556  process.patPhotons.embedGenMatch = False
557  process.patOOTPhotons.embedGenMatch = False
558  process.patTaus.embedGenMatch = False
559  process.patTausBoosted.embedGenMatch = False
560  process.patJets.embedGenPartonMatch = False
561  #also jet flavour must be switched
562  process.patJetFlavourAssociation.rParam = 0.4
563 
564  from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeJECsForMC
565  pp_on_AA.toModify(process, removeJECsForMC)
566  pp_on_AA.toReplaceWith(task,task.copyAndExclude([process.slimmedGenJetsFlavourInfos]))
567 
568 
570  from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
571  out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
572  out.splitLevel = cms.untracked.int32(0)
573  out.dropMetaData = cms.untracked.string('ALL')
574  out.fastCloning= cms.untracked.bool(False)
575  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
576  out.compressionAlgorithm = cms.untracked.string('LZMA')
577 
579  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
580  runOnData( process, outputModules = [] )
581  process.load("RecoPPS.Local.ctppsLocalTrackLiteProducer_cff")
582  process.load("RecoPPS.ProtonReconstruction.ctppsProtons_cff")
583  process.load("Geometry.VeryForwardGeometry.geometryRPFromDB_cfi")
584  process.load('L1Trigger.L1TGlobal.simGtExtFakeProd_cfi')
585  task = getPatAlgosToolsTask(process)
586  task.add(process.simGtExtUnprefireable)
587  from Configuration.Eras.Modifier_ctpps_cff import ctpps
588  ctpps.toModify(task, func=lambda t: t.add(process.ctppsLocalTrackLiteProducer))
589  ctpps.toModify(task, func=lambda t: t.add(process.ctppsProtons))
590  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
591  run2_miniAOD_UL.toModify(task, func=lambda t: t.add(process.simGtExtUnprefireable))
592 
594  miniAOD_customizeCommon(process)
595  miniAOD_customizeData(process)
596  return process
597 
599  miniAOD_customizeCommon(process)
600  miniAOD_customizeMC(process)
601  return process
602 
604  miniAOD_customizeCommon(process)
605  miniAOD_customizeMC(process)
606  from PhysicsTools.PatAlgos.slimming.metFilterPaths_cff import miniAOD_customizeMETFiltersFastSim
607  process = miniAOD_customizeMETFiltersFastSim(process)
608  from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
609  process = miniAOD_customizeIsolatedTracksFastSim(process)
610  process.patMuons.addTriggerMatching = False
611  # Disable pixelClusterTagInfos in FastSim (no siPixelCluster available)
612  from Configuration.Eras.Modifier_fastSim_cff import fastSim
613  fastSim.toModify(process.patJets, addTagInfos = cms.bool(False) )
614  fastSim.toModify(process.slimmedJetsNoDeepFlavour, dropTagInfos = cms.string('1') )
615  fastSim.toModify(process.updatedPatJetsSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
616  fastSim.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
617 
618  return process
def makeInputForPUPPIIsolationMuon(process)
def miniAOD_customizeAllData(process)
def miniAOD_customizeData(process)
def miniAOD_customizeCommon(process)
def applySubstructure(process, postfix="")
def miniAOD_customizeMETFiltersFastSim(process)
def switchOnVIDElectronIdProducer(process, dataFormat, task=None)
Electrons.
Definition: vid_id_tools.py:66
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
def makeInputForPUPPIIsolationEgm(process)
def setupAllVIDIdsInModule(process, id_module_name, setupFunction, patProducer=None, addUserData=True, task=None)
Definition: vid_id_tools.py:49
def runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets", photonColl="selectedPatPhotons", electronColl="selectedPatElectrons", muonColl="selectedPatMuons", tauColl="selectedPatTaus", pfCandColl="particleFlow", jetCleaning="LepClean", jetSelection="pt>15 && abs(eta)<9.9", jecUnFile="", jetFlavor="AK4PFchs", recoMetFromPFCs=False, postfix="")
def miniAOD_customizeAllMC(process)
def applyDeepBtagging(process, postfix="")
def miniAOD_customizeAllMCFastSim(process)
def miniAOD_customizeIsolatedTracksFastSim(process)
switchOnTriggerStandAlone
Definition: trigTools.py:283
def makeVIDBitsModifier(process, eleVIDModuleName, phoVIDModuleName)
def miniAOD_customizeOutput(out)
def miniAOD_customizeMC(process)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def getPatAlgosToolsTask(process)
Definition: helpers.py:13
def switchOnVIDPhotonIdProducer(process, dataFormat, task=None)
Photons.
#define str(s)