CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
miniAOD_tools Namespace Reference

Functions

def miniAOD_customizeAllData
 
def miniAOD_customizeAllMC
 
def miniAOD_customizeAllMCFastSim
 
def miniAOD_customizeCommon
 
def miniAOD_customizeData
 
def miniAOD_customizeMC
 
def miniAOD_customizeOutput
 

Function Documentation

def miniAOD_tools.miniAOD_customizeAllData (   process)

Definition at line 628 of file miniAOD_tools.py.

References miniAOD_customizeCommon(), and miniAOD_customizeData().

629 def miniAOD_customizeAllData(process):
630  miniAOD_customizeCommon(process)
631  miniAOD_customizeData(process)
632  return process
def miniAOD_customizeCommon
def miniAOD_customizeAllData
def miniAOD_customizeData
def miniAOD_tools.miniAOD_customizeAllMC (   process)

Definition at line 633 of file miniAOD_tools.py.

References miniAOD_customizeCommon(), and miniAOD_customizeMC().

634 def miniAOD_customizeAllMC(process):
635  miniAOD_customizeCommon(process)
636  miniAOD_customizeMC(process)
637  return process
def miniAOD_customizeAllMC
def miniAOD_customizeCommon
def miniAOD_tools.miniAOD_customizeAllMCFastSim (   process)

Definition at line 638 of file miniAOD_tools.py.

References miniAOD_customizeCommon(), isolatedTracks_cfi.miniAOD_customizeIsolatedTracksFastSim(), miniAOD_customizeMC(), and metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim().

