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 186 of file nano_cff.py.

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

Referenced by nanoAOD_customizeCommon().

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

◆ nanoAOD_addBoostedTauIds()

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

Definition at line 121 of file nano_cff.py.

Referenced by nanoAOD_customizeCommon().

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

◆ nanoAOD_addTauIds()

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

Definition at line 106 of file nano_cff.py.

Referenced by nanoAOD_customizeCommon().

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

◆ nanoAOD_addUTagToTaus()

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

Definition at line 137 of file nano_cff.py.

Referenced by nanoAOD_customizeCommon().

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

◆ nanoAOD_customizeCommon()

def nano_cff.nanoAOD_customizeCommon (   process)

Definition at line 202 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().

202 def nanoAOD_customizeCommon(process):
203 
204  process = nanoAOD_activateVID(process)
205 
206  run2_nanoAOD_106Xv2.toModify(
207  nanoAOD_addDeepInfoAK4CHS_switch, nanoAOD_addParticleNet_switch=True,
208  nanoAOD_addRobustParTAK4Tag_switch=False,
209  nanoAOD_addUnifiedParTAK4Tag_switch=True,
210  )
211 
212  # This function is defined in jetsAK4_Puppi_cff.py
213  process = nanoAOD_addDeepInfoAK4(process,
214  addParticleNet=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addParticleNet_switch,
215  addRobustParTAK4=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addRobustParTAK4Tag_switch,
216  addUnifiedParTAK4=nanoAOD_addDeepInfoAK4_switch.nanoAOD_addUnifiedParTAK4Tag_switch
217  )
218 
219  # This function is defined in jetsAK4_CHS_cff.py
220  process = nanoAOD_addDeepInfoAK4CHS(process,
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,
225  addUnifiedParTAK4=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addUnifiedParTAK4Tag_switch
226  )
227 
228  # This function is defined in jetsAK8_cff.py
229  process = nanoAOD_addDeepInfoAK8(process,
230  addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
231  addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBoostedJet_switch,
232  addDeepDoubleX=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleX_switch,
233  addDeepDoubleXV2=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleXV2_switch,
234  addParticleNetMassLegacy=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNetMassLegacy_switch,
235  addParticleNet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNet_switch,
236  addGlobalParT=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addGlobalParT_switch,
237  jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload
238  )
239 
240  nanoAOD_tau_switch = cms.PSet(
241  idsToAdd = cms.vstring(),
242  addUParTInfo = cms.bool(False),
243  addPNet = cms.bool(False)
244  )
245  (run2_nanoAOD_106Xv2).toModify(
246  nanoAOD_tau_switch, idsToAdd = ["deepTau2018v2p5"]
247  ).toModify(
248  process, lambda p : nanoAOD_addTauIds(p, nanoAOD_tau_switch.idsToAdd.value())
249  )
250 
251  # Add Unified Tagger for CHS jets (PNet) for Run 2 era,
252  # but don't add Unified Tagger for PUPPI jets (as different PUPPI tune
253  # and base jet algorithm)
254  (run2_nanoAOD_106Xv2).toModify(
255  nanoAOD_tau_switch, addPNet = True
256  )
257  # Add Unified Taggers for Run 3 pre 142X (pre v15) era (Unified taggers
258  # are already added to slimmedTaus in miniAOD for newer eras)
259  run3_nanoAOD_pre142X.toModify(
260  nanoAOD_tau_switch, addPNet = True, addUParTInfo = True
261  )
262 
263  # Add Unified Tagger For CHS Jets (PNet 2023)
264  nanoAOD_addUTagToTaus(process,
265  addUTagInfo = nanoAOD_tau_switch.addPNet.value(),
266  usePUPPIjets = False
267  )
268 
269  # Add Unified Tagger For PUPPI Jets (UParT 2024)
270  nanoAOD_addUTagToTaus(process,
271  addUTagInfo = nanoAOD_tau_switch.addUParTInfo.value(),
272  usePUPPIjets = True
273  )
274 
275  nanoAOD_boostedTau_switch = cms.PSet(
276  idsToAdd = cms.vstring()
277  )
278  run2_nanoAOD_106Xv2.toModify(
279  nanoAOD_boostedTau_switch, idsToAdd = ["mvaIso", "mvaIsoNewDM", "mvaIsoDR0p3", "againstEle", "boostedDeepTauRunIIv2p0"]
280  ).toModify(
281  process, lambda p : nanoAOD_addBoostedTauIds(p, nanoAOD_boostedTau_switch.idsToAdd.value())
282  )
283  run3_nanoAOD_pre142X.toModify(
284  nanoAOD_boostedTau_switch, idsToAdd = ["boostedDeepTauRunIIv2p0"]
285  ).toModify(
286  process, lambda p : nanoAOD_addBoostedTauIds(p, nanoAOD_boostedTau_switch.idsToAdd.value())
287  )
288 
289  # Add lepton time-life info
290  from PhysicsTools.NanoAOD.leptonTimeLifeInfo_common_cff import addTimeLifeInfoBase
291  process = addTimeLifeInfoBase(process)
292 
293  return process
294 
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNetMassLegacy, addParticleNet, addGlobalParT, jecPayload)
Definition: jetsAK8_cff.py:172
def nanoAOD_activateVID(process)
Definition: nano_cff.py:186
def nanoAOD_customizeCommon(process)
Definition: nano_cff.py:202
def nanoAOD_addUTagToTaus(process, addUTagInfo=False, usePUPPIjets=False)
Definition: nano_cff.py:137
def nanoAOD_addTauIds(process, idsToRun=[])
Definition: nano_cff.py:106
def nanoAOD_addDeepInfoAK4(process, addParticleNet, addRobustParTAK4=False, addUnifiedParTAK4=False)
def nanoAOD_addBoostedTauIds(process, idsToRun=[])
Definition: nano_cff.py:121
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 296 of file nano_cff.py.

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

