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 = cms.bool(True)
29  process.patMuons.computeMuonMVA = cms.bool(True)
30  process.patMuons.computeSoftMuonMVA = cms.bool(True)
31 
32  #
33  # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer
34  process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core
35  process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
36  process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
37  process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster
38  process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters
39  process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters
40  process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters
41  process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters
42  process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer
43  process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
44  process.patElectrons.usePfCandidateMultiMap = True
45  process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap")
46  process.patElectrons.electronIDSources = cms.PSet()
47  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
48  run2_miniAOD_80XLegacy.toModify(process.patElectrons,
49  addPFClusterIso = cms.bool(True),
50  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso"),
51  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso"))
52  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
53  run2_miniAOD_94XFall17.toModify(process.patElectrons,
54  addPFClusterIso = cms.bool(True),
55  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso"),
56  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso"))
57 
58  #add puppi isolation in miniAOD
59  process.patElectrons.addPuppiIsolation = cms.bool(True)
60  process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001")
61  process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000")
62  process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008")
63  process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001")
64  process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000")
65  process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008")
66 
67  process.patElectrons.computeMiniIso = cms.bool(True)
68 
69  process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
70  process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
71  process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
72  process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
73  process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
74  #
75  process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster
76  process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster
77  process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters
78  process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters
79  process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer
80 
81  #add puppi isolation in miniAOD
82  process.patPhotons.addPuppiIsolation = cms.bool(True)
83  process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-")
84  process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-")
85  process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-")
86 
87  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
88  run2_miniAOD_80XLegacy.toModify(process.patPhotons,
89  addPFClusterIso = cms.bool(True),
90  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso"),
91  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso"))
92  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
93  run2_miniAOD_94XFall17.toModify(process.patPhotons,
94  addPFClusterIso = cms.bool(True),
95  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso"),
96  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso"))
97  #the 80X legacy customsations are done in ootPhotonProducer for OOT photons
98  run2_miniAOD_94XFall17.toModify(process.patOOTPhotons,
99  addPFClusterIso = cms.bool(True),
100  ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "ootPhoEcalPFClusIso"),
101  hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "ootPhoHcalPFClusIso"))
102 
103 
104  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
105  process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
106 
107  process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
108  process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
109  process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
110  process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
111  process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
112  #
113  process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons")
114  process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
115  #
116  process.selectedPatJets.cut = cms.string("pt > 10")
117  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
118 
119  from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
120  phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )")
121 
122  process.selectedPatElectrons.cut = cms.string("")
123  process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5")
124  process.selectedPatPhotons.cut = cms.string("")
125 
126  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
127 
128  from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
129  applySubstructure( process )
130 
131 
132  #
133  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
134  switchOnTriggerStandAlone( process, outputModule = '' )
135  process.patTrigger.packTriggerPathNames = cms.bool(True)
136  #
137  # apply type I + other PFMEt corrections to pat::MET object
138  # and estimate systematic uncertainties on MET
139 
140  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
141  runMetCorAndUncForMiniAODProduction(process, metType="PF",
142  jetCollUnskimmed="patJets")
143 
144  #caloMET computation
145  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
146  addMETCollection(process,
147  labelName = "patCaloMet",
148  metSource = "caloMetM"
149  )
150 
151  #noHF pfMET =========
152 
153  task = getPatAlgosToolsTask(process)
154 
155  process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
156  src=cms.InputTag("particleFlow"),
157  cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
158  )
159  task.add(process.noHFCands)
160 
162  pfCandColl=cms.InputTag("noHFCands"),
163  recoMetFromPFCs=True, #needed for HF removal
164  jetSelection="pt>15 && abs(eta)<3.",
165  postfix="NoHF"
166  )
167 
168  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
169  task.add(process.slimmedMETs)
170  addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task)
171  process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF")
172  process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF")
173  process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF")
174  process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF")
175  process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF")
176  process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF")
177  process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF")
178  process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF")
179  process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF")
180  process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF")
181  del process.slimmedMETsNoHF.caloMET
182  # ================== NoHF pfMET
183 
184  # ================== CHSMET
185  process.CHSCands = cms.EDFilter("CandPtrSelector",
186  src=cms.InputTag("packedPFCandidates"),
187  cut=cms.string("fromPV(0) > 0")
188  )
189  task.add(process.CHSCands)
190 
191  process.pfMetCHS = cms.EDProducer("PFMETProducer",
192  src = cms.InputTag("CHSCands"),
193  alias = cms.string('pfMet'),
194  globalThreshold = cms.double(0.0),
195  calculateSignificance = cms.bool(False),
196  )
197  task.add(process.pfMetCHS)
198 
199  addMETCollection(process,
200  labelName = "patCHSMet",
201  metSource = "pfMetCHS"
202  )
203 
204  process.patCHSMet.computeMETSignificance = cms.bool(False)
205 
206  # ================== CHSMET
207 
208  # ================== TrkMET
209  process.TrkCands = cms.EDFilter("CandPtrSelector",
210  src=cms.InputTag("packedPFCandidates"),
211  cut=cms.string("charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0")
212  )
213  task.add(process.TrkCands)
214 
215  process.pfMetTrk = cms.EDProducer("PFMETProducer",
216  src = cms.InputTag("TrkCands"),
217  alias = cms.string('pfMet'),
218  globalThreshold = cms.double(0.0),
219  calculateSignificance = cms.bool(False),
220  )
221 
222  task.add(process.pfMetTrk)
223 
224  addMETCollection(process,
225  labelName = "patTrkMet",
226  metSource = "pfMetTrk"
227  )
228 
229  process.patTrkMet.computeMETSignificance = cms.bool(False)
230 
231  # ================== TrkMET
232 
233 
234  ## PU JetID
235  process.load("RecoJets.JetProducers.PileupJetID_cfi")
236  task.add(process.pileUpJetIDTask)
237 
238  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
239  process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ]
240 
241  ## Quark Gluon Likelihood
242  process.load('RecoJets.JetProducers.QGTagger_cfi')
243  task.add(process.QGTaggerTask)
244 
245  process.patJets.userData.userFloats.src += [ cms.InputTag('QGTagger:qgLikelihood'), ]
246 
247  ## DeepCSV meta discriminators (simple arithmethic on output probabilities)
248  process.load('RecoBTag.Combined.deepFlavour_cff')
249  task.add(process.pfDeepCSVDiscriminatorsJetTags)
250  process.patJets.discriminatorSources.extend([
251  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:BvsAll' ),
252  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsB' ),
253  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsL' ),
254  ])
255 
256  ## CaloJets
257  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
258  src = process.patJets.jetSource,
259  matched = cms.InputTag("ak4CaloJets"),
260  distMax = cms.double(0.4),
261  values = cms.vstring('pt','emEnergyFraction'),
262  valueLabels = cms.vstring('pt','emEnergyFraction'),
263  lazyParser = cms.bool(True) )
264  task.add(process.caloJetMap)
265  process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ]
266 
267  #Muon object modifications
268  from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
270 
271  #EGM object modifications
272  from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
274  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
275  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
276  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
277 
278  #VID Electron IDs
279  process.patElectrons.addElectronID = cms.bool(True)
280  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
281  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
282  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
283  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
284  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
285  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
286  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
287  ]
288  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
289  process.egmGsfElectronIDs.physicsObjectSrc = \
290  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
291  process.electronMVAValueMapProducer.src = \
292  cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
293  process.electronRegressionValueMapProducer.src = \
294  cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
295  for idmod in electron_ids:
296  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
297 
298  #heepIDVarValueMaps only exists if HEEP V6.1 or HEEP 7.0 ID has already been loaded
299  if hasattr(process,'heepIDVarValueMaps'):
300  process.heepIDVarValueMaps.elesMiniAOD = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
301  #force HEEP to use miniAOD (otherwise it'll detect the AOD)
302  process.heepIDVarValueMaps.dataFormat = cms.int32(2)
303 
304  #add the HEEP trk isol to the slimmed electron, add it to the first FromFloatValMap modifier
305  for pset in process.slimmedElectrons.modifierConfig.modifications:
306  if pset.hasParameter("modifierName") and pset.modifierName == cms.string('EGExtraInfoModifierFromFloatValueMaps'):
307  pset.electron_config.heepTrkPtIso = cms.InputTag("heepIDVarValueMaps","eleTrkPtIso")
308  break
309 
310 
311  #VID Photon IDs
312  process.patPhotons.addPhotonID = cms.bool(True)
313  photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
314  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1_cff',
315  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
316  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
317  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff']
318  switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
319  process.egmPhotonIsolation.srcToIsolate = \
320  cms.InputTag("reducedEgamma","reducedGedPhotons")
321  for iPSet in process.egmPhotonIsolation.isolationConeDefinitions:
322  iPSet.particleBasedIsolation = cms.InputTag("reducedEgamma","reducedPhotonPfCandMap")
323 
324  process.egmPhotonIDs.physicsObjectSrc = \
325  cms.InputTag("reducedEgamma","reducedGedPhotons")
326  process.photonIDValueMapProducer.src = \
327  cms.InputTag("reducedEgamma","reducedGedPhotons")
328  process.photonRegressionValueMapProducer.src = \
329  cms.InputTag("reducedEgamma","reducedGedPhotons")
330  process.photonIDValueMapProducer.particleBasedIsolation = \
331  cms.InputTag("reducedEgamma","reducedPhotonPfCandMap")
332  process.photonMVAValueMapProducer.src = \
333  cms.InputTag('reducedEgamma','reducedGedPhotons')
334  for idmod in photon_ids:
335  setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)
336 
337  #add the cut base IDs bitmaps of which cuts passed
338  from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier
339  egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs"))
340 
341  #-- Adding boosted taus
342  from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
343  addBoostedTaus(process)
344  process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
345  process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
346  #-- Adding customization for 94X 2017 legacy reMniAOD
347  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
348  _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
349  _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask)
350  run2_miniAOD_94XFall17.toReplaceWith(
351  process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
352  )
353  #-- Adding customization for 80X 2016 legacy reMiniAOD
354  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
355  _makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
356  _makePatTausTaskWithTauReReco.add(process.PFTauTask)
357  run2_miniAOD_80XLegacy.toReplaceWith(
358  process.makePatTausTask, _makePatTausTaskWithTauReReco
359  )
360 
361  # Adding puppi jets
362  if not hasattr(process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call
363  process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
364  task.add(process.ak4PFJets)
365  task.add(process.ak4PFJetsPuppi)
366  process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
367  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
368  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
369  j2tParametersVX,
370  jets = cms.InputTag("ak4PFJetsPuppi")
371  )
372  task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
373  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
374  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
375  var = cms.string('Pt'),
376  exp = cms.double(1.0)
377  )
378  task.add(process.patJetPuppiCharge)
379 
380  noDeepFlavourDiscriminators = [x.value() for x in process.patJets.discriminatorSources if not "DeepFlavour" in x.value()]
381  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
382  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
383  pfCandidates = cms.InputTag("particleFlow"),
384  algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
385  )
386 
387  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
388 
389  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
390 
391  process.selectedPatJetsPuppi.cut = cms.string("pt > 15")
392 
393  process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi')
394 
395  # update slimmed jets to include DeepFlavour (keep same name)
396  from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
397  # make clone for DeepFlavour-less slimmed jets, so output name is preserved
398  process.slimmedJetsNoDeepFlavour = process.slimmedJets.clone()
399  task.add(process.slimmedJetsNoDeepFlavour)
400  updateJetCollection(
401  process,
402  jetSource = cms.InputTag('slimmedJetsNoDeepFlavour'),
403  # updateJetCollection defaults to MiniAOD inputs but
404  # here it is made explicit (as in training or MINIAOD redoing)
405  pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'),
406  pfCandidates = cms.InputTag('packedPFCandidates'),
407  svSource = cms.InputTag('slimmedSecondaryVertices'),
408  muSource = cms.InputTag('slimmedMuons'),
409  elSource = cms.InputTag('slimmedElectrons'),
410  jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
411  btagDiscriminators = [
412  'pfDeepFlavourJetTags:probb',
413  'pfDeepFlavourJetTags:probbb',
414  'pfDeepFlavourJetTags:problepb',
415  'pfDeepFlavourJetTags:probc',
416  'pfDeepFlavourJetTags:probuds',
417  'pfDeepFlavourJetTags:probg',
418  ],
419  postfix = 'SlimmedDeepFlavour',
420  printWarning = False
421  )
422 
423  # slimmedJets with DeepFlavour (remove DeepFlavour-less)
424  delattr(process, 'slimmedJets')
425  process.slimmedJets = process.selectedUpdatedPatJetsSlimmedDeepFlavour.clone()
426  # delete module not used anymore (slimmedJets substitutes)
427  delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour')
428 
429  task.add(process.slimmedJets)
430  task.add(process.slimmedJetsAK8)
431 
432  addToProcessAndTask('slimmedJetsPuppiNoMultiplicities', process.slimmedJetsNoDeepFlavour.clone(), process, task)
433  process.slimmedJetsPuppiNoMultiplicities.src = cms.InputTag("selectedPatJetsPuppi")
434  process.slimmedJetsPuppiNoMultiplicities.packedPFCandidates = cms.InputTag("packedPFCandidates")
435 
436  from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer
437  process.patPuppiJetSpecificProducer = patPuppiJetSpecificProducer.clone(
438  src=cms.InputTag("slimmedJetsPuppiNoMultiplicities"),
439  )
440  task.add(process.patPuppiJetSpecificProducer)
441  updateJetCollection(
442  process,
443  labelName = 'PuppiJetSpecific',
444  jetSource = cms.InputTag('slimmedJetsPuppiNoMultiplicities'),
445  )
446  process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = ['patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ]
447  process.slimmedJetsPuppi = process.selectedUpdatedPatJetsPuppiJetSpecific.clone()
448  delattr(process, 'selectedUpdatedPatJetsPuppiJetSpecific')
449 
450  task.add(process.slimmedJetsPuppi)
451 
452  ## puppi met
453  from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies
454  makePuppies( process );
455 
456  runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
457  pfCandColl=cms.InputTag("puppiForMET"),
458  jetCollUnskimmed="slimmedJetsPuppi",
459  recoMetFromPFCs=True,
460  jetFlavor="AK4PFPuppi",
461  postfix="Puppi"
462  )
463 
464  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
465  task.add(process.slimmedMETs)
466  addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
467  process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
468  process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
469  process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
470  process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
471  process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
472  process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
473  process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
474  process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
475  process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
476  process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
477  del process.slimmedMETsPuppi.caloMET
478 
479  # add DetIdAssociatorRecords to EventSetup (for isolatedTracks)
480  process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
481 
482  # EGamma objects from HGCal are not yet in GED
483  # so add companion collections for Phase-II MiniAOD production
484  from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
485  process.load("RecoEgamma.EgammaTools.slimmedEgammaFromMultiCl_cff")
486  phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaFromMultiClTask))
487 
488 
489 def miniAOD_customizeMC(process):
490  task = getPatAlgosToolsTask(process)
491  #GenJetFlavourInfos
492  process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
493  task.add(process.selectedHadronsAndPartons)
494  task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
495 
496  process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
497  task.add(process.ak4GenJetFlavourInfos)
498 
499  process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
500  task.add(process.slimmedGenJetsFlavourInfos)
501 
502  #slimmed pileup information
503  process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
504  task.add(process.slimmedAddPileupInfo)
505 
506  process.muonMatch.matched = "prunedGenParticles"
507  process.electronMatch.matched = "prunedGenParticles"
508  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
509  process.photonMatch.matched = "prunedGenParticles"
510  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
511  process.ootPhotonMatch.matched = "prunedGenParticles"
512  process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
513  process.tauMatch.matched = "prunedGenParticles"
514  process.tauGenJets.GenParticles = "prunedGenParticles"
515  #Boosted taus
516  process.tauMatchBoosted.matched = "prunedGenParticles"
517  process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
518  process.patJetPartons.particles = "genParticles"
519  process.patJetPartonMatch.matched = "prunedGenParticles"
520  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
521  process.patJetGenJetMatch.matched = "slimmedGenJets"
522  process.patJetGenJetMatchAK8.matched = "slimmedGenJetsAK8"
523  process.patMuons.embedGenMatch = False
524  process.patElectrons.embedGenMatch = False
525  process.patPhotons.embedGenMatch = False
526  process.patOOTPhotons.embedGenMatch = False
527  process.patTaus.embedGenMatch = False
528  process.patTausBoosted.embedGenMatch = False
529  process.patJets.embedGenPartonMatch = False
530  #also jet flavour must be switched
531  process.patJetFlavourAssociation.rParam = 0.4
532 
534  from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
535  out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
536  out.splitLevel = cms.untracked.int32(0)
537  out.dropMetaData = cms.untracked.string('ALL')
538  out.fastCloning= cms.untracked.bool(False)
539  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
540  out.compressionAlgorithm = cms.untracked.string('LZMA')
541 
543  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
544  runOnData( process, outputModules = [] )
545  process.load("RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff")
546  task = getPatAlgosToolsTask(process)
547  task.add(process.ctppsLocalTrackLiteProducer)
548 
550  miniAOD_customizeCommon(process)
551  miniAOD_customizeData(process)
552  return process
553 
555  miniAOD_customizeCommon(process)
556  miniAOD_customizeMC(process)
557  return process
558 
560  miniAOD_customizeCommon(process)
561  miniAOD_customizeMC(process)
562  from PhysicsTools.PatAlgos.slimming.metFilterPaths_cff import miniAOD_customizeMETFiltersFastSim
563  process = miniAOD_customizeMETFiltersFastSim(process)
564  from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
565  process = miniAOD_customizeIsolatedTracksFastSim(process)
566  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:27
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 miniAOD_customizeAllMCFastSim(process)
def miniAOD_customizeIsolatedTracksFastSim(process)
switchOnTriggerStandAlone
Definition: trigTools.py:281
def makeVIDBitsModifier(process, eleVIDModuleName, phoVIDModuleName)
def miniAOD_customizeOutput(out)
def miniAOD_customizeMC(process)
def getPatAlgosToolsTask(process)
Definition: helpers.py:12
def switchOnVIDPhotonIdProducer(process, dataFormat, task=None)
Photons.