1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
20 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
21 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff
import run2_nanoAOD_94X2016
22 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff
import run2_nanoAOD_94XMiniAODv1
23 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff
import run2_nanoAOD_94XMiniAODv2
24 from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff
import run2_nanoAOD_102Xv1
25 from Configuration.Eras.Modifier_run2_nanoAOD_106Xv1_cff
import run2_nanoAOD_106Xv1
27 nanoMetadata = cms.EDProducer(
"UniqueStringProducer",
29 tag = cms.string(
"untagged"),
33 linkedObjects = cms.EDProducer(
"PATObjectCrossLinker",
34 jets=cms.InputTag(
"finalJets"),
35 muons=cms.InputTag(
"finalMuons"),
36 electrons=cms.InputTag(
"finalElectrons"),
37 taus=cms.InputTag(
"finalTaus"),
38 photons=cms.InputTag(
"finalPhotons"),
41 simpleCleanerTable = cms.EDProducer(
"NanoAODSimpleCrossCleaner",
42 name=cms.string(
"cleanmask"),
43 doc=cms.string(
"simple cleaning mask with priority to leptons"),
44 jets=cms.InputTag(
"linkedObjects",
"jets"),
45 muons=cms.InputTag(
"linkedObjects",
"muons"),
46 electrons=cms.InputTag(
"linkedObjects",
"electrons"),
47 taus=cms.InputTag(
"linkedObjects",
"taus"),
48 photons=cms.InputTag(
"linkedObjects",
"photons"),
49 jetSel=cms.string(
"pt>15"),
50 muonSel=cms.string(
"track.isNonnull && isLooseMuon && isPFMuon && innerTrack.validFraction >= 0.49 && ( isGlobalMuon && globalTrack.normalizedChi2 < 3 && combinedQuality.chi2LocalPosition < 12 && combinedQuality.trkKink < 20 && segmentCompatibility >= 0.303 || segmentCompatibility >= 0.451 )"),
51 electronSel=cms.string(
""),
52 tauSel=cms.string(
""),
53 photonSel=cms.string(
""),
54 jetName=cms.string(
"Jet"),muonName=cms.string(
"Muon"),electronName=cms.string(
"Electron"),
55 tauName=cms.string(
"Tau"),photonName=cms.string(
"Photon")
58 btagSFdir=
"PhysicsTools/NanoAOD/data/btagSF/"
60 btagWeightTable = cms.EDProducer(
"BTagSFProducer",
61 src = cms.InputTag(
"linkedObjects",
"jets"),
62 cut = cms.string(
"pt > 25. && abs(eta) < 2.5"),
63 discNames = cms.vstring(
64 "pfCombinedInclusiveSecondaryVertexV2BJetTags",
65 "pfDeepCSVJetTags:probb+pfDeepCSVJetTags:probbb",
66 "pfCombinedMVAV2BJetTags"
68 discShortNames = cms.vstring(
73 weightFiles = cms.vstring(
74 btagSFdir+
"CSVv2_94XSF_V2_B_F.csv",
75 btagSFdir+
"DeepCSV_94XSF_V2_B_F.csv",
78 operatingPoints = cms.vstring(
"3",
"3",
"3"),
79 measurementTypesB = cms.vstring(
"iterativefit",
"iterativefit",
"iterativefit"),
80 measurementTypesC = cms.vstring(
"iterativefit",
"iterativefit",
"iterativefit"),
81 measurementTypesUDSG = cms.vstring(
"iterativefit",
"iterativefit",
"iterativefit"),
82 sysTypes = cms.vstring(
"central",
"central",
"central")
85 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
86 modifier.toModify(btagWeightTable,
87 cut = cms.string(
"pt > 25. && abs(eta) < 2.4"),
88 weightFiles = cms.vstring(
89 btagSFdir+
"CSVv2_Moriond17_B_H.csv",
91 btagSFdir+
"cMVAv2_Moriond17_B_H.csv"
96 genWeightsTable = cms.EDProducer(
"GenWeightsTableProducer",
97 genEvent = cms.InputTag(
"generator"),
98 genLumiInfoHeader = cms.InputTag(
"generator"),
99 lheInfo = cms.VInputTag(cms.InputTag(
"externalLHEProducer"), cms.InputTag(
"source")),
100 preferredPDFs = cms.VPSet(
101 cms.PSet( name = cms.string(
"PDF4LHC15_nnlo_30_pdfas"), lhaid = cms.uint32(91400) ),
102 cms.PSet( name = cms.string(
"NNPDF31_nnlo_hessian_pdfas"), lhaid = cms.uint32(306000) ),
103 cms.PSet( name = cms.string(
"NNPDF30_nlo_as_0118"), lhaid = cms.uint32(260000) ),
104 cms.PSet( name = cms.string(
"NNPDF30_lo_as_0130"), lhaid = cms.uint32(262000) ),
105 cms.PSet( name = cms.string(
"NNPDF30_nlo_nf_4_pdfas"), lhaid = cms.uint32(292000) ),
106 cms.PSet( name = cms.string(
"NNPDF30_nlo_nf_5_pdfas"), lhaid = cms.uint32(292200) ),
107 cms.PSet( name = cms.string(
"NNPDF31_lo_as_0130"), lhaid = cms.uint32(315200) ),
109 namedWeightIDs = cms.vstring(),
110 namedWeightLabels = cms.vstring(),
111 lheWeightPrecision = cms.int32(14),
112 maxPdfWeights = cms.uint32(150),
113 debug = cms.untracked.bool(
False),
115 lheInfoTable = cms.EDProducer(
"LHETablesProducer",
116 lheInfo = cms.VInputTag(cms.InputTag(
"externalLHEProducer"), cms.InputTag(
"source")),
117 precision = cms.int32(14),
118 storeLHEParticles = cms.bool(
True)
121 l1bits=cms.EDProducer(
"L1TriggerResultsConverter", src=cms.InputTag(
"gtStage2Digis"), legacyL1=cms.bool(
False),
122 storeUnprefireableBit=cms.bool(
True), src_ext=cms.InputTag(
"gtStage2Digis"))
123 (run2_miniAOD_80XLegacy | run2_nanoAOD_94X2016 | run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_102Xv1).toModify(l1bits, storeUnprefireableBit=
False)
125 nanoSequenceCommon = cms.Sequence(
126 nanoMetadata + jetSequence + muonSequence + tauSequence + electronSequence+photonSequence+vertexSequence+
127 isoTrackSequence + jetLepSequence +
129 jetTables + muonTables + tauTables + electronTables + photonTables + globalTables +vertexTables+ metTables+simpleCleanerTable + isoTrackTables
131 nanoSequenceOnlyFullSim = cms.Sequence(triggerObjectTables + l1bits)
133 nanoSequence = cms.Sequence(nanoSequenceCommon + nanoSequenceOnlyFullSim)
135 nanoSequenceFS = cms.Sequence(genParticleSequence + particleLevelSequence + nanoSequenceCommon + jetMC + muonMC + electronMC + photonMC + tauMC + metMC + ttbarCatMCProducers + globalTablesMC + btagWeightTable + genWeightsTable + genParticleTables + particleLevelTables + lheInfoTable + ttbarCategoryTable )
137 nanoSequenceMC = nanoSequenceFS.copy()
138 nanoSequenceMC.insert(nanoSequenceFS.index(nanoSequenceCommon)+1,nanoSequenceOnlyFullSim)
141 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1:
142 modifier.toModify(extraFlagsTable, variables= cms.PSet())
143 modifier.toModify(extraFlagsTable, variables = dict(Flag_ecalBadCalibFilterV2 =
ExtVar(cms.InputTag(
"ecalBadCalibFilterNanoTagger"), bool, doc =
"Bad ECAL calib flag (updated xtal list)")))
146 import RecoTauTag.RecoTau.tools.runTauIdMVA
as tauIdConfig
148 updatedTauName =
"slimmedTausUpdated"
149 tauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug =
False, updatedTauName = updatedTauName,
150 toKeep = [
"deepTau2017v2p1" ])
151 tauIdEmbedder.runTauID()
152 process.patTauMVAIDsSeq.insert(process.patTauMVAIDsSeq.index(getattr(process, updatedTauName)),
153 process.rerunMvaIsolationSequence)
158 _btagDiscriminators=[]
160 print(
"Updating process to run DeepCSV btag")
161 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc']
163 print(
"Updating process to run DeepFlavour btag")
164 _btagDiscriminators += [
'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
'pfDeepFlavourJetTags:probc']
165 if len(_btagDiscriminators)==0:
return process
166 print(
"Will recalculate the following discriminators: "+
", ".
join(_btagDiscriminators))
169 jetSource = cms.InputTag(
'slimmedJets'),
170 jetCorrections = (
'AK4PFchs', cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
171 btagDiscriminators = _btagDiscriminators,
172 postfix =
'WithDeepInfo',
174 process.load(
"Configuration.StandardSequences.MagneticField_cff")
175 process.jetCorrFactorsNano.src=
"selectedUpdatedPatJetsWithDeepInfo"
176 process.updatedJets.jetSource=
"selectedUpdatedPatJetsWithDeepInfo"
179 from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties
import runMetCorAndUncFromMiniAOD
183 process.nanoSequenceCommon.insert(process.nanoSequenceCommon.index(process.jetSequence),cms.Sequence(process.fullPatMetSequence))
184 process.basicJetsForMetForT1METNano = process.basicJetsForMet.clone(
185 src = process.updatedJetsWithUserData.src,
187 type1JetPtThreshold = 0.0,
188 calcMuonSubtrRawPtAsValueMap = cms.bool(
True),
190 process.jetSequence.insert(process.jetSequence.index(process.updatedJetsWithUserData),cms.Sequence(process.basicJetsForMetForT1METNano))
191 process.updatedJetsWithUserData.userFloats.muonSubtrRawPt = cms.InputTag(
"basicJetsForMetForT1METNano:MuonSubtrRawPt")
192 process.corrT1METJetTable.src = process.finalJets.src
193 process.corrT1METJetTable.cut =
"pt<15 && abs(eta)<9.9"
194 for table
in process.jetTable, process.corrT1METJetTable:
195 table.variables.muonSubtrFactor =
Var(
"1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc=
"1-(muon-subtracted raw pt)/(raw pt)",precision=6)
196 process.metTables += process.corrT1METJetTable
207 for modname
in electron_id_modules_WorkingPoints_nanoAOD.modules:
209 process.electronSequence.insert(process.electronSequence.index(process.bitmapVIDForEle),process.egmGsfElectronIDSequence)
210 for modifier
in run2_miniAOD_80XLegacy, :
211 modifier.toModify(process.electronMVAValueMapProducer, src =
"slimmedElectronsUpdated")
212 modifier.toModify(process.egmGsfElectronIDs, physicsObjectSrc =
"slimmedElectronsUpdated")
213 for modifier
in run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016 ,run2_nanoAOD_102Xv1:
214 modifier.toModify(process.electronMVAValueMapProducer, src =
"slimmedElectronsTo106X")
215 modifier.toModify(process.egmGsfElectronIDs, physicsObjectSrc =
"slimmedElectronsTo106X")
220 for modname
in photon_id_modules_WorkingPoints_nanoAOD.modules:
222 process.photonSequence.insert(process.photonSequence.index(bitmapVIDForPho),process.egmPhotonIDSequence)
223 for modifier
in run2_miniAOD_80XLegacy,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016 ,run2_nanoAOD_102Xv1:
224 modifier.toModify(process.photonMVAValueMapProducer, src =
"slimmedPhotonsTo106X")
225 modifier.toModify(process.egmPhotonIDs, physicsObjectSrc =
"slimmedPhotonsTo106X")
229 _btagDiscriminators=[]
231 print(
"Updating process to run DeepCSV btag to AK8 jets")
232 _btagDiscriminators += [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb']
233 if addDeepBoostedJet:
234 print(
"Updating process to run DeepBoostedJet on datasets before 103X")
236 _btagDiscriminators += pfDeepBoostedJetTagsAll
238 print(
"Updating process to run DeepDoubleX on datasets before 104X")
239 _btagDiscriminators += [
'pfDeepDoubleBvLJetTags:probHbb', \
240 'pfDeepDoubleCvLJetTags:probHcc', \
241 'pfDeepDoubleCvBJetTags:probHcc', \
242 'pfMassIndependentDeepDoubleBvLJetTags:probHbb',
'pfMassIndependentDeepDoubleCvLJetTags:probHcc',
'pfMassIndependentDeepDoubleCvBJetTags:probHcc']
243 if len(_btagDiscriminators)==0:
return process
244 print(
"Will recalculate the following discriminators on AK8 jets: "+
", ".
join(_btagDiscriminators))
247 jetSource = cms.InputTag(
'slimmedJetsAK8'),
248 pvSource = cms.InputTag(
'offlineSlimmedPrimaryVertices'),
249 svSource = cms.InputTag(
'slimmedSecondaryVertices'),
251 jetCorrections = (jecPayload.value(), cms.vstring([
'L1FastJet',
'L2Relative',
'L3Absolute',
'L2L3Residual']),
'None'),
252 btagDiscriminators = _btagDiscriminators,
253 postfix=
'AK8WithDeepInfo',
256 process.jetCorrFactorsAK8.src=
"selectedUpdatedPatJetsAK8WithDeepInfo"
257 process.updatedJetsAK8.jetSource=
"selectedUpdatedPatJetsAK8WithDeepInfo"
260 from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties
import runMetCorAndUncFromMiniAOD
264 fixEE2017Params = {
'userawPt':
True,
'ptThreshold':50.0,
'minEtaThreshold':2.65,
'maxEtaThreshold': 3.139},
265 postfix =
"FixEE2017")
266 process.nanoSequenceCommon.insert(process.nanoSequenceCommon.index(jetSequence),process.fullPatMetSequenceFixEE2017)
271 nanoAOD_addDeepInfo_switch = cms.PSet(
272 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
273 nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(
False),
275 run2_miniAOD_80XLegacy.toModify(nanoAOD_addDeepInfo_switch, nanoAOD_addDeepBTag_switch = cms.untracked.bool(
True))
276 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
277 modifier.toModify(nanoAOD_addDeepInfo_switch, nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(
True))
279 addDeepBTag=nanoAOD_addDeepInfo_switch.nanoAOD_addDeepBTag_switch,
280 addDeepFlavour=nanoAOD_addDeepInfo_switch.nanoAOD_addDeepFlavourTag_switch)
281 nanoAOD_addDeepInfoAK8_switch = cms.PSet(
282 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
False),
283 nanoAOD_addDeepBoostedJet_switch = cms.untracked.bool(
True),
284 nanoAOD_addDeepDoubleX_switch = cms.untracked.bool(
True),
285 jecPayload = cms.untracked.string(
'AK8PFPuppi')
288 run2_miniAOD_80XLegacy.toModify(nanoAOD_addDeepInfoAK8_switch,
289 nanoAOD_addDeepBTag_switch = cms.untracked.bool(
True),
290 nanoAOD_addDeepBoostedJet_switch = cms.untracked.bool(
False),
291 nanoAOD_addDeepDoubleX_switch = cms.untracked.bool(
False),
292 jecPayload = cms.untracked.string(
'AK8PFchs'))
294 addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
295 addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBoostedJet_switch,
296 addDeepDoubleX=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleX_switch,
297 jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload)
298 (run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94X2016 | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1).toModify(process,
lambda p :
nanoAOD_addTauIds(p))
304 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
311 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
316 _80x_sequence = nanoSequenceCommon.copy()
318 _80x_sequence.remove(isoTrackTables)
319 _80x_sequence.remove(isoTrackSequence)
321 _80x_sequence.insert(_80x_sequence.index(jetSequence), extraFlagsProducers)
322 _80x_sequence.insert(_80x_sequence.index(simpleCleanerTable)+1, extraFlagsTable)
324 run2_miniAOD_80XLegacy.toReplaceWith( nanoSequenceCommon, _80x_sequence)
326 _102x_sequence = nanoSequenceCommon.copy()
328 _102x_sequence.insert(_102x_sequence.index(jetSequence),extraFlagsProducers102x)
329 _102x_sequence.insert(_102x_sequence.index(simpleCleanerTable)+1,extraFlagsTable)
331 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1:
332 modifier.toReplaceWith(nanoSequenceCommon, _102x_sequence)