CMS 3D CMS Logo

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

Functions

def addBadMuonFilters
 
def addDiscardedPFCandidates
 
def cleanPFCandidates
 
def customizeAll
 
def loadJetMETBTag
 

Function Documentation

def customizeMiniAOD_MuEGFixMoriond2017.addBadMuonFilters (   process)

Definition at line 7 of file customizeMiniAOD_MuEGFixMoriond2017.py.

Referenced by customizeAll().

7 
8 def addBadMuonFilters(process):
9  process.load("RecoMET.METFilters.badGlobalMuonTaggersAOD_cff")
10  process.Flag_noBadMuons = cms.Path(process.noBadGlobalMuons)
11  process.Flag_badMuons = cms.Path(process.badGlobalMuonTagger)
12  process.Flag_duplicateMuons = cms.Path(process.cloneGlobalMuonTagger)
13  for P in process.Flag_noBadMuons, process.Flag_badMuons, process.Flag_duplicateMuons:
14  process.schedule.insert(0, P)
def customizeMiniAOD_MuEGFixMoriond2017.addDiscardedPFCandidates (   process,
  inputCollection,
  verbose = False 
)

Definition at line 48 of file customizeMiniAOD_MuEGFixMoriond2017.py.

References helpers.addKeepStatement().

Referenced by customizeAll().

48 
49 def addDiscardedPFCandidates(process, inputCollection, verbose=False):
50  process.primaryVertexAssociationDiscardedCandidates = process.primaryVertexAssociation.clone(
51  particles = inputCollection,
52  )
53  process.packedPFCandidatesDiscarded = process.packedPFCandidates.clone(
54  inputCollection = inputCollection,
55  PuppiNoLepSrc = cms.InputTag(""),
56  PuppiSrc = cms.InputTag(""),
57  secondaryVerticesForWhiteList = cms.VInputTag(),
58  vertexAssociator = cms.InputTag("primaryVertexAssociationDiscardedCandidates","original")
59  )
60  addKeepStatement(process, "keep patPackedCandidates_packedPFCandidates_*_*",
61  ["keep patPackedCandidates_packedPFCandidatesDiscarded_*_*"],
62  verbose=verbose)
63  # Now make the mixed map for rekeying
64  from PhysicsTools.PatAlgos.slimming.packedPFCandidateRefMixer_cfi import packedPFCandidateRefMixer
65  process.oldPFCandToPackedOrDiscarded = packedPFCandidateRefMixer.clone(
66  pf2pf = cms.InputTag(inputCollection.moduleLabel),
67  pf2packed = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))
68  )
69  # Fix slimmed muon keying
70  process.slimmedMuons.pfCandidates = cms.VInputTag(cms.InputTag(inputCollection.moduleLabel), inputCollection)
71  process.slimmedMuons.packedPFCandidates = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))
def addKeepStatement
Definition: helpers.py:427
def customizeMiniAOD_MuEGFixMoriond2017.cleanPFCandidates (   process,
  badMuons,
  verbose = False 
)

Definition at line 15 of file customizeMiniAOD_MuEGFixMoriond2017.py.

Referenced by customizeAll().

15 
16 def cleanPFCandidates(process, badMuons, verbose=False):
17  process.load("CommonTools.ParticleFlow.muonsCleaned_cfi")
18  process.patMuons.userData.userInts.src = [ cms.InputTag("muonsCleaned:oldPF") ]
19 
20  process.load("CommonTools.ParticleFlow.pfCandidatesBadMuonsCleaned_cfi")
21  process.muonsCleaned.badmuons = badMuons
22  replaceMuons = MassSearchReplaceAnyInputTagVisitor("muons", "muonsCleaned", verbose=verbose)
23  needOriginalMuons = [ process.muonsCleaned ] + [ getattr(process,l.moduleLabel) for l in badMuons ]
24  replacePFCandidates = MassSearchReplaceAnyInputTagVisitor("particleFlow", "pfCandidatesBadMuonsCleaned", verbose=verbose)
25  for everywhere in [ process.producers, process.filters, process.analyzers, process.psets, process.vpsets ]:
26  for name,obj in everywhere.iteritems():
27  if obj not in needOriginalMuons:
28  replaceMuons.doIt(obj, name)
29  if obj != process.pfCandidatesBadMuonsCleaned:
30  replacePFCandidates.doIt(obj, name)
31 
32  process.load("CommonTools.ParticleFlow.pfEGammaToCandidateRemapper_cfi")
33  process.pfEGammaToCandidateRemapper.pf2pf = cms.InputTag("pfCandidatesBadMuonsCleaned")
34  process.reducedEgamma.gsfElectronsPFValMap = cms.InputTag("pfEGammaToCandidateRemapper","electrons")
35  process.reducedEgamma.photonsPFValMap = cms.InputTag("pfEGammaToCandidateRemapper","photons")
36  if hasattr(process,"gedGsfElectronsGSFixed"):
37  # also reconfigure pfEGammaToCandidateRemapper because of GS Fix
38  # first the old one
39  process.pfEGammaToCandidateRemapperBeforeGSFix = process.pfEGammaToCandidateRemapper.clone()
40  process.reducedEgammaBeforeGSFix.gsfElectronsPFValMap = cms.InputTag("pfEGammaToCandidateRemapperBeforeGSFix","electrons")
41  process.reducedEgammaBeforeGSFix.photonsPFValMap = cms.InputTag("pfEGammaToCandidateRemapperBeforeGSFix","photons")
42  # then the new one
43  process.pfEGammaToCandidateRemapper.electrons = cms.InputTag("gedGsfElectronsGSFixed")
44  process.pfEGammaToCandidateRemapper.photons = cms.InputTag("gedPhotonsGSFixed")
45  process.pfEGammaToCandidateRemapper.electron2pf = cms.InputTag("particleBasedIsolationGSFixed","gedGsfElectrons")
46  process.pfEGammaToCandidateRemapper.photon2pf = cms.InputTag("particleBasedIsolationGSFixed","gedPhotons")
47 
def customizeMiniAOD_MuEGFixMoriond2017.customizeAll (   process,
  verbose = False 
)

