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 
70 
71 
72  process.l1CustomReco = cms.Path(
73  process.ak4PFCHSL1FastL2L3ResidualCorrectorChain
74  +process.ak4CaloL1FastL2L3ResidualCorrectorChain
75  +process.HBHENoiseFilterResultProducer
76  +process.correctionTermsPfMetType1Type2
77  +process.pfMetT1
78  +process.egmGsfElectronIDSequence
79  +process.BadPFMuonFilter
80  +process.BadChargedCandidateFilter
81  )
82 
83  process.schedule.append(process.l1CustomReco)
84 
85  return process
86 
87 
88 def getJECFromSQLite(process):
89 
90  process.load("CondCore.CondDB.CondDB_cfi")
91 
92  process.jec = cms.ESSource(
93  "PoolDBESSource",
94  DBParameters = cms.PSet(
95  messageLevel = cms.untracked.int32(0)
96  ),
97  timetype = cms.string('runnumber'),
98  toGet = cms.VPSet(
99  cms.PSet(
100  record = cms.string('JetCorrectionsRecord'),
101  # for data
102  tag = cms.string('JetCorrectorParametersCollection_Summer15_25nsV6_DATA_AK4PFchs'),
103  # for MC
104  #tag = cms.string('JetCorrectorParametersCollection_Fall15_25nsV2_MC_AK4PFchs'),
105  label = cms.untracked.string('AK4PFCHS')
106  ),
107  ),
108  connect = cms.string('sqlite:Summer15_25nsV6_DATA.db')
109  # uncomment above tag lines and this comment to use MC JEC
110  # connect = cms.string('sqlite:Fall15_25nsV2_MC.db')
111  )
112 
113  process.es_prefer_jec = cms.ESPrefer('PoolDBESSource','jec')
114 
115  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