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 
31  #
32  # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer
33  process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core
34  process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
35  process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
36  process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster
37  process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters
38  process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters
39  process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters
40  process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters
41  process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer
42  process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
43  process.patElectrons.usePfCandidateMultiMap = True
44  process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap")
45  process.patElectrons.electronIDSources = cms.PSet(
46  # configure many IDs as InputTag <someName> = <someTag> you
47  # can comment out those you don't want to save some disk space
48  eidRobustLoose = cms.InputTag("reducedEgamma","eidRobustLoose"),
49  eidRobustTight = cms.InputTag("reducedEgamma","eidRobustTight"),
50  eidLoose = cms.InputTag("reducedEgamma","eidLoose"),
51  eidTight = cms.InputTag("reducedEgamma","eidTight"),
52  eidRobustHighEnergy = cms.InputTag("reducedEgamma","eidRobustHighEnergy"),
53  )
54  process.patElectrons.addPFClusterIso = cms.bool(True)
55  #add puppi isolation in miniAOD
56  process.patElectrons.addPuppiIsolation = cms.bool(True)
57  process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001")
58  process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000")
59  process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008")
60  process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001")
61  process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000")
62  process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008")
63 
64  process.patElectrons.computeMiniIso = cms.bool(True)
65 
66  process.patElectrons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso")
67  process.patElectrons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso")
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  process.patPhotons.addPFClusterIso = cms.bool(True)
81 
82  #add puppi isolation in miniAOD
83  process.patPhotons.addPuppiIsolation = cms.bool(True)
84  process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-")
85  process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-")
86  process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-")
87 
88  process.patPhotons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso")
89  process.patPhotons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso")
90  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
91  process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
92  process.patPhotons.photonIDSources = cms.PSet(
93  PhotonCutBasedIDLoose = cms.InputTag('reducedEgamma',
94  'PhotonCutBasedIDLoose'),
95  PhotonCutBasedIDTight = cms.InputTag('reducedEgamma',
96  'PhotonCutBasedIDTight')
97  )
98 
99  process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
100  process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
101  process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
102  process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
103  process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
104  #
105  process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons")
106  process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
107  #
108  process.selectedPatJets.cut = cms.string("pt > 10")
109  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
110 
111  from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
112  phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )")
113 
114  process.selectedPatElectrons.cut = cms.string("")
115  process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5")
116  process.selectedPatPhotons.cut = cms.string("")
117 
118  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
119 
120  from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
121  applySubstructure( process )
122 
123 
124  #
125  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
126  switchOnTriggerStandAlone( process, outputModule = '' )
127  process.patTrigger.packTriggerPathNames = cms.bool(True)
128  #
129  # apply type I + other PFMEt corrections to pat::MET object
130  # and estimate systematic uncertainties on MET
131 
132  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
133  runMetCorAndUncForMiniAODProduction(process, metType="PF",
134  jetCollUnskimmed="patJets")
135 
136  #caloMET computation
137  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
138  addMETCollection(process,
139  labelName = "patCaloMet",
140  metSource = "caloMetM"
141  )
142 
143  #noHF pfMET =========
144 
145  task = getPatAlgosToolsTask(process)
146 
147  process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
148  src=cms.InputTag("particleFlow"),
149  cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
150  )
151  task.add(process.noHFCands)
152 
154  pfCandColl=cms.InputTag("noHFCands"),
155  recoMetFromPFCs=True, #needed for HF removal
156  jetSelection="pt>15 && abs(eta)<3.",
157  postfix="NoHF"
158  )
159 
160  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
161  task.add(process.slimmedMETs)
162  addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task)
163  process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF")
164  process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF")
165  process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF")
166  process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF")
167  process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF")
168  process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF")
169  process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF")
170  process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF")
171  process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF")
172  process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF")
173  del process.slimmedMETsNoHF.caloMET
174  # ================== NoHF pfMET
175 
176  # ================== CHSMET
177  process.CHSCands = cms.EDFilter("CandPtrSelector",
178  src=cms.InputTag("packedPFCandidates"),
179  cut=cms.string("fromPV(0) > 0")
180  )
181  task.add(process.CHSCands)
182 
183  process.pfMetCHS = cms.EDProducer("PFMETProducer",
184  src = cms.InputTag("CHSCands"),
185  alias = cms.string('pfMet'),
186  globalThreshold = cms.double(0.0),
187  calculateSignificance = cms.bool(False),
188  )
189  task.add(process.pfMetCHS)
190 
191  addMETCollection(process,
192  labelName = "patCHSMet",
193  metSource = "pfMetCHS"
194  )
195 
196  process.patCHSMet.computeMETSignificance = cms.bool(False)
197 
198  # ================== CHSMET
199 
200  # ================== TrkMET
201  process.TrkCands = cms.EDFilter("CandPtrSelector",
202  src=cms.InputTag("packedPFCandidates"),
203  cut=cms.string("charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0")
204  )
205  task.add(process.TrkCands)
206 
207  process.pfMetTrk = cms.EDProducer("PFMETProducer",
208  src = cms.InputTag("TrkCands"),
209  alias = cms.string('pfMet'),
210  globalThreshold = cms.double(0.0),
211  calculateSignificance = cms.bool(False),
212  )
213 
214  task.add(process.pfMetTrk)
215 
216  addMETCollection(process,
217  labelName = "patTrkMet",
218  metSource = "pfMetTrk"
219  )
220 
221  process.patTrkMet.computeMETSignificance = cms.bool(False)
222 
223  # ================== TrkMET
224 
225 
226  ## PU JetID
227  process.load("RecoJets.JetProducers.PileupJetID_cfi")
228  task.add(process.pileUpJetIDTask)
229 
230  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
231  process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ]
232 
233  ## Quark Gluon Likelihood
234  process.load('RecoJets.JetProducers.QGTagger_cfi')
235  task.add(process.QGTaggerTask)
236 
237  process.patJets.userData.userFloats.src += [ cms.InputTag('QGTagger:qgLikelihood'), ]
238 
239  ## DeepCSV meta discriminators (simple arithmethic on output probabilities)
240  process.load('RecoBTag.Combined.deepFlavour_cff')
241  task.add(process.pfDeepCSVDiscriminatorsJetTags)
242  process.patJets.discriminatorSources.extend([
243  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:BvsAll' ),
244  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsB' ),
245  cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsL' ),
246  ])
247 
248  ## CaloJets
249  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
250  src = process.patJets.jetSource,
251  matched = cms.InputTag("ak4CaloJets"),
252  distMax = cms.double(0.4),
253  values = cms.vstring('pt','emEnergyFraction'),
254  valueLabels = cms.vstring('pt','emEnergyFraction'),
255  lazyParser = cms.bool(True) )
256  task.add(process.caloJetMap)
257  process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ]
258 
259  #Muon object modifications
260  from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
262 
263  #EGM object modifications
264  from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
266  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
267  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
268  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
269 
270  #VID Electron IDs
271  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_PHYS14_PU20bx25_V2_cff',
272  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff',
273  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_50ns_V2_cff',
274  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV60_cff',
275  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_nonTrig_V1_cff',
276  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_Trig_V1_cff',
277  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_50ns_Trig_V1_cff',
278  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
279  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
280  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
281  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
282  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
283  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
284  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
285  ]
286  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
287  process.egmGsfElectronIDs.physicsObjectSrc = \
288  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
289  process.electronMVAValueMapProducer.src = \
290  cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
291  process.electronRegressionValueMapProducer.src = \
292  cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
293  for idmod in electron_ids:
294  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
295 
296  #heepIDVarValueMaps only exists if HEEP V6.1 or HEEP 7.0 ID has already been loaded
297  if hasattr(process,'heepIDVarValueMaps'):
298  process.heepIDVarValueMaps.elesMiniAOD = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
299  #force HEEP to use miniAOD (otherwise it'll detect the AOD)
300  process.heepIDVarValueMaps.dataFormat = cms.int32(2)
301 
302  #add the HEEP trk isol to the slimmed electron, add it to the first FromFloatValMap modifier
303  for pset in process.slimmedElectrons.modifierConfig.modifications:
304  if pset.hasParameter("modifierName") and pset.modifierName == cms.string('EGExtraInfoModifierFromFloatValueMaps'):
305  pset.electron_config.heepTrkPtIso = cms.InputTag("heepIDVarValueMaps","eleTrkPtIso")
306  break
307 
308  #VID Photon IDs
309  photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff',
310  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_50ns_V1_cff',
311  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_25ns_nonTrig_V2p1_cff',
312  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_50ns_nonTrig_V2p1_cff',
313  '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 custimization 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  # Adding puppi jets
361  if not hasattr(process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call
362  process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
363  task.add(process.ak4PFJets)
364  task.add(process.ak4PFJetsPuppi)
365  process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
366  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
367  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
368  j2tParametersVX,
369  jets = cms.InputTag("ak4PFJetsPuppi")
370  )
371  task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
372  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
373  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
374  var = cms.string('Pt'),
375  exp = cms.double(1.0)
376  )
377  task.add(process.patJetPuppiCharge)
378 
379  noDeepFlavourDiscriminators = [x.value() for x in process.patJets.discriminatorSources if not "DeepFlavour" in x.value()]
380  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
381  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
382  pfCandidates = cms.InputTag('puppi'), # using Puppi candidates as input for b tagging of Puppi jets
383  algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
384  )
385 
386  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
387 
388  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
389 
390  process.selectedPatJetsPuppi.cut = cms.string("pt > 15")
391 
392  from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging
393  applyDeepBtagging( process )
394 
395  addToProcessAndTask('slimmedJetsPuppiNoMultiplicities', process.slimmedJetsNoDeepFlavour.clone(), process, task)
396  process.slimmedJetsPuppiNoMultiplicities.src = cms.InputTag("selectedPatJetsPuppi")
397  process.slimmedJetsPuppiNoMultiplicities.packedPFCandidates = cms.InputTag("packedPFCandidates")
398 
399  from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer
400  from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
401  process.patPuppiJetSpecificProducer = patPuppiJetSpecificProducer.clone(
402  src=cms.InputTag("slimmedJetsPuppiNoMultiplicities"),
403  )
404  task.add(process.patPuppiJetSpecificProducer)
405  updateJetCollection(
406  process,
407  labelName = 'PuppiJetSpecific',
408  jetSource = cms.InputTag('slimmedJetsPuppiNoMultiplicities'),
409  )
410  process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = ['patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ]
411  process.slimmedJetsPuppi = process.selectedUpdatedPatJetsPuppiJetSpecific.clone()
412  delattr(process, 'selectedUpdatedPatJetsPuppiJetSpecific')
413 
414  task.add(process.slimmedJetsPuppi)
415 
416  ## puppi met
417  from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies
418  makePuppies( process );
419 
420  runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
421  pfCandColl=cms.InputTag("puppiForMET"),
422  jetCollUnskimmed="slimmedJetsPuppi",
423  recoMetFromPFCs=True,
424  jetFlavor="AK4PFPuppi",
425  postfix="Puppi"
426  )
427 
428  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
429  task.add(process.slimmedMETs)
430  addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
431  process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
432  process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
433  process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
434  process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
435  process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
436  process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
437  process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
438  process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
439  process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
440  process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
441  del process.slimmedMETsPuppi.caloMET
442 
443  # add DetIdAssociatorRecords to EventSetup (for isolatedTracks)
444  process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
445 
446 
447 def miniAOD_customizeMC(process):
448  task = getPatAlgosToolsTask(process)
449  #GenJetFlavourInfos
450  process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
451  task.add(process.selectedHadronsAndPartons)
452  task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
453 
454  process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
455  task.add(process.ak4GenJetFlavourInfos)
456 
457  process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
458  task.add(process.slimmedGenJetsFlavourInfos)
459 
460  #slimmed pileup information
461  process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
462  task.add(process.slimmedAddPileupInfo)
463 
464  process.muonMatch.matched = "prunedGenParticles"
465  process.electronMatch.matched = "prunedGenParticles"
466  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
467  process.photonMatch.matched = "prunedGenParticles"
468  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
469  process.ootPhotonMatch.matched = "prunedGenParticles"
470  process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
471  process.tauMatch.matched = "prunedGenParticles"
472  process.tauGenJets.GenParticles = "prunedGenParticles"
473  #Boosted taus
474  process.tauMatchBoosted.matched = "prunedGenParticles"
475  process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
476  process.patJetPartons.particles = "genParticles"
477  process.patJetPartonMatch.matched = "prunedGenParticles"
478  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
479  process.patJetGenJetMatch.matched = "slimmedGenJets"
480  process.patJetGenJetMatchAK8.matched = "slimmedGenJetsAK8"
481  process.patMuons.embedGenMatch = False
482  process.patElectrons.embedGenMatch = False
483  process.patPhotons.embedGenMatch = False
484  process.patOOTPhotons.embedGenMatch = False
485  process.patTaus.embedGenMatch = False
486  process.patTausBoosted.embedGenMatch = False
487  process.patJets.embedGenPartonMatch = False
488  #also jet flavour must be switched
489  process.patJetFlavourAssociation.rParam = 0.4
490 
492  from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
493  out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
494  out.splitLevel = cms.untracked.int32(0)
495  out.dropMetaData = cms.untracked.string('ALL')
496  out.fastCloning= cms.untracked.bool(False)
497  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
498  out.compressionAlgorithm = cms.untracked.string('LZMA')
499 
501  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
502  runOnData( process, outputModules = [] )
503  process.load("RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff")
504  task = getPatAlgosToolsTask(process)
505  task.add(process.ctppsLocalTrackLiteProducer)
506 
508  miniAOD_customizeCommon(process)
509  miniAOD_customizeData(process)
510  return process
511 
513  miniAOD_customizeCommon(process)
514  miniAOD_customizeMC(process)
515  return process
516 
518  miniAOD_customizeCommon(process)
519  miniAOD_customizeMC(process)
520  from PhysicsTools.PatAlgos.slimming.metFilterPaths_cff import miniAOD_customizeMETFiltersFastSim
521  process = miniAOD_customizeMETFiltersFastSim(process)
522  from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
523  process = miniAOD_customizeIsolatedTracksFastSim(process)
524  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 applyDeepBtagging(process, postfix="")
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.