639 def miniAOD_customizeAllMCFastSim(process):
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  # Disable pixelClusterTagInfos in FastSim (no siPixelCluster available)
648  from Configuration.Eras.Modifier_fastSim_cff import fastSim
649  fastSim.toModify(process.patJets, addTagInfos = cms.bool(False) )
650  fastSim.toModify(process.slimmedJetsNoDeepFlavour, dropTagInfos = cms.string('1') )
651  fastSim.toModify(process.updatedPatJetsSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
652  fastSim.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
653 
654  return process
def miniAOD_customizeAllMCFastSim
def miniAOD_customizeCommon
def miniAOD_customizeIsolatedTracksFastSim
def miniAOD_tools.miniAOD_customizeCommon (   process)

Definition at line 11 of file miniAOD_tools.py.

References boostedHPSPFTaus_cfi.addBoostedTaus(), helpers.addToProcessAndTask(), applyDeepBtagging_cff.applyDeepBtagging(), applySubstructure_cff.applySubstructure(), clone(), helpers.getPatAlgosToolsTask(), egmIsolationsPUPPI_cfi.makeInputForPUPPIIsolationEgm(), muonIsolationsPUPPI_cfi.makeInputForPUPPIIsolationMuon(), egammaObjectModifications_tools.makeVIDBitsModifier(), runMETCorrectionsAndUncertainties.runMetCorAndUncForMiniAODProduction(), vid_id_tools.setupAllVIDIdsInModule(), str, trigTools.switchOnTriggerStandAlone, vid_id_tools.switchOnVIDElectronIdProducer(), and vid_id_tools.switchOnVIDPhotonIdProducer().

Referenced by miniAOD_customizeAllData(), miniAOD_customizeAllMC(), and miniAOD_customizeAllMCFastSim().

11 
12 def miniAOD_customizeCommon(process):
13  process.patMuons.isoDeposits = cms.PSet()
14  process.patElectrons.isoDeposits = cms.PSet()
15  process.patTaus.isoDeposits = cms.PSet()
16  process.patPhotons.isoDeposits = cms.PSet()
17  #
18  process.patMuons.embedTrack = True # used for IDs
19  process.patMuons.embedCombinedMuon = True # used for IDs
20  process.patMuons.embedMuonBestTrack = True # used for IDs
21  process.patMuons.embedStandAloneMuon = True # maybe?
22  process.patMuons.embedPickyMuon = False # no, use best track
23  process.patMuons.embedTpfmsMuon = False # no, use best track
24  process.patMuons.embedDytMuon = False # no, use best track
25  process.patMuons.addPuppiIsolation = cms.bool(True)
26  process.patMuons.puppiIsolationChargedHadrons = cms.InputTag("muonPUPPIIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
27  process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag("muonPUPPIIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
28  process.patMuons.puppiIsolationPhotons = cms.InputTag("muonPUPPIIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
29  process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
30  process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
31  process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
32 
33  process.patMuons.computeMiniIso = True
34  process.patMuons.computeMuonMVA = True
35  process.patMuons.computeSoftMuonMVA = True
36 
37  process.patMuons.addTriggerMatching = True
38  from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016
39  from Configuration.Eras.Modifier_run2_muon_2017_cff import run2_muon_2017
40  from Configuration.Eras.Modifier_run2_muon_2018_cff import run2_muon_2018
41  run2_muon_2016.toModify( process.patMuons, effectiveAreaVec = [0.0735,0.0619,0.0465,0.0433,0.0577])
42  run2_muon_2017.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
43  run2_muon_2018.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
44  run2_muon_2016.toModify( process.patMuons, mvaTrainingFile = "RecoMuon/MuonIdentification/data/mu_2016_BDTG.weights.xml")
45 
46  process.patMuons.computePuppiCombinedIso = True
47  #
48  # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer
49  process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core
50  process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
51  process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
52  process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster
53  process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters
54  process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters
55  process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters
56  process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters
57  process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer
58  process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
59  process.patElectrons.usePfCandidateMultiMap = True
60  process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap")
61  process.patElectrons.electronIDSources = cms.PSet()
62 
63  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
64  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
65  (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify(process.patElectrons,
66  addPFClusterIso = True,
67  ecalPFClusterIsoMap = "reducedEgamma:eleEcalPFClusIso",
68  hcalPFClusterIsoMap = "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  (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify(process.patPhotons,
100  addPFClusterIso = True,
101  ecalPFClusterIsoMap = "reducedEgamma:phoEcalPFClusIso",
102  hcalPFClusterIsoMap = "reducedEgamma:phoHcalPFClusIso")
103  #the 80X legacy customsations are done in ootPhotonProducer for OOT photons
104  run2_miniAOD_94XFall17.toModify(process.patOOTPhotons,
105  addPFClusterIso = True,
106  ecalPFClusterIsoMap = "reducedEgamma:ootPhoEcalPFClusIso",
107  hcalPFClusterIsoMap = "reducedEgamma:ootPhoHcalPFClusIso")
108 
109 
110  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
111  process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
112 
113  process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
114  process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
115  process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
116  process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
117  process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
118  #
119  process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons")
120  process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
121  #
122  process.selectedPatJets.cut = cms.string("pt > 10")
123  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
124 
125  from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
126  phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )")
127  from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
128  pp_on_AA.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 1.2 && (isGlobalMuon || isStandAloneMuon) )")
129 
130  process.selectedPatElectrons.cut = cms.string("")
131  process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5")
132  process.selectedPatPhotons.cut = cms.string("")
133 
134  _dummyPatJets = process.selectedPatJets.clone(cut = "pt < 0")
135  task = getPatAlgosToolsTask(process)
136 
137  def _applySubstructure(process):
138  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
139 
140  from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
141  applySubstructure( process )
142  (~pp_on_AA).toModify(process, _applySubstructure)
143 
144  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJets', p.selectedPatJets.clone(), p, task))
145  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsAK8', _dummyPatJets.clone(), p, task))
146 
147  #
148  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
149  switchOnTriggerStandAlone( process, outputModule = '' )
150  process.patTrigger.packTriggerPathNames = cms.bool(True)
151  #
152  # apply type I + other PFMEt corrections to pat::MET object
153  # and estimate systematic uncertainties on MET
154 
155  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
156  runMetCorAndUncForMiniAODProduction(process, metType="PF",
157  jetCollUnskimmed="patJets")
158 
159  #caloMET computation
160  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
161  addMETCollection(process,
162  labelName = "patCaloMet",
163  metSource = "caloMetM"
164  )
165 
166  #noHF pfMET =========
167 
168  process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
169  src=cms.InputTag("particleFlow"),
170  cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
171  )
172  task.add(process.noHFCands)
173 
175  pfCandColl=cms.InputTag("noHFCands"),
176  recoMetFromPFCs=True, #needed for HF removal
177  jetSelection="pt>15 && abs(eta)<3.",
178  postfix="NoHF"
179  )
180 
181  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
182  task.add(process.slimmedMETs)
183  (~pp_on_AA).toModify(process.slimmedMETs, addDeepMETs = True)
184 
185  def _add_slimmedMETsNoHF(process):
186  addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task)
187  process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF")
188  process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF")
189  process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF")
190  process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF")
191  process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF")
192  process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF")
193  process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF")
194  process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF")
195  process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF")
196  process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF")
197  del process.slimmedMETsNoHF.caloMET
198  (~pp_on_AA).toModify(process, _add_slimmedMETsNoHF)
199  # ================== NoHF pfMET
200 
201  # ================== CHSMET
202  process.load("CommonTools.ParticleFlow.pfCHS_cff")
203  task.add(process.packedPrimaryVertexAssociationJME)
204  task.add(process.pfCHS)
205 
206  from RecoMET.METProducers.pfMet_cfi import pfMet
207  process.pfMetCHS = pfMet.clone(src = 'pfCHS')
208  task.add(process.pfMetCHS)
209 
210  addMETCollection(process,
211  labelName = "patCHSMet",
212  metSource = "pfMetCHS"
213  )
214 
215  process.patCHSMet.computeMETSignificance = cms.bool(False)
216 
217  # ================== CHSMET
218 
219  # ================== TrkMET
220  process.TrkCands = chargedPackedCandsForTkMet.clone()
221  task.add(process.TrkCands)
222 
223  process.pfMetTrk = pfMet.clone(src = 'TrkCands')
224  task.add(process.pfMetTrk)
225 
226  addMETCollection(process,
227  labelName = "patTrkMet",
228  metSource = "pfMetTrk"
229  )
230 
231  process.patTrkMet.computeMETSignificance = cms.bool(False)
232 
233  # ================== TrkMET
234 
235 
236  ## PU JetID
237  process.load("RecoJets.JetProducers.PileupJetID_cfi")
238  task.add(process.pileUpJetIDTask)
239 
240  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
241  process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ]
242 
243  ## Quark Gluon Likelihood
244  process.load('RecoJets.JetProducers.QGTagger_cfi')
245  task.add(process.QGTaggerTask)
246 
247  process.patJets.userData.userFloats.src += [ 'QGTagger:qgLikelihood', ]
248 
249  #HF jet shower shape
250  process.load('RecoJets.JetProducers.hfJetShowerShape_cfi')
251  task.add(process.hfJetShowerShape)
252 
253  process.patJets.userData.userFloats.src += [ 'hfJetShowerShape:sigmaEtaEta', 'hfJetShowerShape:sigmaPhiPhi']
254  process.patJets.userData.userInts.src += [ 'hfJetShowerShape:centralEtaStripSize', 'hfJetShowerShape:adjacentEtaStripsSize']
255 
256  ## DeepCSV meta discriminators (simple arithmethic on output probabilities)
257  def _add_deepFlavour(process):
258  process.load('RecoBTag.Combined.deepFlavour_cff')
259  task.add(process.pfDeepCSVDiscriminatorsJetTags)
260  process.patJets.discriminatorSources.extend([
261  'pfDeepCSVDiscriminatorsJetTags:BvsAll',
262  'pfDeepCSVDiscriminatorsJetTags:CvsB',
263  'pfDeepCSVDiscriminatorsJetTags:CvsL',
264  ])
265  (~pp_on_AA).toModify(process, _add_deepFlavour)
266 
267  ## CaloJets
268  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
269  src = process.patJets.jetSource,
270  matched = cms.InputTag("ak4CaloJets"),
271  distMax = cms.double(0.4),
272  values = cms.vstring('pt','emEnergyFraction'),
273  valueLabels = cms.vstring('pt','emEnergyFraction'),
274  lazyParser = cms.bool(True) )
275  task.add(process.caloJetMap)
276  process.patJets.userData.userFloats.src += [ 'caloJetMap:pt', 'caloJetMap:emEnergyFraction' ]
277 
278  pp_on_AA.toModify(process.patJets.userData.userInts, src = [] )
279  pp_on_AA.toModify(process.patJets.userData.userFloats, src = [] )
280 
281  #Muon object modifications
282  from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
284 
285  #EGM object modifications
286  from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
288  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
289  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
290  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
291 
292  #VID Electron IDs
293  process.patElectrons.addElectronID = cms.bool(True)
294  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
295  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV71_cff',
296  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
297  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
298  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
299  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
300  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
301  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
302  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
303  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
304  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
305  ]
306  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
307  process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
308  process.electronMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
309 
310  # To use older DataFormats, the electronMVAValueMapProducer MUST take a updated electron collection
311  # such that the conversion variables are filled correctly.
312  process.load("RecoEgamma.EgammaTools.gedGsfElectronsTo106X_cff")
313  run2_miniAOD_80XLegacy.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom80XTo106XTask))
314  run2_miniAOD_80XLegacy.toModify(process.electronMVAValueMapProducer,
315  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
316  src = cms.InputTag("gedGsfElectronsFrom80XTo106X"))
317 
318  run2_miniAOD_94XFall17.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
319  run2_miniAOD_94XFall17.toModify(process.electronMVAValueMapProducer,
320  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
321  src = cms.InputTag("gedGsfElectronsFrom94XTo106X"))
322 
323  from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
324  pp_on_AA.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
325  pp_on_AA.toModify(process.electronMVAValueMapProducer,
326  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
327  src = "gedGsfElectronsFrom94XTo106X")
328 
329  for idmod in electron_ids:
330  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
331 
332  #VID Photon IDs
333  process.patPhotons.addPhotonID = cms.bool(True)
334  photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
335  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
336  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
337  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
338  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
339  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff']
340  switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
341  process.egmPhotonIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedPhotons")
342  process.photonMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedPhotons')
343  for idmod in photon_ids:
344  setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)
345 
346  #add the cut base IDs bitmaps of which cuts passed
347  from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier
348  egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs"))
349 
350  #-- Adding boosted taus
351  from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
352  addBoostedTaus(process)
353  process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
354  process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
355  #-- Adding customization for 94X 2017 legacy reMniAOD
356  _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
357  _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauBasicDiscriminatorsTask,
358  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask,
359  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask,
360  process.hpsPFTauBasicDiscriminatorsdR03Task,
361  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTTask,
362  process.hpsPFTauDiscriminationByMVA6rawElectronRejection,
363  process.hpsPFTauDiscriminationByMVA6ElectronRejection,
364  process.hpsPFTauDiscriminationByMuonRejection3)
365  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
366  (run2_miniAOD_94XFall17 | run2_miniAOD_UL).toReplaceWith(
367  process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
368  )
369  #-- Adding DeepTauID
370  # deepTau v2p1
371  _updatedTauName = 'slimmedTausDeepIDsv2p1'
372  _noUpdatedTauName = 'slimmedTausNoDeepIDs'
373  import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
374  tauIdEmbedder = tauIdConfig.TauIDEmbedder(
375  process, debug = False,
376  originalTauName = _noUpdatedTauName,
377  updatedTauName = _updatedTauName,
378  toKeep = ['deepTau2017v2p1']
379  )
380  from Configuration.Eras.Modifier_phase2_common_cff import phase2_common #Phase2 Tau MVA
381  phase2_common.toModify(tauIdEmbedder.toKeep, func=lambda t:t.append('newDMPhase2v1')) #Phase2 Tau isolation MVA
382  phase2_common.toModify(tauIdEmbedder.toKeep, func=lambda t:t.append('againstElePhase2v1')) #Phase2 Tau anti-e MVA
383  tauIdEmbedder.runTauID()
384  addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(),process,task)
385  delattr(process, 'slimmedTaus')
386  process.slimmedTaus = getattr(process, _updatedTauName).clone()
387  process.rerunMvaIsolationTask.add(process.slimmedTaus)
388  task.add(process.rerunMvaIsolationTask)
389 
390  #-- Rerun tauID against dead ECal towers to taus for the various re-MiniAOD eras
391  # to enable default behoviour with leading track extrapolation to ECAL
392  _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy()
393  _makePatTausTaskWithDeadECalVeto.add(
394  process.hpsPFTauDiscriminationByDeadECALElectronRejection
395  )
396  _run2_miniAOD_ANY = (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17 | run2_miniAOD_UL)
397  _run2_miniAOD_ANY.toReplaceWith(
398  process.makePatTausTask, _makePatTausTaskWithDeadECalVeto
399  )
400 
401  #-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions
402  _makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
403  _makePatTausTaskWithTauReReco.add(process.PFTauTask)
404  (run2_miniAOD_80XLegacy | pp_on_AA).toReplaceWith(
405  process.makePatTausTask, _makePatTausTaskWithTauReReco
406  )
407 
408  # Adding puppi jets
409  process.load('CommonTools.PileupAlgos.Puppi_cff')
410  process.load('RecoJets.JetProducers.ak4PFJets_cfi')
411  from Configuration.Eras.Modifier_pA_2016_cff import pA_2016
412  _rerun_puppijets_task = task.copy()
413  _rerun_puppijets_task.add(process.puppi, process.ak4PFJetsPuppi)
414  (_run2_miniAOD_ANY | pA_2016 | pp_on_AA).toReplaceWith(task, _rerun_puppijets_task)
415 
416  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
417  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
418  j2tParametersVX,
419  jets = cms.InputTag("ak4PFJetsPuppi")
420  )
421  task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
422  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
423  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
424  var = cms.string('Pt'),
425  exp = cms.double(1.0)
426  )
427  task.add(process.patJetPuppiCharge)
428 
429  def _add_jetsPuppi(process):
430  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
431  noDeepFlavourDiscriminators = [x.value() if isinstance(x, cms.InputTag) else x for x in process.patJets.discriminatorSources
432  if not "DeepFlavour" in str(x)]
433  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
434  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
435  pfCandidates = cms.InputTag("particleFlow"),
436  algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
437  )
438 
439  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
440 
441  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
442 
443  process.selectedPatJetsPuppi.cut = cms.string("pt > 15")
444 
445  from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging
446  applyDeepBtagging( process )
447 
448  addToProcessAndTask('slimmedJetsPuppi', process.slimmedJetsNoDeepFlavour.clone(
449  src = "selectedPatJetsPuppi", packedPFCandidates = "packedPFCandidates"),
450  process, task)
451 
452  task.add(process.slimmedJetsPuppi)
453 
454  process.slimmedJetsNoDeepFlavour.dropTagInfos = '0'
455  process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.addTagInfos = True
456  process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.tagInfoSources = ["pixelClusterTagInfos"]
457  _run2_miniAOD_ANY.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = False )
458  (~pp_on_AA).toModify(process, _add_jetsPuppi)
459 
460  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsPuppi', _dummyPatJets.clone(), p, task))
461 
462  # Embed pixelClusterTagInfos in slimmedJets
463  process.patJets.addTagInfos = True
464  process.patJets.tagInfoSources = ["pixelClusterTagInfos"]
465 
466  _run2_miniAOD_ANY.toModify(process.patJets, addTagInfos = False )
467 
468  pp_on_AA.toModify(process.patJets, tagInfoSources = cms.VInputTag(["impactParameterTagInfos","secondaryVertexTagInfos"]) )
469 
470  ## puppi met
471  def _add_metPuppi(process):
472  process.load('RecoMET.METProducers.pfMetPuppi_cfi')
473  _rerun_puppimet_task = task.copy()
474  _rerun_puppimet_task.add(process.puppiNoLep, process.pfMetPuppi)
475  (_run2_miniAOD_ANY | pA_2016 | pp_on_AA).toReplaceWith(task, _rerun_puppimet_task)
476 
477  runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
478  jetCollUnskimmed="slimmedJetsPuppi",
479  recoMetFromPFCs=True,
480  jetFlavor="AK4PFPuppi",
481  postfix="Puppi"
482  )
483  (~pp_on_AA).toModify(process, _add_metPuppi)
484 
485  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
486  task.add(process.slimmedMETs)
487 
488  def _add_slimmedMETsPuppi(process):
489  addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
490  process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
491  process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
492  process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
493  process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
494  process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
495  process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
496  process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
497  process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
498  process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
499  process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
500  del process.slimmedMETsPuppi.caloMET
501  (~pp_on_AA).toModify(process, _add_slimmedMETsPuppi)
502 
503  def _add_deepMET(process):
504  process.load('RecoMET.METPUSubtraction.deepMETProducer_cfi')
505 
506  addToProcessAndTask('deepMETsResolutionTune', process.deepMETProducer.clone(), process, task)
507  addToProcessAndTask('deepMETsResponseTune', process.deepMETProducer.clone(), process, task)
508  process.deepMETsResponseTune.graph_path = 'RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb'
509 
510  from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
511  phase2_common.toModify(
512  process.deepMETsResolutionTune,
513  max_n_pf=12500,
514  graph_path="RecoMET/METPUSubtraction/data/deepmet/deepmet_v1_phase2.pb"
515  )
516  phase2_common.toModify(
517  process.deepMETsResponseTune,
518  max_n_pf=12500,
519  graph_path="RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_phase2.pb"
520  )
521 
522  from Configuration.Eras.Modifier_run2_jme_2016_cff import run2_jme_2016
523  run2_jme_2016.toModify(
524  process.deepMETsResponseTune,
525  graph_path="RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb"
526  )
527  (~pp_on_AA).toModify(process, _add_deepMET)
528 
529  # add DetIdAssociatorRecords to EventSetup (for isolatedTracks)
530  process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
531 
532  # EGamma objects from HGCal are not yet in GED
533  # so add companion collections for Phase-II MiniAOD production
534  from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
535  process.load("RecoEgamma.EgammaTools.slimmedEgammaHGC_cff")
536  phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaHGCTask))
537 
538  # L1 pre-firing weights for 2016, 2017, and 2018
539  from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring
540  from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
541  from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
542  from Configuration.Eras.Modifier_stage2L1Trigger_2018_cff import stage2L1Trigger_2018
543  from Configuration.Eras.Modifier_tracker_apv_vfp30_2016_cff import tracker_apv_vfp30_2016
544  process.load("PhysicsTools.PatUtils.L1PrefiringWeightProducer_cff")
545  (stage2L1Trigger & tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016preVFP", DataEraMuon = "2016preVFP" )
546  (stage2L1Trigger & ~tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016postVFP", DataEraMuon = "2016postVFP" )
547  stage2L1Trigger_2017.toModify(process.prefiringweight, DataEraECAL = "UL2017BtoF", DataEraMuon = "20172018")
548  stage2L1Trigger_2018.toModify(process.prefiringweight, DataEraECAL = "None", DataEraMuon = "20172018")
549  run2_L1prefiring.toModify(task, func=lambda t: t.add(process.prefiringweight))
550 
551  from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeL1FastJetJECs
552  pp_on_AA.toModify(process, removeL1FastJetJECs)
def setupAllVIDIdsInModule
Definition: vid_id_tools.py:49
def switchOnVIDElectronIdProducer
Electrons.
Definition: vid_id_tools.py:66
def getPatAlgosToolsTask
Definition: helpers.py:13
def miniAOD_customizeCommon
tuple switchOnTriggerStandAlone
Definition: trigTools.py:283
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def switchOnVIDPhotonIdProducer
Photons.
#define str(s)
def addToProcessAndTask
Definition: helpers.py:28
def miniAOD_tools.miniAOD_customizeData (   process)

Definition at line 614 of file miniAOD_tools.py.

References helpers.getPatAlgosToolsTask().

Referenced by customizeMiniAOD_MuEGFixMoriond2017.customizeAll(), and miniAOD_customizeAllData().

615 def miniAOD_customizeData(process):
616  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
617  runOnData( process, outputModules = [] )
618  process.load("RecoPPS.Local.ctppsLocalTrackLiteProducer_cff")
619  process.load("RecoPPS.ProtonReconstruction.ctppsProtons_cff")
620  process.load("Geometry.VeryForwardGeometry.geometryRPFromDB_cfi")
621  process.load('L1Trigger.L1TGlobal.simGtExtFakeProd_cfi')
622  task = getPatAlgosToolsTask(process)
623  from Configuration.Eras.Modifier_ctpps_cff import ctpps
624  ctpps.toModify(task, func=lambda t: t.add(process.ctppsLocalTrackLiteProducer))
625  ctpps.toModify(task, func=lambda t: t.add(process.ctppsProtons))
626  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
627  run2_miniAOD_UL.toModify(task, func=lambda t: t.add(process.simGtExtUnprefireable))
def getPatAlgosToolsTask
Definition: helpers.py:13
def miniAOD_customizeData
def miniAOD_tools.miniAOD_customizeMC (   process)

Definition at line 553 of file miniAOD_tools.py.

References helpers.getPatAlgosToolsTask().

Referenced by miniAOD_customizeAllMC(), and miniAOD_customizeAllMCFastSim().

554 def miniAOD_customizeMC(process):
555  task = getPatAlgosToolsTask(process)
556  #GenJetFlavourInfos
557  process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
558  task.add(process.selectedHadronsAndPartons)
559  task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
560 
561  process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
562  task.add(process.ak4GenJetFlavourInfos)
563 
564  process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
565  task.add(process.slimmedGenJetsFlavourInfos)
566 
567  #slimmed pileup information
568  process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
569  task.add(process.slimmedAddPileupInfo)
570 
571  process.muonMatch.matched = "prunedGenParticles"
572  process.electronMatch.matched = "prunedGenParticles"
573  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
574  process.photonMatch.matched = "prunedGenParticles"
575  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
576  process.ootPhotonMatch.matched = "prunedGenParticles"
577  process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
578  process.tauMatch.matched = "prunedGenParticles"
579  process.tauGenJets.GenParticles = "prunedGenParticles"
580  #Boosted taus
581  process.tauMatchBoosted.matched = "prunedGenParticles"
582  process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
583  process.patJetPartons.particles = "genParticles"
584  process.patJetPartonMatch.matched = "prunedGenParticles"
585  pp_on_AA.toModify(process.patJetPartonMatch, matched = "hiSignalGenParticles")
586  from Configuration.ProcessModifiers.genJetSubEvent_cff import genJetSubEvent
587  genJetSubEvent.toModify(process.patJetPartonMatch, matched = "cleanedPartons")
588  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
589  process.patJetGenJetMatch.matched = "slimmedGenJets"
590  (~pp_on_AA).toModify(process, patJetGenJetMatchAK8Puppi = dict(matched = "slimmedGenJetsAK8"))
591  process.patMuons.embedGenMatch = False
592  process.patElectrons.embedGenMatch = False
593  process.patPhotons.embedGenMatch = False
594  process.patOOTPhotons.embedGenMatch = False
595  process.patTaus.embedGenMatch = False
596  process.patTausBoosted.embedGenMatch = False
597  process.patJets.embedGenPartonMatch = False
598  #also jet flavour must be switched
599  process.patJetFlavourAssociation.rParam = 0.4
600 
601  from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeJECsForMC
602  pp_on_AA.toModify(process, removeJECsForMC)
603  pp_on_AA.toReplaceWith(task,task.copyAndExclude([process.slimmedGenJetsFlavourInfos]))
604 
def getPatAlgosToolsTask
Definition: helpers.py:13
def miniAOD_tools.miniAOD_customizeOutput (   out)

Definition at line 605 of file miniAOD_tools.py.

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

606 def miniAOD_customizeOutput(out):
607  from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
608  out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
609  out.splitLevel = cms.untracked.int32(0)
610  out.dropMetaData = cms.untracked.string('ALL')
611  out.fastCloning= cms.untracked.bool(False)
612  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
613  out.compressionAlgorithm = cms.untracked.string('LZMA')
def miniAOD_customizeOutput