CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
muonRecoMitigation.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 
5 def muonRecoMitigation(process,
6  pfCandCollection,
7  runOnMiniAOD,
8  selection="",
9  muonCollection="",
10  cleanCollName="cleanMuonsPFCandidates",
11  cleaningScheme="all",
12  postfix=""):
13 
14  sequence=cms.Sequence()
15 
16  if selection=="":
17  typeFix=""
18 
19  if runOnMiniAOD:
20  from RecoMET.METFilters.badGlobalMuonTaggersMiniAOD_cff import badGlobalMuonTaggerMAOD, cloneGlobalMuonTaggerMAOD
21  typeFix="MAOD"
22  badMuModule=badGlobalMuonTaggerMAOD
23  cloneMuModule=cloneGlobalMuonTaggerMAOD
24  else:
25  from RecoMET.METFilters.badGlobalMuonTaggersAOD_cff import badGlobalMuonTagger, cloneGlobalMuonTagger
26  badMuModule=badGlobalMuonTagger
27  cloneMuModule=cloneGlobalMuonTagger
28 
29  vtags=cms.VInputTag()
30  if cleaningScheme in ["bad","all","computeAllApplyBad","computeAllApplyClone"]:
31  setattr(process, 'badGlobalMuonTagger'+typeFix+postfix, badMuModule.clone() )
32  sequence +=getattr(process,"badGlobalMuonTagger"+typeFix+postfix)
33  if cleaningScheme in ["bad","computeAllApplyBad"]:
34  badMuonCollection = 'badGlobalMuonTagger'+typeFix+postfix+':bad'
35  if cleaningScheme in ["clone","duplicated","all","computeAllApplyBad","computeAllApplyClone"]:
36  setattr(process, 'cloneGlobalMuonTagger'+typeFix+postfix, cloneMuModule.clone() )
37  sequence +=getattr(process,"cloneGlobalMuonTagger"+typeFix+postfix)
38  if cleaningScheme in ["clone","duplicated","computeAllApplyClone"]:
39  badMuonCollection = 'cloneGlobalMuonTagger'+typeFix+postfix+':bad'
40 
41  if cleaningScheme=="all":
42  badMuonCollection="badMuons"+postfix
43  badMuonProducer = cms.EDProducer(
44  "CandViewMerger",
45  src = cms.VInputTag(
46  cms.InputTag('badGlobalMuonTagger'+typeFix+postfix,'bad'),
47  cms.InputTag('cloneGlobalMuonTagger'+typeFix+postfix,'bad'),
48  )
49  )
50  setattr(process,badMuonCollection,badMuonProducer)
51  sequence +=getattr(process, badMuonCollection )
52  else:
53  badMuonCollection="badMuons"+postfix
54  badMuonModule = cms.EDFilter("CandViewSelector",
55  src = cms.InputTag(muonCollection),
56  cut = cms.string(selection)
57  )
58 
59  # now cleaning ================================
60  cleanedPFCandCollection=cleanCollName+postfix
61  if runOnMiniAOD:
62  cleanedPFCandProducer = cms.EDProducer("CandPtrProjector",
63  src = cms.InputTag(pfCandCollection),
64  veto = cms.InputTag(badMuonCollection)
65  )
66  else:
67  cleanedPFCandProducer = cms.EDProducer("PFCandPtrProjector",
68  src = cms.InputTag(pfCandCollection),
69  veto = cms.InputTag(badMuonCollection)
70  )
71  #pfCandTmpPtrs = cms.EDProducer("PFCandidateFwdPtrProducer",
72  # src = cms.InputTag(pfCandCollection)
73  # )
74  #muonTmpPtrs = cms.EDProducer("PFCandidateFwdPtrProducer",
75  # src = cms.InputTag(badMuonCollection)
76  # )
77  #setattr(process,"candPtrTmp"+postfix,pfCandTmpPtrs)
78  #setattr(process,"muonPtrTmp"+postfix,muonTmpPtrs)
79  #cleanedPFCandProducer = cms.EDProducer(
80  # "TPPFCandidatesOnPFCandidates",
81  # enable = cms.bool( True ),
82  # verbose = cms.untracked.bool( False ),
83  # name = cms.untracked.string(""),
84  # topCollection = cms.InputTag(pfCandCollection),
85  # bottomCollection = cms.InputTag(badMuonCollection),
86  # )
87 
88  setattr(process,cleanedPFCandCollection,cleanedPFCandProducer)
89  sequence +=getattr(process, cleanedPFCandCollection )
90 
91  return sequence