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_customizeCommon (process)
 
def nanoAOD_customizeData (process)
 
def nanoAOD_customizeMC (process)
 
def nanoAOD_recalibrateMETs (process, isData)
 
def nanoAOD_runMETfixEE2017 (process, isData)
 
def nanoWmassGenCustomize (process)
 increasing the precision of selected GenParticles. More...
 

Variables

 _nanoTableTaskCommonRun2
 
 boostedTaus
 
 doc
 
 electronName
 
 electrons
 
 electronSel
 
 jetName
 
 jets
 
 jetSel
 
 lhcInfoTable
 
 linkedObjects
 
 lowPtElectronName
 
 lowPtElectrons
 
 lowPtElectronSel
 
 muonName
 
 muons
 
 muonSel
 
 name
 
 nanoMetadata
 
 nanoSequence
 
 nanoSequenceCommon
 
 nanoSequenceFS
 
 nanoSequenceMC
 
 nanoSequenceOnlyData
 
 nanoSequenceOnlyFullSim
 
 nanoTableTaskCommon
 
 nanoTableTaskFS
 
 photonName
 
 photons
 
 photonSel
 
 simpleCleanerTable
 
 strings
 
 tag
 
 tauName
 
 taus
 
 tauSel
 
 vertices
 

Function Documentation

◆ nanoAOD_activateVID()

def nano_cff.nanoAOD_activateVID (   process)

Definition at line 138 of file nano_cff.py.

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

Referenced by nanoAOD_customizeCommon(), nanoAOD_recalibrateMETs(), and nanoAOD_runMETfixEE2017().

138 def nanoAOD_activateVID(process):
139 
140  switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD,electronTask)
141  for modname in electron_id_modules_WorkingPoints_nanoAOD.modules:
142  setupAllVIDIdsInModule(process,modname,setupVIDElectronSelection)
143 
144  process.electronTask.add( process.egmGsfElectronIDTask )
145 
146  switchOnVIDPhotonIdProducer(process,DataFormat.MiniAOD,photonTask) # do not call this to avoid resetting photon IDs in VID, if called before inside makePuppiesFromMiniAOD
147  for modname in photon_id_modules_WorkingPoints_nanoAOD.modules:
148  setupAllVIDIdsInModule(process,modname,setupVIDPhotonSelection)
149 
150  process.photonTask.add( process.egmPhotonIDTask )
151 
152  return process
153 
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:138
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(), and nanoAOD_runMETfixEE2017().

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(), and nanoAOD_runMETfixEE2017().

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 , process.patTauMVAIDsTask )
118 
119  return process
120 
def nanoAOD_addTauIds(process, idsToRun=[])
Definition: nano_cff.py:106

◆ nanoAOD_customizeCommon()

def nano_cff.nanoAOD_customizeCommon (   process)

Definition at line 154 of file nano_cff.py.

References nanoAOD_activateVID(), nanoAOD_addBoostedTauIds(), jetsAK4_CHS_cff.nanoAOD_addDeepInfoAK4CHS(), jetsAK8_cff.nanoAOD_addDeepInfoAK8(), and nanoAOD_addTauIds().

Referenced by nanoAOD_customizeData(), nanoAOD_customizeMC(), and nanoAOD_runMETfixEE2017().

154 def nanoAOD_customizeCommon(process):
155 
156  process = nanoAOD_activateVID(process)
157 
158  # This function is defined in jetsAK4_CHS_cff.py
159  process = nanoAOD_addDeepInfoAK4CHS(process,
160  addDeepBTag=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepBTag_switch,
161  addDeepFlavour=nanoAOD_addDeepInfoAK4CHS_switch.nanoAOD_addDeepFlavourTag_switch
162  )
163 
164  # This function is defined in jetsAK8_cff.py
165  process = nanoAOD_addDeepInfoAK8(process,
166  addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
167  addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBoostedJet_switch,
168  addDeepDoubleX=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleX_switch,
169  addDeepDoubleXV2=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleXV2_switch,
170  addParticleNet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNet_switch,
171  addParticleNetMass=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNetMass_switch,
172  jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload
173  )
174 
175  nanoAOD_tau_switch = cms.PSet(
176  idsToAdd = cms.vstring()
177  )
178  (run2_nanoAOD_106Xv2 | run3_nanoAOD_122).toModify(
179  nanoAOD_tau_switch, idsToAdd = ["deepTau2018v2p5"]
180  ).toModify(
181  process, lambda p : nanoAOD_addTauIds(p, nanoAOD_tau_switch.idsToAdd.value())
182  )
183  nanoAOD_boostedTau_switch = cms.PSet(
184  idsToAdd = cms.vstring()
185  )
186  run2_nanoAOD_106Xv2.toModify(
187  nanoAOD_boostedTau_switch, idsToAdd = ["2017v2", "dR0p32017v2", "newDM2017v2","againstEle2018"]
188  ).toModify(
189  process, lambda p : nanoAOD_addBoostedTauIds(p, nanoAOD_boostedTau_switch.idsToAdd.value())
190  )
191 
192  return process
193 
def nanoAOD_customizeCommon(process)
Definition: nano_cff.py:154
def nanoAOD_addTauIds(process, idsToRun=[])
Definition: nano_cff.py:106
def nanoAOD_addBoostedTauIds(process, idsToRun=[])
Definition: nano_cff.py:121
def nanoAOD_addDeepInfoAK4CHS(process, addDeepBTag, addDeepFlavour)
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNet, addParticleNetMass, jecPayload)
Definition: jetsAK8_cff.py:146
def nanoAOD_activateVID(process)
Definition: nano_cff.py:138

