1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
32 nanoMetadata = cms.EDProducer(
"UniqueStringProducer",
34 tag = cms.string(
"untagged"),
38 linkedObjects = cms.EDProducer(
"PATObjectCrossLinker",
39 jets=cms.InputTag(
"finalJetsPuppi"),
40 muons=cms.InputTag(
"finalMuons"),
41 electrons=cms.InputTag(
"finalElectrons"),
42 lowPtElectrons=cms.InputTag(
"finalLowPtElectrons"),
43 taus=cms.InputTag(
"finalTaus"),
44 boostedTaus=cms.InputTag(
"finalBoostedTaus"),
45 photons=cms.InputTag(
"finalPhotons"),
46 vertices=cms.InputTag(
"slimmedSecondaryVertices")
50 run2_nanoAOD_ANY.toModify(
51 linkedObjects, jets=
"finalJets" 55 run3_nanoAOD_122.toModify(
56 linkedObjects, boostedTaus=
None,
59 lhcInfoTable = cms.EDProducer(
"LHCInfoProducer")
61 nanoTableTaskCommon = cms.Task(
62 cms.Task(nanoMetadata),
63 jetPuppiTask, jetPuppiForMETTask, jetAK8Task,
64 extraFlagsProducersTask, muonTask, tauTask, boostedTauTask,
65 electronTask , lowPtElectronTask, photonTask,
66 vertexTask, isoTrackTask, jetAK8LepTask,
68 cms.Task(linkedObjects),
69 jetPuppiTablesTask, jetAK8TablesTask,
70 muonTablesTask, fsrTablesTask, tauTablesTask, boostedTauTablesTask,
71 electronTablesTask, lowPtElectronTablesTask, photonTablesTask,
72 globalTablesTask, vertexTablesTask, metTablesTask, extraFlagsTableTask,
73 isoTrackTablesTask,softActivityTablesTask
77 _nanoTableTaskCommonRun2 = nanoTableTaskCommon.copy()
78 _nanoTableTaskCommonRun2.replace(jetPuppiTask, jetTask)
79 _nanoTableTaskCommonRun2.replace(jetPuppiForMETTask, jetForMETTask)
80 _nanoTableTaskCommonRun2.replace(jetPuppiTablesTask, jetTablesTask)
81 run2_nanoAOD_ANY.toReplaceWith(
82 nanoTableTaskCommon, _nanoTableTaskCommonRun2
85 nanoSequenceCommon = cms.Sequence(nanoTableTaskCommon)
87 nanoSequenceOnlyFullSim = cms.Sequence(triggerObjectTablesTask)
88 nanoSequenceOnlyData = cms.Sequence(cms.Sequence(protonTablesTask) + lhcInfoTable)
90 nanoSequence = cms.Sequence(nanoSequenceCommon + nanoSequenceOnlyData + nanoSequenceOnlyFullSim)
92 nanoTableTaskFS = cms.Task(
93 genParticleTask, particleLevelTask, jetMCTask, muonMCTask, electronMCTask, lowPtElectronMCTask, photonMCTask,
94 tauMCTask, boostedTauMCTask,
95 metMCTable, ttbarCatMCProducersTask, globalTablesMCTask, ttbarCategoryTableTask,
96 genWeightsTableTask, genVertexTablesTask, genParticleTablesTask, genProtonTablesTask, particleLevelTablesTask
99 nanoSequenceFS = cms.Sequence(nanoSequenceCommon + cms.Sequence(nanoTableTaskFS))
102 nanoSequenceMC = nanoSequenceFS.copy()
103 nanoSequenceMC.insert(nanoSequenceFS.index(nanoSequenceCommon)+1,nanoSequenceOnlyFullSim)
106 import RecoTauTag.RecoTau.tools.runTauIdMVA
as tauIdConfig
109 updatedTauName =
"slimmedTausUpdated" 110 tauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug =
False,
111 updatedTauName = updatedTauName,
114 tauIdEmbedder.runTauID()
115 process.finalTaus.src = updatedTauName
118 process.tauTask.add( process.rerunMvaIsolationTaskForNano , process.patTauMVAIDsTask )
124 updatedBoostedTauName =
"slimmedTausBoostedNewID" 125 boostedTauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug =
False,
126 originalTauName =
"slimmedTausBoosted",
127 updatedTauName = updatedBoostedTauName,
128 postfix =
"BoostedForNano",
130 boostedTauIdEmbedder.runTauID()
131 process.finalBoostedTaus.src = updatedBoostedTauName
134 process.boostedTauTask.add( process.rerunMvaIsolationTaskBoostedForNano, getattr(process, updatedBoostedTauName))
140 originalTauName = process.finalTaus.src.value()
141 updatedTauName = originalTauName+
'WithPNet' 142 jetCollection =
"updatedJets" 143 process.load(
'RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff')
144 pnetTagName =
"pfParticleNetFromMiniAODAK4CHSCentralJetTag" 145 pnetDiscriminators = [];
146 for tag
in getattr(process,pnetTagName+
"s").flav_names.value():
147 pnetDiscriminators.append(pnetTagName+
"s:"+tag)
150 from PhysicsTools.PatAlgos.patTauHybridProducer_cfi
import patTauHybridProducer
151 setattr(process, updatedTauName, patTauHybridProducer.clone(
152 src = originalTauName,
153 jetSource = jetCollection,
157 pnetLabel = pnetTagName+
"s",
158 pnetScoreNames = pnetDiscriminators,
161 checkTauScoreIsBest =
False,
162 chargeAssignmentProbMin = 0.2,
163 addGenJetMatch =
False,
166 process.finalTaus.src = updatedTauName
173 addDeepFlavour =
False,
174 addParticleNet =
True 179 process.tauTask.add(process.jetTask, getattr(process, updatedTauName))
187 for modname
in electron_id_modules_WorkingPoints_nanoAOD.modules:
190 process.electronTask.add( process.egmGsfElectronIDTask )
193 for modname
in photon_id_modules_WorkingPoints_nanoAOD.modules:
196 process.photonTask.add( process.egmPhotonIDTask )
204 run2_nanoAOD_106Xv2.toModify(
205 nanoAOD_addDeepInfoAK4CHS_switch, nanoAOD_addParticleNet_switch=
True,
206 nanoAOD_addRobustParTAK4Tag_switch=
True,
211 addParticleNet=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addParticleNet_switch,
212 addRobustParTAK4=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addRobustParTAK4Tag_switch
217 addDeepBTag=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepBTag_switch,
218 addDeepFlavour=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepFlavourTag_switch,
219 addParticleNet=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addParticleNet_switch,
220 addRobustParTAK4=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addRobustParTAK4Tag_switch
225 addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
226 addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBoostedJet_switch,
227 addDeepDoubleX=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleX_switch,
228 addDeepDoubleXV2=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleXV2_switch,
229 addParticleNetMassLegacy=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNetMassLegacy_switch,
230 addParticleNet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNet_switch,
231 jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload
234 nanoAOD_tau_switch = cms.PSet(
235 idsToAdd = cms.vstring(),
236 runPNetAK4 = cms.bool(
False),
237 addPNet = cms.bool(
True)
239 (run2_nanoAOD_106Xv2 | run3_nanoAOD_122).toModify(
240 nanoAOD_tau_switch, idsToAdd = [
"deepTau2018v2p5"]
248 (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
249 nanoAOD_tau_switch, runPNetAK4 =
True 252 addPNetInfo = nanoAOD_tau_switch.addPNet.value(),
253 runPNetCHSAK4 = nanoAOD_tau_switch.runPNetAK4.value()
255 nanoAOD_boostedTau_switch = cms.PSet(
256 idsToAdd = cms.vstring()
258 run2_nanoAOD_106Xv2.toModify(
259 nanoAOD_boostedTau_switch, idsToAdd = [
"2017v2",
"dR0p32017v2",
"newDM2017v2",
"againstEle2018"]
268 pdgSelection=
"?(abs(pdgId) == 11|| abs(pdgId)==13 || abs(pdgId)==15 ||abs(pdgId)== 12 || abs(pdgId)== 14 || abs(pdgId)== 16|| abs(pdgId)== 24|| pdgId== 23)" 270 ptPrecision=
"{}?{}:{}".
format(pdgSelection, CandVars.pt.precision.value(),genParticleTable.variables.pt.precision.value())
271 process.genParticleTable.variables.pt.precision=cms.string(ptPrecision)
272 phiPrecision=
"{} ? {} : {}".
format(pdgSelection, CandVars.phi.precision.value(), genParticleTable.variables.phi.precision.value())
273 process.genParticleTable.variables.phi.precision=cms.string(phiPrecision)
274 etaPrecision=
"{} ? {} : {}".
format(pdgSelection, CandVars.eta.precision.value(), genParticleTable.variables.eta.precision.value())
275 process.genParticleTable.variables.eta.precision=cms.string(etaPrecision)
279 process.nanoTableTaskCommon.add(process.l1TablesTask)
284 process.nanoTableTaskCommon.add(process.l1TablesTask)
def nanoL1TrigObjCustomizeFull(process)
def nanoAOD_addDeepInfoAK4(process, addParticleNet, addRobustParTAK4=False)
def nanoAOD_activateVID(process)
def nanoWmassGenCustomize(process)
increasing the precision of selected GenParticles.
def nanoAOD_customizeCommon(process)
def nanoAOD_addDeepInfoAK4CHS(process, addDeepBTag, addDeepFlavour, addParticleNet, addRobustParTAK4=False)
def nanoAOD_addTauIds(process, idsToRun=[])
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNetMassLegacy, addParticleNet, jecPayload)
def nanoAOD_addBoostedTauIds(process, idsToRun=[])
def nanoL1TrigObjCustomize(process)
def nanoAOD_addPNetToTaus(process, addPNetInfo=False, runPNetCHSAK4=False)
def setL1NanoToReduced(process)