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 from PhysicsTools.NanoAOD.lhcInfoProducer_cfi
import lhcInfoProducer
60 lhcInfoTable = lhcInfoProducer.clone()
61 (~run3_common).toModify(
62 lhcInfoTable, useNewLHCInfo=
False 65 nanoTableTaskCommon = cms.Task(
66 cms.Task(nanoMetadata),
67 jetPuppiTask, jetPuppiForMETTask, jetAK8Task,
68 extraFlagsProducersTask, muonTask, tauTask, boostedTauTask,
69 electronTask , lowPtElectronTask, photonTask,
70 vertexTask, isoTrackTask, jetAK8LepTask,
72 cms.Task(linkedObjects),
73 jetPuppiTablesTask, jetAK8TablesTask,
74 muonTablesTask, fsrTablesTask, tauTablesTask, boostedTauTablesTask,
75 electronTablesTask, lowPtElectronTablesTask, photonTablesTask,
76 globalTablesTask, vertexTablesTask, metTablesTask, extraFlagsTableTask,
77 isoTrackTablesTask,softActivityTablesTask
81 _nanoTableTaskCommonRun2 = nanoTableTaskCommon.copy()
82 _nanoTableTaskCommonRun2.replace(jetPuppiTask, jetTask)
83 _nanoTableTaskCommonRun2.replace(jetPuppiForMETTask, jetForMETTask)
84 _nanoTableTaskCommonRun2.replace(jetPuppiTablesTask, jetTablesTask)
85 run2_nanoAOD_ANY.toReplaceWith(
86 nanoTableTaskCommon, _nanoTableTaskCommonRun2
89 nanoSequenceCommon = cms.Sequence(nanoTableTaskCommon)
91 nanoSequenceOnlyFullSim = cms.Sequence(triggerObjectTablesTask)
92 nanoSequenceOnlyData = cms.Sequence(cms.Sequence(protonTablesTask) + lhcInfoTable)
94 nanoSequence = cms.Sequence(nanoSequenceCommon + nanoSequenceOnlyData + nanoSequenceOnlyFullSim)
96 nanoTableTaskFS = cms.Task(
97 genParticleTask, particleLevelTask, jetMCTask, muonMCTask, electronMCTask, lowPtElectronMCTask, photonMCTask,
98 tauMCTask, boostedTauMCTask,
99 metMCTable, ttbarCatMCProducersTask, globalTablesMCTask, ttbarCategoryTableTask,
100 genWeightsTableTask, genVertexTablesTask, genParticleTablesTask, genProtonTablesTask, particleLevelTablesTask
103 nanoSequenceFS = cms.Sequence(nanoSequenceCommon + cms.Sequence(nanoTableTaskFS))
106 nanoSequenceMC = nanoSequenceFS.copy()
107 nanoSequenceMC.insert(nanoSequenceFS.index(nanoSequenceCommon)+1,nanoSequenceOnlyFullSim)
110 import RecoTauTag.RecoTau.tools.runTauIdMVA
as tauIdConfig
113 updatedTauName =
"slimmedTausUpdated" 114 tauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug =
False,
115 updatedTauName = updatedTauName,
118 tauIdEmbedder.runTauID()
119 process.finalTaus.src = updatedTauName
122 process.tauTask.add( process.rerunMvaIsolationTaskForNano , process.patTauMVAIDsTask )
128 updatedBoostedTauName =
"slimmedTausBoostedNewID" 129 boostedTauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug =
False,
130 originalTauName =
"slimmedTausBoosted",
131 updatedTauName = updatedBoostedTauName,
132 postfix =
"BoostedForNano",
134 boostedTauIdEmbedder.runTauID()
135 process.finalBoostedTaus.src = updatedBoostedTauName
138 process.boostedTauTask.add( process.rerunMvaIsolationTaskBoostedForNano, getattr(process, updatedBoostedTauName))
144 originalTauName = process.finalTaus.src.value()
145 updatedTauName = originalTauName+
'WithPNet' 146 jetCollection =
"updatedJets" 147 process.load(
'RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff')
148 pnetTagName =
"pfParticleNetFromMiniAODAK4CHSCentralJetTag" 149 pnetDiscriminators = [];
150 for tag
in getattr(process,pnetTagName+
"s").flav_names.value():
151 pnetDiscriminators.append(pnetTagName+
"s:"+tag)
154 from PhysicsTools.PatAlgos.patTauHybridProducer_cfi
import patTauHybridProducer
155 setattr(process, updatedTauName, patTauHybridProducer.clone(
156 src = originalTauName,
157 jetSource = jetCollection,
161 pnetLabel = pnetTagName+
"s",
162 pnetScoreNames = pnetDiscriminators,
165 checkTauScoreIsBest =
False,
166 chargeAssignmentProbMin = 0.2,
167 addGenJetMatch =
False,
170 process.finalTaus.src = updatedTauName
177 addDeepFlavour =
False,
178 addParticleNet =
True 183 process.tauTask.add(process.jetTask, getattr(process, updatedTauName))
191 for modname
in electron_id_modules_WorkingPoints_nanoAOD.modules:
194 process.electronTask.add( process.egmGsfElectronIDTask )
197 for modname
in photon_id_modules_WorkingPoints_nanoAOD.modules:
200 process.photonTask.add( process.egmPhotonIDTask )
208 run2_nanoAOD_106Xv2.toModify(
209 nanoAOD_addDeepInfoAK4CHS_switch, nanoAOD_addParticleNet_switch=
True,
210 nanoAOD_addRobustParTAK4Tag_switch=
True,
215 addParticleNet=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addParticleNet_switch,
216 addRobustParTAK4=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addRobustParTAK4Tag_switch
221 addDeepBTag=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepBTag_switch,
222 addDeepFlavour=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepFlavourTag_switch,
223 addParticleNet=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addParticleNet_switch,
224 addRobustParTAK4=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addRobustParTAK4Tag_switch
229 addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
230 addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBoostedJet_switch,
231 addDeepDoubleX=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleX_switch,
232 addDeepDoubleXV2=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleXV2_switch,
233 addParticleNetMassLegacy=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNetMassLegacy_switch,
234 addParticleNet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNet_switch,
235 jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload
238 nanoAOD_tau_switch = cms.PSet(
239 idsToAdd = cms.vstring(),
240 runPNetAK4 = cms.bool(
False),
241 addPNet = cms.bool(
True)
243 (run2_nanoAOD_106Xv2 | run3_nanoAOD_122).toModify(
244 nanoAOD_tau_switch, idsToAdd = [
"deepTau2018v2p5"]
252 (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
253 nanoAOD_tau_switch, runPNetAK4 =
True 256 addPNetInfo = nanoAOD_tau_switch.addPNet.value(),
257 runPNetCHSAK4 = nanoAOD_tau_switch.runPNetAK4.value()
259 nanoAOD_boostedTau_switch = cms.PSet(
260 idsToAdd = cms.vstring()
262 run2_nanoAOD_106Xv2.toModify(
263 nanoAOD_boostedTau_switch, idsToAdd = [
"2017v2",
"dR0p32017v2",
"newDM2017v2",
"againstEle2018"]
272 pdgSelection=
"?(abs(pdgId) == 11|| abs(pdgId)==13 || abs(pdgId)==15 ||abs(pdgId)== 12 || abs(pdgId)== 14 || abs(pdgId)== 16|| abs(pdgId)== 24|| pdgId== 23)" 274 ptPrecision=
"{}?{}:{}".
format(pdgSelection, CandVars.pt.precision.value(),genParticleTable.variables.pt.precision.value())
275 process.genParticleTable.variables.pt.precision=cms.string(ptPrecision)
276 phiPrecision=
"{} ? {} : {}".
format(pdgSelection, CandVars.phi.precision.value(), genParticleTable.variables.phi.precision.value())
277 process.genParticleTable.variables.phi.precision=cms.string(phiPrecision)
278 etaPrecision=
"{} ? {} : {}".
format(pdgSelection, CandVars.eta.precision.value(), genParticleTable.variables.eta.precision.value())
279 process.genParticleTable.variables.eta.precision=cms.string(etaPrecision)
283 process.nanoTableTaskCommon.add(process.l1TablesTask)
288 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)