1 import FWCore.ParameterSet.Config
as cms
3 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
4 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff
import run2_nanoAOD_94X2016
9 from PhysicsTools.PatAlgos.tools.jetCollectionTools
import GenJetAdder, RecoJetAdder
41 config_genjets =
list(
filter(
lambda k: k[
'enabled'], config_genjets))
63 "name" :
"GenJetAK10",
80 "inputCollection" :
"slimmedJetsPuppi",
81 "genJetsCollection":
"slimmedGenJets",
86 "inputCollection" :
"slimmedCaloJets",
87 "genJetsCollection":
"slimmedGenJets",
92 "inputCollection" :
"",
93 "genJetsCollection":
"slimmedGenJets",
98 "inputCollection" :
"",
99 "genJetsCollection":
"slimmedGenJetsAK8",
104 "inputCollection" :
"",
105 "genJetsCollection":
"slimmedGenJetsAK8",
110 "inputCollection" :
"",
111 "genJetsCollection":
"AK6GenJetsNoNu",
116 "inputCollection" :
"",
117 "genJetsCollection":
"AK10GenJetsNoNu",
120 config_recojets =
list(
filter(
lambda k: k[
'enabled'], config_recojets))
124 nanoInfo_recojets = {
127 "doc" :
"AK4PFPUPPI jets",
131 "doc" :
"AK4Calo jets",
135 "doc" :
"AK4PF jets",
139 "doc" :
"AK8PF jets",
142 "name" :
"FatJetCHS",
143 "doc" :
"AK8PFCHS jets",
147 "doc" :
"AK6PF jets",
150 "name" :
"FatJetAK10PF",
151 "doc" :
"AK10PF jets",
159 recojetNameInNano = [
"Jet",
"FatJet" ]
164 genjetNameInNano = [
"GenJet",
"GenJetAK8" ]
166 JETVARS = cms.PSet(P4Vars,
167 HFHEF =
Var(
"HFHadronEnergyFraction()", float, doc =
"energy fraction in forward hadronic calorimeter", precision = 6),
168 HFEMEF =
Var(
"HFEMEnergyFraction()", float, doc =
"energy fraction in forward EM calorimeter", precision = 6),
169 area = jetTable.variables.area,
170 chHEF = jetTable.variables.chHEF,
171 neHEF = jetTable.variables.neHEF,
172 chEmEF = jetTable.variables.chEmEF,
173 neEmEF = jetTable.variables.neEmEF,
174 muEF = jetTable.variables.muEF,
175 rawFactor = jetTable.variables.rawFactor,
176 jetId = jetTable.variables.jetId,
177 jercCHPUF = jetTable.variables.jercCHPUF,
178 jercCHF = jetTable.variables.jercCHF,
181 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
182 modifier.toModify(JETVARS,
183 jetId =
Var(
"userInt('tightId')*2+userInt('looseId')", int, doc =
"Jet ID flags bit1 is loose, bit2 is tight")
193 Tool to store gen jet variables in NanoAOD for customized 205 resultSequence = cms.Sequence()
206 for idx, task
in enumerate(tasks):
208 resultSequence = cms.Sequence(getattr(proc, task))
210 resultSequence.insert(idx, getattr(proc, task))
211 return resultSequence
216 print(
"custom_jme_cff::TableGenJetAdder::addTable: Adding Table for GenJet Collection: {}".
format(genJetInfo.jet))
218 name = nanoInfo_genjets[genJetInfo.jet][
"name"]
219 doc = nanoInfo_genjets[genJetInfo.jet][
"doc"]
221 if name
in genjetNameInNano:
222 raise RuntimeError(
'GenJet collection name (%s) taken in NanoAOD for %s' %(name, genJetInfo.jet))
227 table =
"{}Table".
format(genJetInfo.jetTagName)
228 genJetsCollection =
"{}{}{}".
format(genJetInfo.jetAlgo.upper(), genJetInfo.jetSize,
'GenJetsNoNu')
229 setattr(proc, table, cms.EDProducer(
"SimpleCandidateFlatTableProducer",
230 src = cms.InputTag(genJetsCollection),
231 cut = cms.string(
""),
232 name = cms.string(name),
233 doc = cms.string(
'{} (generator level)'.
format(doc)),
234 singleton = cms.bool(
False),
235 extension = cms.bool(
False),
236 variables = cms.PSet(P4Vars,
237 area = jetTable.variables.area,
241 currentTasks.append(table)
246 genFlavour =
"{}Flavour".
format(genJetInfo.jetTagName)
247 genFlavourTable =
"{}Table".
format(genFlavour)
248 if genFlavourTable
in self.
main:
249 raise ValueError(
"Step '%s' already implemented" % genFlavourTable)
250 setattr(proc, genFlavourTable, cms.EDProducer(
"GenJetFlavourTableProducer",
251 name = cms.string(name),
252 src = cms.InputTag(genJetsCollection),
253 cut = cms.string(
""),
254 deltaR = cms.double(0.1),
255 jetFlavourInfos = cms.InputTag(genFlavour),
258 currentTasks.append(genFlavourTable)
259 self.main.extend(currentTasks)
268 Tool to store reco jet variables in NanoAOD for customized 269 reco jet collections. 277 resultSequence = cms.Sequence()
278 for idx, task
in enumerate(tasks):
280 resultSequence = cms.Sequence(getattr(proc, task))
282 resultSequence.insert(idx, getattr(proc, task))
283 return resultSequence
289 print(
"custom_jme_cff::TableRecoJetAdder::addTable: Adding Table for Reco Jet Collection: {}".
format(recoJetInfo.jet))
291 name = nanoInfo_recojets[recoJetInfo.jet][
"name"]
292 doc = nanoInfo_recojets[recoJetInfo.jet][
"doc"]
294 if name
in recojetNameInNano:
295 raise RuntimeError(
'RecoJet collection name (%s) taken in NanoAOD for %s' %(name, recoJetInfo.jet))
297 table =
"{}Table".
format(recoJetInfo.jetTagName)
298 if recoJetInfo.skipUserData:
299 if recoJetInfo.doCalo:
300 tableContents = cms.PSet(
302 area = jetTable.variables.area,
303 rawFactor = jetTable.variables.rawFactor,
304 emf =
Var(
"emEnergyFraction()", float, doc =
"electromagnetic energy fraction", precision = 10),
307 tableContents = cms.PSet(
309 area = jetTable.variables.area,
310 rawFactor = jetTable.variables.rawFactor,
313 tableContents = JETVARS.clone()
315 updatedJets =
"updatedJets{}".
format(recoJetInfo.jetTagName)
316 setattr(proc, table, cms.EDProducer(
"SimpleCandidateFlatTableProducer",
317 src = cms.InputTag(updatedJets),
318 cut = cms.string(
""),
319 name = cms.string(name),
320 doc = cms.string(doc),
321 singleton = cms.bool(
False),
322 extension = cms.bool(
False),
323 variables = tableContents,
326 currentTasks.append(table)
328 tightJetIdLepVeto =
"tightJetIdLepVeto{}".
format(recoJetInfo.jetTagName)
329 if not recoJetInfo.skipUserData:
330 altTasks = copy.deepcopy(currentTasks)
331 for idx, task
in enumerate(altTasks):
332 if task == tightJetIdLepVeto:
333 altTasks[idx] = looseJetId
334 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
335 modifier.toReplaceWith(currentTasks, altTasks)
336 self.main.extend(currentTasks)
343 process.genJetTable.variables.area = JETVARS.area
347 process.genJetAK8Table.variables.area = JETVARS.area
351 process.jetTable.variables.HFHEF = JETVARS.HFHEF
352 process.jetTable.variables.HFEMEF = JETVARS.HFEMEF
359 process.fatJetTable.variables.chHEF =
Var(
"?isPFJet()?chargedHadronEnergyFraction():-1", float, doc=
"charged Hadron Energy Fraction", precision = 6)
360 process.fatJetTable.variables.neHEF =
Var(
"?isPFJet()?neutralHadronEnergyFraction():-1", float, doc=
"neutral Hadron Energy Fraction", precision = 6)
361 process.fatJetTable.variables.chEmEF =
Var(
"?isPFJet()?chargedEmEnergyFraction():-1", float, doc=
"charged Electromagnetic Energy Fraction", precision = 6)
362 process.fatJetTable.variables.neEmEF =
Var(
"?isPFJet()?neutralEmEnergyFraction():-1", float, doc=
"neutral Electromagnetic Energy Fraction", precision = 6)
363 process.fatJetTable.variables.muEF =
Var(
"?isPFJet()?muonEnergyFraction():-1", float, doc=
"muon Energy Fraction", precision = 6)
364 process.fatJetTable.variables.HFHEF =
Var(
"?isPFJet()?HFHadronEnergyFraction():-1", float, doc=
"energy fraction in forward hadronic calorimeter", precision = 6)
365 process.fatJetTable.variables.HFEMEF =
Var(
"?isPFJet()?HFEMEnergyFraction():-1", float, doc=
"energy fraction in forward EM calorimeter", precision = 6)
369 process.jercVarsFatJet = process.jercVars.clone(
370 srcJet =
"updatedJetsAK8",
373 process.jetSequence.insert(process.jetSequence.index(process.updatedJetsAK8WithUserData), process.jercVarsFatJet)
375 process.updatedJetsAK8WithUserData.userFloats.jercCHPUF = cms.InputTag(
376 "%s:chargedHadronPUEnergyFraction" % process.jercVarsFatJet.label()
378 process.updatedJetsAK8WithUserData.userFloats.jercCHF = cms.InputTag(
379 "%s:chargedHadronCHSEnergyFraction" % process.jercVarsFatJet.label()
381 process.fatJetTable.variables.jercCHPUF = JETVARS.jercCHPUF
382 process.fatJetTable.variables.jercCHF = JETVARS.jercCHF
386 process.finalJets.cut =
"" 387 process.finalJetsAK8.cut =
"" 388 process.genJetTable.cut =
"" 389 process.genJetFlavourTable.cut =
"" 390 process.genJetAK8Table.cut =
"" 391 process.genJetAK8FlavourTable.cut =
"" 398 genJA = GenJetAdder()
401 for jetConfig
in config_genjets:
402 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled" }
403 genJetInfo = genJA.addGenJetCollection(process, **cfg)
404 tableGenJA.addTable(process, genJetInfo)
406 process.nanoSequenceMC += genJA.getSequence(process)
407 process.nanoSequenceMC += tableGenJA.getSequence(process)
412 recoJA = RecoJetAdder()
415 for jetConfig
in config_recojets:
416 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled" }
417 recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
418 tableRecoJA.addTable(process, recoJetInfo)
420 process.nanoSequenceMC += recoJA.getSequence(process)
421 process.nanoSequenceMC += tableRecoJA.getSequence(process)
def getSequence(self, proc)
def addTable(self, proc, recoJetInfo)
S & print(S &os, JobReport::InputFile const &f)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
def addTable(self, proc, genJetInfo)
def getSequence(self, proc)
def PrepJMECustomNanoAOD(process)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run