CMS 3D CMS Logo

Functions
customizeMiniAOD_MuEGFixMoriond2017 Namespace Reference

Functions

def addBadMuonFilters (process)
 
def addDiscardedPFCandidates (process, inputCollection, verbose=False)
 
def cleanPFCandidates (process, badMuons, verbose=False)
 
def customizeAll (process, verbose=False)
 
def loadJetMETBTag (process)
 

Function Documentation

◆ addBadMuonFilters()

def customizeMiniAOD_MuEGFixMoriond2017.addBadMuonFilters (   process)

Definition at line 9 of file customizeMiniAOD_MuEGFixMoriond2017.py.

References helpers.getPatAlgosToolsTask().

Referenced by customizeAll().

9 def addBadMuonFilters(process):
10 
11  task = getPatAlgosToolsTask(process)
12 
13  process.load("RecoMET.METFilters.badGlobalMuonTaggersAOD_cff")
14  task.add(process.badGlobalMuonTagger)
15  task.add(process.cloneGlobalMuonTagger)
16  process.Flag_noBadMuons = cms.Path(process.noBadGlobalMuons)
17  process.Flag_badMuons = cms.Path(process.badGlobalMuonTagger)
18  process.Flag_duplicateMuons = cms.Path(process.cloneGlobalMuonTagger)
19  for P in process.Flag_noBadMuons, process.Flag_badMuons, process.Flag_duplicateMuons:
20  process.schedule.insert(0, P)
21 
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

◆ addDiscardedPFCandidates()

def customizeMiniAOD_MuEGFixMoriond2017.addDiscardedPFCandidates (   process,
  inputCollection,
  verbose = False 
)

Definition at line 63 of file customizeMiniAOD_MuEGFixMoriond2017.py.

References helpers.addKeepStatement(), and helpers.getPatAlgosToolsTask().

Referenced by customizeAll().

63 def addDiscardedPFCandidates(process, inputCollection, verbose=False):
64 
65  task = getPatAlgosToolsTask(process)
66 
67  process.primaryVertexAssociationDiscardedCandidates = process.primaryVertexAssociation.clone(
68  particles = inputCollection,
69  )
70  task.add(process.primaryVertexAssociationDiscardedCandidates)
71  process.packedPFCandidatesDiscarded = process.packedPFCandidates.clone(
72  inputCollection = inputCollection,
73  PuppiNoLepSrc = cms.InputTag(""),
74  PuppiSrc = cms.InputTag(""),
75  secondaryVerticesForWhiteList = cms.VInputTag(),
76  vertexAssociator = cms.InputTag("primaryVertexAssociationDiscardedCandidates","original")
77  )
78  task.add(process.packedPFCandidatesDiscarded)
79  addKeepStatement(process, "keep patPackedCandidates_packedPFCandidates_*_*",
80  ["keep patPackedCandidates_packedPFCandidatesDiscarded_*_*"],
81  verbose=verbose)
82  # Now make the mixed map for rekeying
83  from PhysicsTools.PatAlgos.slimming.packedPFCandidateRefMixer_cfi import packedPFCandidateRefMixer
84  process.oldPFCandToPackedOrDiscarded = packedPFCandidateRefMixer.clone(
85  pf2pf = cms.InputTag(inputCollection.moduleLabel),
86  pf2packed = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))
87  )
88  task.add(process.oldPFCandToPackedOrDiscarded)
89  # Fix slimmed muon keying
90  process.slimmedMuons.pfCandidates = cms.VInputTag(cms.InputTag(inputCollection.moduleLabel), inputCollection)
91  process.slimmedMuons.packedPFCandidates = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))
92 
93  #MM point to uncleaned collection for hadronic taus, to avoid remaking them
94  #no impact expected, as no muons are included here
95  process.slimmedTaus.packedPFCandidates=cms.InputTag("packedPFCandidatesBackup")
96 
def addDiscardedPFCandidates(process, inputCollection, verbose=False)
def addKeepStatement(process, oldKeep, newKeeps, verbose=False)
Definition: helpers.py:354
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

◆ cleanPFCandidates()

def customizeMiniAOD_MuEGFixMoriond2017.cleanPFCandidates (   process,
  badMuons,
  verbose = False 
)

Definition at line 22 of file customizeMiniAOD_MuEGFixMoriond2017.py.

References helpers.getPatAlgosToolsTask().

Referenced by customizeAll().

22 def cleanPFCandidates(process, badMuons, verbose=False):
23 
24  task = getPatAlgosToolsTask(process)
25 
26  process.load("CommonTools.ParticleFlow.muonsCleaned_cfi")
27  task.add(process.muonsCleaned)
28  process.patMuons.userData.userInts.src = [ cms.InputTag("muonsCleaned:oldPF") ]
29 
30  process.load("CommonTools.ParticleFlow.pfCandidatesBadMuonsCleaned_cfi")
31  task.add(process.pfCandidatesBadMuonsCleaned)
32  process.muonsCleaned.badmuons = badMuons
33  replaceMuons = MassSearchReplaceAnyInputTagVisitor("muons", "muonsCleaned", verbose=verbose)
34  needOriginalMuons = [ process.muonsCleaned ] + [ getattr(process,l.moduleLabel) for l in badMuons ]
35  replacePFCandidates = MassSearchReplaceAnyInputTagVisitor("particleFlow", "pfCandidatesBadMuonsCleaned", verbose=verbose)
36  for everywhere in [ process.producers, process.filters, process.analyzers, process.psets, process.vpsets ]:
37  for name,obj in everywhere.items():
38  if obj not in needOriginalMuons:
39  replaceMuons.doIt(obj, name)
40  if obj != process.pfCandidatesBadMuonsCleaned:
41  replacePFCandidates.doIt(obj, name)
42 
43  process.load("CommonTools.ParticleFlow.pfEGammaToCandidateRemapper_cfi")
44  task.add(process.pfEGammaToCandidateRemapper)
45  process.pfEGammaToCandidateRemapper.pf2pf = cms.InputTag("pfCandidatesBadMuonsCleaned")
46  process.reducedEgamma.gsfElectronsPFValMap = cms.InputTag("pfEGammaToCandidateRemapper","electrons")
47  process.reducedEgamma.photonsPFValMap = cms.InputTag("pfEGammaToCandidateRemapper","photons")
48  if hasattr(process,"gedGsfElectronsFixed"):
49  # also reconfigure pfEGammaToCandidateRemapper because of GS Fix
50  # first the old one
51  process.pfEGammaToCandidateRemapperBeforeGSFix = process.pfEGammaToCandidateRemapper.clone()
52  task.add(process.pfEGammaToCandidateRemapperBeforeGSFix)
53  process.reducedEgammaBeforeGSFix.gsfElectronsPFValMap = cms.InputTag("pfEGammaToCandidateRemapperBeforeGSFix","electrons")
54  process.reducedEgammaBeforeGSFix.photonsPFValMap = cms.InputTag("pfEGammaToCandidateRemapperBeforeGSFix","photons")
55  # then the new one
56  process.pfEGammaToCandidateRemapper.electrons = cms.InputTag("gedGsfElectronsFixed")
57  process.pfEGammaToCandidateRemapper.photons = cms.InputTag("gedPhotonsFixed")
58  process.pfEGammaToCandidateRemapper.electron2pf = cms.InputTag("particleBasedIsolationGSFixed","gedGsfElectrons")
59  process.pfEGammaToCandidateRemapper.photon2pf = cms.InputTag("particleBasedIsolationGSFixed","gedPhotons")
60  else:
61  sys.stderr.write("WARNING : attempt to use gain switch corrected electron/photon collection gedGsfElectronsFixed, but the current process does not contain such collection")
62 
def cleanPFCandidates(process, badMuons, verbose=False)
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

◆ customizeAll()

def customizeMiniAOD_MuEGFixMoriond2017.customizeAll (   process,
  verbose = False 
)

Definition at line 123 of file customizeMiniAOD_MuEGFixMoriond2017.py.

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

123 def customizeAll(process, verbose=False):
124 
125  #disabled for now, backup in case 90X needs similar fix
126  #process = customizeGSFixForPAT(process)
127 
128  loadJetMETBTag(process)
129  backupJetSequences = backupJetsFirstStep(process)
130 
131  addBadMuonFilters(process)
132  badMuons = cms.VInputTag( cms.InputTag("badGlobalMuonTagger","bad"), cms.InputTag("cloneGlobalMuonTagger","bad") )
133  # clean the muons and PF candidates, and make *everything* point to the new candidates
134  cleanPFCandidates(process, badMuons, verbose=verbose)
135 
136  addDiscardedPFCandidates(process, cms.InputTag("pfCandidatesBadMuonsCleaned","discarded"), verbose=verbose)
137 
138  # now make the backup sequences point to the right place
139  backupJetsSecondStep(process, backupJetSequences, badMuons, verbose=verbose)
140 
141 
142  process.patMuons.embedCaloMETMuonCorrs = False # FIXME
143 
144  from PhysicsTools.PatAlgos.slimming.extraSlimmedMETs_MuEGFixMoriond2017 import addExtraMETCollections,addExtraPuppiMETCorrections
145 
146 
148  addExtraMETCollections(process,
149  unCleanPFCandidateCollection="particleFlow",
150  cleanElectronCollection="slimmedElectrons",
151  cleanPhotonCollection="slimmedPhotons",
152  unCleanElectronCollection="slimmedElectrons",
153  unCleanPhotonCollection="slimmedPhotons")
154 
156  cleanPFCandidateCollection="particleFlow",
157  unCleanPFCandidateCollection="pfCandidatesBadMuonsCleaned",
158  cleanElectronCollection="slimmedElectrons",
159  cleanPhotonCollection="slimmedPhotons",
160  unCleanElectronCollection="slimmedElectrons",
161  unCleanPhotonCollection="slimmedPhotons")
162 
163  addKeepStatement(process,
164  "keep *_slimmedMETs_*_*",
165  ["keep *_slimmedMETsUncorrected_*_*",
166  "keep *_slimmedMETsEGClean_*_*",
167  "keep *_slimmedMETsMuEGClean_*_*"],
168  verbose=verbose)
169  addKeepStatement(process,
170  "keep *_slimmedMETsPuppi_*_*",
171  ["keep *_puppiMETEGCor_*_*",
172  "keep *_puppiMETMuCor_*_*"],
173  verbose=verbose)
174 
175 
176 
177  #redo the miniAOD data customization for new JEC modules created during the backup process
178  from PhysicsTools.PatAlgos.slimming.miniAOD_tools import miniAOD_customizeData
179  miniAOD_customizeData(process)
180 
181  return process
182 
def addExtraPuppiMETCorrections(process, cleanPFCandidateCollection, unCleanPFCandidateCollection, cleanElectronCollection, cleanPhotonCollection, unCleanElectronCollection, unCleanPhotonCollection)
def addDiscardedPFCandidates(process, inputCollection, verbose=False)
def backupJetsSecondStep(process, sequences, badMuons, verbose=False)
def miniAOD_customizeData(process)
def addKeepStatement(process, oldKeep, newKeeps, verbose=False)
Definition: helpers.py:354
def cleanPFCandidates(process, badMuons, verbose=False)
def addExtraMETCollections(process, unCleanPFCandidateCollection, cleanElectronCollection, cleanPhotonCollection, unCleanElectronCollection, unCleanPhotonCollection)

◆ loadJetMETBTag()

def customizeMiniAOD_MuEGFixMoriond2017.loadJetMETBTag (   process)

Definition at line 97 of file customizeMiniAOD_MuEGFixMoriond2017.py.

References helpers.getPatAlgosToolsTask().

Referenced by customizeAll().

97 def loadJetMETBTag(process):
98 
99  task = getPatAlgosToolsTask(process)
100 
102  process.ak4PFJetsCHS = RecoJets.Configuration.RecoPFJets_cff.ak4PFJetsCHS.clone()
103  task.add(process.ak4PFJetsCHS)
104  process.ak8PFJetsCHS = RecoJets.Configuration.RecoPFJets_cff.ak8PFJetsCHS.clone()
105  task.add(process.ak8PFJetsCHS)
106  process.load("RecoMET.METProducers.pfMet_cfi")
107  task.add(process.pfMet)
108  process.load("RecoBTag.ImpactParameter.impactParameter_cff")
109  task.add(process.impactParameterTask)
110  process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
111  task.add(process.secondaryVertexTask)
112  process.load("RecoBTag.SoftLepton.softLepton_cff")
113  task.add(process.softLeptonTask)
114  process.load("RecoBTag.Combined.combinedMVA_cff")
115  task.add(process.combinedMVATask)
116  process.load("RecoBTag.CTagging.cTagging_cff")
117  task.add(process.cTaggingTask)
118  process.load("RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff")
119  task.add(process.inclusiveVertexingTask)
120  task.add(process.inclusiveCandidateVertexingTask)
121  task.add(process.inclusiveCandidateVertexingCvsLTask)
122 
def getPatAlgosToolsTask(process)
Definition: helpers.py:13