CMS 3D CMS Logo

Functions
miniAOD_tools Namespace Reference

Functions

def miniAOD_customizeAllData (process)
 
def miniAOD_customizeAllMC (process)
 
def miniAOD_customizeAllMCFastSim (process)
 
def miniAOD_customizeCommon (process)
 
def miniAOD_customizeData (process)
 
def miniAOD_customizeMC (process)
 
def miniAOD_customizeOutput (out)
 

Function Documentation

◆ miniAOD_customizeAllData()

def miniAOD_tools.miniAOD_customizeAllData (   process)

Definition at line 615 of file miniAOD_tools.py.

References miniAOD_customizeCommon(), and miniAOD_customizeData().

615 def miniAOD_customizeAllData(process):
616  miniAOD_customizeCommon(process)
617  miniAOD_customizeData(process)
618  return process
619 
def miniAOD_customizeAllData(process)
def miniAOD_customizeData(process)
def miniAOD_customizeCommon(process)

◆ miniAOD_customizeAllMC()

def miniAOD_tools.miniAOD_customizeAllMC (   process)

Definition at line 620 of file miniAOD_tools.py.

References miniAOD_customizeCommon(), and miniAOD_customizeMC().

620 def miniAOD_customizeAllMC(process):
621  miniAOD_customizeCommon(process)
622  miniAOD_customizeMC(process)
623  return process
624 
def miniAOD_customizeCommon(process)
def miniAOD_customizeAllMC(process)
def miniAOD_customizeMC(process)

◆ miniAOD_customizeAllMCFastSim()

def miniAOD_tools.miniAOD_customizeAllMCFastSim (   process)

Definition at line 625 of file miniAOD_tools.py.

References miniAOD_customizeCommon(), isolatedTracks_cfi.miniAOD_customizeIsolatedTracksFastSim(), miniAOD_customizeMC(), and metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim().

625 def miniAOD_customizeAllMCFastSim(process):
626  miniAOD_customizeCommon(process)
627  miniAOD_customizeMC(process)
628  from PhysicsTools.PatAlgos.slimming.metFilterPaths_cff import miniAOD_customizeMETFiltersFastSim
629  process = miniAOD_customizeMETFiltersFastSim(process)
630  from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
631  process = miniAOD_customizeIsolatedTracksFastSim(process)
632  process.patMuons.addTriggerMatching = False
633  # Disable pixelClusterTagInfos in FastSim (no siPixelCluster available)
634  from Configuration.Eras.Modifier_fastSim_cff import fastSim
635  fastSim.toModify(process.patJets, addTagInfos = cms.bool(False) )
636  fastSim.toModify(process.slimmedJetsNoDeepFlavour, dropTagInfos = cms.string('1') )
637  fastSim.toModify(process.updatedPatJetsSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
638  fastSim.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = cms.bool(False) )
639 
640  return process
641 
def miniAOD_customizeCommon(process)
def miniAOD_customizeMETFiltersFastSim(process)
def miniAOD_customizeAllMCFastSim(process)
def miniAOD_customizeIsolatedTracksFastSim(process)
def miniAOD_customizeMC(process)

◆ miniAOD_customizeCommon()

def miniAOD_tools.miniAOD_customizeCommon (   process)

Definition at line 11 of file miniAOD_tools.py.

References boostedHPSPFTaus_cfi.addBoostedTaus(), helpers.addToProcessAndTask(), applyDeepBtagging_cff.applyDeepBtagging(), applySubstructure_cff.applySubstructure(), clone(), helpers.getPatAlgosToolsTask(), egmIsolationsPUPPI_cfi.makeInputForPUPPIIsolationEgm(), muonIsolationsPUPPI_cfi.makeInputForPUPPIIsolationMuon(), egammaObjectModifications_tools.makeVIDBitsModifier(), runMETCorrectionsAndUncertainties.runMetCorAndUncForMiniAODProduction(), vid_id_tools.setupAllVIDIdsInModule(), str, trigTools.switchOnTriggerStandAlone, vid_id_tools.switchOnVIDElectronIdProducer(), and vid_id_tools.switchOnVIDPhotonIdProducer().

