CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SUSY_pattuple_cff.py
Go to the documentation of this file.
1 #
2 # SUSY-PAT configuration fragment
3 #
4 # PAT configuration for the SUSY group - 53X series
5 # More information here:
6 # https://twiki.cern.ch/twiki/bin/view/CMS/SusyPatLayer1DefV12
7 #test
8 
9 
10 import FWCore.ParameterSet.Config as cms
11 
12 def addDefaultSUSYPAT(process,mcInfo=True,HLTMenu='HLT',jetMetCorrections=['L2Relative', 'L3Absolute'],mcVersion='',theJetNames = ['AK5PF'],doValidation=False,extMatch=False,doSusyTopProjection=False,doType1MetCorrection=True,doType0MetCorrection=False):
13  loadPF2PAT(process,mcInfo,jetMetCorrections,extMatch,doSusyTopProjection,doType1MetCorrection,doType0MetCorrection,'PF')
14  addTagInfos(process,jetMetCorrections)
15  if not mcInfo:
16  removeMCDependence(process)
17  loadPAT(process,jetMetCorrections,extMatch)
18  addJetMET(process,theJetNames,jetMetCorrections,mcVersion)
19  # loadType1METSequence(process) # defines process.Type1METSequence
20  # loadPATTriggers(process,HLTMenu,theJetNames,electronMatches,muonMatches,tauMatches,jetMatches,photonMatches)
21 
22  #-- Counter for the number of processed events --------------------------------
23  process.eventCountProducer = cms.EDProducer("EventCountProducer")
24 
25  # Full path
26  #process.load('RecoTauTag.Configuration.RecoPFTauTag_cff')
27  process.susyPatDefaultSequence = cms.Sequence( process.eventCountProducer
28  # * process.PFTau
29  # * process.Type1METSequence
30  * process.patPF2PATSequence
31  * process.patPF2PATSequencePF
32  )
33 
34  if mcInfo and extMatch:
35  extensiveMatching(process)
36  process.susyPatDefaultSequence.replace(process.patDefaultSequence, process.extensiveMatching+process.patDefaultSequence)
37 
38  if doValidation:
39  loadSusyValidation(process)
40  process.susyPatDefaultSequence.replace(process.patPF2PATSequencePF, process.patPF2PATSequencePF * process.ak5CaloJetsL2L3 * process.metJESCorAK5CaloJet * process.RecoSusyValidation * process.PatSusyValidation*process.MEtoEDMConverter)
41 
42 def extensiveMatching(process):
43  process.load("SimGeneral.TrackingAnalysis.trackingParticlesNoSimHits_cfi") # On RECO
44  process.load("SimMuon.MCTruth.MuonAssociatorByHits_cfi") # On RECO
45  process.mergedTruth = cms.EDProducer("GenPlusSimParticleProducer",
46  src = cms.InputTag("g4SimHits"), # use "famosSimHits" for FAMOS
47  setStatus = cms.int32(5), # set status = 8 for GEANT GPs
48  filter = cms.vstring("pt > 0.0"), # just for testing (optional)
49  genParticles = cms.InputTag("genParticles") # original genParticle list
50  )
51  process.load("MuonAnalysis.MuonAssociators.muonClassificationByHits_cfi")
52 
53  from MuonAnalysis.MuonAssociators.muonClassificationByHits_cfi import addUserData as addClassByHits
54  addClassByHits(process.patMuons,labels=['classByHitsGlb'],extraInfo=True)
55  addClassByHits(process.patMuonsPF,labels=['classByHitsGlb'],extraInfo=True)
56 
57  process.extensiveMatching = cms.Sequence(process.mergedTruth+process.muonClassificationByHits)
58 
59 def loadPAT(process,jetMetCorrections,extMatch):
60  #-- Changes for electron and photon ID ----------------------------------------
61  from PhysicsTools.PatAlgos.tools.pfTools import usePFIso
62  usePFIso( process )
63  process.patElectrons.isolationValues = cms.PSet(
64  pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral03PFIdPFIso"),
65  pfChargedAll = cms.InputTag("elPFIsoValueChargedAll03PFIdPFIso"),
66  pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU03PFIdPFIso"),
67  pfPhotons = cms.InputTag("elPFIsoValueGamma03PFIdPFIso"),
68  pfChargedHadrons = cms.InputTag("elPFIsoValueCharged03PFIdPFIso")
69  )
70  process.patElectrons.isolationValuesNoPFId = cms.PSet(
71  pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral03NoPFIdPFIso"),
72  pfChargedAll = cms.InputTag("elPFIsoValueChargedAll03NoPFIdPFIso"),
73  pfPUChargedHadrons = cms.InputTag("elPFIsoValuePU03NoPFIdPFIso"),
74  pfPhotons = cms.InputTag("elPFIsoValueGamma03NoPFIdPFIso"),
75  pfChargedHadrons = cms.InputTag("elPFIsoValueCharged03NoPFIdPFIso")
76  )
77  process.patDefaultSequence.replace(process.patElectrons,process.eleIsoSequence+process.patElectrons)
78  process.patDefaultSequence.replace(process.patMuons,process.muIsoSequence+process.patMuons)
79 
80  # Turn off photon-electron cleaning (i.e., flag only)
81  process.cleanPatPhotons.checkOverlaps.electrons.requireNoOverlaps = False
82 
83  # Embed tracks, since we drop them
84  process.patElectrons.embedTrack = True
85  process.patMuons.embedTrack = True
86 
87  #include tau decay mode in pat::Taus (elese it will just be uninitialized)
88  #decay modes are dropped and have to be redone, this is a bit dangorous since the decay modes insered are *not* the ones used in RECO
89  #process.patTaus.addDecayMode = True
90  #process.makePatTaus.replace( process.patTaus, process.shrinkingConePFTauDecayModeProducer + process.patTaus )
91 
92  #Additional electron ids as defined for VBTF
93  process.load("ElectroWeakAnalysis.WENu.simpleEleIdSequence_cff")
94  process.patElectrons.electronIDSources = cms.PSet(
95  eidTight = cms.InputTag("eidTight"),
96  eidLoose = cms.InputTag("eidLoose"),
97  eidRobustTight = cms.InputTag("eidRobustTight"),
98  eidRobustHighEnergy = cms.InputTag("eidRobustHighEnergy"),
99  eidRobustLoose = cms.InputTag("eidRobustLoose"),
100  simpleEleId95relIso= cms.InputTag("simpleEleId95relIso"),
101  simpleEleId90relIso= cms.InputTag("simpleEleId90relIso"),
102  simpleEleId85relIso= cms.InputTag("simpleEleId85relIso"),
103  simpleEleId80relIso= cms.InputTag("simpleEleId80relIso"),
104  simpleEleId70relIso= cms.InputTag("simpleEleId70relIso"),
105  simpleEleId60relIso= cms.InputTag("simpleEleId60relIso"),
106  simpleEleId95cIso= cms.InputTag("simpleEleId95cIso"),
107  simpleEleId90cIso= cms.InputTag("simpleEleId90cIso"),
108  simpleEleId85cIso= cms.InputTag("simpleEleId85cIso"),
109  simpleEleId80cIso= cms.InputTag("simpleEleId80cIso"),
110  simpleEleId70cIso= cms.InputTag("simpleEleId70cIso"),
111  simpleEleId60cIso= cms.InputTag("simpleEleId60cIso"))
112  process.patDefaultSequence.replace(process.patElectrons,process.simpleEleIdSequence+process.patElectrons)
113 
114  #-- Tuning of Monte Carlo matching --------------------------------------------
115  # Also match with leptons of opposite charge
116  process.electronMatch.checkCharge = False
117  process.electronMatch.maxDeltaR = cms.double(0.2)
118  process.electronMatch.maxDPtRel = cms.double(999999.)
119  process.muonMatch.checkCharge = False
120  process.muonMatch.maxDeltaR = cms.double(0.2)
121  process.muonMatch.maxDPtRel = cms.double(999999.)
122  #process.tauMatch.checkCharge = False
123  #process.tauMatch.maxDeltaR = cms.double(0.3)
124  process.patJetPartonMatch.maxDeltaR = cms.double(0.25)
125  process.patJetPartonMatch.maxDPtRel = cms.double(999999.)
126  process.patJetGenJetMatch.maxDeltaR = cms.double(0.25)
127  process.patJetGenJetMatch.maxDPtRel = cms.double(999999.)
128  if extMatch:
129  process.electronMatch.mcStatus = cms.vint32(1,5)
130  process.electronMatch.matched = "mergedTruth"
131  process.muonMatch.mcStatus = cms.vint32(1,5)
132  process.muonMatch.matched = "mergedTruth"
133  process.patJetPartonMatch.matched = "mergedTruth"
134  process.patJetPartons.src = "mergedTruth"
135  process.photonMatch.matched = "mergedTruth"
136  #process.tauGenJets.GenParticles = "mergedTruth"
137  #process.tauMatch.matched = "mergedTruth"
138 
139 
140  #-- Taus ----------------------------------------------------------------------
141  #some tau discriminators have been switched off during development. They can be switched on again...
142  #setattr(process.patTaus.tauIDSources, "trackIsolation", cms.InputTag("shrinkingConePFTauDiscriminationByTrackIsolation"))
143  #setattr(process.patTaus.tauIDSources, "ecalIsolation", cms.InputTag("shrinkingConePFTauDiscriminationByECALIsolation"))
144  #setattr(process.patTaus.tauIDSources, "byIsolation", cms.InputTag("shrinkingConePFTauDiscriminationByIsolation"))
145  #setattr(process.patTaus.tauIDSources, "leadingPionPtCut", cms.InputTag("shrinkingConePFTauDiscriminationByLeadingPionPtCut"))
146  #setattr(process.patTaus.tauIDSources, "trackIsolationUsingLeadingPion", cms.InputTag("shrinkingConePFTauDiscriminationByTrackIsolationUsingLeadingPion"))
147  #setattr(process.patTaus.tauIDSources, "ecalIsolationUsingLeadingPion", cms.InputTag("shrinkingConePFTauDiscriminationByECALIsolationUsingLeadingPion"))
148  #setattr(process.patTaus.tauIDSources, "byIsolationUsingLeadingPion", cms.InputTag("shrinkingConePFTauDiscriminationByIsolationUsingLeadingPion"))
149  #setattr(process.patTaus.tauIDSources, "byTaNC", cms.InputTag("shrinkingConePFTauDiscriminationByTaNC"))
150  #setattr(process.patTaus.tauIDSources, "byTaNCfrOnePercent", cms.InputTag("shrinkingConePFTauDiscriminationByTaNCfrOnePercent"))
151  #setattr(process.patTaus.tauIDSources, "byTaNCfrHalfPercent", cms.InputTag("shrinkingConePFTauDiscriminationByTaNCfrHalfPercent"))
152  #setattr(process.patTaus.tauIDSources, "byTaNCfrQuarterPercent", cms.InputTag("shrinkingConePFTauDiscriminationByTaNCfrQuarterPercent"))
153  #setattr(process.patTaus.tauIDSources, "byTaNCfrTenthPercent", cms.InputTag("shrinkingConePFTauDiscriminationByTaNCfrTenthPercent"))
154 
155 
156  #-- Jet corrections -----------------------------------------------------------
157  # L1 FastJet jet corrections
158  # kt6PFJets for FastJet corrections are already run and placed before jetCorrection calculation
159  # apply FastJet corrections only if demanded
160  # TODO: Check if still necessary to switch here
161  if ("L1FastJet" in jetMetCorrections):
162  process.pfJets.doAreaFastjet = True
163  process.pfJetsPF.doAreaFastjet = True
164 
165 def loadPF2PAT(process,mcInfo,jetMetCorrections,extMatch,doSusyTopProjection,doType1MetCorrection,doType0MetCorrection,postfix):
166  #-- PAT standard config -------------------------------------------------------
167  process.load("PhysicsTools.PatAlgos.patSequences_cff")
168  #-- Jet corrections -----------------------------------------------------------
169  process.patJetCorrFactors.levels = jetMetCorrections
170  #-- PF2PAT config -------------------------------------------------------------
171  from PhysicsTools.PatAlgos.tools.pfTools import usePF2PAT
172  usePF2PAT(process,runPF2PAT=True,
173  jetAlgo = 'AK5',
174  runOnMC = (mcInfo==1),
175  postfix = postfix,
176  jetCorrections = ('AK5PFchs', jetMetCorrections),
177  typeIMetCorrections = doType1MetCorrection)
178 
179  if doType0MetCorrection:
180  getattr(process,'patType1CorrectedPFMet'+postfix).srcType1Corrections = cms.VInputTag(
181  cms.InputTag("patPFJetMETtype1p2Corr"+postfix,"type1"),
182  cms.InputTag("patPFMETtype0Corr"+postfix)
183  )
184 
185 
186  #process.patJetsPF.embedGenJetMatch = False
187  #process.patJetsPF.embedPFCandidates = False
188  #drop tracks
189  process.patElectronsPF.embedTrack = True
190  process.patMuonsPF.embedTrack = True
191  process.electronMatchPF.maxDeltaR = cms.double(0.2)
192  process.electronMatchPF.maxDPtRel = cms.double(999999.)
193  process.electronMatchPF.checkCharge = False
194  process.muonMatchPF.maxDeltaR = cms.double(0.2)
195  process.muonMatchPF.maxDPtRel = cms.double(999999.)
196  process.muonMatchPF.checkCharge = False
197  if extMatch:
198  process.electronMatchPF.mcStatus = cms.vint32(1,5)
199  process.electronMatchPF.matched = "mergedTruth"
200  process.muonMatchPF.mcStatus = cms.vint32(1,5)
201  process.muonMatchPF.matched = "mergedTruth"
202  process.genParticlesForJets.src = "mergedTruth"
203  process.genParticlesForJetsNoMuNoNu.src = "mergedTruth"
204  process.genParticlesForJetsNoNu.src = "mergedTruth"
205  process.patJetPartonMatchPF.matched = "mergedTruth"
206  process.patJetPartonsPF.src = "mergedTruth"
207  process.photonMatchPF.matched = "mergedTruth"
208  #process.tauGenJetsPF.GenParticles = "mergedTruth"
209  #process.tauMatchPF.matched = "mergedTruth"
210 
211  #Remove jet pt cut
212  #process.pfJetsPF.ptMin = 0.
213  #include tau decay mode in pat::Taus (elese it will just be uninitialized)
214  #process.patTausPF.addDecayMode = True
215  #process.patTausPF.decayModeSrc = "shrinkingConePFTauDecayModeProducerPF"
216 
217  #Set isolation cone to 0.3 for PF leptons
218  # TODO: fix this for electrons and muons
219  #process.pfElectrons.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFId"))
220  #process.pfElectrons.deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFId")
221  #process.pfElectrons.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("elPFIsoValueNeutral03PFId"), cms.InputTag("elPFIsoValueGamma03PFId"))
222  #process.pfIsolatedElectrons.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFId"))
223  #process.pfIsolatedElectrons.deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFId")
224  #process.pfIsolatedElectrons.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("elPFIsoValueNeutral03PFId"), cms.InputTag("elPFIsoValueGamma03PFId"))
225 
226  #process.pfElectronsPF.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFIdPF"))
227  #process.pfElectronsPF.deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFIdPF")
228  #process.pfElectronsPF.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("elPFIsoValueNeutral03PFIdPF"), cms.InputTag("elPFIsoValueGamma03PFIdPF"))
229  #process.pfIsolatedElectronsPF.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("elPFIsoValueCharged03PFIdPF"))
230  #process.pfIsolatedElectronsPF.deltaBetaIsolationValueMap = cms.InputTag("elPFIsoValuePU03PFIdPF")
231  #process.pfIsolatedElectronsPF.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("elPFIsoValueNeutral03PFIdPF"), cms.InputTag("elPFIsoValueGamma03PFIdPF"))
232 
233  #process.pfMuons.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("muPFIsoValueCharged03mu03"))
234  #process.pfMuons.deltaBetaIsolationValueMap = cms.InputTag("muPFIsoValuePU03")
235  #process.pfMuons.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("muPFIsoValueNeutral03"), cms.InputTag("muPFIsoValueGamma03"))
236  #process.pfIsolatedMuons.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("muPFIsoValueCharged03mu03"))
237  #process.pfIsolatedMuons.deltaBetaIsolationValueMap = cms.InputTag("muPFIsoValuePU03")
238  #process.pfIsolatedMuons.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("muPFIsoValueNeutral03"), cms.InputTag("muPFIsoValueGamma03"))
239 
240  #process.pfMuonsPF.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("muPFIsoValueCharged03mu03PF"))
241  #process.pfMuonsPF.deltaBetaIsolationValueMap = cms.InputTag("muPFIsoValuePU03PF")
242  #process.pfMuonsPF.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("muPFIsoValueNeutral03PF"), cms.InputTag("muPFIsoValueGamma03PF"))
243  #process.pfIsolatedMuonsPF.isolationValueMapsCharged = cms.VInputTag(cms.InputTag("muPFIsoValueCharged03mu03PF"))
244  #process.pfIsolatedMuonsPF.deltaBetaIsolationValueMap = cms.InputTag("muPFIsoValuePU03PF")
245  #process.pfIsolatedMuonsPF.isolationValueMapsNeutral = cms.VInputTag(cms.InputTag("muPFIsoValueNeutral03PF"), cms.InputTag("muPFIsoValueGamma03PF"))
246 
247  #-- Enable pileup sequence -------------------------------------------------------------
248  #Vertices
249  process.goodVertices = cms.EDFilter("VertexSelector",
250  src = cms.InputTag("offlinePrimaryVertices"),
251  cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
252  filter = cms.bool(False),
253  )
254 
255  process.pfPileUpPF.Vertices = "goodVertices"
256  process.pfPileUpPF.Enable = True
257 
258  process.pfNoPileUpSequencePF.replace(process.pfPileUpPF,
259  process.goodVertices + process.pfPileUpPF)
260 
261  if not doSusyTopProjection:
262  return
263  #-- Top projection selection -----------------------------------------------------------
264  #Electrons
265  #relax all selectors *before* pat-lepton creation
266  process.pfElectronsFromVertexPF.dzCut = 9999.0
267  process.pfElectronsFromVertexPF.d0Cut = 9999.0
268  process.pfSelectedElectronsPF.cut = ""
269  process.pfRelaxedElectronsPF = process.pfIsolatedElectronsPF.clone(isolationCut = 3.)
270  process.pfIsolatedElectronsPF.isolationCut = 0.15
271 
272  process.pfElectronsFromGoodVertex = cms.EDFilter(
273  "IPCutPFCandidateSelector",
274  src = cms.InputTag("pfIsolatedElectronsPF"), # PFCandidate source
275  vertices = cms.InputTag("goodVertices"), # vertices source
276  d0Cut = cms.double(0.04), # transverse IP
277  dzCut = cms.double(1.), # longitudinal IP
278  d0SigCut = cms.double(99.), # transverse IP significance
279  dzSigCut = cms.double(99.), # longitudinal IP significance
280  )
281 
282  electronSelection = "abs( eta ) < 2.5 & pt > 5"
283  electronSelection += " & mva_e_pi > 0.4" # same as patElectron::mva()
284  #electronSelection += " & (isEB & (sigmaIetaIeta < 0.024 & hadronicOverEm < 0.15) | isEE & (sigmaIetaIeta < 0.040 & hadronicOverEm < 0.10))" #caloIdVL
285  #electronSelection += " & (isEB & (deltaPhiSuperClusterTrackAtVtx < 0.15 & deltaEtaSuperClusterTrackAtVtx < 0.01) | isEE & (deltaPhiSuperClusterTrackAtVtx < 0.10 & deltaEtaSuperClusterTrackAtVtx < 0.01))" #trkIdVL
286  electronSelection += " & gsfTrackRef().isNonnull() & gsfTrackRef().trackerExpectedHitsInner().numberOfHits() <= 0"
287  process.pfUnclusteredElectronsPF = cms.EDFilter( "GenericPFCandidateSelector",
288  src = cms.InputTag("pfElectronsFromGoodVertex"), #pfSelectedElectronsPF
289  cut = cms.string(electronSelection)
290  )
291  process.pfElectronSequencePF.replace(process.pfIsolatedElectronsPF,
292  process.pfIsolatedElectronsPF +
293  process.goodVertices * process.pfElectronsFromGoodVertex +
294  process.pfUnclusteredElectronsPF + process.pfRelaxedElectronsPF)
295  process.patElectronsPF.pfElectronSource = "pfRelaxedElectronsPF"
296  process.pfNoElectronPF.topCollection = "pfUnclusteredElectronsPF"
297  #Muons
298  #relaxe built-in preselection
299  process.pfMuonsFromVertexPF.dzCut = 9999.0
300  process.pfMuonsFromVertexPF.d0Cut = 9999.0
301  process.pfSelectedMuonsPF.cut = ""
302  process.pfRelaxedMuonsPF = process.pfIsolatedMuonsPF.clone(isolationCut = 3)
303  process.pfIsolatedMuonsPF.isolationCut = 0.15
304 
305  process.pfMuonsFromGoodVertex = cms.EDFilter(
306  "IPCutPFCandidateSelector",
307  src = cms.InputTag("pfIsolatedMuonsPF"), # PFCandidate source
308  vertices = cms.InputTag("goodVertices"), # vertices source
309  d0Cut = cms.double(0.02), # transverse IP
310  dzCut = cms.double(1.), # longitudinal IP
311  d0SigCut = cms.double(99.), # transverse IP significance
312  dzSigCut = cms.double(99.), # longitudinal IP significance
313  )
314  muonSelection = "abs( eta ) < 2.5 & pt > 5"
315  #GlobalMuonPromptTight
316  muonSelection += " & muonRef().isNonnull & muonRef().isGlobalMuon()"
317  muonSelection += " & muonRef().isTrackerMuon() & muonRef().numberOfMatches > 1"
318  muonSelection += " & muonRef().globalTrack().normalizedChi2() < 10"
319  muonSelection += " & muonRef().track().numberOfValidHits() > 10"
320  muonSelection += " & muonRef().globalTrack().hitPattern().numberOfValidMuonHits() > 0"
321  muonSelection += " & muonRef().innerTrack().hitPattern().numberOfValidPixelHits() > 0"
322  process.pfUnclusteredMuonsPF = cms.EDFilter( "GenericPFCandidateSelector",
323  src = cms.InputTag("pfMuonsFromGoodVertex"), #pfSelectedMuonsPF
324  cut = cms.string(muonSelection)
325  )
326  process.pfMuonSequencePF.replace(process.pfIsolatedMuonsPF,
327  process.pfIsolatedMuonsPF +
328  process.goodVertices * process.pfMuonsFromGoodVertex +
329  process.pfUnclusteredMuonsPF + process.pfRelaxedMuonsPF)
330  process.patMuonsPF.pfMuonSource = "pfRelaxedMuonsPF"
331  process.pfNoMuonPF.topCollection = "pfUnclusteredMuonsPF"
332  #Taus
333  # TODO: Fix taus in 52X
334  #process.pfTausPF.discriminators = cms.VPSet()
335  #process.pfUnclusteredTausPF = process.pfTausPF.clone(
336  # cut = cms.string("pt < 0")
337  #)
338  #process.pfTauSequencePF.replace(process.pfTausPF, process.pfTausPF+ process.pfUnclusteredTausPF)
339  #process.pfNoTauPF.topCollection = "pfUnclusteredTausPF"
340 
341 
342 def loadPATTriggers(process,HLTMenu,theJetNames,electronMatches,muonMatches,tauMatches,jetMatches,photonMatches):
343  #-- Trigger matching ----------------------------------------------------------
344  def pfSwitchOnTriggerMatchEmbedding(process, matches, src, embedder, sequence='patDefaultSequencePF'):
345  setattr(process,src.replace('PF','TriggerMatchPF'),getattr(process,embedder).clone(src=src, matches=matches))
346  theSequence = getattr(process,sequence)
347  theSequence += getattr(process,src.replace('PF','TriggerMatchPF'))
348  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTrigger, switchOnTriggerMatchEmbedding
349  switchOnTrigger(process, triggerProducer='patTrigger', triggerEventProducer='patTriggerEvent', sequence='patDefaultSequence', hltProcess=HLTMenu)
350  process.patTriggerPF = process.patTrigger.clone()
351  process.patTriggerEventPF = process.patTriggerEvent.clone()
352  process.patDefaultSequencePF += process.patTriggerPF
353  process.patDefaultSequencePF += process.patTriggerEventPF
354  switchOnTrigger(process, triggerProducer='patTriggerPF', triggerEventProducer='patTriggerEventPF', sequence='patDefaultSequencePF', hltProcess=HLTMenu)
355  #Electrons
356  from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi import cleanElectronTriggerMatchHLTEle20SWL1R
357  process.patElectronMatch = cleanElectronTriggerMatchHLTEle20SWL1R.clone(matchedCuts = cms.string( electronMatches ))
358  process.patElectronMatchPF = cleanElectronTriggerMatchHLTEle20SWL1R.clone(matchedCuts = cms.string( electronMatches ), src='selectedPatElectronsPF')
359  process.patDefaultSequencePF += process.patElectronMatchPF
360  switchOnTriggerMatchEmbedding( process, ['patElectronMatch'], hltProcess=HLTMenu)
361  pfSwitchOnTriggerMatchEmbedding( process, ['patElectronMatchPF'], 'selectedPatElectronsPF', 'cleanPatElectronsTriggerMatch' )
362  #Muons
363  from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi import cleanMuonTriggerMatchHLTMu9
364  process.patMuonMatch = cleanMuonTriggerMatchHLTMu9.clone(matchedCuts = cms.string( muonMatches ))
365  process.patMuonMatchPF = cleanMuonTriggerMatchHLTMu9.clone(matchedCuts = cms.string( muonMatches ),src = 'selectedPatMuonsPF',matched='patTriggerPF')
366  process.patDefaultSequencePF += process.patMuonMatchPF
367  switchOnTriggerMatchEmbedding( process, ['patMuonMatch'], hltProcess=HLTMenu)
368  pfSwitchOnTriggerMatchEmbedding( process, ['patMuonMatchPF'], 'selectedPatMuonsPF', 'cleanPatMuonsTriggerMatch' )
369  #Photons
370  from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi import cleanPhotonTriggerMatchHLTPhoton20CleanedL1R
371  process.patPhotonMatch = cleanPhotonTriggerMatchHLTPhoton20CleanedL1R.clone(matchedCuts = cms.string( photonMatches ))
372  switchOnTriggerMatchEmbedding( process, ['patPhotonMatch'], hltProcess=HLTMenu)
373  #Jets
374  from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi import cleanJetTriggerMatchHLTJet15U
375  process.patJetMatchAK5Calo = cleanJetTriggerMatchHLTJet15U.clone(matchedCuts = cms.string( jetMatches ),src='cleanPatJetsAK5Calo')
376  switchOnTriggerMatchEmbedding( process, ['patJetMatchAK5Calo'], hltProcess=HLTMenu)
377  for jetType in theJetNames:
378  setattr(process,'patJetMatch'+jetType,cleanJetTriggerMatchHLTJet15U.clone(matchedCuts = cms.string( jetMatches ),src = 'cleanPatJets'+jetType))
379  process.patJetMatchPF = cleanJetTriggerMatchHLTJet15U.clone(src='selectedPatJetsPF', matchedCuts = cms.string( jetMatches ))
380  process.patDefaultSequencePF += process.patJetMatchPF
381  for jetType in theJetNames:
382  switchOnTriggerMatchEmbedding( process, ['patJetMatch'+jetType], hltProcess=HLTMenu)
383  pfSwitchOnTriggerMatchEmbedding( process, ['patJetMatchPF'], 'selectedPatJetsPF', 'cleanPatJetsAK5CaloTriggerMatch' )
384  #Taus
385  from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi import cleanTauTriggerMatchHLTDoubleLooseIsoTau15
386  process.patTauMatch = cleanTauTriggerMatchHLTDoubleLooseIsoTau15.clone(matchedCuts = cms.string( tauMatches ))
387  process.patTauMatchPF = cleanTauTriggerMatchHLTDoubleLooseIsoTau15.clone(src='selectedPatTausPF', matchedCuts = cms.string( tauMatches ))
388  process.patDefaultSequencePF += process.patTauMatchPF
389  switchOnTriggerMatchEmbedding( process, ['patTauMatch'], hltProcess=HLTMenu)
390  pfSwitchOnTriggerMatchEmbedding( process, ['patTauMatchPF'], 'selectedPatTausPF', 'cleanPatTausTriggerMatch' )
391 
392 def loadType1METSequence(process):
393  process.load("JetMETCorrections.Type1MET.pfMETCorrections_cff")
394  ## Type 0?
395  # process.pfType1CorrectedMet.srcCHSSums = cms.VInputTag(cms.InputTag("pfchsMETcorr","type0"))
396  # process.pfType1CorrectedMet.applyType2Corrections = cms.bool(False)
397  # process.pfType1CorrectedMet.type0Rsoft = cms.double(0.6)
398  # process.pfType1CorrectedMet.applyType0Corrections = cms.bool(True)
399  process.Type1METSequence = cms.Sequence(process.producePFMETCorrections)
400 
401 
402 def addTypeIIMet(process) :
403  # Add reco::MET with Type II correction
404  from PhysicsTools.PatAlgos.recoLayer0.jetMETCorrections_cff import metJESCorAK5CaloJet
405  process.metJESCorAK5CaloJetTypeII = metJESCorAK5CaloJet.clone()
406  process.metJESCorAK5CaloJetTypeII.useTypeII = True
407  process.metJESCorAK5CaloJetTypeII.hasMuonsCorr = False
408  # Add muon corrections for above II reco::MET
409  process.metJESCorAK5CaloJetMuonsTypeII = process.metJESCorAK5CaloJetMuons.clone(
410  uncorMETInputTag = cms.InputTag('metJESCorAK5CaloJetTypeII')
411  )
412  # Add to recoLayer0 sequence
413  process.patMETCorrections.replace(
414  process.metJESCorAK5CaloJet,
415  (process.metJESCorAK5CaloJetTypeII*
416  process.metJESCorAK5CaloJetMuonsTypeII)+
417  process.metJESCorAK5CaloJet
418  )
419  # Add pat::MET with Type II correction
420  process.patMETsAK5CaloTypeII = process.patMETs.clone(
421  metSource = cms.InputTag("metJESCorAK5CaloJetMuonsTypeII")
422  )
423  # Add to producersLayer1 sequence
424  process.patDefaultSequence.replace(
425  process.patMETsAK5Calo,
426  process.patMETsAK5Calo+
427  process.patMETsAK5CaloTypeII
428  )
429 
430 def addTagInfos(process,jetMetCorrections):
431  from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection
432  switchJetCollection( process,
433  jetCollection=cms.InputTag('ak5CaloJets'),
434  jetCorrLabel=('AK5Calo', jetMetCorrections))
435 
436 def addSUSYJetCollection(process,jetMetCorrections,jets = 'IC5Calo',mcVersion='',doJTA=True,doType1MET=True,doJetID=True,jetIdLabel=None):
437  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
438  algorithm = jets[0:3]
439  type = jets[3:len(jets)]
440  jetCorrLabel = (jets,cms.vstring(jetMetCorrections))
441  if 'IC' in algorithm: collection = algorithm.replace('IC','iterativeCone')
442  elif 'SC' in algorithm: collection = algorithm.replace('SC','sisCone')
443  elif 'AK' in algorithm: collection = algorithm.replace('AK','ak')
444  elif 'KT' in algorithm: collection = algorithm.replace('KT','kt')
445  else: raise ValueError, "Unknown jet algorithm: %s" % (jets)
446  jetIdLabel = algorithm.lower()
447  if type == 'Calo':
448  jetCollection = '%(collection)sCaloJets' % locals()
449  if not 'AK7' in algorithm:
450  doType1MET = True
451  elif type == 'PF':
452  jetCollection = '%(collection)sPFJets' % locals()
453  doJetID = False
454  elif type == 'JPT':
455  if 'IC' in algorithm: collectionJPT = algorithm.replace('IC','Icone')
456  elif 'SC' in algorithm: collectionJPT = algorithm.replace('SC','Siscone')
457  elif 'AK' in algorithm: collectionJPT = algorithm.replace('AK','AntiKt')
458  else: raise ValueError, "Unknown jet algorithm: %s" % (jets)
459  jetCollection = 'JetPlusTrackZSPCorJet%(collectionJPT)s' % locals()
460  elif type == 'Track':
461  jetCollection = '%(collection)sTrackJets' % locals()
462  jetCorrLabel = None
463  doJetID = False
464  else: raise ValueError, "Unknown jet type: %s" % (jets)
465 
466  addJetCollection(process, cms.InputTag(jetCollection),
467  algorithm, type,
468  doJTA = doJTA,
469  doBTagging = True,
470  jetCorrLabel = jetCorrLabel,
471  doType1MET = doType1MET,
472  doL1Cleaning = True,
473  doL1Counters = True,
474  doJetID = doJetID,
475  jetIdLabel = jetIdLabel,
476  genJetCollection = cms.InputTag('%(collection)sGenJets' % locals())
477  )
478 
479 def addJetMET(process,theJetNames,jetMetCorrections,mcVersion):
480  #-- Extra Jet/MET collections -------------------------------------------------
481  # Add a few jet collections...
482  for jetName in theJetNames:
483  addSUSYJetCollection(process,jetMetCorrections,jetName,mcVersion)
484 
485  #-- Tune contents of jet collections -----------------------------------------
486  theJetNames.append('')
487  for jetName in theJetNames:
488  module = getattr(process,'patJets'+jetName)
489  module.addTagInfos = False # Remove tag infos
490  module.embedGenJetMatch = False # Only keep reference, since we anyway keep the genJet collections
491  #module.embedCaloTowers = True # To drop calo towers
492  theJetNames.pop()
493 
494  # Add tcMET
495  from PhysicsTools.PatAlgos.tools.metTools import addTcMET #, addPfMET
496  addTcMET(process,'TC')
497  #addPfMET(process,'PF') #is in PF2PAT
498 
499  # Rename default jet collection for uniformity
500  process.cleanPatJetsAK5Calo = process.cleanPatJets
501  process.patMETsAK5Calo = process.patMETs
502 
503  # TODO: fix type2 MET in 52X
504  #addTypeIIMet(process)
505 
506  # Modify subsequent modules
507  process.patHemispheres.patJets = process.cleanPatJetsAK5Calo.label()
508  process.countPatJets.src = process.cleanPatJetsAK5Calo.label()
509 
510  # Modify counters' input
511  process.patCandidateSummary.candidates.remove(cms.InputTag('patMETs'))
512  process.patCandidateSummary.candidates.append(cms.InputTag('patMETsAK5Calo'))
513  process.patCandidateSummary.candidates.append(cms.InputTag('patMHTsAK5Calo'))
514  process.cleanPatCandidateSummary.candidates.remove(cms.InputTag('cleanPatJets'))
515  process.cleanPatCandidateSummary.candidates.append(cms.InputTag('cleanPatJetsAK5Calo'))
516  # Add new jet collections to counters (MET done automatically)
517  for jets in theJetNames:
518  process.patCandidateSummary.candidates.append(cms.InputTag('patJets'+jets))
519  process.selectedPatCandidateSummary.candidates.append(cms.InputTag('selectedPatJets'+jets))
520  process.cleanPatCandidateSummary.candidates.append(cms.InputTag('cleanPatJets'+jets))
521 
522 def removeMCDependence( process ):
523  #-- Remove MC dependence ------------------------------------------------------
524  from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching
525  removeMCMatching(process, ['All'])
526 
527 def loadSusyValidation(process):
528  process.load("JetMETCorrections.Configuration.JetCorrectionProducers_cff")
529  process.load("DQM.Physics.susyValidation_cfi")
530  process.load("DQMServices.Components.MEtoEDMConverter_cfi")
531  process.load("DQMServices.Core.DQM_cfg")
532  process.load("DQMServices.Components.DQMEnvironment_cfi")
533  process.DQMStore = cms.Service("DQMStore")
534  process.DQMStore.collateHistograms = cms.untracked.bool(True)
535  process.options = cms.untracked.PSet(
536  fileMode = cms.untracked.string('NOMERGE')
537  )
538 
540  from PhysicsTools.PatAlgos.patEventContent_cff import patEventContent, patExtraAodEventContent, patTriggerEventContent, patTriggerStandAloneEventContent, patEventContentTriggerMatch
541  keepList = []
542  susyAddEventContent = [ # PAT Objects
543  #'keep *_triggerMatched*_*_*',
544  # Keep PF2PAT output
545  'keep *_selectedPatMuonsPF_*_*',
546  'keep *_selectedPatElectronsPF_*_*',
547  'keep *_selectedPatTausPF_*_*',
548  'keep *_selectedPatJetsPF_*_*',
549  #L1 trigger info
550  'keep L1GlobalTriggerObjectMapRecord_*_*_*',
551  'keep L1GlobalTriggerReadoutRecord_*_*_*',
552  # Generator information
553  'keep recoGenJets_*GenJets*_*_*',
554  'keep recoGenMETs_*_*_*',
555  #Number of processed events
556  'keep edmMergeableCounter_eventCountProducer_*_*',
557  'keep recoRecoChargedRefCandidates_trackRefsForJets_*_*',
558  #'keep recoTrackJets_ak5TrackJets_*_*',
559  'keep *_electronMergedSeeds_*_*',
560  'keep *_Conversions_*_*',
561  'keep recoPFCandidates_particleFlow_*_*',
562  #'keep recoSuperClusters_corrected*_*_*',
563  #'keep recoSuperClusters_pfElectronTranslator_*_*',
564  #'keep *_gsfElectronCores_*_*', #Keep electron core
565  #'keep *_photonCore_*_*', #Keep electron core
566  'keep recoConversions_conversions_*_*',
567  'keep recoTracks_*onversions_*_*',
568  'keep HcalNoiseSummary_*_*_*', #Keep the one in RECO
569  'keep *BeamHaloSummary_*_*_*',
570  # Keep Gap Vertices for comparison
571  'keep *_offlinePrimaryVerticesGap_*_*',
572  'keep *_offlinePrimaryVerticesGapWithBS_*_*',
573  #DQM
574  'keep *_MEtoEDMConverter_*_PAT',
575  'drop recoTracks_generalTracks*_*_*',
576  'drop *_towerMaker_*_*',
577  'keep *_pfType1CorrectedMet*_*_*',
578  ]
579  keepList.extend(patEventContent)
580  keepList.extend(patExtraAodEventContent)
581  keepList.extend(patTriggerEventContent)
582  keepList.extend(patEventContentTriggerMatch)
583  keepList.extend(susyAddEventContent)
584  return keepList
585 
def usePF2PAT
Definition: pfTools.py:536
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
tuple switchOnTriggerMatchEmbedding
Definition: trigTools.py:720
tuple switchOnTrigger
Definition: trigTools.py:197
def usePFIso
Definition: pfTools.py:89