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.elPFIsoDepositCharged.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
40  process.elPFIsoDepositChargedAll.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
41  process.elPFIsoDepositNeutral.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
42  process.elPFIsoDepositGamma.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
43  process.elPFIsoDepositPU.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
44  #
45  process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster
46  process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster
47  process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters
48  process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters
49  process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer
50  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
51  process.patPhotons.photonIDSources = cms.PSet(
52  PhotonCutBasedIDLoose = cms.InputTag('reducedEgamma',
53  'PhotonCutBasedIDLoose'),
54  PhotonCutBasedIDTight = cms.InputTag('reducedEgamma',
55  'PhotonCutBasedIDTight')
56  )
57 
58  process.phPFIsoDepositCharged.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
59  process.phPFIsoDepositChargedAll.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
60  process.phPFIsoDepositNeutral.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
61  process.phPFIsoDepositGamma.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
62  process.phPFIsoDepositPU.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
63  #
64  process.selectedPatJets.cut = cms.string("pt > 10")
65  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
66  process.selectedPatElectrons.cut = cms.string("")
67  process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFinding')> 0.5")
68  process.selectedPatPhotons.cut = cms.string("")
69  #
70  from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection
71  #switch to AK4 (though it should soon be unnecessary as ak4 should become the 71X default)
72  #FIXME: still using AK5PFchs for jet energy corrections, while waiting for a new globalTag
73  switchJetCollection(process, jetSource = cms.InputTag('ak4PFJetsCHS'),
74  jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), ''),
75  btagDiscriminators = ['jetBProbabilityBJetTags', 'jetProbabilityBJetTags', 'trackCountingHighPurBJetTags', 'trackCountingHighEffBJetTags', 'simpleSecondaryVertexHighEffBJetTags',
76  'simpleSecondaryVertexHighPurBJetTags', 'combinedSecondaryVertexBJetTags' , 'combinedInclusiveSecondaryVertexBJetTags' ],
77  )
78  #add CA8
79  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
80  addJetCollection(process, labelName = 'AK8', jetSource = cms.InputTag('ak8PFJetsCHS'),algo= 'AK', rParam = 0.8, jetCorrections = ('AK7PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None') )
81  process.patJetsAK8.userData.userFloats.src = [] # start with empty list of user floats
82  process.selectedPatJetsAK8.cut = cms.string("pt > 100")
83  process.patJetGenJetMatchAK8.matched = 'slimmedGenJets'
84  ## AK8 groomed masses
85  from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSFiltered, ak8PFJetsCHSTrimmed
86  process.ak8PFJetsCHSPruned = ak8PFJetsCHSPruned.clone()
87  process.ak8PFJetsCHSTrimmed = ak8PFJetsCHSTrimmed.clone()
88  process.ak8PFJetsCHSFiltered = ak8PFJetsCHSFiltered.clone()
89  process.load("RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi")
90  process.patJetsAK8.userData.userFloats.src += ['ak8PFJetsCHSPrunedLinks','ak8PFJetsCHSTrimmedLinks','ak8PFJetsCHSFilteredLinks']
91  ### CA8 groomed masses (for the matched jet): doesn't seem to work, it produces tons of warnings "Matched jets separated by dR greater than distMax=0.8"
92  # from RecoJets.Configuration.RecoPFJets_cff import ca8PFJetsCHSFiltered, ca8PFJetsCHSTrimmed # ca8PFJetsCHSPruned is already in AOD
93  # process.ca8PFJetsCHSTrimmed = ca8PFJetsCHSTrimmed.clone()
94  # process.ca8PFJetsCHSFiltered = ca8PFJetsCHSFiltered.clone()
95  # process.load("RecoJets.JetProducers.ca8PFJetsCHS_groomingValueMaps_cfi")
96  # process.ca8PFJetsCHSPrunedLinks.src = cms.InputTag("ak8PFJetsCHS")
97  # process.ca8PFJetsCHSTrimmedLinks.src = cms.InputTag("ak8PFJetsCHS")
98  # process.ca8PFJetsCHSFilteredLinks.src = cms.InputTag("ak8PFJetsCHS")
99  # process.patJetsAK8.userData.userFloats.src += ['ca8PFJetsCHSPrunedLinks','ca8PFJetsCHSTrimmedLinks','ca8PFJetsCHSFilteredLinks']
100  ## cmsTopTagger (note: it is already run in RECO, we just add the value)
101  process.cmsTopTagPFJetsCHSLinksAK8 = process.ak8PFJetsCHSPrunedLinks.clone()
102  process.cmsTopTagPFJetsCHSLinksAK8.src = cms.InputTag("ak8PFJetsCHS")
103  process.cmsTopTagPFJetsCHSLinksAK8.matched = cms.InputTag("cmsTopTagPFJetsCHS")
104  process.patJetsAK8.userData.userFloats.src += ['cmsTopTagPFJetsCHSLinksAK8']
105 
106  #
107  ## PU JetID
108  process.load("PhysicsTools.PatAlgos.slimming.pileupJetId_cfi")
109  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
110  #
111  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
112  switchOnTriggerStandAlone( process, outputModule = '' )
113  process.patTrigger.packTriggerPathNames = cms.bool(True)
114  #
115  # apply type I/type I + II PFMEt corrections to pat::MET object
116  # and estimate systematic uncertainties on MET
117  # FIXME: this and the typeI MET should become AK4 once we have the proper JEC?
118  from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties
119  addJetCollection(process, postfix = "ForMetUnc", labelName = 'AK5PF', jetSource = cms.InputTag('ak5PFJets'), jetCorrections = ('AK5PF', ['L1FastJet', 'L2Relative', 'L3Absolute'], ''))
120  runMEtUncertainties(process,jetCollection="selectedPatJetsAK5PFForMetUnc", outputModule=None)
121 
122  #keep this after all addJetCollections otherwise it will attempt computing them also for stuf with no taginfos
123  #Some useful BTAG vars
124  process.patJets.userData.userFunctions = cms.vstring(
125  '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.M):(0)',
126  '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).nTracks):(0)',
127  '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().flightDistance(0).value):(0)',
128  '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().flightDistance(0).significance):(0)',
129  )
130  process.patJets.userData.userFunctionLabels = cms.vstring('vtxMass','vtxNtracks','vtx3DVal','vtx3DSig')
131  process.patJets.tagInfoSources = cms.VInputTag(cms.InputTag("secondaryVertexTagInfos"))
132  process.patJets.addTagInfos = cms.bool(True)
133 
134  #VID Electron IDs
135  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_50ns_V1_cff',
136  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_PU20bx25_V0_cff',
137  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_25ns_cff',
138  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_startup_cff']
140  process.egmGsfElectronIDs.physicsObjectSrc = \
141  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
142  process.electronIDValueMapProducer.src = \
143  cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
144  process.electronIDValueMapProducer.ebReducedRecHitCollection = \
145  cms.InputTag("reducedEgamma","reducedEBRecHits")
146  process.electronIDValueMapProducer.eeReducedRecHitCollection = \
147  cms.InputTag("reducedEgamma","reducedEERecHits")
148  process.electronIDValueMapProducer.esReducedRecHitCollection = \
149  cms.InputTag("reducedEgamma","reducedESRecHits")
150  for idmod in electron_ids:
151  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection)
152 
153 
154 
155 def miniAOD_customizeMC(process):
156  process.muonMatch.matched = "prunedGenParticles"
157  process.electronMatch.matched = "prunedGenParticles"
158  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
159  process.photonMatch.matched = "prunedGenParticles"
160  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
161  process.tauMatch.matched = "prunedGenParticles"
162  process.patJetPartonMatch.matched = "prunedGenParticles"
163  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
164  process.patJetGenJetMatch.matched = "slimmedGenJets"
165  process.patMuons.embedGenMatch = False
166  process.patElectrons.embedGenMatch = False
167  process.patPhotons.embedGenMatch = False
168  process.patTaus.embedGenMatch = False
169  process.patJets.embedGenPartonMatch = False
170  #also jet flavour must be switched to ak4
171  process.patJetFlavourAssociation.rParam = 0.4
172 
174  out.dropMetaData = cms.untracked.string('ALL')
175  out.fastCloning= cms.untracked.bool(False)
176  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
177  out.compressionAlgorithm = cms.untracked.string('LZMA')
178 
180  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
181  runOnData( process, outputModules = [] )
182 
184  miniAOD_customizeCommon(process)
185  miniAOD_customizeData(process)
186  return process
187 
189  miniAOD_customizeCommon(process)
190  miniAOD_customizeMC(process)
191  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