Referenced by miniAOD_customizeAllData(), miniAOD_customizeAllMC(), and miniAOD_customizeAllMCFastSim().

11 def miniAOD_customizeCommon(process):
12  process.patMuons.isoDeposits = cms.PSet()
13  process.patElectrons.isoDeposits = cms.PSet()
14  process.patTaus.isoDeposits = cms.PSet()
15  process.patPhotons.isoDeposits = cms.PSet()
16  #
17  process.patMuons.embedTrack = True # used for IDs
18  process.patMuons.embedCombinedMuon = True # used for IDs
19  process.patMuons.embedMuonBestTrack = True # used for IDs
20  process.patMuons.embedStandAloneMuon = True # maybe?
21  process.patMuons.embedPickyMuon = False # no, use best track
22  process.patMuons.embedTpfmsMuon = False # no, use best track
23  process.patMuons.embedDytMuon = False # no, use best track
24  process.patMuons.addPuppiIsolation = cms.bool(True)
25  process.patMuons.puppiIsolationChargedHadrons = cms.InputTag("muonPUPPIIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
26  process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag("muonPUPPIIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
27  process.patMuons.puppiIsolationPhotons = cms.InputTag("muonPUPPIIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
28  process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h+-DR040-ThresholdVeto000-ConeVeto000")
29  process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001")
30  process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001")
31 
32  process.patMuons.computeMiniIso = True
33  process.patMuons.computeMuonIDMVA = True
34  process.patMuons.computeSoftMuonMVA = True
35 
36  process.patMuons.addTriggerMatching = True
37  from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016
38  from Configuration.Eras.Modifier_run2_muon_2017_cff import run2_muon_2017
39  from Configuration.Eras.Modifier_run2_muon_2018_cff import run2_muon_2018
40  run2_muon_2016.toModify( process.patMuons, effectiveAreaVec = [0.0735,0.0619,0.0465,0.0433,0.0577])
41  run2_muon_2017.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
42  run2_muon_2018.toModify( process.patMuons, effectiveAreaVec = [0.0566, 0.0562, 0.0363, 0.0119, 0.0064])
43 
44  process.patMuons.computePuppiCombinedIso = True
45  #
46  # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer
47  process.patElectrons.embedGsfElectronCore = False
48  process.patElectrons.embedSuperCluster = False
49  process.patElectrons.embedPflowSuperCluster = False
50  process.patElectrons.embedSeedCluster = False
51  process.patElectrons.embedBasicClusters = False
52  process.patElectrons.embedPreshowerClusters = False
53  process.patElectrons.embedPflowBasicClusters = False
54  process.patElectrons.embedPflowPreshowerClusters = False
55  process.patElectrons.embedRecHits = False
56  process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
57  process.patElectrons.usePfCandidateMultiMap = True
58  process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap")
59  process.patElectrons.electronIDSources = cms.PSet()
60 
61  from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
62  from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
63  (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify(process.patElectrons,
64  addPFClusterIso = True,
65  ecalPFClusterIsoMap = "reducedEgamma:eleEcalPFClusIso",
66  hcalPFClusterIsoMap = "reducedEgamma:eleHcalPFClusIso")
67 
68  #add puppi isolation in miniAOD
69  process.patElectrons.addPuppiIsolation = cms.bool(True)
70  process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001")
71  process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000")
72  process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008")
73  process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001")
74  process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000")
75  process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008")
76 
77  process.patElectrons.computeMiniIso = cms.bool(True)
78 
79  process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
80  process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
81  process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
82  process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
83  process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
84  #
85  process.patPhotons.embedSuperCluster = False
86  process.patPhotons.embedSeedCluster = False
87  process.patPhotons.embedBasicClusters = False
88  process.patPhotons.embedPreshowerClusters = False
89  process.patPhotons.embedRecHits = False
90 
91  #add puppi isolation in miniAOD
92  process.patPhotons.addPuppiIsolation = cms.bool(True)
93  process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-")
94  process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-")
95  process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-")
96 
97  (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify(process.patPhotons,
98  addPFClusterIso = True,
99  ecalPFClusterIsoMap = "reducedEgamma:phoEcalPFClusIso",
100  hcalPFClusterIsoMap = "reducedEgamma:phoHcalPFClusIso")
101  #the 80X legacy customsations are done in ootPhotonProducer for OOT photons
102  run2_miniAOD_94XFall17.toModify(process.patOOTPhotons,
103  addPFClusterIso = True,
104  ecalPFClusterIsoMap = "reducedEgamma:ootPhoEcalPFClusIso",
105  hcalPFClusterIsoMap = "reducedEgamma:ootPhoHcalPFClusIso")
106 
107 
108  process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
109  process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
110 
111  process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
112  process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
113  process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
114  process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
115  process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
116  #
117  process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons")
118  process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
119  #
120  process.selectedPatJets.cut = cms.string("pt > 10")
121  process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))")
122 
123  from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
124  phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )")
125  from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
126  pp_on_AA.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 1.2 && (isGlobalMuon || isStandAloneMuon) )")
127 
128  process.selectedPatElectrons.cut = cms.string("")
129  process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5")
130  process.selectedPatPhotons.cut = cms.string("")
131 
132  _dummyPatJets = process.selectedPatJets.clone(cut = "pt < 0")
133  task = getPatAlgosToolsTask(process)
134 
135  def _applySubstructure(process):
136  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
137 
138  from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure
139  applySubstructure( process )
140  (~pp_on_AA).toModify(process, _applySubstructure)
141 
142  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJets', p.selectedPatJets.clone(), p, task))
143  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsAK8', _dummyPatJets.clone(), p, task))
144 
145  #
146  from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
147  switchOnTriggerStandAlone( process, outputModule = '' )
148  process.patTrigger.packTriggerPathNames = cms.bool(True)
149  #
150  # apply type I + other PFMEt corrections to pat::MET object
151  # and estimate systematic uncertainties on MET
152 
153  from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
154  runMetCorAndUncForMiniAODProduction(process, metType="PF",
155  jetCollUnskimmed="patJets")
156 
157  #caloMET computation
158  from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
159  addMETCollection(process,
160  labelName = "patCaloMet",
161  metSource = "caloMetM"
162  )
163 
164  #noHF pfMET =========
165 
166  process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
167  src=cms.InputTag("particleFlow"),
168  cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
169  )
170  task.add(process.noHFCands)
171 
173  pfCandColl=cms.InputTag("noHFCands"),
174  recoMetFromPFCs=True, #needed for HF removal
175  jetSelection="pt>15 && abs(eta)<3.",
176  postfix="NoHF"
177  )
178 
179  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
180  task.add(process.slimmedMETs)
181  (~pp_on_AA).toModify(process.slimmedMETs, addDeepMETs = True)
182 
183  def _add_slimmedMETsNoHF(process):
184  addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task)
185  process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF")
186  process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF")
187  process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF")
188  process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF")
189  process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF")
190  process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF")
191  process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF")
192  process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF")
193  process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF")
194  process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF")
195  del process.slimmedMETsNoHF.caloMET
196  (~pp_on_AA).toModify(process, _add_slimmedMETsNoHF)
197  # ================== NoHF pfMET
198 
199  # ================== CHSMET
200  process.load("CommonTools.ParticleFlow.pfCHS_cff")
201  task.add(process.pfCHS)
202 
203  from RecoMET.METProducers.pfMet_cfi import pfMet
204  process.pfMetCHS = pfMet.clone(src = 'pfCHS')
205  task.add(process.pfMetCHS)
206 
207  addMETCollection(process,
208  labelName = "patCHSMet",
209  metSource = "pfMetCHS"
210  )
211 
212  process.patCHSMet.computeMETSignificance = cms.bool(False)
213 
214  # ================== CHSMET
215 
216  # ================== TrkMET
217  process.TrkCands = chargedPackedCandsForTkMet.clone()
218  task.add(process.TrkCands)
219 
220  process.pfMetTrk = pfMet.clone(src = 'TrkCands')
221  task.add(process.pfMetTrk)
222 
223  addMETCollection(process,
224  labelName = "patTrkMet",
225  metSource = "pfMetTrk"
226  )
227 
228  process.patTrkMet.computeMETSignificance = cms.bool(False)
229 
230  # ================== TrkMET
231 
232 
233 
234  process.load("RecoJets.JetProducers.PileupJetID_cfi")
235  task.add(process.pileUpJetIDTask)
236 
237  process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]
238  process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ]
239 
240 
241  process.load('RecoJets.JetProducers.QGTagger_cfi')
242  task.add(process.QGTagger)
243 
244  process.patJets.userData.userFloats.src += [ 'QGTagger:qgLikelihood', ]
245 
246  #HF jet shower shape
247  process.load('RecoJets.JetProducers.hfJetShowerShape_cfi')
248  task.add(process.hfJetShowerShape)
249 
250  process.patJets.userData.userFloats.src += [ 'hfJetShowerShape:sigmaEtaEta', 'hfJetShowerShape:sigmaPhiPhi']
251  process.patJets.userData.userInts.src += [ 'hfJetShowerShape:centralEtaStripSize', 'hfJetShowerShape:adjacentEtaStripsSize']
252 
253 
254  def _add_deepFlavour(process):
255  process.load('RecoBTag.Combined.deepFlavour_cff')
256  task.add(process.pfDeepCSVDiscriminatorsJetTags)
257  process.patJets.discriminatorSources.extend([
258  'pfDeepCSVDiscriminatorsJetTags:BvsAll',
259  'pfDeepCSVDiscriminatorsJetTags:CvsB',
260  'pfDeepCSVDiscriminatorsJetTags:CvsL',
261  ])
262  from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
263  (~pp_on_AA_2018).toModify(process, _add_deepFlavour)
264 
265 
266  process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer",
267  src = process.patJets.jetSource,
268  matched = cms.InputTag("ak4CaloJets"),
269  distMax = cms.double(0.4),
270  values = cms.vstring('pt','emEnergyFraction'),
271  valueLabels = cms.vstring('pt','emEnergyFraction'),
272  lazyParser = cms.bool(True) )
273  task.add(process.caloJetMap)
274  process.patJets.userData.userFloats.src += [ 'caloJetMap:pt', 'caloJetMap:emEnergyFraction' ]
275 
276  pp_on_AA.toModify(process.patJets.userData.userInts, src = [] )
277  pp_on_AA.toModify(process.patJets.userData.userFloats, src = [] )
278 
279  #Muon object modifications
280  from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon
282 
283  #EGM object modifications
284  from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm
286  from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications
287  process.slimmedElectrons.modifierConfig.modifications = egamma_modifications
288  process.slimmedPhotons.modifierConfig.modifications = egamma_modifications
289 
290  #VID Electron IDs
291  process.patElectrons.addElectronID = cms.bool(True)
292  electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
293  'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV71_cff',
294  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
295  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
296  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Winter22_122X_V1_cff',
297  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
298  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
299  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
300  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
301  'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
302  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff',
303  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff',
304  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer16UL_ID_ISO_cff',
305  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer17UL_ID_ISO_cff',
306  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff',
307  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_noIso_V1_cff',
308  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_iso_V1_cff'
309  ]
310  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task)
311  process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
312  process.electronMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
313 
314  # To use older DataFormats, the electronMVAValueMapProducer MUST take a updated electron collection
315  # such that the conversion variables are filled correctly.
316  process.load("RecoEgamma.EgammaTools.gedGsfElectronsTo106X_cff")
317  run2_miniAOD_80XLegacy.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom80XTo106XTask))
318  run2_miniAOD_80XLegacy.toModify(process.electronMVAValueMapProducer,
319  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
320  src = cms.InputTag("gedGsfElectronsFrom80XTo106X"))
321 
322  run2_miniAOD_94XFall17.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
323  run2_miniAOD_94XFall17.toModify(process.electronMVAValueMapProducer,
324  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
325  src = cms.InputTag("gedGsfElectronsFrom94XTo106X"))
326 
327  from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
328  pp_on_AA_2018.toModify(task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask))
329  pp_on_AA_2018.toModify(process.electronMVAValueMapProducer,
330  keysForValueMaps = cms.InputTag('reducedEgamma','reducedGedGsfElectrons'),
331  src = "gedGsfElectronsFrom94XTo106X")
332 
333  for idmod in electron_ids:
334  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task)
335 
336  #VID Photon IDs
337  process.patPhotons.addPhotonID = cms.bool(True)
338  photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff',
339  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff',
340  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff',
341  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff',
342  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
343  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff',
344  'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Winter22_122X_V1_cff',
345  'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_RunIIIWinter22_122X_V1_cff']
346 
347  switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task)
348  process.egmPhotonIDs.physicsObjectSrc = cms.InputTag("reducedEgamma","reducedGedPhotons")
349  process.photonMVAValueMapProducer.src = cms.InputTag('reducedEgamma','reducedGedPhotons')
350  for idmod in photon_ids:
351  setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task)
352 
353  #add the cut base IDs bitmaps of which cuts passed
354  from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier
355  egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs"))
356 
357  #-- Adding boosted taus
358  from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
359  addBoostedTaus(process)
360  process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
361  process.load("RecoTauTag.Configuration.HPSPFTaus_cff")
362  #-- Adding customization for 94X 2017 legacy reMniAOD
363  _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy()
364  _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauBasicDiscriminatorsTask,
365  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask,
366  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask,
367  process.hpsPFTauBasicDiscriminatorsdR03Task,
368  process.hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTTask,
369  process.hpsPFTauDiscriminationByMVA6rawElectronRejection,
370  process.hpsPFTauDiscriminationByMVA6ElectronRejection,
371  process.hpsPFTauDiscriminationByMuonRejection3)
372  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
373  (run2_miniAOD_94XFall17 | run2_miniAOD_UL).toReplaceWith(
374  process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID
375  )
376  #-- Adding DeepTauID
377  # deepTau v2p1 and v2p5
378  _updatedTauName = 'slimmedTausDeepIDsv2p1'
379  _noUpdatedTauName = 'slimmedTausNoDeepIDs'
380  import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
381  tauIdEmbedder = tauIdConfig.TauIDEmbedder(
382  process, debug = False,
383  originalTauName = _noUpdatedTauName,
384  updatedTauName = _updatedTauName,
385  postfix = 'ForMini',
386  toKeep = ['deepTau2017v2p1','deepTau2018v2p5']
387  )
388  from Configuration.Eras.Modifier_phase2_common_cff import phase2_common #Phase2 Tau MVA
389  _tauIds_phase2 = ['deepTau2026v2p5']
390  phase2_common.toModify(tauIdEmbedder.toKeep, func=lambda t:t.extend(_tauIds_phase2))
391  tauIdEmbedder.runTauID()
392  addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(),process,task)
393  delattr(process, 'slimmedTaus')
394  process.slimmedTaus = getattr(process, _updatedTauName).clone()
395  process.rerunMvaIsolationTaskForMini.add(process.slimmedTaus)
396  task.add(process.rerunMvaIsolationTaskForMini)
397 
398  #-- Rerun tauID against dead ECal towers to taus for the various re-MiniAOD eras
399  # to enable default behoviour with leading track extrapolation to ECAL
400  _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy()
401  _makePatTausTaskWithDeadECalVeto.add(
402  process.hpsPFTauDiscriminationByDeadECALElectronRejection
403  )
404  _run2_miniAOD_ANY = (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17 | run2_miniAOD_UL)
405  _run2_miniAOD_ANY.toReplaceWith(
406  process.makePatTausTask, _makePatTausTaskWithDeadECalVeto
407  )
408 
409  #-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions
410  _makePatTausTaskWithTauReReco = process.makePatTausTask.copy()
411  _makePatTausTaskWithTauReReco.add(process.PFTauTask)
412  (run2_miniAOD_80XLegacy | pp_on_AA).toReplaceWith(
413  process.makePatTausTask, _makePatTausTaskWithTauReReco
414  )
415 
416  # Adding puppi jets
417  process.load('CommonTools.PileupAlgos.Puppi_cff')
418  process.load('RecoJets.JetProducers.ak4PFJets_cfi')
419  from Configuration.Eras.Modifier_pA_2016_cff import pA_2016
420  _rerun_puppijets_task = task.copy()
421  _rerun_puppijets_task.add(process.puppi, process.ak4PFJetsPuppi)
422  (_run2_miniAOD_ANY | pA_2016 | pp_on_AA).toReplaceWith(task, _rerun_puppijets_task)
423 
424  from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
425  process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
426  j2tParametersVX,
427  jets = cms.InputTag("ak4PFJetsPuppi")
428  )
429  task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex)
430  process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
431  src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
432  var = cms.string('Pt'),
433  exp = cms.double(1.0)
434  )
435  task.add(process.patJetPuppiCharge)
436 
437  def _add_jetsPuppi(process):
438  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
439  noDeepFlavourDiscriminators = [x.value() if isinstance(x, cms.InputTag) else x for x in process.patJets.discriminatorSources
440  if (not "DeepFlavour" in str(x) and not "Transformer" in str(x))]
441  addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
442  jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''),
443  pfCandidates = cms.InputTag("particleFlow"),
444  algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators
445  )
446 
447  process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
448 
449  process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")
450 
451  process.selectedPatJetsPuppi.cut = cms.string("pt > 10")
452 
453  from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging
454  applyDeepBtagging( process )
455 
456  process.slimmedJetsNoDeepFlavour.dropTagInfos = '0'
457  process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.addTagInfos = True
458  process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.tagInfoSources = ["pixelClusterTagInfos"]
459  _run2_miniAOD_ANY.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = False )
460  (~pp_on_AA).toModify(process, _add_jetsPuppi)
461 
462  pp_on_AA.toModify(process, func = lambda p: addToProcessAndTask('slimmedJetsPuppi', _dummyPatJets.clone(), p, task))
463 
464  # Embed pixelClusterTagInfos in slimmedJets
465  process.patJets.addTagInfos = True
466  process.patJets.tagInfoSources = ["pixelClusterTagInfos"]
467 
468  _run2_miniAOD_ANY.toModify(process.patJets, addTagInfos = False )
469 
470  from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
471  pp_on_AA_2018.toModify(process.patJets, tagInfoSources = cms.VInputTag(["impactParameterTagInfos","secondaryVertexTagInfos"]) )
472 
473 
474  def _add_metPuppi(process):
475  process.load('RecoMET.METProducers.pfMetPuppi_cfi')
476  _rerun_puppimet_task = task.copy()
477  _rerun_puppimet_task.add(process.puppiNoLep, process.pfMetPuppi)
478  (_run2_miniAOD_ANY | pA_2016 | pp_on_AA).toReplaceWith(task, _rerun_puppimet_task)
479 
480  runMetCorAndUncForMiniAODProduction(process, metType="Puppi",
481  jetCollUnskimmed="slimmedJetsPuppi",
482  recoMetFromPFCs=True,
483  jetFlavor="AK4PFPuppi",
484  postfix="Puppi"
485  )
486  (~pp_on_AA).toModify(process, _add_metPuppi)
487 
488  process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
489  task.add(process.slimmedMETs)
490 
491  def _add_slimmedMETsPuppi(process):
492  addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task)
493  process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi")
494  process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi")
495  process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi")
496  process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi")
497  process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi")
498  process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi")
499  process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi")
500  process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi")
501  process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi")
502  process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi")
503  del process.slimmedMETsPuppi.caloMET
504  (~pp_on_AA).toModify(process, _add_slimmedMETsPuppi)
505 
506  def _add_deepMET(process):
507  from RecoMET.METPUSubtraction.deepMETProducer_cff import deepMETsResolutionTune, deepMETsResponseTune
508 
509  addToProcessAndTask('deepMETsResolutionTune', deepMETsResolutionTune, process, task)
510  addToProcessAndTask('deepMETsResponseTune', deepMETsResponseTune, process, task)
511  (~pp_on_AA).toModify(process, _add_deepMET)
512 
513  # add DetIdAssociatorRecords to EventSetup (for isolatedTracks)
514  process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
515 
516  # EGamma objects from HGCal are not yet in GED
517  # so add companion collections for Phase-II MiniAOD production
518  from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
519  process.load("RecoEgamma.EgammaTools.slimmedEgammaHGC_cff")
520  phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaHGCTask))
521 
522  # L1 pre-firing weights for 2016, 2017, and 2018
523  from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring
524  from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
525  from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017
526  from Configuration.Eras.Modifier_stage2L1Trigger_2018_cff import stage2L1Trigger_2018
527  from Configuration.Eras.Modifier_tracker_apv_vfp30_2016_cff import tracker_apv_vfp30_2016
528  if not hasattr(process,'prefiringweight'):
529  process.load("PhysicsTools.PatUtils.L1PrefiringWeightProducer_cff")
530  (stage2L1Trigger & tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016preVFP", DataEraMuon = "2016preVFP" )
531  (stage2L1Trigger & ~tracker_apv_vfp30_2016).toModify(process.prefiringweight, DataEraECAL = "UL2016postVFP", DataEraMuon = "2016postVFP" )
532  stage2L1Trigger_2017.toModify(process.prefiringweight, DataEraECAL = "UL2017BtoF", DataEraMuon = "20172018")
533  stage2L1Trigger_2018.toModify(process.prefiringweight, DataEraECAL = "None", DataEraMuon = "20172018")
534  run2_L1prefiring.toModify(task, func=lambda t: t.add(process.prefiringweight))
535 
536  from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeL1FastJetJECs
537  pp_on_AA.toModify(process, removeL1FastJetJECs)
538 
def makeInputForPUPPIIsolationMuon(process)
def miniAOD_customizeCommon(process)
def applySubstructure(process, postfix="")
def switchOnVIDElectronIdProducer(process, dataFormat, task=None)
Electrons.
Definition: vid_id_tools.py:66
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
def makeInputForPUPPIIsolationEgm(process)
def setupAllVIDIdsInModule(process, id_module_name, setupFunction, patProducer=None, addUserData=True, task=None)
Definition: vid_id_tools.py:49
def runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets", photonColl="selectedPatPhotons", electronColl="selectedPatElectrons", muonColl="selectedPatMuons", tauColl="selectedPatTaus", pfCandColl="particleFlow", jetCleaning="LepClean", jetSelection="pt>15 && abs(eta)<9.9", jecUnFile="", jetFlavor="AK4PFchs", recoMetFromPFCs=False, postfix="")
def applyDeepBtagging(process, postfix="")
switchOnTriggerStandAlone
Definition: trigTools.py:283
def makeVIDBitsModifier(process, eleVIDModuleName, phoVIDModuleName)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def getPatAlgosToolsTask(process)
Definition: helpers.py:13
def switchOnVIDPhotonIdProducer(process, dataFormat, task=None)
Photons.
#define str(s)

◆ miniAOD_customizeData()

def miniAOD_tools.miniAOD_customizeData (   process)

Definition at line 600 of file miniAOD_tools.py.

References helpers.getPatAlgosToolsTask().

Referenced by customizeMiniAOD_MuEGFixMoriond2017.customizeAll(), and miniAOD_customizeAllData().

600 def miniAOD_customizeData(process):
601  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
602  runOnData( process, outputModules = [] )
603  process.load("RecoPPS.Local.ctppsLocalTrackLiteProducer_cff")
604  process.load("RecoPPS.ProtonReconstruction.ctppsProtons_cff")
605  process.load("Geometry.VeryForwardGeometry.geometryRPFromDB_cfi")
606  process.load('L1Trigger.L1TGlobal.simGtExtFakeProd_cfi')
607  task = getPatAlgosToolsTask(process)
608  task.add(process.simGtExtUnprefireable)
609  from Configuration.Eras.Modifier_ctpps_cff import ctpps
610  ctpps.toModify(task, func=lambda t: t.add(process.ctppsLocalTrackLiteProducer))
611  ctpps.toModify(task, func=lambda t: t.add(process.ctppsProtons))
612  from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
613  run2_miniAOD_UL.toModify(task, func=lambda t: t.add(process.simGtExtUnprefireable))
614 
def miniAOD_customizeData(process)
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

◆ miniAOD_customizeMC()

def miniAOD_tools.miniAOD_customizeMC (   process)

Definition at line 539 of file miniAOD_tools.py.

References helpers.getPatAlgosToolsTask().

Referenced by miniAOD_customizeAllMC(), and miniAOD_customizeAllMCFastSim().

539 def miniAOD_customizeMC(process):
540  task = getPatAlgosToolsTask(process)
541  #GenJetFlavourInfos
542  process.load("PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi")
543  task.add(process.selectedHadronsAndPartons)
544  task.add(process.selectedHadronsAndPartonsForGenJetsFlavourInfos)
545 
546  process.load("PhysicsTools.JetMCAlgos.AK4GenJetFlavourInfos_cfi")
547  task.add(process.ak4GenJetFlavourInfos)
548 
549  process.load('PhysicsTools.PatAlgos.slimming.slimmedGenJetsFlavourInfos_cfi')
550  task.add(process.slimmedGenJetsFlavourInfos)
551 
552  #slimmed pileup information
553  process.load('PhysicsTools.PatAlgos.slimming.slimmedAddPileupInfo_cfi')
554  task.add(process.slimmedAddPileupInfo)
555 
556  process.muonMatch.matched = "prunedGenParticles"
557  process.electronMatch.matched = "prunedGenParticles"
558  process.electronMatch.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
559  process.photonMatch.matched = "prunedGenParticles"
560  process.photonMatch.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
561  process.ootPhotonMatch.matched = "prunedGenParticles"
562  process.ootPhotonMatch.src = cms.InputTag("reducedEgamma","reducedOOTPhotons")
563  process.tauMatch.matched = "prunedGenParticles"
564  process.tauGenJets.GenParticles = "prunedGenParticles"
565  #Boosted taus
566  process.tauMatchBoosted.matched = "prunedGenParticles"
567  process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
568  process.patJetPartons.particles = "genParticles"
569  process.patJetPartonMatch.matched = "prunedGenParticles"
570  pp_on_AA.toModify(process.patJetPartonMatch, matched = "hiSignalGenParticles")
571  from Configuration.ProcessModifiers.genJetSubEvent_cff import genJetSubEvent
572  genJetSubEvent.toModify(process.patJetPartonMatch, matched = "cleanedPartons")
573  process.patJetPartonMatch.mcStatus = [ 3, 23 ]
574  process.patJetGenJetMatch.matched = "slimmedGenJets"
575  (~pp_on_AA).toModify(process, patJetGenJetMatchAK8Puppi = dict(matched = "slimmedGenJetsAK8"))
576  process.patMuons.embedGenMatch = False
577  process.patElectrons.embedGenMatch = False
578  process.patPhotons.embedGenMatch = False
579  process.patOOTPhotons.embedGenMatch = False
580  process.patTaus.embedGenMatch = False
581  process.patTausBoosted.embedGenMatch = False
582  process.patJets.embedGenPartonMatch = False
583  #also jet flavour must be switched
584  process.patJetFlavourAssociation.rParam = 0.4
585 
586  from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeJECsForMC
587  pp_on_AA.toModify(process, removeJECsForMC)
588  pp_on_AA.toReplaceWith(task,task.copyAndExclude([process.slimmedGenJetsFlavourInfos]))
589 
590 
def miniAOD_customizeMC(process)
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

◆ miniAOD_customizeOutput()

def miniAOD_tools.miniAOD_customizeOutput (   out)

Definition at line 591 of file miniAOD_tools.py.

Referenced by ConfigBuilder.ConfigBuilder.addOutput().

591 def miniAOD_customizeOutput(out):
592  from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
593  out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
594  out.splitLevel = cms.untracked.int32(0)
595  out.dropMetaData = cms.untracked.string('ALL')
596  out.fastCloning= cms.untracked.bool(False)
597  out.overrideInputFileSplitLevels = cms.untracked.bool(True)
598  out.compressionAlgorithm = cms.untracked.string('LZMA')
599 
def miniAOD_customizeOutput(out)