CMS 3D CMS Logo

Functions | Variables
nano_cff Namespace Reference

Functions

def nanoAOD_activateVID (process)
 
def nanoAOD_addBoostedTauIds (process, idsToRun=[])
 
def nanoAOD_addTauIds (process, idsToRun=[])
 
def nanoAOD_addUTagToTaus (process, addUTagInfo=False, usePUPPIjets=False)
 
def nanoAOD_customizeCommon (process)
 
def nanoWmassGenCustomize (process)
 increasing the precision of selected GenParticles. More...
 

Variables

 _nanoTableTaskCommonRun2
 
 boostedTaus
 
 electrons
 
 jets
 
 lhcInfoTable
 
 linkedObjects
 
 lowPtElectrons
 
 muons
 
 nanoMetadata
 
 nanoSequence
 
 nanoSequenceCommon
 
 nanoSequenceFS
 
 nanoSequenceMC
 
 nanoSequenceOnlyData
 
 nanoSequenceOnlyFullSim
 
 nanoTableTaskCommon
 
 nanoTableTaskFS
 
 photons
 
 strings
 
 tag
 
 taus
 
 useNewLHCInfo
 
 vertices
 

Function Documentation

◆ nanoAOD_activateVID()

def nano_cff.nanoAOD_activateVID (   process)

Definition at line 190 of file nano_cff.py.

References vid_id_tools.setupAllVIDIdsInModule(), vid_id_tools.switchOnVIDElectronIdProducer(), and vid_id_tools.switchOnVIDPhotonIdProducer().

Referenced by nanoAOD_customizeCommon().

190 def nanoAOD_activateVID(process):
191 
192  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD,electronTask)
193  for modname in electron_id_modules_WorkingPoints_nanoAOD.modules:
194  setupAllVIDIdsInModule(process,modname,setupVIDElectronSelection)
195 
196  process.electronTask.add( process.egmGsfElectronIDTask )
197 
198  switchOnVIDPhotonIdProducer(process,DataFormat.MiniAOD,photonTask) # do not call this to avoid resetting photon IDs in VID, if called before inside makePuppiesFromMiniAOD
199  for modname in photon_id_modules_WorkingPoints_nanoAOD.modules:
200  setupAllVIDIdsInModule(process,modname,setupVIDPhotonSelection)
201 
202  process.photonTask.add( process.egmPhotonIDTask )
203 
204  return process
205 
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 nanoAOD_activateVID(process)
Definition: nano_cff.py:190
def switchOnVIDPhotonIdProducer(process, dataFormat, task=None)
Photons.

◆ nanoAOD_addBoostedTauIds()

def nano_cff.nanoAOD_addBoostedTauIds (   process,
  idsToRun = [] 
)

Definition at line 125 of file nano_cff.py.

Referenced by nanoAOD_customizeCommon().

125 def nanoAOD_addBoostedTauIds(process, idsToRun=[]):
126  if idsToRun: #no-empty list of tauIDs to run
127  updatedBoostedTauName = "slimmedTausBoostedNewID"
128  boostedTauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug = False,
129  originalTauName = "slimmedTausBoosted",
130  updatedTauName = updatedBoostedTauName,
131  postfix = "BoostedForNano",
132  toKeep = idsToRun)
133  boostedTauIdEmbedder.runTauID()
134  process.finalBoostedTaus.src = updatedBoostedTauName
135  #remember to adjust the selection and tables with added IDs
136 
137  process.boostedTauTask.add( process.rerunMvaIsolationTaskBoostedForNano, getattr(process, updatedBoostedTauName))
138 
139  return process
140 
def nanoAOD_addBoostedTauIds(process, idsToRun=[])
Definition: nano_cff.py:125

◆ nanoAOD_addTauIds()

def nano_cff.nanoAOD_addTauIds (   process,
  idsToRun = [] 
)

Definition at line 110 of file nano_cff.py.

Referenced by nanoAOD_customizeCommon().

110 def nanoAOD_addTauIds(process, idsToRun=[]):
111  if idsToRun: #no-empty list of tauIDs to run
112  updatedTauName = "slimmedTausUpdated"
113  tauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug = False,
114  updatedTauName = updatedTauName,
115  postfix = "ForNano",
116  toKeep = idsToRun)
117  tauIdEmbedder.runTauID()
118  process.finalTaus.src = updatedTauName
119  #remember to adjust the selection and tables with added IDs
120 
121  process.tauTask.add( process.rerunMvaIsolationTaskForNano, getattr(process, updatedTauName) )
122 
123  return process
124 
def nanoAOD_addTauIds(process, idsToRun=[])
Definition: nano_cff.py:110

