CMS 3D CMS Logo

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