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  #VID Electron IDs
146  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_50ns_V1_cff',
147  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_PU20bx25_V0_cff',
148  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_25ns_cff',
149  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_startup_cff']
151  process.egmGsfElectronIDs.physicsObjectSrc = \
152  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
153  process.electronIDValueMapProducer.src = \
154  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
155  process.electronIDValueMapProducer.ebReducedRecHitCollection = \
156  cms.InputTag("reducedEgamma","reducedEBRecHits")
157  process.electronIDValueMapProducer.eeReducedRecHitCollection = \
158  cms.InputTag("reducedEgamma","reducedEERecHits")
159  process.electronIDValueMapProducer.esReducedRecHitCollection = \
160  cms.InputTag("reducedEgamma","reducedESRecHits")
161  for idmod in electron_ids:
162  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection)
163 
164  # Adding puppi jets
165  process.load('CommonTools.PileupAlgos.Puppi_cff')
166  process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
167  process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
168  #process.puppi.candName = cms.InputTag('packedPFCandidates')
169  #process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')
170 
171  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
172  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
173  j2tParametersVX,
174  jets = cms.InputTag("ak4PFJetsPuppi")
175  )
176  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
177  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
178  var = cms.string('Pt'),
179  exp = cms.double(1.0)
180  )
181 
182  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
183  jetCorrections = ('AK4PFchs', ['L2Relative', 'L3Absolute'], ''),
184  algo= 'AK', rParam = 0.4, btagDiscriminators = map(lambda x: x.value() ,process.patJets.discriminatorSources)
185  )
186 
187  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
188 
189  process.patJetsPuppi.userData.userFloats.src = cms.VInputTag(cms.InputTag(""))
190  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
191 
192  process.selectedPatJetsPuppi.cut = cms.string("pt > 20")
193 
194  process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi')
195  process.slimmedJetsPuppi = process.slimmedJets.clone()
196  process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi")
197  process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag("packedPFCandidates")
198 
199  ## puppi met
200  process.load('RecoMET.METProducers.PFMET_cfi')
201  process.pfMetPuppi = process.pfMet.clone()
202  process.pfMetPuppi.src = cms.InputTag("puppi")
203  process.pfMetPuppi.alias = cms.string('pfMetPuppi')
204  ## type1 correction, from puppi jets
205  process.corrPfMetType1Puppi = process.corrPfMetType1.clone(
206  src = 'ak4PFJetsPuppi',
207  jetCorrLabel = 'ak4PFCHSL2L3Corrector',
208  )
209  del process.corrPfMetType1Puppi.offsetCorrLabel # no L1 for PUPPI jets
210  process.pfMetT1Puppi = process.pfMetT1.clone(
211  src = 'pfMetPuppi',
212  srcCorrections = [ cms.InputTag("corrPfMetType1Puppi","type1") ]
213  )
214 
215  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
216  addMETCollection(process, labelName='patMETPuppi', metSource='pfMetT1Puppi') # T1
217  addMETCollection(process, labelName='patPFMetPuppi', metSource='pfMetPuppi') # RAW
218 
219  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
220  process.slimmedMETsPuppi = process.slimmedMETs.clone()
221  process.slimmedMETsPuppi.src = cms.InputTag("patMETPuppi")
222  process.slimmedMETsPuppi.rawUncertainties = cms.InputTag("patPFMetPuppi") # only central value
223  process.slimmedMETsPuppi.type1Uncertainties = cms.InputTag("patPFMetT1") # only central value for now
224  del process.slimmedMETsPuppi.type1p2Uncertainties # not available
225 
226 
227 def miniAOD_customizeMC(process):
228  process.muonMatch.matched = "prunedGenParticles"
229  process.electronMatch.matched = "prunedGenParticles"
230  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
231  process.photonMatch.matched = "prunedGenParticles"
232  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
233  process.tauMatch.matched = "prunedGenParticles"
234  process.tauGenJets.GenParticles = "prunedGenParticles"
235  process.patJetPartonMatch.matched = "prunedGenParticles"
236  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
237  process.patJetGenJetMatch.matched = "slimmedGenJets"
238  process.patJetGenJetMatchAK8.matched = "slimmedGenJetsAK8"
239  process.patMuons.embedGenMatch = False
240  process.patElectrons.embedGenMatch = False
241  process.patPhotons.embedGenMatch = False
242  process.patTaus.embedGenMatch = False
243  process.patJets.embedGenPartonMatch = False
244  #also jet flavour must be switched to ak4
245  process.patJetFlavourAssociation.rParam = 0.4
246 
248  out.dropMetaData = cms.untracked.string('ALL')
249  out.fastCloning= cms.untracked.bool(False)
250  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
251  out.compressionAlgorithm = cms.untracked.string('LZMA')
252 
254  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
255  runOnData( process, outputModules = [] )
256 
258  miniAOD_customizeCommon(process)
259  miniAOD_customizeData(process)
260  return process
261 
263  miniAOD_customizeCommon(process)
264  miniAOD_customizeMC(process)
265  return process
def setupAllVIDIdsInModule
Definition: vid_id_tools.py:31
def switchOnVIDElectronIdProducer
Electrons.
Definition: vid_id_tools.py:45
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