CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
miniAOD_tools.py
Go to the documentation of this file.
2 
4 
6  process.patMuons.isoDeposits = cms.PSet()
7  process.patElectrons.isoDeposits = cms.PSet()
8  process.patTaus.isoDeposits = cms.PSet()
9  process.patPhotons.isoDeposits = cms.PSet()
10  #
11  process.patMuons.embedTrack = True # used for IDs
12  process.patMuons.embedCombinedMuon = True # used for IDs
13  process.patMuons.embedMuonBestTrack = True # used for IDs
14  process.patMuons.embedStandAloneMuon = True # maybe?
15  process.patMuons.embedPickyMuon = False # no, use best track
16  process.patMuons.embedTpfmsMuon = False # no, use best track
17  process.patMuons.embedDytMuon = False # no, use best track
18  #
19  # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer
20  process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core
21  process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
22  process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster
23  process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster
24  process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters
25  process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters
26  process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters
27  process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters
28  process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer
29  process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
30  process.patElectrons.electronIDSources = cms.PSet(
31  # configure many IDs as InputTag <someName> = <someTag> you
32  # can comment out those you don't want to save some disk space
33  eidRobustLoose = cms.InputTag("reducedEgamma","eidRobustLoose"),
34  eidRobustTight = cms.InputTag("reducedEgamma","eidRobustTight"),
35  eidLoose = cms.InputTag("reducedEgamma","eidLoose"),
36  eidTight = cms.InputTag("reducedEgamma","eidTight"),
37  eidRobustHighEnergy = cms.InputTag("reducedEgamma","eidRobustHighEnergy"),
38  )
39  process.patElectrons.addPFClusterIso = cms.bool(True)
40  process.patElectrons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso")
41  process.patElectrons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso")
42 
43  process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
44  process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
45  process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
46  process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
47  process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
48  #
49  process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster
50  process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster
51  process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters
52  process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters
53  process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer
54  process.patPhotons.addPFClusterIso = cms.bool(True)
55  process.patPhotons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso")
56  process.patPhotons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso")
57  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
58  process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
59  process.patPhotons.photonIDSources = cms.PSet(
60  PhotonCutBasedIDLoose = cms.InputTag('reducedEgamma',
61  'PhotonCutBasedIDLoose'),
62  PhotonCutBasedIDTight = cms.InputTag('reducedEgamma',
63  'PhotonCutBasedIDTight')
64  )
65 
66  process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
67  process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
68  process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
69  process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
70  process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
71  #
72  process.selectedPatJets.cut = cms.string("pt > 10")
73  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
74  process.selectedPatElectrons.cut = cms.string("")
75  process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5")
76  process.selectedPatPhotons.cut = cms.string("")
77 
78  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
79 
80  from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
81  applySubstructure( process )
82 
83 
84  #
85  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
86  switchOnTriggerStandAlone( process, outputModule = '' )
87  process.patTrigger.packTriggerPathNames = cms.bool(True)
88  #
89  # apply type I/type I + II PFMEt corrections to pat::MET object
90  # and estimate systematic uncertainties on MET
91  # FIXME: are we 100% sure this should still be PF and not PFchs?
92  from PhysicsTools.PatUtils.tools.runType1PFMEtUncertainties import runType1PFMEtUncertainties
93  addJetCollection(process, postfix = "ForMetUnc", labelName = 'AK4PF', jetSource = cms.InputTag('ak4PFJets'), jetCorrections = ('AK4PF', ['L1FastJet', 'L2Relative', 'L3Absolute'], ''))
94  process.patJetsAK4PFForMetUnc.getJetMCFlavour = False
96  addToPatDefaultSequence=False,
97  jetCollectionUnskimmed="patJetsAK4PFForMetUnc",
98  jetCollection="selectedPatJetsAK4PFForMetUnc",
99  electronCollection="selectedPatElectrons",
100  muonCollection="selectedPatMuons",
101  tauCollection="selectedPatTaus",
102  makeType1p2corrPFMEt=True,
103  doSmearJets=False,
104  outputModule=None)
105 
106  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
107  addMETCollection(process,
108  labelName = "patCaloMet",
109  metSource = "caloMetM"
110  )
111 
112 
113  #keep this after all addJetCollections otherwise it will attempt computing them also for stuf with no taginfos
114  #Some useful BTAG vars
115  process.patJets.userData.userFunctions = cms.vstring(
116  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.M):(0)',
117  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).numberOfSourceCandidatePtrs):(0)',
118  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").flightDistance(0).value):(0)',
119  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").flightDistance(0).significance):(0)',
120  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.x):(0)',
121  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.y):(0)',
122  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.z):(0)',
123  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.x):(0)',
124  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.y):(0)',
125  '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.z):(0)',
126  )
127  process.patJets.userData.userFunctionLabels = cms.vstring('vtxMass','vtxNtracks','vtx3DVal','vtx3DSig','vtxPx','vtxPy','vtxPz','vtxPosX','vtxPosY','vtxPosZ')
128  process.patJets.tagInfoSources = cms.VInputTag(cms.InputTag("pfSecondaryVertexTagInfos"))
129  process.patJets.addTagInfos = cms.bool(True)
130  #
131  ## PU JetID
132  process.load("PhysicsTools.PatAlgos.slimming.pileupJetId_cfi")
133  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
134 
135  ## CaloJets
136  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
137  src = process.patJets.jetSource,
138  matched = cms.InputTag("ak4CaloJets"),
139  distMax = cms.double(0.4),
140  values = cms.vstring('pt','emEnergyFraction'),
141  valueLabels = cms.vstring('pt','emEnergyFraction'),
142  lazyParser = cms.bool(True) )
143  process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ]
144 
145  #EGM object modifications
146  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
147  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
148  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
149 
150  #VID Electron IDs
151  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_50ns_V1_cff',
152  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_PU20bx25_V0_cff',
153  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_25ns_cff',
154  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_startup_cff']
155  switchOnVIDElectronIdProducer(process, DataFormat.MiniAOD)
156  process.egmGsfElectronIDs.physicsObjectSrc = \
157  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
158  process.electronIDValueMapProducer.src = \
159  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
160  process.electronIDValueMapProducer.ebReducedRecHitCollection = \
161  cms.InputTag("reducedEgamma","reducedEBRecHits")
162  process.electronIDValueMapProducer.eeReducedRecHitCollection = \
163  cms.InputTag("reducedEgamma","reducedEERecHits")
164  process.electronIDValueMapProducer.esReducedRecHitCollection = \
165  cms.InputTag("reducedEgamma","reducedESRecHits")
166  for idmod in electron_ids:
167  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False)
168 
169  # Adding puppi jets
170  process.load('CommonTools.PileupAlgos.Puppi_cff')
171  process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
172  process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
173  #process.puppi.candName = cms.InputTag('packedPFCandidates')
174  #process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')
175 
176  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
177  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
178  j2tParametersVX,
179  jets = cms.InputTag("ak4PFJetsPuppi")
180  )
181  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
182  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
183  var = cms.string('Pt'),
184  exp = cms.double(1.0)
185  )
186 
187  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
188  jetCorrections = ('AK4PFchs', ['L2Relative', 'L3Absolute'], ''),
189  algo= 'AK', rParam = 0.4, btagDiscriminators = map(lambda x: x.value() ,process.patJets.discriminatorSources)
190  )
191 
192  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
193 
194  process.patJetsPuppi.userData.userFloats.src = cms.VInputTag(cms.InputTag(""))
195  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
196 
197  process.selectedPatJetsPuppi.cut = cms.string("pt > 20")
198 
199  process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi')
200  process.slimmedJetsPuppi = process.slimmedJets.clone()
201  process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi")
202  process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag("packedPFCandidates")
203 
204  ## puppi met
205  process.load('RecoMET.METProducers.PFMET_cfi')
206  process.pfMetPuppi = process.pfMet.clone()
207  process.pfMetPuppi.src = cms.InputTag("puppi")
208  process.pfMetPuppi.alias = cms.string('pfMetPuppi')
209  ## type1 correction, from puppi jets
210  process.corrPfMetType1Puppi = process.corrPfMetType1.clone(
211  src = 'ak4PFJetsPuppi',
212  jetCorrLabel = 'ak4PFCHSL2L3Corrector',
213  )
214  del process.corrPfMetType1Puppi.offsetCorrLabel # no L1 for PUPPI jets
215  process.pfMetT1Puppi = process.pfMetT1.clone(
216  src = 'pfMetPuppi',
217  srcCorrections = [ cms.InputTag("corrPfMetType1Puppi","type1") ]
218  )
219 
220  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
221  addMETCollection(process, labelName='patMETPuppi', metSource='pfMetT1Puppi') # T1
222  addMETCollection(process, labelName='patPFMetPuppi', metSource='pfMetPuppi') # RAW
223 
224  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
225  process.slimmedMETsPuppi = process.slimmedMETs.clone()
226  process.slimmedMETsPuppi.src = cms.InputTag("patMETPuppi")
227  process.slimmedMETsPuppi.rawUncertainties = cms.InputTag("patPFMetPuppi") # only central value
228  process.slimmedMETsPuppi.type1Uncertainties = cms.InputTag("patPFMetT1") # only central value for now
229  del process.slimmedMETsPuppi.type1p2Uncertainties # not available
230 
231 def miniAOD_customizeMC(process):
232  process.muonMatch.matched = "prunedGenParticles"
233  process.electronMatch.matched = "prunedGenParticles"
234  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
235  process.photonMatch.matched = "prunedGenParticles"
236  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
237  process.tauMatch.matched = "prunedGenParticles"
238  process.tauGenJets.GenParticles = "prunedGenParticles"
239  process.patJetPartonMatch.matched = "prunedGenParticles"
240  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
241  process.patJetGenJetMatch.matched = "slimmedGenJets"
242  process.patJetGenJetMatchAK8.matched = "slimmedGenJetsAK8"
243  process.patMuons.embedGenMatch = False
244  process.patElectrons.embedGenMatch = False
245  process.patPhotons.embedGenMatch = False
246  process.patTaus.embedGenMatch = False
247  process.patJets.embedGenPartonMatch = False
248  #also jet flavour must be switched to ak4
249  process.patJetFlavourAssociation.rParam = 0.4
250 
252  out.dropMetaData = cms.untracked.string('ALL')
253  out.fastCloning= cms.untracked.bool(False)
254  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
255  out.compressionAlgorithm = cms.untracked.string('LZMA')
256 
258  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
259  runOnData( process, outputModules = [] )
260 
262  miniAOD_customizeCommon(process)
263  miniAOD_customizeData(process)
264  return process
265 
267  miniAOD_customizeCommon(process)
268  miniAOD_customizeMC(process)
269  return process
def setupAllVIDIdsInModule
Definition: vid_id_tools.py:50
def switchOnVIDElectronIdProducer
Definition: vid_id_tools.py:69
def miniAOD_customizeAllMC
def miniAOD_customizeCommon
Definition: miniAOD_tools.py:5
def miniAOD_customizeAllData
def miniAOD_customizeOutput
tuple switchOnTriggerStandAlone
Definition: trigTools.py:276
def miniAOD_customizeData