1 import FWCore.ParameterSet.Config
as cms
6 from CommonTools.PileupAlgos.softKiller_cfi
import softKiller
12 from RecoJets.JetProducers.ak4GenJets_cfi
import ak4GenJets
14 from RecoJets.JetProducers.ak4CaloJets_cfi
import ak4CaloJets
32 Class to hold information of a genjet collection 43 jetRegex = re.compile(
44 r'(?P<{algo}>({algoList}))(?P<{size}>[0-9]+)gen'.
format(
46 algoList =
'|'.
join(supportedJetAlgos.keys()),
50 jetMatch = jetRegex.match(jet.lower())
52 raise RuntimeError(
'Invalid jet collection: %s' % jet)
64 Tool to schedule modules for building a genjet collection with input MiniAODs 81 print(
"jetCollectionTools::GenJetAdder::addGenJetCollection: Adding Gen Jet Collection: {}".
format(jet))
86 jetLower = jet.lower()
87 jetUpper = jet.upper()
97 if not inputCollection:
98 print(
"jetCollectionTools::GenJetAdder::addGenJetCollection: inputCollection not specified. Building genjet collection now")
102 packedGenPartNoNu =
"packedGenParticlesForJetsNoNu" 105 src = cms.InputTag(
"packedGenParticles"),
106 cut = cms.string(
"abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16"),
109 self.prerequisites.append(packedGenPartNoNu)
113 genJetsCollection =
"{}{}{}".
format(genJetInfo.jetAlgo.upper(), genJetInfo.jetSize,
'GenJetsNoNu')
115 src = packedGenPartNoNu,
116 jetAlgorithm = cms.string(supportedJetAlgos[genJetInfo.jetAlgo]),
117 rParam = cms.double(genJetInfo.jetSizeNr),
120 self.prerequisites.append(genJetsCollection)
131 Class to hold information of a recojet collection 142 puMethodKey =
'puMethod' 143 jetRegex = re.compile(
144 r'(?P<{algo}>({algoList}))(?P<{size}>[0-9]+)(?P<{reco}>(pf|calo))(?P<{puMethod}>(chs|puppi|sk|cs|))'.
format(
146 algoList =
'|'.
join(supportedJetAlgos.keys()),
149 puMethod = puMethodKey,
152 jetMatch = jetRegex.match(jet.lower())
154 raise RuntimeError(
'Invalid jet collection: %s' % jet)
170 self.jetAlgo.upper(), self.
jetSize,
"Calo" if self.
doCalo else self.jetReco.upper()
187 Tool to schedule modules for building a patJet collection from MiniAODs 193 self.
pvLabel =
"offlineSlimmedPrimaryVertices" 199 self.
patJetsInMiniAOD = [
"slimmedJets",
"slimmedJetsAK8",
"slimmedJetsPuppi",
"slimmedCaloJets"]
208 inputCollection =
"",
209 genJetsCollection =
"",
210 bTagDiscriminators = [
"None"],
211 JETCorrLevels = [
"L1FastJet",
"L2Relative",
"L3Absolute",
"L2L3Residual"],
213 print(
"jetCollectionTools::RecoJetAdder::addRecoJetCollection: Adding Reco Jet Collection: {}".
format(jet))
218 raise RuntimeError(
"Invalid input collection: %s" % inputCollection)
226 jetLower = recoJetInfo.jetLower
227 jetUpper = recoJetInfo.jetUpper
228 tagName = recoJetInfo.jetTagName
230 if inputCollection ==
"slimmedJets":
231 assert(jetLower ==
"ak4pfchs")
232 elif inputCollection ==
"slimmedJetsAK8":
233 assert(jetLower ==
"ak8pfpuppi")
234 elif inputCollection ==
"slimmedJetsPuppi":
235 assert(jetLower ==
"ak4pfpuppi")
236 elif inputCollection ==
"slimmedCaloJets":
237 assert(jetLower ==
"ak4calo")
245 if not inputCollection
or recoJetInfo.doCalo:
246 print(
"jetCollectionTools::RecoJetAdder::addRecoJetCollection: inputCollection not specified. Building recojet collection now")
260 if recoJetInfo.jetPUMethod
not in [
"",
"cs" ]:
261 pfCand += recoJetInfo.jetPUMethod
272 if recoJetInfo.jetPUMethod
in [
"",
"cs" ]:
277 elif recoJetInfo.jetPUMethod ==
"chs":
279 src = cms.InputTag(self.
pfLabel),
280 cut = cms.string(
"fromPV"),
283 self.prerequisites.append(pfCand)
287 elif recoJetInfo.jetPUMethod ==
"puppi":
291 clonePackedCands =
True,
292 useExistingWeights =
True,
295 self.prerequisites.append(pfCand)
299 elif recoJetInfo.jetPUMethod ==
"sk":
302 rParam = recoJetInfo.jetSizeNr,
305 self.prerequisites.append(pfCand)
307 raise RuntimeError(
"Currently unsupported PU method: '%s'" % recoJetInfo.jetPUMethod)
314 if not recoJetInfo.doCalo:
315 jetCollection =
'{}Collection'.
format(jetUpper)
317 if jetCollection
in self.
main:
318 raise ValueError(
"Step '%s' already implemented" % jetCollection)
322 if recoJetInfo.jetPUMethod ==
"chs":
327 elif recoJetInfo.jetPUMethod ==
"puppi":
332 elif recoJetInfo.jetPUMethod ==
"sk":
337 elif recoJetInfo.jetPUMethod ==
"cs":
347 getattr(proc, jetCollection).jetAlgorithm = supportedJetAlgos[recoJetInfo.jetAlgo]
348 getattr(proc, jetCollection).rParam = recoJetInfo.jetSizeNr
349 currentTasks.append(jetCollection)
351 jetCollection = inputCollection
362 if recoJetInfo.jetPUMethod ==
"puppi":
363 jetCorrLabel =
"Puppi" 364 elif recoJetInfo.jetPUMethod
in [
"cs",
"sk" ]:
367 jetCorrLabel = recoJetInfo.jetPUMethod
371 recoJetInfo.jetAlgo.upper(),
373 "Calo" if recoJetInfo.doCalo
else recoJetInfo.jetReco.upper(),
380 postfix =
"Recluster" if inputCollection ==
"" else "" 383 labelName = jetUpper,
385 jetSource = cms.InputTag(jetCollection),
386 algo = recoJetInfo.jetAlgo,
387 rParam = recoJetInfo.jetSizeNr,
388 pvSource = cms.InputTag(self.
pvLabel),
389 pfCandidates = cms.InputTag(self.
pfLabel),
390 svSource = cms.InputTag(self.
svLabel),
391 muSource = cms.InputTag(self.
muLabel),
392 elSource = cms.InputTag(self.
elLabel),
393 genJetCollection = cms.InputTag(genJetsCollection),
394 genParticles = cms.InputTag(self.
gpLabel),
395 jetCorrections = jetCorrections,
401 if recoJetInfo.jetPUMethod ==
"puppi":
402 getattr(proc,
"patJetFlavourAssociation{}{}".
format(tagName,postfix)).weights = cms.InputTag(pfCand)
404 getJetMCFlavour =
not recoJetInfo.doCalo
and recoJetInfo.jetPUMethod !=
"cs" 406 delattr(proc,
'patJetGenJetMatch{}{}'.
format(tagName,postfix))
407 delattr(proc,
'patJetPartonMatch{}{}'.
format(tagName,postfix))
408 getJetMCFlavour =
False 409 setattr(getattr(proc,
"patJets{}{}".
format(tagName,postfix)),
"getJetMCFlavour", cms.bool(getJetMCFlavour))
411 selectedPatJetCollection =
"selectedPatJets{}{}".
format(tagName,postfix)
422 labelName = jetUpper,
424 jetSource = cms.InputTag(selectedPatJetCollection),
425 jetCorrections = jetCorrections,
426 btagDiscriminators = bTagDiscriminators,
429 patJetFinalCollection=
"selectedUpdatedPatJets{}{}".
format(tagName,
"Final")
431 patJetFinalCollection = inputCollection
433 self.main.extend(currentTasks)
def addToProcessAndTask(label, module, process, task)
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)
def getPatAlgosToolsTask(process)