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  #
145  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
146  switchOnTriggerStandAlone( process, outputModule = '' )
147  process.patTrigger.packTriggerPathNames = cms.bool(True)
148  #
149  # apply type I + other PFMEt corrections to pat::MET object
150  # and estimate systematic uncertainties on MET
151 
152  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
153  runMetCorAndUncForMiniAODProduction(process, metType="PF",
154  jetCollUnskimmed="patJets")
155 
156  #caloMET computation
157  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
158  addMETCollection(process,
159  labelName = "patCaloMet",
160  metSource = "caloMetM"
161  )
162 
163  #noHF pfMET =========
164 
165  task = getPatAlgosToolsTask(process)
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 
183  addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task)
184  process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF")
185  process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF")
186  process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF")
187  process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF")
188  process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF")
189  process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF")
190  process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF")
191  process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF")
192  process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF")
193  process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF")
194  del process.slimmedMETsNoHF.caloMET
195  # ================== NoHF pfMET
196 
197  # ================== CHSMET
198  process.CHSCands = cms.EDFilter("CandPtrSelector",
199  src=cms.InputTag("packedPFCandidates"),
200  cut=cms.string("fromPV(0) > 0")
201  )
202  task.add(process.CHSCands)
203 
204  process.pfMetCHS = cms.EDProducer("PFMETProducer",
205  src = cms.InputTag("CHSCands"),
206  alias = cms.string('pfMet'),
207  globalThreshold = cms.double(0.0),
208  calculateSignificance = cms.bool(False),
209  )
210  task.add(process.pfMetCHS)
211 
212  addMETCollection(process,
213  labelName = "patCHSMet",
214  metSource = "pfMetCHS"
215  )
216 
217  process.patCHSMet.computeMETSignificance = cms.bool(False)
218 
219  # ================== CHSMET
220 
221  # ================== TrkMET
222  process.TrkCands = cms.EDFilter("CandPtrSelector",
223  src=cms.InputTag("packedPFCandidates"),
224  cut=cms.string("charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0")
225  )
226  task.add(process.TrkCands)
227 
228  process.pfMetTrk = cms.EDProducer("PFMETProducer",
229  src = cms.InputTag("TrkCands"),
230  alias = cms.string('pfMet'),
231  globalThreshold = cms.double(0.0),
232  calculateSignificance = cms.bool(False),
233  )
234 
235  task.add(process.pfMetTrk)
236 
237  addMETCollection(process,
238  labelName = "patTrkMet",
239  metSource = "pfMetTrk"
240  )
241 
242  process.patTrkMet.computeMETSignificance = cms.bool(False)
243 
244  # ================== TrkMET
245 
246 
247  ## PU JetID
248  process.load("RecoJets.JetProducers.PileupJetID_cfi")
249  task.add(process.pileUpJetIDTask)
250 
251  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
252  process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ]
253 
254  ## Quark Gluon Likelihood
255  process.load('RecoJets.JetProducers.QGTagger_cfi')
256  task.add(process.QGTaggerTask)
257 
258  process.patJets.userData.userFloats.src += [ 'QGTagger:qgLikelihood', ]
259 
260  #HF jet shower shape
261  process.load('RecoJets.JetProducers.hfJetShowerShape_cfi')
262  task.add(process.hfJetShowerShape)
263 
264  run2_miniAOD_UL.toModify(process.patJets.userData.userFloats,
265  src = process.patJets.userData.userFloats.src + ['hfJetShowerShape:sigmaEtaEta', 'hfJetShowerShape:sigmaPhiPhi'])
266  run2_miniAOD_UL.toModify(process.patJets.userData.userInts,
267  src = process.patJets.userData.userInts.src + ['hfJetShowerShape:centralEtaStripSize', 'hfJetShowerShape:adjacentEtaStripsSize'])
268 
269  ## DeepCSV meta discriminators (simple arithmethic on output probabilities)
270  process.load('RecoBTag.Combined.deepFlavour_cff')
271  task.add(process.pfDeepCSVDiscriminatorsJetTags)
272  process.patJets.discriminatorSources.extend([
273  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:BvsAll' ),
274  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsB' ),
275  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsL' ),
276  ])
277 
278  ## CaloJets
279  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
280  src = process.patJets.jetSource,
281  matched = cms.InputTag("ak4CaloJets"),
282  distMax = cms.double(0.4),
283  values = cms.vstring('pt','emEnergyFraction'),
284  valueLabels = cms.vstring('pt','emEnergyFraction'),
285  lazyParser = cms.bool(True) )
286  task.add(process.caloJetMap)
287  process.patJets.userData.userFloats.src += [ 'caloJetMap:pt', 'caloJetMap:emEnergyFraction' ]
288 
289  #Muon object modifications
290  from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
292 
293  #EGM object modifications
294  from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
296  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
297  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
298  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
299 
300  #VID Electron IDs
301  process.patElectrons.addElectronID = cms.bool(True)
302  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
303  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV71_cff',
304  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
305  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
306  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
307  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
308  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
309  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
310  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
311  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
312  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
313  ]
314  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
315  process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
316  process.electronMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
317 
318  # To use older DataFormats, the electronMVAValueMapProducer MUST take a updated electron collection
319  # such that the conversion variables are filled correctly.
320  process.load("RecoEgamma.EgammaTools.gedGsfElectronsTo106X_cff")
321  run2_miniAOD_80XLegacy.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom80XTo106XTask))
322  run2_miniAOD_80XLegacy.toModify(process.electronMVAValueMapProducer,
323  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
324  src = cms.InputTag("gedGsfElectronsFrom80XTo106X"))
325 
326  run2_miniAOD_94XFall17.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
327  run2_miniAOD_94XFall17.toModify(process.electronMVAValueMapProducer,
328  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
329  src = cms.InputTag("gedGsfElectronsFrom94XTo106X"))
330 
331  for idmod in electron_ids:
332  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
333 
334  #VID Photon IDs
335  process.patPhotons.addPhotonID = cms.bool(True)
336  photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
337  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
338  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
339  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
340  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
341  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff']
342  switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
343  process.egmPhotonIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedPhotons")
344  process.photonMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedPhotons')
345  for idmod in photon_ids:
346  setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)
347 
348  #add the cut base IDs bitmaps of which cuts passed
349  from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier
350  egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs"))
351 
352  #-- Adding boosted taus
353  from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
354  addBoostedTaus(process)
355  process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
356  process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
357  #-- Adding customization for 94X 2017 legacy reMiniAOD
358  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
359  _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
360  _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask,
361  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask,
362  process.hpsPFTauIsolationSums03Task,
363  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTTask)
364  run2_miniAOD_94XFall17.toReplaceWith(
365  process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
366  )
367  #-- Adding customization for UL reMiniAOD:
368  # running retrained anti-e MVA6 discriminants as setup in the HPS PFTau
369  # master configuration for this era.
370  _makePatTausTaskWithMVA6ElectronRejection = process.makePatTausTask.copy()
371  _makePatTausTaskWithMVA6ElectronRejection.add(
372  process.hpsPFTauDiscriminationByMVA6ElectronRejectionTask
373  )
374  run2_miniAOD_UL.toReplaceWith(
375  process.makePatTausTask, _makePatTausTaskWithMVA6ElectronRejection
376  )
377  #-- Adding DeepTauID
378  # deepTau v2
379  _updatedTauName = 'slimmedTausDeepIDsv2'
380  _noUpdatedTauName = 'slimmedTausNoDeepIDs'
381  import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
382  tauIdEmbedder = tauIdConfig.TauIDEmbedder(
383  process, cms, debug = False,
384  updatedTauName = _updatedTauName,
385  toKeep = ['deepTau2017v2']
386  )
387  tauIdEmbedder.runTauID()
388  addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(),process,task)
389  delattr(process, 'slimmedTaus')
390  process.deepTau2017v2.taus = _noUpdatedTauName
391  process.slimmedTaus = getattr(process, _updatedTauName).clone(
392  src = _noUpdatedTauName
393  )
394  process.deepTauIDTask = cms.Task(process.deepTau2017v2, process.slimmedTaus)
395  task.add(process.deepTauIDTask)
396 
397  # deepTau v2p1
398  _updatedTauNameNew = 'slimmedTausDeepIDsv2p1'
399  tauIdEmbedderNew = tauIdConfig.TauIDEmbedder(
400  process, cms, debug = False,
401  updatedTauName = _updatedTauNameNew,
402  toKeep = ['deepTau2017v2p1']
403  )
404  tauIdEmbedderNew.runTauID()
405  process.deepTau2017v2p1.taus = _noUpdatedTauName
406  deepTauIDTaskNew_ = cms.Task(process.deepTau2017v2p1,process.slimmedTaus)
407 
408  from Configuration.Eras.Modifier_run2_tau_ul_2016_cff import run2_tau_ul_2016
409  from Configuration.Eras.Modifier_run2_tau_ul_2018_cff import run2_tau_ul_2018
410  for era in [run2_miniAOD_UL,run2_tau_ul_2016,run2_tau_ul_2018]:
411  era.toReplaceWith(process.slimmedTaus,
412  getattr(process, _updatedTauNameNew).clone(src = _noUpdatedTauName))
413  era.toReplaceWith(process.deepTauIDTask,
414  deepTauIDTaskNew_)
415 
416  #-- Adding tauID against dead ECal towers to taus
417  # note: default (AOD) behoviour of the tauID modified (leading track
418  # extrapolation to ECAL enabled) in the HPS PFTau master
419  # configuration for this era.
420  _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy()
421  _makePatTausTaskWithDeadECalVeto.add(
422  process.hpsPFTauDiscriminationByDeadECALElectronRejection
423  )
424  run2_miniAOD_UL.toReplaceWith(
425  process.makePatTausTask, _makePatTausTaskWithDeadECalVeto
426  )
427  _withDeadEcalTauIDPs = cms.PSet(
428  process.patTaus.tauIDSources,
429  againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejection")
430  )
431  run2_miniAOD_UL.toModify(process.patTaus,
432  tauIDSources = _withDeadEcalTauIDPs)
433  #... and to boosted taus
434  _withDeadEcalTauIDBoostedPs = cms.PSet(
435  process.patTausBoosted.tauIDSources,
436  againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejectionBoosted")
437  )
438  run2_miniAOD_UL.toModify(process.patTausBoosted,
439  tauIDSources = _withDeadEcalTauIDBoostedPs)
440 
441  #-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions
442  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
443  from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
444  _makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
445  _makePatTausTaskWithTauReReco.add(process.PFTauTask)
446  (run2_miniAOD_80XLegacy | pp_on_AA_2018).toReplaceWith(
447  process.makePatTausTask, _makePatTausTaskWithTauReReco
448  )
449 
450  # Adding puppi jets
451  if not hasattr(process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call
452  process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
453  task.add(process.ak4PFJets)
454  task.add(process.ak4PFJetsPuppi)
455  process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
456  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
457  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
458  j2tParametersVX,
459  jets = cms.InputTag("ak4PFJetsPuppi")
460  )
461  task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
462  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
463  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
464  var = cms.string('Pt'),
465  exp = cms.double(1.0)
466  )
467  task.add(process.patJetPuppiCharge)
468 
469  noDeepFlavourDiscriminators = [x.value() for x in process.patJets.discriminatorSources if not "DeepFlavour" in x.value()]
470  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
471  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
472  pfCandidates = cms.InputTag("particleFlow"),
473  algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
474  )
475 
476  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
477 
478  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
479 
480  process.selectedPatJetsPuppi.cut = cms.string("pt > 15")
481 
482  from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging
483  applyDeepBtagging( process )
484 
485  addToProcessAndTask('slimmedJetsPuppiNoMultiplicities', process.slimmedJetsNoDeepFlavour.clone(), process, task)
486  process.slimmedJetsPuppiNoMultiplicities.src = cms.InputTag("selectedPatJetsPuppi")
487  process.slimmedJetsPuppiNoMultiplicities.packedPFCandidates = cms.InputTag("packedPFCandidates")
488 
489  from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer
490  from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
491  process.patPuppiJetSpecificProducer = patPuppiJetSpecificProducer.clone(
492  src=cms.InputTag("slimmedJetsPuppiNoMultiplicities"),
493  )
494  task.add(process.patPuppiJetSpecificProducer)
495  updateJetCollection(
496  process,
497  labelName = 'PuppiJetSpecific',
498  jetSource = cms.InputTag('slimmedJetsPuppiNoMultiplicities'),
499  )
500  process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = ['patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ]
501  process.slimmedJetsPuppi = process.selectedUpdatedPatJetsPuppiJetSpecific.clone()
502  delattr(process, 'selectedUpdatedPatJetsPuppiJetSpecific')
503 
504  task.add(process.slimmedJetsPuppi)
505 
506  ## puppi met
507  from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies
508  makePuppies( process );
509 
510  runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
511  pfCandColl=cms.InputTag("puppiForMET"),
512  jetCollUnskimmed="slimmedJetsPuppi",
513  recoMetFromPFCs=True,
514  jetFlavor="AK4PFPuppi",
515  postfix="Puppi"
516  )
517 
518  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
519  task.add(process.slimmedMETs)
520  addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
521  process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
522  process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
523  process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
524  process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
525  process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
526  process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
527  process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
528  process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
529  process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
530  process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
531  del process.slimmedMETsPuppi.caloMET
532 
533  process.load('RecoMET.METPUSubtraction.deepMETProducer_cfi')
534 
535  process.deepMETsResolutionTune = process.deepMETProducer.clone()
536  process.deepMETsResponseTune = process.deepMETProducer.clone()
537  process.deepMETsResponseTune.graph_path = 'RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb'
538 
539  from Configuration.Eras.Modifier_run2_jme_2016_cff import run2_jme_2016
540  run2_jme_2016.toModify(
541  process.deepMETsResponseTune,
542  graph_path="RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb"
543  )
544 
545  run2_miniAOD_UL.toModify(task, func=lambda t: t.add(process.deepMETsResolutionTune, process.deepMETsResponseTune))
546  run2_miniAOD_UL.toModify(process.slimmedMETs, addDeepMETs = True)
547 
548  # add DetIdAssociatorRecords to EventSetup (for isolatedTracks)
549  process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
550 
551  # EGamma objects from HGCal are not yet in GED
552  # so add companion collections for Phase-II MiniAOD production
553  from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
554  process.load("RecoEgamma.EgammaTools.slimmedEgammaFromMultiCl_cff")
555  phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaFromMultiClTask))
556 
557  # L1 pre-firing weights for 2016 and 2017
558  from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring
559  from Configuration.Eras.Modifier_stage1L1Trigger_cff import stage1L1Trigger
560  from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
561  process.load("PhysicsTools.PatUtils.L1ECALPrefiringWeightProducer_cff")
562  stage1L1Trigger.toModify(process.prefiringweight, DataEra = "2016BtoH")
563  stage2L1Trigger_2017.toModify(process.prefiringweight, DataEra = "2017BtoF")
564  run2_L1prefiring.toModify(task, func=lambda t: t.add(process.prefiringweight))
565 
566 def miniAOD_customizeMC(process):
567  task = getPatAlgosToolsTask(process)
568  #GenJetFlavourInfos
569  process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
570  task.add(process.selectedHadronsAndPartons)
571  task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
572 
573  process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
574  task.add(process.ak4GenJetFlavourInfos)
575 
576  process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
577  task.add(process.slimmedGenJetsFlavourInfos)
578 
579  #slimmed pileup information
580  process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
581  task.add(process.slimmedAddPileupInfo)
582 
583  process.muonMatch.matched = "prunedGenParticles"
584  process.electronMatch.matched = "prunedGenParticles"
585  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
586  process.photonMatch.matched = "prunedGenParticles"
587  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
588  process.ootPhotonMatch.matched = "prunedGenParticles"
589  process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
590  process.tauMatch.matched = "prunedGenParticles"
591  process.tauGenJets.GenParticles = "prunedGenParticles"
592  #Boosted taus
593  process.tauMatchBoosted.matched = "prunedGenParticles"
594  process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
595  process.patJetPartons.particles = "genParticles"
596  process.patJetPartonMatch.matched = "prunedGenParticles"
597  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
598  process.patJetGenJetMatch.matched = "slimmedGenJets"
599  process.patJetGenJetMatchAK8.matched = "slimmedGenJetsAK8"
600  process.patMuons.embedGenMatch = False
601  process.patElectrons.embedGenMatch = False
602  process.patPhotons.embedGenMatch = False
603  process.patOOTPhotons.embedGenMatch = False
604  process.patTaus.embedGenMatch = False
605  process.patTausBoosted.embedGenMatch = False
606  process.patJets.embedGenPartonMatch = False
607  #also jet flavour must be switched
608  process.patJetFlavourAssociation.rParam = 0.4
609 
611  from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
612  out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
613  out.splitLevel = cms.untracked.int32(0)
614  out.dropMetaData = cms.untracked.string('ALL')
615  out.fastCloning= cms.untracked.bool(False)
616  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
617  out.compressionAlgorithm = cms.untracked.string('LZMA')
618 
620  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
621  runOnData( process, outputModules = [] )
622  process.load("RecoCTPPS.Configuration.recoCTPPS_cff")
623  task = getPatAlgosToolsTask(process)
624  from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016
625  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
626  (ctpps_2016 & ~run2_miniAOD_UL).toModify(task, func=lambda t: t.add(process.ctppsLocalTrackLiteProducer, process.ctppsProtons))
627  (ctpps_2016 & run2_miniAOD_UL).toModify(task, func=lambda t: t.add(process.recoCTPPSTask))
628 
630  miniAOD_customizeCommon(process)
631  miniAOD_customizeData(process)
632  return process
633 
635  miniAOD_customizeCommon(process)
636  miniAOD_customizeMC(process)
637  return process
638 
640  miniAOD_customizeCommon(process)
641  miniAOD_customizeMC(process)
642  from PhysicsTools.PatAlgos.slimming.metFilterPaths_cff import miniAOD_customizeMETFiltersFastSim
643  process = miniAOD_customizeMETFiltersFastSim(process)
644  from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
645  process = miniAOD_customizeIsolatedTracksFastSim(process)
646  process.patMuons.addTriggerMatching = False
647 
648  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.