CMS 3D CMS Logo

customiseL1CustomReco.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 
4 from CondCore.CondDB.CondDB_cfi import *
6 from PhysicsTools.SelectorUtils.centralIDRegistry import central_id_registry
8 from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
9 
10 def L1NtupleCustomReco(process):
11 
12 
13 
14 
15  # load JEC from SQLite file
16  process.load("CondCore.CondDB.CondDB_cfi")
17 
18  # re-apply JEC for AK4 CHS PF jets
19  process.load('JetMETCorrections.Configuration.JetCorrectors_cff')
20 
21  process.load('L1Trigger.L1TNtuples.l1JetRecoTree_cfi')
22 
23  addJetCollection(
24  process,
25  labelName = "CorrectedPuppiJets",
26  jetSource = process.l1JetRecoTree.puppiJetToken,
27  jetCorrections = ('AK4PFPuppi', ['L1FastJet', 'L2Relative', 'L3Absolute','L2L3Residual'], 'None'),
28  pfCandidates = cms.InputTag("particleFlow"),
29  algo= 'AK', rParam = 0.4,
30  getJetMCFlavour=False
31  )
32  delattr(process, 'patJetGenJetMatchCorrectedPuppiJets')
33  delattr(process, 'patJetPartonMatchCorrectedPuppiJets')
34 
35 
36 
37 
38 
39  # load hbhe noise filter result producer
40  process.load('CommonTools/RecoAlgos/HBHENoiseFilterResultProducer_cfi')
41 
42  # Type-1 pf MET correction
43  process.load("JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff")
44  process.load("JetMETCorrections.Type1MET.correctedMet_cff")
45 
46  # Bad PF Muon filter for MET & HT
47  process.load('RecoMET.METFilters.BadPFMuonFilter_cfi')
48  process.BadPFMuonFilter.muons = cms.InputTag("muons")
49  process.BadPFMuonFilter.PFCandidates = cms.InputTag("particleFlow")
50 
51  # bad charged candidate filter
52  process.load('RecoMET.METFilters.BadChargedCandidateFilter_cfi')
53  process.BadChargedCandidateFilter.muons = cms.InputTag("muons")
54  process.BadChargedCandidateFilter.PFCandidates = cms.InputTag("particleFlow")
55 
56 
57 
58 
59  # turn on VID producer, indicate data format to be
60  # DataFormat.AOD or DataFormat.MiniAOD, as appropriate
61  dataFormat = DataFormat.AOD
62  switchOnVIDElectronIdProducer(process, dataFormat)
63  process.load("RecoEgamma.ElectronIdentification.egmGsfElectronIDs_cfi")
64  process.egmGsfElectronIDSequence = cms.Sequence(process.egmGsfElectronIDs)
65  # define which IDs we want to produce
66  idmod = 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff'
67  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection)
68 
69  switchOnVIDPhotonIdProducer(process, dataFormat)
70  process.load("RecoEgamma.PhotonIdentification.egmPhotonIDs_cfi")
71  process.load("RecoEgamma.PhotonIdentification.PhotonMVAValueMapProducer_cfi")
72  process.egmPhotonIDs.physicsObjectSrc = cms.InputTag("photons")
73  process.photonMVAValueMapProducer.src = cms.InputTag("photons")
74  process.egmPhotonIDSequence = cms.Sequence(process.photonMVAValueMapProducer*process.egmPhotonIDs)
75  idmod_photon = 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Winter22_122X_V1_cff'
76  setupAllVIDIdsInModule(process,idmod_photon,setupVIDPhotonSelection)
77 
78  process.l1CustomReco = cms.Path(
79  process.ak4PFCHSL1FastL2L3ResidualCorrectorChain
80  +process.ak4CaloL1FastL2L3ResidualCorrectorChain
81  +process.HBHENoiseFilterResultProducer
82  +process.correctionTermsPfMetType1Type2
83  +process.pfMetT1
84  +process.egmGsfElectronIDSequence
85  +process.egmPhotonIDSequence
86  +process.BadPFMuonFilter
87  +process.BadChargedCandidateFilter
88  )
89 
90  process.schedule.append(process.l1CustomReco)
91 
92  return process
93 
94 
95 def getJECFromSQLite(process):
96 
97  process.load("CondCore.CondDB.CondDB_cfi")
98 
99  process.jec = cms.ESSource(
100  "PoolDBESSource",
101  DBParameters = cms.PSet(
102  messageLevel = cms.untracked.int32(0)
103  ),
104  timetype = cms.string('runnumber'),
105  toGet = cms.VPSet(
106  cms.PSet(
107  record = cms.string('JetCorrectionsRecord'),
108  # for data
109  tag = cms.string('JetCorrectorParametersCollection_Summer15_25nsV6_DATA_AK4PFchs'),
110  # for MC
111  #tag = cms.string('JetCorrectorParametersCollection_Fall15_25nsV2_MC_AK4PFchs'),
112  label = cms.untracked.string('AK4PFCHS')
113  ),
114  ),
115  connect = cms.string('sqlite:Summer15_25nsV6_DATA.db')
116  # uncomment above tag lines and this comment to use MC JEC
117  # connect = cms.string('sqlite:Fall15_25nsV2_MC.db')
118  )
119 
120  process.es_prefer_jec = cms.ESPrefer('PoolDBESSource','jec')
121 
122  return process
def switchOnVIDElectronIdProducer(process, dataFormat, task=None)
Electrons.
Definition: vid_id_tools.py:66
def setupAllVIDIdsInModule(process, id_module_name, setupFunction, patProducer=None, addUserData=True, task=None)
Definition: vid_id_tools.py:49
def switchOnVIDPhotonIdProducer(process, dataFormat, task=None)
Photons.