◆ nanoAOD_addUTagToTaus()

def nano_cff.nanoAOD_addUTagToTaus (   process,
  addUTagInfo = False,
  usePUPPIjets = False 
)

Definition at line 141 of file nano_cff.py.

Referenced by nanoAOD_customizeCommon().

141 def nanoAOD_addUTagToTaus(process, addUTagInfo=False, usePUPPIjets=False):
142 
143  if addUTagInfo:
144  originalTauName = process.finalTaus.src.value()
145 
146  if usePUPPIjets: # option to use PUPPI jets
147  jetCollection = "updatedJetsPuppi"
148  TagName = "pfUnifiedParticleTransformerAK4JetTags"
149  tag_prefix = "byUTagPUPPI"
150  updatedTauName = originalTauName+'WithUTagPUPPI'
151  # Unified ParT Tagger used for PUPPI jets
152  from RecoBTag.ONNXRuntime.pfUnifiedParticleTransformerAK4JetTags_cfi import pfUnifiedParticleTransformerAK4JetTags
153  Discriminators = [TagName+":"+tag for tag in pfUnifiedParticleTransformerAK4JetTags.flav_names.value()]
154  else: # use CHS jets by default
155  jetCollection = "updatedJets"
156  TagName = "pfParticleNetFromMiniAODAK4CHSCentralJetTags"
157  tag_prefix = "byUTagCHS"
158  updatedTauName = originalTauName+'WithUTagCHS'
159  # PNet tagger used for CHS jets
160  from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import pfParticleNetFromMiniAODAK4CHSCentralJetTags
161  Discriminators = [TagName+":"+tag for tag in pfParticleNetFromMiniAODAK4CHSCentralJetTags.flav_names.value()]
162 
163  # Define "hybridTau" producer
164  from PhysicsTools.PatAlgos.patTauHybridProducer_cfi import patTauHybridProducer
165  setattr(process, updatedTauName, patTauHybridProducer.clone(
166  src = originalTauName,
167  jetSource = jetCollection,
168  dRMax = 0.4,
169  jetPtMin = 15,
170  jetEtaMax = 2.5,
171  UTagLabel = TagName,
172  UTagScoreNames = Discriminators,
173  tagPrefix = tag_prefix,
174  tauScoreMin = -1,
175  vsJetMin = 0.05,
176  checkTauScoreIsBest = False,
177  chargeAssignmentProbMin = 0.2,
178  addGenJetMatch = False,
179  genJetMatch = ""
180  ))
181  process.finalTaus.src = updatedTauName
182 
183  #remember to adjust the selection and tables with added IDs
184 
185  process.tauTask.add(process.jetTask, getattr(process, updatedTauName))
186 
187  return process
188 
def nanoAOD_addUTagToTaus(process, addUTagInfo=False, usePUPPIjets=False)
Definition: nano_cff.py:141

◆ nanoAOD_customizeCommon()

def nano_cff.nanoAOD_customizeCommon (   process)

Definition at line 206 of file nano_cff.py.

References leptonTimeLifeInfo_common_cff.addTimeLifeInfoBase(), nanoAOD_activateVID(), nanoAOD_addBoostedTauIds(), jetsAK4_Puppi_cff.nanoAOD_addDeepInfoAK4(), jetsAK4_CHS_cff.nanoAOD_addDeepInfoAK4CHS(), jetsAK8_cff.nanoAOD_addDeepInfoAK8(), nanoAOD_addTauIds(), and nanoAOD_addUTagToTaus().

206 def nanoAOD_customizeCommon(process):
207 
208  process = nanoAOD_activateVID(process)
209 
210  run2_nanoAOD_106Xv2.toModify(
211  nanoAOD_addDeepInfoAK4CHS_switch, nanoAOD_addParticleNet_switch=True,
212  nanoAOD_addRobustParTAK4Tag_switch=False,
213  nanoAOD_addUnifiedParTAK4Tag_switch=True,
214  )
215 
216  # enable rerun of PNet for CHS jets for early run3 eras
217  # (it is rerun for run2 within jet tasks while is not needed for newer
218  # run3 eras as it is present in miniAOD)
219  (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
220  nanoAOD_addDeepInfoAK4CHS_switch, nanoAOD_addParticleNet_switch = True
221  )
222 
223  # This function is defined in jetsAK4_Puppi_cff.py
224  process = nanoAOD_addDeepInfoAK4(process,
225  addParticleNet=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addParticleNet_switch,
226  addRobustParTAK4=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addRobustParTAK4Tag_switch,
227  addUnifiedParTAK4=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addUnifiedParTAK4Tag_switch
228  )
229 
230  # This function is defined in jetsAK4_CHS_cff.py
231  process = nanoAOD_addDeepInfoAK4CHS(process,
232  addDeepBTag=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepBTag_switch,
233  addDeepFlavour=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepFlavourTag_switch,
234  addParticleNet=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addParticleNet_switch,
235  addRobustParTAK4=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addRobustParTAK4Tag_switch,
236  addUnifiedParTAK4=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addUnifiedParTAK4Tag_switch
237  )
238 
239  # This function is defined in jetsAK8_cff.py
240  process = nanoAOD_addDeepInfoAK8(process,
241  addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
242  addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBoostedJet_switch,
243  addDeepDoubleX=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleX_switch,
244  addDeepDoubleXV2=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleXV2_switch,
245  addParticleNetMassLegacy=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNetMassLegacy_switch,
246  addParticleNet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNet_switch,
247  jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload
248  )
249 
250  nanoAOD_tau_switch = cms.PSet(
251  idsToAdd = cms.vstring(),
252  addUParTInfo = cms.bool(True),
253  addPNet = cms.bool(True)
254  )
255  (run2_nanoAOD_106Xv2 | run3_nanoAOD_122).toModify(
256  nanoAOD_tau_switch, idsToAdd = ["deepTau2018v2p5"]
257  ).toModify(
258  process, lambda p : nanoAOD_addTauIds(p, nanoAOD_tau_switch.idsToAdd.value())
259  )
260 
261  # Don't add Unified Tagger for PUPPI jets for Run 2 (as different PUPPI tune
262  # and base jet algorithm) or early Run 3 eras
263  (run3_nanoAOD_122 | run3_nanoAOD_124 | run2_nanoAOD_106Xv2).toModify(
264  nanoAOD_tau_switch, addUParTInfo = False
265  )
266 
267  # Add Unified Tagger For CHS Jets (PNet 2023)
268  nanoAOD_addUTagToTaus(process,
269  addUTagInfo = nanoAOD_tau_switch.addPNet.value(),
270  usePUPPIjets = False
271  )
272 
273  # Add Unified Tagger For PUPPI Jets (UParT 2024)
274  nanoAOD_addUTagToTaus(process,
275  addUTagInfo = nanoAOD_tau_switch.addUParTInfo.value(),
276  usePUPPIjets = True
277  )
278 
279  nanoAOD_boostedTau_switch = cms.PSet(
280  idsToAdd = cms.vstring()
281  )
282  run2_nanoAOD_106Xv2.toModify(
283  nanoAOD_boostedTau_switch, idsToAdd = ["mvaIso", "mvaIsoNewDM", "mvaIsoDR0p3", "againstEle"]
284  ).toModify(
285  process, lambda p : nanoAOD_addBoostedTauIds(p, nanoAOD_boostedTau_switch.idsToAdd.value())
286  )
287 
288  # Add lepton time-life info
289  from PhysicsTools.NanoAOD.leptonTimeLifeInfo_common_cff import addTimeLifeInfoBase
290  process = addTimeLifeInfoBase(process)
291 
292  return process
293 
def nanoAOD_activateVID(process)
Definition: nano_cff.py:190
def nanoAOD_customizeCommon(process)
Definition: nano_cff.py:206
def nanoAOD_addUTagToTaus(process, addUTagInfo=False, usePUPPIjets=False)
Definition: nano_cff.py:141
def nanoAOD_addTauIds(process, idsToRun=[])
Definition: nano_cff.py:110
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNetMassLegacy, addParticleNet, jecPayload)
Definition: jetsAK8_cff.py:220
def nanoAOD_addDeepInfoAK4(process, addParticleNet, addRobustParTAK4=False, addUnifiedParTAK4=False)
def nanoAOD_addBoostedTauIds(process, idsToRun=[])
Definition: nano_cff.py:125
def nanoAOD_addDeepInfoAK4CHS(process, addDeepBTag, addDeepFlavour, addParticleNet, addRobustParTAK4=False, addUnifiedParTAK4=False)