Variable Documentation

◆ _nanoTableTaskCommonRun2

nano_cff._nanoTableTaskCommonRun2
private

Definition at line 76 of file nano_cff.py.

◆ boostedTaus

nano_cff.boostedTaus

Definition at line 44 of file nano_cff.py.

Referenced by PATObjectCrossLinker.produce().

◆ electrons

nano_cff.electrons

Definition at line 41 of file nano_cff.py.

◆ jets

nano_cff.jets

Definition at line 39 of file nano_cff.py.

◆ lhcInfoTable

nano_cff.lhcInfoTable

Definition at line 55 of file nano_cff.py.

◆ linkedObjects

nano_cff.linkedObjects

Definition at line 38 of file nano_cff.py.

◆ lowPtElectrons

nano_cff.lowPtElectrons

Definition at line 42 of file nano_cff.py.

Referenced by PATObjectCrossLinker.produce().

◆ muons

nano_cff.muons

Definition at line 40 of file nano_cff.py.

◆ nanoMetadata

nano_cff.nanoMetadata

Definition at line 32 of file nano_cff.py.

◆ nanoSequence

nano_cff.nanoSequence

Definition at line 89 of file nano_cff.py.

◆ nanoSequenceCommon

nano_cff.nanoSequenceCommon

Definition at line 84 of file nano_cff.py.

◆ nanoSequenceFS

nano_cff.nanoSequenceFS

Definition at line 98 of file nano_cff.py.

◆ nanoSequenceMC

nano_cff.nanoSequenceMC

Definition at line 101 of file nano_cff.py.

◆ nanoSequenceOnlyData

nano_cff.nanoSequenceOnlyData

Definition at line 87 of file nano_cff.py.

◆ nanoSequenceOnlyFullSim

nano_cff.nanoSequenceOnlyFullSim

Definition at line 86 of file nano_cff.py.

◆ nanoTableTaskCommon

nano_cff.nanoTableTaskCommon

Definition at line 60 of file nano_cff.py.

◆ nanoTableTaskFS

nano_cff.nanoTableTaskFS

Definition at line 91 of file nano_cff.py.

◆ photons

nano_cff.photons

Definition at line 45 of file nano_cff.py.

◆ strings

nano_cff.strings

Definition at line 33 of file nano_cff.py.

◆ tag

nano_cff.tag

Definition at line 34 of file nano_cff.py.

◆ taus

nano_cff.taus

Definition at line 43 of file nano_cff.py.

◆ useNewLHCInfo

nano_cff.useNewLHCInfo

Definition at line 57 of file nano_cff.py.

◆ vertices

nano_cff.vertices

Definition at line 46 of file nano_cff.py.