1 import FWCore.ParameterSet.Config
as cms
5 from CommonTools.ParticleFlow.pfCHS_cff
import pfCHS
8 from CommonTools.PileupAlgos.softKiller_cfi
import softKiller
15 from RecoJets.JetProducers.ak4GenJets_cfi
import ak4GenJets
17 from RecoJets.JetProducers.ak4CaloJets_cfi
import ak4CaloJets
35 Class to hold information of a genjet collection 46 jetRegex = re.compile(
47 r'(?P<{algo}>({algoList}))(?P<{size}>[0-9]+)gen'.
format(
49 algoList =
'|'.
join(supportedJetAlgos.keys()),
53 jetMatch = jetRegex.match(jet.lower())
55 raise RuntimeError(
'Invalid jet collection: %s' % jet)
67 Tool to schedule modules for building a genjet collection with input MiniAODs 84 print(
"jetCollectionTools::GenJetAdder::addGenJetCollection: Adding Gen Jet Collection: {}".
format(jet))
90 jetLower = genJetInfo.jetLower
91 jetUpper = genJetInfo.jetUpper
99 if not inputCollection:
100 print(
"jetCollectionTools::GenJetAdder::addGenJetCollection: inputCollection not specified. Building genjet collection now")
104 packedGenPartNoNu =
"packedGenParticlesForJetsNoNu" 107 src = cms.InputTag(
"packedGenParticles"),
108 cut = cms.string(
"abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16"),
115 genJetsCollection =
"{}{}{}".
format(genJetInfo.jetAlgo.upper(), genJetInfo.jetSize,
'GenJetsNoNu')
117 src = packedGenPartNoNu,
118 jetAlgorithm = cms.string(supportedJetAlgos[genJetInfo.jetAlgo]),
119 rParam = cms.double(genJetInfo.jetSizeNr),
125 if minPtFastjet !=
None:
126 getattr(proc, genJetsCollection).jetPtMin = minPtFastjet
137 Class to hold information of a recojet collection 148 puMethodKey =
'puMethod' 149 jetRegex = re.compile(
150 r'(?P<{algo}>({algoList}))(?P<{size}>[0-9]+)(?P<{reco}>(pf|calo))(?P<{puMethod}>(chs|puppi|sk|cs|))'.
format(
152 algoList =
'|'.
join(supportedJetAlgos.keys()),
155 puMethod = puMethodKey,
158 jetMatch = jetRegex.match(jet.lower())
160 raise RuntimeError(
'Invalid jet collection: %s' % jet)
195 Tool to schedule modules for building a patJet collection from MiniAODs 201 self.
pvLabel =
"offlineSlimmedPrimaryVertices" 207 self.
patJetsInMiniAOD = [
"slimmedJets",
"slimmedJetsAK8",
"slimmedJetsPuppi",
"slimmedCaloJets"]
216 inputCollection = "",
218 genJetsCollection = "",
219 bTagDiscriminators = ["None"],
220 JETCorrLevels = ["L1FastJet", "L2Relative", "L3Absolute", "L2L3Residual"],
222 print(
"jetCollectionTools::RecoJetAdder::addRecoJetCollection: Adding Reco Jet Collection: {}".
format(jet))
227 raise RuntimeError(
"Invalid input collection: %s" % inputCollection)
235 jetLower = recoJetInfo.jetLower
236 jetUpper = recoJetInfo.jetUpper
237 tagName = recoJetInfo.jetTagName
239 if inputCollection ==
"slimmedJets":
240 assert(jetLower ==
"ak4pfchs")
241 elif inputCollection ==
"slimmedJetsAK8":
242 assert(jetLower ==
"ak8pfpuppi")
243 elif inputCollection ==
"slimmedJetsPuppi":
244 assert(jetLower ==
"ak4pfpuppi")
245 elif inputCollection ==
"slimmedCaloJets":
246 assert(jetLower ==
"ak4calo")
254 if not inputCollection
or recoJetInfo.doCalo:
255 print(
"jetCollectionTools::RecoJetAdder::addRecoJetCollection: inputCollection not specified. Building recojet collection now")
269 if recoJetInfo.jetPUMethod
not in [
"",
"cs" ]:
270 pfCand += recoJetInfo.jetPUMethod
281 if recoJetInfo.jetPUMethod
in [
"",
"cs" ]:
286 elif recoJetInfo.jetPUMethod ==
"chs":
295 elif recoJetInfo.jetPUMethod ==
"puppi":
299 clonePackedCands =
True,
300 useExistingWeights =
True,
307 elif recoJetInfo.jetPUMethod ==
"sk":
310 rParam = recoJetInfo.jetSizeNr,
315 raise RuntimeError(
"Currently unsupported PU method: '%s'" % recoJetInfo.jetPUMethod)
322 if not recoJetInfo.doCalo:
323 jetCollection =
'{}Collection'.
format(jetUpper)
325 if jetCollection
in self.
main:
326 raise ValueError(
"Step '%s' already implemented" % jetCollection)
330 if recoJetInfo.jetPUMethod ==
"chs":
335 elif recoJetInfo.jetPUMethod ==
"puppi":
341 elif recoJetInfo.jetPUMethod ==
"sk":
346 elif recoJetInfo.jetPUMethod ==
"cs":
356 getattr(proc, jetCollection).jetAlgorithm = supportedJetAlgos[recoJetInfo.jetAlgo]
357 getattr(proc, jetCollection).rParam = recoJetInfo.jetSizeNr
361 if minPtFastjet !=
None:
362 getattr(proc, jetCollection).jetPtMin = minPtFastjet
363 currentTasks.append(jetCollection)
365 jetCollection = inputCollection
376 if recoJetInfo.jetPUMethod ==
"puppi":
377 jetCorrLabel =
"Puppi" 378 elif recoJetInfo.jetPUMethod
in [
"cs",
"sk" ]:
381 jetCorrLabel = recoJetInfo.jetPUMethod
385 recoJetInfo.jetAlgo.upper(),
387 "Calo" if recoJetInfo.doCalo
else recoJetInfo.jetReco.upper(),
394 postfix =
"Recluster" if inputCollection ==
"" else "" 397 labelName = jetUpper,
399 jetSource = cms.InputTag(jetCollection),
400 algo = recoJetInfo.jetAlgo,
401 rParam = recoJetInfo.jetSizeNr,
402 pvSource = cms.InputTag(self.
pvLabel),
403 pfCandidates = cms.InputTag(self.
pfLabel),
404 svSource = cms.InputTag(self.
svLabel),
405 muSource = cms.InputTag(self.
muLabel),
406 elSource = cms.InputTag(self.
elLabel),
407 genJetCollection = cms.InputTag(genJetsCollection),
408 genParticles = cms.InputTag(self.
gpLabel),
409 jetCorrections = jetCorrections,
415 if recoJetInfo.jetPUMethod ==
"puppi":
416 getattr(proc,
"patJetFlavourAssociation{}{}".
format(jetUpper,postfix)).weights = cms.InputTag(pfCand)
418 getJetMCFlavour =
not recoJetInfo.doCalo
and recoJetInfo.jetPUMethod !=
"cs" 420 delattr(proc,
'patJetGenJetMatch{}{}'.
format(jetUpper,postfix))
421 delattr(proc,
'patJetPartonMatch{}{}'.
format(jetUpper,postfix))
422 getJetMCFlavour =
False 423 setattr(getattr(proc,
"patJets{}{}".
format(jetUpper,postfix)),
"getJetMCFlavour", cms.bool(getJetMCFlavour))
425 selectedPatJets =
"selectedPatJets{}{}".
format(jetUpper,postfix)
436 labelName = jetUpper,
438 jetSource = cms.InputTag(selectedPatJets),
439 jetCorrections = jetCorrections,
440 btagDiscriminators = bTagDiscriminators,
443 recoJetInfo.patJetFinalCollection =
"selectedUpdatedPatJets{}{}".
format(jetUpper,
"Final")
445 recoJetInfo.patJetFinalCollection = inputCollection
447 self.
main.extend(currentTasks)
def addToProcessAndTask(label, module, process, task)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)
def getPatAlgosToolsTask(process)