Definition at line 84 of file customizeMiniAOD_MuEGFixMoriond2017.py.

References addBadMuonFilters(), addDiscardedPFCandidates(), extraSlimmedMETs_MuEGFixMoriond2017.addExtraMETCollections(), extraSlimmedMETs_MuEGFixMoriond2017.addExtraPuppiMETCorrections(), helpers.addKeepStatement(), extraJets_MuEGFixMoriond2017.backupJetsFirstStep(), extraJets_MuEGFixMoriond2017.backupJetsSecondStep(), cleanPFCandidates(), egammaGainSwitchFixToolsForPAT_cff.customizeGSFixForPAT(), loadJetMETBTag(), and miniAOD_tools.miniAOD_customizeData().

84 
85 def customizeAll(process, verbose=False):
86 
87  process = customizeGSFixForPAT(process)
88 
89  loadJetMETBTag(process)
90  backupJetSequences = backupJetsFirstStep(process)
91 
92  addBadMuonFilters(process)
93  badMuons = cms.VInputTag( cms.InputTag("badGlobalMuonTagger","bad"), cms.InputTag("cloneGlobalMuonTagger","bad") )
94  # clean the muons and PF candidates, and make *everything* point to the new candidates
95  cleanPFCandidates(process, badMuons, verbose=verbose)
96 
97  addDiscardedPFCandidates(process, cms.InputTag("pfCandidatesBadMuonsCleaned","discarded"), verbose=verbose)
98 
99  # now make the backup sequences point to the right place
100  backupJetsSecondStep(process, backupJetSequences, badMuons, verbose=verbose)
101 
102 
103  process.patMuons.embedCaloMETMuonCorrs = False # FIXME
104  ##extra METs and MET corrections ===============================================================
105  from PhysicsTools.PatAlgos.slimming.extraSlimmedMETs_MuEGFixMoriond2017 import addExtraMETCollections,addExtraPuppiMETCorrections
106 
107  addExtraMETCollections(process,
108  unCleanPFCandidateCollection="particleFlow",
109  cleanElectronCollection="slimmedElectrons",
110  cleanPhotonCollection="slimmedPhotons",
111  unCleanElectronCollection="slimmedElectronsBeforeGSFix",
112  unCleanPhotonCollection="slimmedPhotonsBeforeGSFix")
114  cleanPFCandidateCollection="particleFlow",
115  unCleanPFCandidateCollection="pfCandidatesBadMuonsCleaned",
116  cleanElectronCollection="slimmedElectrons",
117  cleanPhotonCollection="slimmedPhotons",
118  unCleanElectronCollection="slimmedElectronsBeforeGSFix",
119  unCleanPhotonCollection="slimmedPhotonsBeforeGSFix")
120 
121  addKeepStatement(process,
122  "keep *_slimmedMETs_*_*",
123  ["keep *_slimmedMETsUncorrected_*_*",
124  "keep *_slimmedMETsEGClean_*_*",
125  "keep *_slimmedMETsMuEGClean_*_*"],
126  verbose=verbose)
127  addKeepStatement(process,
128  "keep *_slimmedMETsPuppi_*_*",
129  ["keep *_puppiMETEGCor_*_*",
130  "keep *_puppiMETMuCor_*_*"],
131  verbose=verbose)
132 
133 
134 
135  #redo the miniAOD data customization for new JEC modules created during the backup process
136  from PhysicsTools.PatAlgos.slimming.miniAOD_tools import miniAOD_customizeData
137  miniAOD_customizeData(process)
138 
139  return process
def miniAOD_customizeData
def addKeepStatement
Definition: helpers.py:427
def customizeMiniAOD_MuEGFixMoriond2017.loadJetMETBTag (   process)

Definition at line 72 of file customizeMiniAOD_MuEGFixMoriond2017.py.

Referenced by customizeAll().

72 
73 def loadJetMETBTag(process):
75  process.ak4PFJetsCHS = RecoJets.Configuration.RecoPFJets_cff.ak4PFJetsCHS.clone()
76  process.ak8PFJetsCHS = RecoJets.Configuration.RecoPFJets_cff.ak8PFJetsCHS.clone()
77  process.load("RecoMET.METProducers.PFMET_cfi")
78  process.load("RecoBTag.ImpactParameter.impactParameter_cff")
79  process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
80  process.load("RecoBTag.SoftLepton.softLepton_cff")
81  process.load("RecoBTag.Combined.combinedMVA_cff")
82  process.load("RecoBTag.CTagging.cTagging_cff")
83  process.load("RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff")