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 
8  process.patMuons.isoDeposits = cms.PSet()
9  process.patElectrons.isoDeposits = cms.PSet()
10  process.patTaus.isoDeposits = cms.PSet()
11  process.patPhotons.isoDeposits = cms.PSet()
12  #
13  process.patMuons.embedTrack = True # used for IDs
14  process.patMuons.embedCombinedMuon = True # used for IDs
15  process.patMuons.embedMuonBestTrack = True # used for IDs
16  process.patMuons.embedStandAloneMuon = True # maybe?
17  process.patMuons.embedPickyMuon = False # no, use best track
18  process.patMuons.embedTpfmsMuon = False # no, use best track
19  process.patMuons.embedDytMuon = False # no, use best track
20  process.patMuons.addPuppiIsolation = cms.bool(True)
21  process.patMuons.puppiIsolationChargedHadrons = cms.InputTag("muonPUPPIIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
22  process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag("muonPUPPIIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
23  process.patMuons.puppiIsolationPhotons = cms.InputTag("muonPUPPIIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
24  process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
25  process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
26  process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
27 
28  process.patMuons.computeMiniIso = True
29  process.patMuons.computeMuonMVA = True
30  process.patMuons.computeSoftMuonMVA = True
31 
32  process.patMuons.addTriggerMatching = True
33  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
34  from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016
35  from Configuration.Eras.Modifier_run2_muon_2017_cff import run2_muon_2017
36  from Configuration.Eras.Modifier_run2_muon_2018_cff import run2_muon_2018
37  run2_muon_2016.toModify( process.patMuons, effectiveAreaVec = [0.0735,0.0619,0.0465,0.0433,0.0577])
38  run2_muon_2017.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
39  run2_muon_2018.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
40  run2_muon_2016.toModify( process.patMuons, mvaTrainingFile = "RecoMuon/MuonIdentification/data/mu_2016_BDTG.weights.xml")
41  run2_miniAOD_UL.toModify( process.patMuons, getdBFromTrack = True)
42  process.patMuons.computePuppiCombinedIso = True
43  #
44  # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer
45  process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core
46  process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
47  process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
48  process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster
49  process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters
50  process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters
51  process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters
52  process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters
53  process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer
54  process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
55  process.patElectrons.usePfCandidateMultiMap = True
56  process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap")
57  process.patElectrons.electronIDSources = cms.PSet()
58  run2_miniAOD_UL.toModify( process.patElectrons, getdBFromTrack = True)
59  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
60  run2_miniAOD_80XLegacy.toModify(process.patElectrons,
61  addPFClusterIso = cms.bool(True),
62  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso"),
63  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso"))
64  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
65  run2_miniAOD_94XFall17.toModify(process.patElectrons,
66  addPFClusterIso = cms.bool(True),
67  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso"),
68  hcalPFClusterIsoMap = cms.InputTag("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 ## whether to process.patPhotons.embed in AOD externally stored supercluster
88  process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster
89  process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters
90  process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters
91  process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer
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  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
100  run2_miniAOD_80XLegacy.toModify(process.patPhotons,
101  addPFClusterIso = cms.bool(True),
102  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso"),
103  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso"))
104  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
105  run2_miniAOD_94XFall17.toModify(process.patPhotons,
106  addPFClusterIso = cms.bool(True),
107  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso"),
108  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso"))
109  #the 80X legacy customsations are done in ootPhotonProducer for OOT photons
110  run2_miniAOD_94XFall17.toModify(process.patOOTPhotons,
111  addPFClusterIso = cms.bool(True),
112  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "ootPhoEcalPFClusIso"),
113  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "ootPhoHcalPFClusIso"))
114 
115 
116  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
117  process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
118 
119  process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
120  process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
121  process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
122  process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
123  process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
124  #
125  process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons")
126  process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
127  #
128  process.selectedPatJets.cut = cms.string("pt > 10")
129  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
130 
131  from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
132  phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )")
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  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
139 
140  from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
141  applySubstructure( process )
142 
143  #
144  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
145  switchOnTriggerStandAlone( process, outputModule = '' )
146  process.patTrigger.packTriggerPathNames = cms.bool(True)
147  #
148  # apply type I + other PFMEt corrections to pat::MET object
149  # and estimate systematic uncertainties on MET
150 
151  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
152  runMetCorAndUncForMiniAODProduction(process, metType="PF",
153  jetCollUnskimmed="patJets")
154 
155  #caloMET computation
156  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
157  addMETCollection(process,
158  labelName = "patCaloMet",
159  metSource = "caloMetM"
160  )
161 
162  #noHF pfMET =========
163 
164  task = getPatAlgosToolsTask(process)
165 
166  process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
167  src=cms.InputTag("particleFlow"),
168  cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
169  )
170  task.add(process.noHFCands)
171 
173  pfCandColl=cms.InputTag("noHFCands"),
174  recoMetFromPFCs=True, #needed for HF removal
175  jetSelection="pt>15 && abs(eta)<3.",
176  postfix="NoHF"
177  )
178 
179  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
180  task.add(process.slimmedMETs)
181 
182  addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task)
183  process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF")
184  process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF")
185  process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF")
186  process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF")
187  process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF")
188  process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF")
189  process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF")
190  process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF")
191  process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF")
192  process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF")
193  del process.slimmedMETsNoHF.caloMET
194  # ================== NoHF pfMET
195 
196  # ================== CHSMET
197  process.CHSCands = cms.EDFilter("CandPtrSelector",
198  src=cms.InputTag("packedPFCandidates"),
199  cut=cms.string("fromPV(0) > 0")
200  )
201  task.add(process.CHSCands)
202 
203  process.pfMetCHS = cms.EDProducer("PFMETProducer",
204  src = cms.InputTag("CHSCands"),
205  alias = cms.string('pfMet'),
206  globalThreshold = cms.double(0.0),
207  calculateSignificance = cms.bool(False),
208  )
209  task.add(process.pfMetCHS)
210 
211  addMETCollection(process,
212  labelName = "patCHSMet",
213  metSource = "pfMetCHS"
214  )
215 
216  process.patCHSMet.computeMETSignificance = cms.bool(False)
217 
218  # ================== CHSMET
219 
220  # ================== TrkMET
221  process.TrkCands = cms.EDFilter("CandPtrSelector",
222  src=cms.InputTag("packedPFCandidates"),
223  cut=cms.string("charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0")
224  )
225  task.add(process.TrkCands)
226 
227  process.pfMetTrk = cms.EDProducer("PFMETProducer",
228  src = cms.InputTag("TrkCands"),
229  alias = cms.string('pfMet'),
230  globalThreshold = cms.double(0.0),
231  calculateSignificance = cms.bool(False),
232  )
233 
234  task.add(process.pfMetTrk)
235 
236  addMETCollection(process,
237  labelName = "patTrkMet",
238  metSource = "pfMetTrk"
239  )
240 
241  process.patTrkMet.computeMETSignificance = cms.bool(False)
242 
243  # ================== TrkMET
244 
245 
246  ## PU JetID
247  process.load("RecoJets.JetProducers.PileupJetID_cfi")
248  task.add(process.pileUpJetIDTask)
249 
250  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
251  process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ]
252 
253  ## Quark Gluon Likelihood
254  process.load('RecoJets.JetProducers.QGTagger_cfi')
255  task.add(process.QGTaggerTask)
256 
257  process.patJets.userData.userFloats.src += [ 'QGTagger:qgLikelihood', ]
258 
259  #HF jet shower shape
260  process.load('RecoJets.JetProducers.hfJetShowerShape_cfi')
261  task.add(process.hfJetShowerShape)
262 
263  run2_miniAOD_UL.toModify(process.patJets.userData.userFloats,
264  src = process.patJets.userData.userFloats.src + ['hfJetShowerShape:sigmaEtaEta', 'hfJetShowerShape:sigmaPhiPhi'])
265  run2_miniAOD_UL.toModify(process.patJets.userData.userInts,
266  src = process.patJets.userData.userInts.src + ['hfJetShowerShape:centralEtaStripSize', 'hfJetShowerShape:adjacentEtaStripsSize'])
267 
268  ## DeepCSV meta discriminators (simple arithmethic on output probabilities)
269  process.load('RecoBTag.Combined.deepFlavour_cff')
270  task.add(process.pfDeepCSVDiscriminatorsJetTags)
271  process.patJets.discriminatorSources.extend([
272  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:BvsAll' ),
273  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsB' ),
274  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsL' ),
275  ])
276 
277  ## CaloJets
278  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
279  src = process.patJets.jetSource,
280  matched = cms.InputTag("ak4CaloJets"),
281  distMax = cms.double(0.4),
282  values = cms.vstring('pt','emEnergyFraction'),
283  valueLabels = cms.vstring('pt','emEnergyFraction'),
284  lazyParser = cms.bool(True) )
285  task.add(process.caloJetMap)
286  process.patJets.userData.userFloats.src += [ 'caloJetMap:pt', 'caloJetMap:emEnergyFraction' ]
287 
288  #Muon object modifications
289  from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
291 
292  #EGM object modifications
293  from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
295  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
296  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
297  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
298 
299  #VID Electron IDs
300  process.patElectrons.addElectronID = cms.bool(True)
301  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
302  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV71_cff',
303  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
304  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
305  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
306  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
307  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
308  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
309  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
310  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
311  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
312  ]
313  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
314  process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
315  process.electronMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
316 
317  # To use older DataFormats, the electronMVAValueMapProducer MUST take a updated electron collection
318  # such that the conversion variables are filled correctly.
319  process.load("RecoEgamma.EgammaTools.gedGsfElectronsTo106X_cff")
320  run2_miniAOD_80XLegacy.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom80XTo106XTask))
321  run2_miniAOD_80XLegacy.toModify(process.electronMVAValueMapProducer,
322  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
323  src = cms.InputTag("gedGsfElectronsFrom80XTo106X"))
324 
325  run2_miniAOD_94XFall17.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
326  run2_miniAOD_94XFall17.toModify(process.electronMVAValueMapProducer,
327  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
328  src = cms.InputTag("gedGsfElectronsFrom94XTo106X"))
329 
330  for idmod in electron_ids:
331  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
332 
333  #VID Photon IDs
334  process.patPhotons.addPhotonID = cms.bool(True)
335  photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
336  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
337  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
338  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
339  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
340  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff']
341  switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
342  process.egmPhotonIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedPhotons")
343  process.photonMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedPhotons')
344  for idmod in photon_ids:
345  setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)
346 
347  #add the cut base IDs bitmaps of which cuts passed
348  from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier
349  egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs"))
350 
351  #-- Adding boosted taus
352  from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
353  addBoostedTaus(process)
354  process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
355  process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
356  #-- Adding customization for 94X 2017 legacy reMiniAOD
357  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
358  _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
359  _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask,
360  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask,
361  process.hpsPFTauIsolationSums03Task,
362  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTTask)
363  run2_miniAOD_94XFall17.toReplaceWith(
364  process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
365  )
366  #-- Adding customization for UL reMiniAOD:
367  # running retrained anti-e MVA6 discriminants as setup in the HPS PFTau
368  # master configuration for this era.
369  _makePatTausTaskWithMVA6ElectronRejection = process.makePatTausTask.copy()
370  _makePatTausTaskWithMVA6ElectronRejection.add(
371  process.hpsPFTauDiscriminationByMVA6ElectronRejectionTask
372  )
373  run2_miniAOD_UL.toReplaceWith(
374  process.makePatTausTask, _makePatTausTaskWithMVA6ElectronRejection
375  )
376  #-- Adding DeepTauID
377  # deepTau v2
378  _updatedTauName = 'slimmedTausDeepIDsv2'
379  _noUpdatedTauName = 'slimmedTausNoDeepIDs'
380  import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
381  tauIdEmbedder = tauIdConfig.TauIDEmbedder(
382  process, cms, debug = False,
383  originalTauName = _noUpdatedTauName,
384  updatedTauName = _updatedTauName,
385  toKeep = ['deepTau2017v2']
386  )
387  tauIdEmbedder.runTauID()
388  addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(),process,task)
389  delattr(process, 'slimmedTaus')
390  process.slimmedTaus = getattr(process, _updatedTauName).clone()
391  process.deepTauIDTask = cms.Task(process.deepTau2017v2, process.slimmedTaus)
392  task.add(process.deepTauIDTask)
393 
394  # deepTau v2p1
395  _updatedTauNameNew = 'slimmedTausDeepIDsv2p1'
396  tauIdEmbedderNew = tauIdConfig.TauIDEmbedder(
397  process, cms, debug = False,
398  originalTauName = _noUpdatedTauName,
399  updatedTauName = _updatedTauNameNew,
400  toKeep = ['deepTau2017v2p1']
401  )
402  tauIdEmbedderNew.runTauID()
403  deepTauIDTaskNew_ = cms.Task(process.deepTau2017v2p1,process.slimmedTaus)
404 
405  from Configuration.Eras.Modifier_run2_tau_ul_2016_cff import run2_tau_ul_2016
406  from Configuration.Eras.Modifier_run2_tau_ul_2018_cff import run2_tau_ul_2018
407  for era in [run2_miniAOD_UL,run2_tau_ul_2016,run2_tau_ul_2018]:
408  era.toReplaceWith(process.slimmedTaus,
409  getattr(process, _updatedTauNameNew))
410  era.toReplaceWith(process.deepTauIDTask,
411  deepTauIDTaskNew_)
412 
413  #-- Adding tauID against dead ECal towers to taus
414  # note: default (AOD) behoviour of the tauID modified (leading track
415  # extrapolation to ECAL enabled) in the HPS PFTau master
416  # configuration for this era.
417  _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy()
418  _makePatTausTaskWithDeadECalVeto.add(
419  process.hpsPFTauDiscriminationByDeadECALElectronRejection
420  )
421  run2_miniAOD_UL.toReplaceWith(
422  process.makePatTausTask, _makePatTausTaskWithDeadECalVeto
423  )
424  _withDeadEcalTauIDPs = cms.PSet(
425  process.patTaus.tauIDSources,
426  againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejection")
427  )
428  run2_miniAOD_UL.toModify(process.patTaus,
429  tauIDSources = _withDeadEcalTauIDPs)
430  #... and to boosted taus
431  _withDeadEcalTauIDBoostedPs = cms.PSet(
432  process.patTausBoosted.tauIDSources,
433  againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejectionBoosted")
434  )
435  run2_miniAOD_UL.toModify(process.patTausBoosted,
436  tauIDSources = _withDeadEcalTauIDBoostedPs)
437 
438  #-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions
439  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
440  from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
441  _makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
442  _makePatTausTaskWithTauReReco.add(process.PFTauTask)
443  (run2_miniAOD_80XLegacy | pp_on_AA_2018).toReplaceWith(
444  process.makePatTausTask, _makePatTausTaskWithTauReReco
445  )
446 
447  # Adding puppi jets
448  if not hasattr(process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call
449  process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
450  task.add(process.ak4PFJets)
451  task.add(process.ak4PFJetsPuppi)
452  process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
453  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
454  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
455  j2tParametersVX,
456  jets = cms.InputTag("ak4PFJetsPuppi")
457  )
458  task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
459  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
460  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
461  var = cms.string('Pt'),
462  exp = cms.double(1.0)
463  )
464  task.add(process.patJetPuppiCharge)
465 
466  noDeepFlavourDiscriminators = [x.value() for x in process.patJets.discriminatorSources if not "DeepFlavour" in x.value()]
467  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
468  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
469  pfCandidates = cms.InputTag("particleFlow"),
470  algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
471  )
472 
473  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
474 
475  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
476 
477  process.selectedPatJetsPuppi.cut = cms.string("pt > 15")
478 
479  from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging
480  applyDeepBtagging( process )
481 
482  addToProcessAndTask('slimmedJetsPuppiNoMultiplicities', process.slimmedJetsNoDeepFlavour.clone(), process, task)
483  process.slimmedJetsPuppiNoMultiplicities.src = cms.InputTag("selectedPatJetsPuppi")
484  process.slimmedJetsPuppiNoMultiplicities.packedPFCandidates = cms.InputTag("packedPFCandidates")
485 
486  from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer
487  from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
488  process.patPuppiJetSpecificProducer = patPuppiJetSpecificProducer.clone(
489  src=cms.InputTag("slimmedJetsPuppiNoMultiplicities"),
490  )
491  task.add(process.patPuppiJetSpecificProducer)
492  updateJetCollection(
493  process,
494  labelName = 'PuppiJetSpecific',
495  jetSource = cms.InputTag('slimmedJetsPuppiNoMultiplicities'),
496  )
497  process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = ['patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ]
498  process.slimmedJetsPuppi = process.selectedUpdatedPatJetsPuppiJetSpecific.clone()
499  delattr(process, 'selectedUpdatedPatJetsPuppiJetSpecific')
500 
501  task.add(process.slimmedJetsPuppi)
502 
503  ## puppi met
504  from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies
505  makePuppies( process );
506 
507  runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
508  pfCandColl=cms.InputTag("puppiForMET"),
509  jetCollUnskimmed="slimmedJetsPuppi",
510  recoMetFromPFCs=True,
511  jetFlavor="AK4PFPuppi",
512  postfix="Puppi"
513  )
514 
515  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
516  task.add(process.slimmedMETs)
517  addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
518  process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
519  process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
520  process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
521  process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
522  process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
523  process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
524  process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
525  process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
526  process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
527  process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
528  del process.slimmedMETsPuppi.caloMET
529 
530  process.load('RecoMET.METPUSubtraction.deepMETProducer_cfi')
531 
532  process.deepMETsResolutionTune = process.deepMETProducer.clone()
533  process.deepMETsResponseTune = process.deepMETProducer.clone()
534  process.deepMETsResponseTune.graph_path = 'RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb'
535 
536  from Configuration.Eras.Modifier_run2_jme_2016_cff import run2_jme_2016
537  run2_jme_2016.toModify(
538  process.deepMETsResponseTune,
539  graph_path="RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb"
540  )
541 
542  run2_miniAOD_UL.toModify(task, func=lambda t: t.add(process.deepMETsResolutionTune, process.deepMETsResponseTune))
543  run2_miniAOD_UL.toModify(process.slimmedMETs, addDeepMETs = True)
544 
545  # add DetIdAssociatorRecords to EventSetup (for isolatedTracks)
546  process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
547 
548  # EGamma objects from HGCal are not yet in GED
549  # so add companion collections for Phase-II MiniAOD production
550  from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
551  process.load("RecoEgamma.EgammaTools.slimmedEgammaFromMultiCl_cff")
552  phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaFromMultiClTask))
553 
554  # L1 pre-firing weights for 2016 and 2017
555  from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring
556  from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
557  from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
558  process.load("PhysicsTools.PatUtils.L1PrefiringWeightProducer_cff")
559  stage2L1Trigger.toModify(process.prefiringweight, DataEraECAL = "2017BtoF", JetMaxMuonFraction = -1, DoMuons = cms.bool(False) )
560  stage2L1Trigger_2017.toModify(process.prefiringweight, DataEraECAL = "2017BtoF", JetMaxMuonFraction = -1, DoMuons = cms.bool(False))
561  run2_L1prefiring.toModify(task, func=lambda t: t.add(process.prefiringweight))
562 
563 def miniAOD_customizeMC(process):
564  task = getPatAlgosToolsTask(process)
565  #GenJetFlavourInfos
566  process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
567  task.add(process.selectedHadronsAndPartons)
568  task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
569 
570  process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
571  task.add(process.ak4GenJetFlavourInfos)
572 
573  process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
574  task.add(process.slimmedGenJetsFlavourInfos)
575 
576  #slimmed pileup information
577  process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
578  task.add(process.slimmedAddPileupInfo)
579 
580  process.muonMatch.matched = "prunedGenParticles"
581  process.electronMatch.matched = "prunedGenParticles"
582  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
583  process.photonMatch.matched = "prunedGenParticles"
584  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
585  process.ootPhotonMatch.matched = "prunedGenParticles"
586  process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
587  process.tauMatch.matched = "prunedGenParticles"
588  process.tauGenJets.GenParticles = "prunedGenParticles"
589  #Boosted taus
590  process.tauMatchBoosted.matched = "prunedGenParticles"
591  process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
592  process.patJetPartons.particles = "genParticles"
593  process.patJetPartonMatch.matched = "prunedGenParticles"
594  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
595  process.patJetGenJetMatch.matched = "slimmedGenJets"
596  process.patJetGenJetMatchAK8.matched = "slimmedGenJetsAK8"
597  process.patMuons.embedGenMatch = False
598  process.patElectrons.embedGenMatch = False
599  process.patPhotons.embedGenMatch = False
600  process.patOOTPhotons.embedGenMatch = False
601  process.patTaus.embedGenMatch = False
602  process.patTausBoosted.embedGenMatch = False
603  process.patJets.embedGenPartonMatch = False
604  #also jet flavour must be switched
605  process.patJetFlavourAssociation.rParam = 0.4
606 
608  from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
609 
610  MiniAODOverrideBranchesSplitLevelWithBs = MiniAODOverrideBranchesSplitLevel.copy()
611  MiniAODOverrideBranchesSplitLevelWithBs.extend([cms.untracked.PSet(branch = cms.untracked.string("recoVertexs_offlineSlimmedPrimaryVerticesWithBS__*"),splitLevel=cms.untracked.int32(99))])
612 
613  from Configuration.Eras.Modifier_bParking_cff import bParking
614  from Configuration.Eras.Modifier_run2_miniAOD_devel_cff import run2_miniAOD_devel
615 
616  out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
617  (bParking | run2_miniAOD_devel).toModify(out, overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevelWithBs)
618 
619  out.splitLevel = cms.untracked.int32(0)
620  out.dropMetaData = cms.untracked.string('ALL')
621  out.fastCloning= cms.untracked.bool(False)
622  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
623  out.compressionAlgorithm = cms.untracked.string('LZMA')
624 
626  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
627  runOnData( process, outputModules = [] )
628  process.load("RecoCTPPS.Configuration.recoCTPPS_cff")
629  process.load('L1Trigger.L1TGlobal.simGtExtFakeProd_cfi')
630  task = getPatAlgosToolsTask(process)
631  from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016
632  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
633  (ctpps_2016 & ~run2_miniAOD_UL).toModify(task, func=lambda t: t.add(process.ctppsLocalTrackLiteProducer, process.ctppsProtons))
634  (ctpps_2016 & run2_miniAOD_UL).toModify(task, func=lambda t: t.add(process.recoCTPPSTask))
635  run2_miniAOD_UL.toModify(task, func=lambda t: t.add(process.simGtExtUnprefireable))
636 
638  miniAOD_customizeCommon(process)
639  miniAOD_customizeData(process)
640  return process
641 
643  miniAOD_customizeCommon(process)
644  miniAOD_customizeMC(process)
645  return process
646 
648  miniAOD_customizeCommon(process)
649  miniAOD_customizeMC(process)
650  from PhysicsTools.PatAlgos.slimming.metFilterPaths_cff import miniAOD_customizeMETFiltersFastSim
651  process = miniAOD_customizeMETFiltersFastSim(process)
652  from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
653  process = miniAOD_customizeIsolatedTracksFastSim(process)
654  process.patMuons.addTriggerMatching = False
655 
656  return process
def makeInputForPUPPIIsolationMuon(process)
def miniAOD_customizeAllData(process)
def miniAOD_customizeData(process)
def miniAOD_customizeCommon(process)
Definition: miniAOD_tools.py:7
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:29
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 makePuppies(process)
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:14
def switchOnVIDPhotonIdProducer(process, dataFormat, task=None)
Photons.