1 import FWCore.ParameterSet.Config
as cms
6 from CommonTools.PileupAlgos.softKiller_cfi
import softKiller
13 from RecoJets.JetProducers.ak4GenJets_cfi
import ak4GenJets
15 from RecoJets.JetProducers.ak4CaloJets_cfi
import ak4CaloJets
33 Class to hold information of a genjet collection
44 jetRegex = re.compile(
45 r'(?P<{algo}>({algoList}))(?P<{size}>[0-9]+)gen'.
format(
47 algoList =
'|'.
join(supportedJetAlgos.keys()),
51 jetMatch = jetRegex.match(jet.lower())
53 raise RuntimeError(
'Invalid jet collection: %s' % jet)
65 Tool to schedule modules for building a genjet collection with input MiniAODs
82 print(
"jetCollectionTools::GenJetAdder::addGenJetCollection: Adding Gen Jet Collection: {}".
format(jet))
88 jetLower = genJetInfo.jetLower
89 jetUpper = genJetInfo.jetUpper
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),
123 if minPtFastjet !=
None:
124 getattr(proc, genJetsCollection).jetPtMin = minPtFastjet
125 self.prerequisites.append(genJetsCollection)
135 Class to hold information of a recojet collection
146 puMethodKey =
'puMethod'
147 jetRegex = re.compile(
148 r'(?P<{algo}>({algoList}))(?P<{size}>[0-9]+)(?P<{reco}>(pf|calo))(?P<{puMethod}>(chs|puppi|sk|cs|))'.
format(
150 algoList =
'|'.
join(supportedJetAlgos.keys()),
153 puMethod = puMethodKey,
156 jetMatch = jetRegex.match(jet.lower())
158 raise RuntimeError(
'Invalid jet collection: %s' % jet)
174 self.jetAlgo.upper(), self.
jetSize,
"Calo" if self.
doCalo else self.jetReco.upper()
193 Tool to schedule modules for building a patJet collection from MiniAODs
199 self.
pvLabel =
"offlineSlimmedPrimaryVertices"
205 self.
patJetsInMiniAOD = [
"slimmedJets",
"slimmedJetsAK8",
"slimmedJetsPuppi",
"slimmedCaloJets"]
214 inputCollection =
"",
216 genJetsCollection =
"",
217 bTagDiscriminators = [
"None"],
218 JETCorrLevels = [
"L1FastJet",
"L2Relative",
"L3Absolute",
"L2L3Residual"],
220 print(
"jetCollectionTools::RecoJetAdder::addRecoJetCollection: Adding Reco Jet Collection: {}".
format(jet))
225 raise RuntimeError(
"Invalid input collection: %s" % inputCollection)
233 jetLower = recoJetInfo.jetLower
234 jetUpper = recoJetInfo.jetUpper
235 tagName = recoJetInfo.jetTagName
237 if inputCollection ==
"slimmedJets":
238 assert(jetLower ==
"ak4pfchs")
239 elif inputCollection ==
"slimmedJetsAK8":
240 assert(jetLower ==
"ak8pfpuppi")
241 elif inputCollection ==
"slimmedJetsPuppi":
242 assert(jetLower ==
"ak4pfpuppi")
243 elif inputCollection ==
"slimmedCaloJets":
244 assert(jetLower ==
"ak4calo")
252 if not inputCollection
or recoJetInfo.doCalo:
253 print(
"jetCollectionTools::RecoJetAdder::addRecoJetCollection: inputCollection not specified. Building recojet collection now")
267 if recoJetInfo.jetPUMethod
not in [
"",
"cs" ]:
268 pfCand += recoJetInfo.jetPUMethod
279 if recoJetInfo.jetPUMethod
in [
"",
"cs" ]:
284 elif recoJetInfo.jetPUMethod ==
"chs":
285 from CommonTools.ParticleFlow.pfCHS_cff
import pfCHS, packedPrimaryVertexAssociationJME
286 self.
addProcessAndTask(proc,
"packedPrimaryVertexAssociationJME", packedPrimaryVertexAssociationJME.clone())
287 self.prerequisites.append(
"packedPrimaryVertexAssociationJME")
289 self.prerequisites.append(pfCand)
293 elif recoJetInfo.jetPUMethod ==
"puppi":
299 self.prerequisites.append(pfCand)
303 elif recoJetInfo.jetPUMethod ==
"sk":
306 rParam = recoJetInfo.jetSizeNr,
309 self.prerequisites.append(pfCand)
311 raise RuntimeError(
"Currently unsupported PU method: '%s'" % recoJetInfo.jetPUMethod)
318 if not recoJetInfo.doCalo:
319 jetCollection =
'{}Collection'.
format(jetUpper)
321 if jetCollection
in self.
main:
322 raise ValueError(
"Step '%s' already implemented" % jetCollection)
326 if recoJetInfo.jetPUMethod ==
"chs":
331 elif recoJetInfo.jetPUMethod ==
"puppi":
337 elif recoJetInfo.jetPUMethod ==
"sk":
342 elif recoJetInfo.jetPUMethod ==
"cs":
352 getattr(proc, jetCollection).jetAlgorithm = supportedJetAlgos[recoJetInfo.jetAlgo]
353 getattr(proc, jetCollection).rParam = recoJetInfo.jetSizeNr
357 if minPtFastjet !=
None:
358 getattr(proc, jetCollection).jetPtMin = minPtFastjet
359 currentTasks.append(jetCollection)
361 jetCollection = inputCollection
372 if recoJetInfo.jetPUMethod ==
"puppi":
373 jetCorrLabel =
"Puppi"
374 elif recoJetInfo.jetPUMethod
in [
"cs",
"sk" ]:
377 jetCorrLabel = recoJetInfo.jetPUMethod
381 recoJetInfo.jetAlgo.upper(),
383 "Calo" if recoJetInfo.doCalo
else recoJetInfo.jetReco.upper(),
390 postfix =
"Recluster" if inputCollection ==
"" else ""
393 labelName = jetUpper,
395 jetSource = cms.InputTag(jetCollection),
396 algo = recoJetInfo.jetAlgo,
397 rParam = recoJetInfo.jetSizeNr,
398 pvSource = cms.InputTag(self.
pvLabel),
399 pfCandidates = cms.InputTag(self.
pfLabel),
400 svSource = cms.InputTag(self.
svLabel),
401 muSource = cms.InputTag(self.
muLabel),
402 elSource = cms.InputTag(self.
elLabel),
403 genJetCollection = cms.InputTag(genJetsCollection),
404 genParticles = cms.InputTag(self.
gpLabel),
405 jetCorrections = jetCorrections,
411 if recoJetInfo.jetPUMethod ==
"puppi":
412 getattr(proc,
"patJetFlavourAssociation{}{}".
format(jetUpper,postfix)).weights = cms.InputTag(pfCand)
414 getJetMCFlavour =
not recoJetInfo.doCalo
and recoJetInfo.jetPUMethod !=
"cs"
416 delattr(proc,
'patJetGenJetMatch{}{}'.
format(jetUpper,postfix))
417 delattr(proc,
'patJetPartonMatch{}{}'.
format(jetUpper,postfix))
418 getJetMCFlavour =
False
419 setattr(getattr(proc,
"patJets{}{}".
format(jetUpper,postfix)),
"getJetMCFlavour", cms.bool(getJetMCFlavour))
421 selectedPatJets =
"selectedPatJets{}{}".
format(jetUpper,postfix)
432 labelName = jetUpper,
434 jetSource = cms.InputTag(selectedPatJets),
435 jetCorrections = jetCorrections,
436 btagDiscriminators = bTagDiscriminators,
439 recoJetInfo.patJetFinalCollection =
"selectedUpdatedPatJets{}{}".
format(jetUpper,
"Final")
441 recoJetInfo.patJetFinalCollection = inputCollection
443 self.main.extend(currentTasks)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)