◆ nanoAOD_customizeData()

def nano_cff.nanoAOD_customizeData (   process)

Definition at line 194 of file nano_cff.py.

References nanoAOD_customizeCommon().

Referenced by nanoAOD_runMETfixEE2017().

194 def nanoAOD_customizeData(process):
195  process = nanoAOD_customizeCommon(process)
196  return process
197 
def nanoAOD_customizeCommon(process)
Definition: nano_cff.py:154
def nanoAOD_customizeData(process)
Definition: nano_cff.py:194

◆ nanoAOD_customizeMC()

def nano_cff.nanoAOD_customizeMC (   process)

Definition at line 198 of file nano_cff.py.

References nanoAOD_customizeCommon().

Referenced by nanoAOD_runMETfixEE2017().

198 def nanoAOD_customizeMC(process):
199  process = nanoAOD_customizeCommon(process)
200  return process
201 
def nanoAOD_customizeCommon(process)
Definition: nano_cff.py:154
def nanoAOD_customizeMC(process)
Definition: nano_cff.py:198

◆ nanoAOD_recalibrateMETs()

def nano_cff.nanoAOD_recalibrateMETs (   process,
  isData 
)

Definition at line 158 of file nano_cff.py.

References helpers.addToProcessAndTask(), electrons_cff.bool, helpers.getPatAlgosToolsTask(), puppiForMET_cff.makePuppiesFromMiniAOD(), nanoAOD_activateVID(), print(), runMETCorrectionsAndUncertainties.runMetCorAndUncFromMiniAOD(), vid_id_tools.setupAllVIDIdsInModule(), vid_id_tools.switchOnVIDElectronIdProducer(), and vid_id_tools.switchOnVIDPhotonIdProducer().

158 def nanoAOD_recalibrateMETs(process,isData):
159  # add DeepMETs
160  nanoAOD_DeepMET_switch = cms.PSet(
161  ResponseTune_Graph = cms.untracked.string('RecoMET/METPUSubtraction/data/models/deepmet/deepmet_resp_v1_2018/model.graphdef')
162  )
163 
164  print("add DeepMET Producers")
165  process.load('RecoMET.METPUSubtraction.deepMETProducer_cfi')
166  process.deepMETsResolutionTune = process.deepMETProducer.clone()
167  process.deepMETsResponseTune = process.deepMETProducer.clone()
168  process.deepMETsResponseTune.graph_path = nanoAOD_DeepMET_switch.ResponseTune_Graph.value()
169 
170  runMetCorAndUncFromMiniAOD(process,isData=isData)
171  process.nanoSequenceCommon.insert(2,cms.Sequence(process.fullPatMetSequence))
172 
173 
174  from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD
175  makePuppiesFromMiniAOD(process,True)
176  process.puppiNoLep.useExistingWeights = True
177  process.puppi.useExistingWeights = True
178  #run2_nanoAOD_106Xv1.toModify(process.puppiNoLep, useExistingWeights = False)
179  #run2_nanoAOD_106Xv1.toModify(process.puppi, useExistingWeights = False)
180  print("will make Puppies on top of MINIAOD")
181 
182 # makePuppiesFromMiniAOD(process,True) # call this before in the global customizer otherwise it would reset photon IDs in VID
183  nanoAOD_PuppiV15_switch = cms.PSet(
184  recoMetFromPFCs = cms.untracked.bool(False),
185  reclusterJets = cms.untracked.bool(False),
186  )
187  #run2_nanoAOD_106Xv1.toModify(nanoAOD_PuppiV15_switch,recoMetFromPFCs=True,reclusterJets=True)
188  if nanoAOD_PuppiV15_switch.reclusterJets:
189  from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets
190  from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
191  task = getPatAlgosToolsTask(process)
192  addToProcessAndTask('ak4PuppiJets', ak4PFJets.clone (src = 'puppi', doAreaFastjet = True, jetPtMin = 10.), process, task)
193  from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
194  addJetCollection(process,
195  labelName = 'Puppi',
196  jetSource = cms.InputTag('ak4PuppiJets'),
197  algo = 'AK', rParam=0.4,
198  genJetCollection=cms.InputTag('slimmedGenJets'),
199  jetCorrections = ('AK4PFPuppi', ['L1FastJet', 'L2Relative', 'L3Absolute','L2L3Residual'], 'None'),
200  pfCandidates = cms.InputTag('packedPFCandidates'),
201  pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'),
202  svSource = cms.InputTag('slimmedSecondaryVertices'),
203  muSource =cms.InputTag( 'slimmedMuons'),
204  elSource = cms.InputTag('slimmedElectrons'),
205  genParticles= cms.InputTag('prunedGenParticles'),
206  getJetMCFlavour= False
207  )
208 
209  process.patJetsPuppi.addGenPartonMatch = cms.bool(False)
210  process.patJetsPuppi.addGenJetMatch = cms.bool(False)
211 
212  print("nanoAOD_PuppiV15_switch.reclusterJets is true")
213 
214  runMetCorAndUncFromMiniAOD(process,isData=isData,metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi", recoMetFromPFCs=bool(nanoAOD_PuppiV15_switch.recoMetFromPFCs), reclusterJets=bool(nanoAOD_PuppiV15_switch.reclusterJets))
215  process.nanoSequenceCommon.insert(2,cms.Sequence(process.puppiMETSequence+process.fullPatMetSequencePuppi))
216 
217  return process
218 
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:28
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def runMetCorAndUncFromMiniAOD(process, metType="PF", jetCollUnskimmed="slimmedJets", photonColl="slimmedPhotons", electronColl="slimmedElectrons", muonColl="slimmedMuons", tauColl="slimmedTaus", pfCandColl="packedPFCandidates", jetFlavor="AK4PFchs", jetCleaning="LepClean", isData=False, manualJetConfig=False, reclusterJets=None, jetSelection="pt>15 && abs(eta)<9.9", recoMetFromPFCs=None, jetCorLabelL3="ak4PFCHSL1FastL2L3Corrector", jetCorLabelRes="ak4PFCHSL1FastL2L3ResidualCorrector", CHS=False, reapplyJEC=True, jecUncFile="", computeMETSignificance=True, fixEE2017=False, fixEE2017Params=None, extractDeepMETs=False, campaign="", era="", postfix="")
def nanoAOD_recalibrateMETs(process, isData)
Definition: nano_cff.py:158
def getPatAlgosToolsTask(process)
Definition: helpers.py:13
def makePuppiesFromMiniAOD(process, createScheduledSequence=False)

◆ nanoAOD_runMETfixEE2017()

def nano_cff.nanoAOD_runMETfixEE2017 (   process,
  isData 
)

Definition at line 240 of file nano_cff.py.

References nanoAOD_activateVID(), nanoAOD_addBoostedTauIds(), jetsAK4_CHS_cff.nanoAOD_addDeepInfoAK4CHS(), jetsAK8_cff.nanoAOD_addDeepInfoAK8(), nanoAOD_addTauIds(), nanoAOD_customizeCommon(), nanoAOD_customizeData(), nanoAOD_customizeMC(), nanoWmassGenCustomize(), and runMETCorrectionsAndUncertainties.runMetCorAndUncFromMiniAOD().

240 def nanoAOD_runMETfixEE2017(process,isData):
241  runMetCorAndUncFromMiniAOD(process,isData=isData,
242  fixEE2017 = True,
243  fixEE2017Params = {'userawPt': True, 'ptThreshold':50.0, 'minEtaThreshold':2.65, 'maxEtaThreshold': 3.139},
244  postfix = "FixEE2017")
245  process.nanoSequenceCommon.insert(2,process.fullPatMetSequenceFixEE2017)
246 
247 
def runMetCorAndUncFromMiniAOD(process, metType="PF", jetCollUnskimmed="slimmedJets", photonColl="slimmedPhotons", electronColl="slimmedElectrons", muonColl="slimmedMuons", tauColl="slimmedTaus", pfCandColl="packedPFCandidates", jetFlavor="AK4PFchs", jetCleaning="LepClean", isData=False, manualJetConfig=False, reclusterJets=None, jetSelection="pt>15 && abs(eta)<9.9", recoMetFromPFCs=None, jetCorLabelL3="ak4PFCHSL1FastL2L3Corrector", jetCorLabelRes="ak4PFCHSL1FastL2L3ResidualCorrector", CHS=False, reapplyJEC=True, jecUncFile="", computeMETSignificance=True, fixEE2017=False, fixEE2017Params=None, extractDeepMETs=False, campaign="", era="", postfix="")
def nanoAOD_runMETfixEE2017(process, isData)
Definition: nano_cff.py:240

◆ nanoWmassGenCustomize()

def nano_cff.nanoWmassGenCustomize (   process)

increasing the precision of selected GenParticles.

Definition at line 203 of file nano_cff.py.

Referenced by nanoAOD_runMETfixEE2017().

203 def nanoWmassGenCustomize(process):
204  pdgSelection="?(abs(pdgId) == 11|| abs(pdgId)==13 || abs(pdgId)==15 ||abs(pdgId)== 12 || abs(pdgId)== 14 || abs(pdgId)== 16|| abs(pdgId)== 24|| pdgId== 23)"
205  # Keep precision same as default RECO for selected particles
206  ptPrecision="{}?{}:{}".format(pdgSelection, CandVars.pt.precision.value(),genParticleTable.variables.pt.precision.value())
207  process.genParticleTable.variables.pt.precision=cms.string(ptPrecision)
208  phiPrecision="{} ? {} : {}".format(pdgSelection, CandVars.phi.precision.value(), genParticleTable.variables.phi.precision.value())
209  process.genParticleTable.variables.phi.precision=cms.string(phiPrecision)
210  etaPrecision="{} ? {} : {}".format(pdgSelection, CandVars.eta.precision.value(), genParticleTable.variables.eta.precision.value())
211  process.genParticleTable.variables.eta.precision=cms.string(etaPrecision)
212  return process
213 
def nanoWmassGenCustomize(process)
increasing the precision of selected GenParticles.
Definition: nano_cff.py:203

Variable Documentation

◆ _nanoTableTaskCommonRun2

nano_cff._nanoTableTaskCommonRun2
private

Definition at line 76 of file nano_cff.py.

◆ boostedTaus

nano_cff.boostedTaus

Definition at line 43 of file nano_cff.py.

Referenced by PATObjectCrossLinker.produce().

◆ doc

nano_cff.doc

Definition at line 54 of file nano_cff.py.

◆ electronName

nano_cff.electronName

Definition at line 67 of file nano_cff.py.

◆ electrons

nano_cff.electrons

Definition at line 40 of file nano_cff.py.

◆ electronSel

nano_cff.electronSel

Definition at line 63 of file nano_cff.py.

◆ jetName

nano_cff.jetName

Definition at line 67 of file nano_cff.py.

◆ jets

nano_cff.jets

Definition at line 38 of file nano_cff.py.

◆ jetSel

nano_cff.jetSel

Definition at line 61 of file nano_cff.py.

◆ lhcInfoTable

nano_cff.lhcInfoTable

Definition at line 58 of file nano_cff.py.

◆ linkedObjects

nano_cff.linkedObjects

Definition at line 37 of file nano_cff.py.

◆ lowPtElectronName

nano_cff.lowPtElectronName

Definition at line 68 of file nano_cff.py.

◆ lowPtElectrons

nano_cff.lowPtElectrons

Definition at line 41 of file nano_cff.py.

Referenced by PATObjectCrossLinker.produce().

◆ lowPtElectronSel

nano_cff.lowPtElectronSel

Definition at line 64 of file nano_cff.py.

◆ muonName

nano_cff.muonName

Definition at line 67 of file nano_cff.py.

◆ muons

nano_cff.muons

Definition at line 39 of file nano_cff.py.

◆ muonSel

nano_cff.muonSel

Definition at line 62 of file nano_cff.py.

◆ name

nano_cff.name

Definition at line 53 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 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.

◆ photonName

nano_cff.photonName

Definition at line 69 of file nano_cff.py.

◆ photons

nano_cff.photons

Definition at line 44 of file nano_cff.py.

◆ photonSel

nano_cff.photonSel

Definition at line 66 of file nano_cff.py.

◆ simpleCleanerTable

nano_cff.simpleCleanerTable

Definition at line 52 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.

◆ tauName

nano_cff.tauName

Definition at line 69 of file nano_cff.py.

◆ taus

nano_cff.taus

Definition at line 42 of file nano_cff.py.

◆ tauSel

nano_cff.tauSel

Definition at line 65 of file nano_cff.py.

◆ vertices

nano_cff.vertices

Definition at line 45 of file nano_cff.py.