◆ nanoWmassGenCustomize()

def nano_cff.nanoWmassGenCustomize (   process)

increasing the precision of selected GenParticles.

Definition at line 295 of file nano_cff.py.

295 def nanoWmassGenCustomize(process):
296  pdgSelection="?(abs(pdgId) == 11|| abs(pdgId)==13 || abs(pdgId)==15 ||abs(pdgId)== 12 || abs(pdgId)== 14 || abs(pdgId)== 16|| abs(pdgId)== 24|| pdgId== 23)"
297  # Keep precision same as default RECO for selected particles
298  ptPrecision="{}?{}:{}".format(pdgSelection, CandVars.pt.precision.value(),genParticleTable.variables.pt.precision.value())
299  process.genParticleTable.variables.pt.precision=cms.string(ptPrecision)
300  phiPrecision="{} ? {} : {}".format(pdgSelection, CandVars.phi.precision.value(), genParticleTable.variables.phi.precision.value())
301  process.genParticleTable.variables.phi.precision=cms.string(phiPrecision)
302  etaPrecision="{} ? {} : {}".format(pdgSelection, CandVars.eta.precision.value(), genParticleTable.variables.eta.precision.value())
303  process.genParticleTable.variables.eta.precision=cms.string(etaPrecision)
304  return process
305 
306 
def nanoWmassGenCustomize(process)
increasing the precision of selected GenParticles.
Definition: nano_cff.py:295

Variable Documentation

◆ _nanoTableTaskCommonRun2

nano_cff._nanoTableTaskCommonRun2
private

Definition at line 80 of file nano_cff.py.

◆ boostedTaus

nano_cff.boostedTaus

Definition at line 43 of file nano_cff.py.

Referenced by PATObjectCrossLinker.produce().

◆ electrons

nano_cff.electrons

Definition at line 40 of file nano_cff.py.

◆ jets

nano_cff.jets

Definition at line 38 of file nano_cff.py.

◆ lhcInfoTable

nano_cff.lhcInfoTable

Definition at line 59 of file nano_cff.py.

◆ linkedObjects

nano_cff.linkedObjects

Definition at line 37 of file nano_cff.py.

◆ lowPtElectrons

nano_cff.lowPtElectrons

Definition at line 41 of file nano_cff.py.

Referenced by PATObjectCrossLinker.produce().

◆ muons

nano_cff.muons

Definition at line 39 of file nano_cff.py.

◆ nanoMetadata

nano_cff.nanoMetadata

Definition at line 31 of file nano_cff.py.

◆ nanoSequence

nano_cff.nanoSequence

Definition at line 93 of file nano_cff.py.

◆ nanoSequenceCommon

nano_cff.nanoSequenceCommon

Definition at line 88 of file nano_cff.py.

◆ nanoSequenceFS

nano_cff.nanoSequenceFS

Definition at line 102 of file nano_cff.py.

◆ nanoSequenceMC

nano_cff.nanoSequenceMC

Definition at line 105 of file nano_cff.py.

◆ nanoSequenceOnlyData

nano_cff.nanoSequenceOnlyData

Definition at line 91 of file nano_cff.py.

◆ nanoSequenceOnlyFullSim

nano_cff.nanoSequenceOnlyFullSim

Definition at line 90 of file nano_cff.py.

◆ nanoTableTaskCommon

nano_cff.nanoTableTaskCommon

Definition at line 64 of file nano_cff.py.

◆ nanoTableTaskFS

nano_cff.nanoTableTaskFS

Definition at line 95 of file nano_cff.py.

◆ photons

nano_cff.photons

Definition at line 44 of file nano_cff.py.

◆ strings

nano_cff.strings

Definition at line 32 of file nano_cff.py.

◆ tag

nano_cff.tag

Definition at line 33 of file nano_cff.py.

◆ taus

nano_cff.taus

Definition at line 42 of file nano_cff.py.

◆ useNewLHCInfo

nano_cff.useNewLHCInfo

Definition at line 61 of file nano_cff.py.

◆ vertices

nano_cff.vertices

Definition at line 45 of file nano_cff.py.