1 from __future__
import print_function
3 from FWCore.ParameterSet.Mixins import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase
9 from FWCore.ParameterSet.MassReplace
import MassSearchReplaceAnyInputTagVisitor
14 ,
'ca' :
'CambridgeAachen' 20 if not isinstance(jetCorrections, type((
'PAYLOAD-LABEL',[
'CORRECTION-LEVEL-A',
'CORRECTION-LEVEL-B'],
'MET-LABEL'))):
21 raise ValueError(
"In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \ 22 'CORRECTION-LEVEL-B', ...], 'MET-LABEL'). Note that 'MET-LABEL' can be set to 'None' (as a string in quotation marks) in case you do not want to apply MET(Type1) \ 26 def setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix):
35 if jetCorrections[0].
count(
'PF')>0:
37 elif jetCorrections[0].
count(
'Calo')>0:
39 elif jetCorrections[0].
count(
'JPT')>0:
42 raise TypeError(
"In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets.")
44 if 'patJetCorrFactors'+labelName+postfix
in knownModules :
45 _newPatJetCorrFactors=getattr(process,
'patJetCorrFactors'+labelName+postfix)
46 _newPatJetCorrFactors.src=jetSource
47 _newPatJetCorrFactors.primaryVertices=pvSource
50 patJetCorrFactors.clone(src=jetSource, primaryVertices=pvSource),
52 _newPatJetCorrFactors=getattr(process,
"patJetCorrFactors"+labelName+postfix)
53 _newPatJetCorrFactors.payload=jetCorrections[0]
54 _newPatJetCorrFactors.levels=jetCorrections[1]
57 for x
in jetCorrections[1]:
60 _newPatJetCorrFactors.useNPV=
True 61 _newPatJetCorrFactors.primaryVertices=
'offlinePrimaryVertices' 62 _newPatJetCorrFactors.useRho=
False 67 raise ValueError(
"In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \ 68 once. Check the list of correction levels you requested to be applied: "+ jetCorrections[1])
72 raise TypeError(
"In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets.")
74 _newPatJetCorrFactors.useRho=
True 76 _newPatJetCorrFactors.rho=cms.InputTag(
'fixedGridRhoFastjetAll')
78 _newPatJetCorrFactors.rho=cms.InputTag(
'fixedGridRhoFastjetAllCalo')
83 raise ValueError(
"In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \ 84 once. Check the list of correction levels you requested to be applied: "+ jetCorrections[1])
85 patJets.jetCorrFactorsSource=cms.VInputTag(cms.InputTag(
'patJetCorrFactors'+labelName+postfix))
87 if jetCorrections[2].lower() !=
'none' and jetCorrections[2] !=
'':
88 if not jetCorrections[2].lower() ==
'type-1' and not jetCorrections[2].lower() ==
'type-2':
89 raise ValueError(
"In addJetCollection: Wrong choice of MET corrections for new jet collection. Possible choices are None (or empty string), Type-1, Type-2 (i.e.\ 90 Type-1 and Type-2 corrections applied). This choice is not case sensitive. Your choice was: "+ jetCorrections[2])
92 raise ValueError(
"In addJecCollection: MET(type1) corrections are not supported for JPTJets. Please set the MET-LABEL to \"None\" (as string in quatiation \ 93 marks) and use raw tcMET together with JPTJets.")
95 process.load(
"JetMETCorrections.Configuration.JetCorrectorsAllAlgos_cff")
99 task.add(process.jetCorrectorsAllAlgosTask)
100 _payloadType = jetCorrections[0].
split(_type)[0].lower()+_type
103 getattr(process, _payloadType+
'L1FastjetCorrector').
clone(srcRho=cms.InputTag(
'fixedGridRhoFastjetAll')),
107 getattr(process, _payloadType+
'L1FastjetCorrector').
clone(srcRho=cms.InputTag(
'fixedGridRhoFastjetAllCalo')),
109 addToProcessAndTask(jetCorrections[0]+
'L1Offset', getattr(process, _payloadType+
'L1OffsetCorrector').
clone(), process, task)
110 addToProcessAndTask(jetCorrections[0]+
'L2Relative', getattr(process, _payloadType+
'L2RelativeCorrector').
clone(), process, task)
111 addToProcessAndTask(jetCorrections[0]+
'L3Absolute', getattr(process, _payloadType+
'L3AbsoluteCorrector').
clone(), process, task)
112 addToProcessAndTask(jetCorrections[0]+
'L2L3Residual', getattr(process, _payloadType+
'ResidualCorrector').
clone(), process, task)
114 cms.EDProducer(
'ChainedJetCorrectorProducer', correctors = cms.VInputTag()),
116 for x
in jetCorrections[1]:
117 if x !=
'L1FastJet' and x !=
'L1Offset' and x !=
'L2Relative' and x !=
'L3Absolute' and x !=
'L2L3Residual':
118 raise ValueError(
'In addJetCollection: Unsupported JEC for MET(Type1). Currently supported jet correction levels are L1FastJet, L1Offset, L2Relative, L3Asolute, L2L3Residual. Requested was: %s'%(x))
120 _corrector = _payloadType
122 _corrector +=
'L1Fastjet' 123 elif x ==
'L2L3Residual':
124 _corrector +=
'Residual' 127 _corrector +=
'Corrector' 128 getattr(process, jetCorrections[0]+
'CombinedCorrector').correctors.append(cms.InputTag(_corrector))
131 _labelCorrName = labelName
133 _labelCorrName =
'For' + labelName
137 from JetMETCorrections.Type1MET.correctedMet_cff
import caloMetT1
138 from JetMETCorrections.Type1MET.correctedMet_cff
import caloMetT1T2
140 jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
141 corrCaloMetType1.clone(src=jetSource,srcMET =
"caloMetM",jetCorrLabel = cms.InputTag(jetCorrections[0]+
'CombinedCorrector')),
144 jetCorrections[0]+_labelCorrName+
'JetMETcorr2'+postfix,
145 corrCaloMetType2.clone(srcUnclEnergySums = cms.VInputTag(
146 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'type2'),
147 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'offset'),
148 cms.InputTag(
'muCaloMetCorr'))),
151 jetCorrections[0]+_labelCorrName+
'Type1CorMet'+postfix,
152 caloMetT1.clone(src =
"caloMetM", srcCorrections = cms.VInputTag(
153 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'type1'))),
156 caloMetT1T2.clone(src =
"caloMetM", srcCorrections = cms.VInputTag(
157 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'type1'),
158 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr2'+postfix))),
167 from JetMETCorrections.Type1MET.correctedMet_cff
import pfMetT1
168 from JetMETCorrections.Type1MET.correctedMet_cff
import pfMetT1T2
170 pfJetsPtrForMetCorr.clone(src = jetSource), process, task)
172 jetCorrections[0]+_labelCorrName+
'pfCandsNotInJetsPtrForMetCorr'+postfix,
173 pfCandsNotInJetsPtrForMetCorr.clone(topCollection = jetCorrections[0]+_labelCorrName+
'pfJetsPtrForMetCorr'+postfix),
176 jetCorrections[0]+_labelCorrName+
'pfCandsNotInJetsForMetCorr'+postfix,
177 pfCandsNotInJetsForMetCorr.clone(src = jetCorrections[0]+_labelCorrName+
'pfCandsNotInJetsPtrForMetCorr'+postfix),
180 jetCorrections[0]+_labelCorrName+
'CandMETcorr'+postfix,
181 pfCandMETcorr.clone(src = cms.InputTag(jetCorrections[0]+_labelCorrName+
'pfCandsNotInJetsForMetCorr'+postfix)),
184 jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
185 corrPfMetType1.clone(src = jetSource, jetCorrLabel = cms.InputTag(jetCorrections[0]+
'CombinedCorrector')),
188 corrPfMetType2.clone(srcUnclEnergySums = cms.VInputTag(
189 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'type2'),
190 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'offset'),
191 cms.InputTag(jetCorrections[0]+_labelCorrName+
'CandMETcorr'+postfix))),
194 pfMetT1.clone(srcCorrections = cms.VInputTag(
195 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'type1'))),
198 pfMetT1T2.clone(srcCorrections = cms.VInputTag(
199 cms.InputTag(jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix,
'type1'),
200 jetCorrections[0]+_labelCorrName+
'corrPfMetType2'+postfix)),
204 if (
'L1FastJet' in jetCorrections[1]
or 'L1Fastjet' in jetCorrections[1]):
205 getattr(process,jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag(jetCorrections[0]+
'L1FastJet')
210 getattr(process,jetCorrections[0]+_labelCorrName+
'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag(
'')
213 if jetCorrections[2].lower() ==
'type-1':
215 patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+
'Type1CorMet'+postfix),
216 addMuonCorrections =
False),
218 elif jetCorrections[2].lower() ==
'type-2':
220 patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+
'Type1p2CorMet'+postfix),
221 addMuonCorrections =
False),
225 def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(
''), groomedFatJets=cms.InputTag(
'')):
226 btagInfo.useSVClustering = cms.bool(svClustering)
227 btagInfo.jetAlgorithm = cms.string(algo)
228 btagInfo.rParam = cms.double(rParam)
230 if fatJets != cms.InputTag(
''):
231 btagInfo.fatJets = fatJets
232 if groomedFatJets != cms.InputTag(
''):
233 btagInfo.groomedFatJets = groomedFatJets
236 def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
237 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
242 discriminators = set(btagDiscriminators)
243 present_meta = discriminators.intersection(set(supportedMetaDiscr.keys()))
244 discriminators -= present_meta
245 for meta_tagger
in present_meta:
246 for src
in supportedMetaDiscr[meta_tagger]:
247 discriminators.add(src)
248 btagDiscriminators =
list(discriminators)
252 requiredTagInfos =
list(btagInfos)
253 for btagDiscr
in btagDiscriminators :
254 for tagInfoList
in supportedBtagDiscr[btagDiscr] :
255 for requiredTagInfo
in tagInfoList :
256 tagInfoCovered =
False 257 for tagInfo
in requiredTagInfos :
258 if requiredTagInfo == tagInfo :
259 tagInfoCovered =
True 261 if not tagInfoCovered :
262 requiredTagInfos.append(requiredTagInfo)
264 if hasattr( process,
'candidateJetProbabilityComputer' ) ==
False :
266 process.load(
"RecoBTag.ImpactParameter.impactParameter_cff")
267 task.add(process.impactParameterTask)
268 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_cff")
269 task.add(process.secondaryVertexTask)
270 process.load(
"RecoBTag.SoftLepton.softLepton_cff")
271 task.add(process.softLeptonTask)
272 process.load(
"RecoBTag.Combined.combinedMVA_cff")
273 task.add(process.combinedMVATask)
274 process.load(
"RecoBTag.CTagging.cTagging_cff")
275 task.add(process.cTaggingTask)
277 process.load(
"RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
278 process.load(
"RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
279 process.load(
"RecoBTag.SoftLepton.softLepton_EventSetup_cff")
280 process.load(
"RecoBTag.Combined.combinedMVA_EventSetup_cff")
281 process.load(
"RecoBTag.CTagging.cTagging_EventSetup_cff")
283 import RecoJets.JetProducers.caTopTaggers_cff
as toptag
287 sys.stderr.write(
"-------------------------------------------------------------------\n")
288 sys.stderr.write(
" Warning: For a complete switch to the legacy tight b-tag track\n")
289 sys.stderr.write(
" selection, please also enable the \'runIVF\' switch.\n")
290 sys.stderr.write(
"-------------------------------------------------------------------\n")
292 sys.stderr.write(
"-------------------------------------------------------------------\n")
293 sys.stderr.write(
" Warning: With the tight b-tag track selection enabled, it is\n")
294 sys.stderr.write(
" advisable to set \'btagPrefix\' to a non-empty string to\n")
295 sys.stderr.write(
" avoid unintentional modifications to the default\n")
296 sys.stderr.write(
" b tagging setup that might be loaded in the same job.\n")
297 sys.stderr.write(
"-------------------------------------------------------------------\n")
301 svSourceCvsL = copy.deepcopy(svSource)
302 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+
'CvsL')
305 runIVFforCTagOnly =
False 306 ivfcTagInfos = [
'pfInclusiveSecondaryVertexFinderCvsLTagInfos',
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
308 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices' and any(i
in requiredTagInfos
for i
in ivfcTagInfos)
and not runIVF:
309 runIVFforCTagOnly =
True 311 sys.stderr.write(
"-------------------------------------------------------------------\n")
312 sys.stderr.write(
" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
313 sys.stderr.write(
" vertices will be remade.\n")
314 sys.stderr.write(
"-------------------------------------------------------------------\n")
316 if runIVF
and btagPrefix !=
'':
317 if runIVFforCTagOnly:
318 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
320 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
321 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
327 runNegativeVertexing =
False 328 runNegativeCvsLVertexing =
False 329 for btagInfo
in requiredTagInfos:
331 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
332 'pfNegativeDeepFlavourTagInfos',
333 'pfNegativeParticleNetAK4TagInfos',
335 runNegativeVertexing =
True 336 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
337 runNegativeCvsLVertexing =
True 339 if runNegativeVertexing
or runNegativeCvsLVertexing:
340 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff
as NegVertex
342 if runNegativeVertexing:
344 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
347 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
350 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMerger'+labelName+postfix)
351 ,primaryVertices = pvSource
352 ,tracks=pfCandidates),
354 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
355 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitrator'+labelName+postfix)),
358 if runNegativeCvsLVertexing:
359 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
360 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
363 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
366 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexMergerCvsL'+labelName+postfix)
367 ,primaryVertices = pvSource
368 ,tracks=pfCandidates),
370 addToProcessAndTask(btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
371 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+
'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
375 acceptedTagInfos =
list()
376 for btagInfo
in requiredTagInfos:
377 if hasattr(btag,btagInfo):
378 if btagInfo ==
'pfImpactParameterTagInfos':
380 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
383 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
384 _btagInfo.explicitJTA = cms.bool(explicitJTA)
386 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
387 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
388 _btagInfo.minimumNumberOfHits = cms.int32(8)
389 if btagInfo ==
'pfImpactParameterAK8TagInfos':
391 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
394 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
395 _btagInfo.explicitJTA = cms.bool(explicitJTA)
397 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
398 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
399 _btagInfo.minimumNumberOfHits = cms.int32(8)
400 if btagInfo ==
'pfImpactParameterCA15TagInfos':
402 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
405 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
406 _btagInfo.explicitJTA = cms.bool(explicitJTA)
408 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
409 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
410 _btagInfo.minimumNumberOfHits = cms.int32(8)
411 if btagInfo ==
'pfSecondaryVertexTagInfos':
413 btag.pfSecondaryVertexTagInfos.clone(
414 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
417 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
418 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
419 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
420 if btagInfo ==
'pfDeepCSVTagInfos':
422 btag.pfDeepCSVTagInfos.clone(
423 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
425 if svClustering
or fatJets != cms.InputTag(
''):
426 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
427 if btagInfo ==
'pfDeepCSVNegativeTagInfos':
429 btag.pfDeepCSVNegativeTagInfos.clone(
430 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
432 if svClustering
or fatJets != cms.InputTag(
''):
433 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
434 if btagInfo ==
'pfDeepCSVPositiveTagInfos':
436 btag.pfDeepCSVPositiveTagInfos.clone(
437 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
439 if svClustering
or fatJets != cms.InputTag(
''):
440 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
441 if btagInfo ==
'pfDeepCMVATagInfos':
443 btag.pfDeepCMVATagInfos.clone(
444 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
445 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
446 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
447 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
449 if svClustering
or fatJets != cms.InputTag(
''):
450 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
451 if btagInfo ==
'pfDeepCMVANegativeTagInfos':
453 btag.pfDeepCMVATagInfos.clone(
454 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
455 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
456 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
457 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
459 if svClustering
or fatJets != cms.InputTag(
''):
460 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
461 if btagInfo ==
'pfDeepCMVAPositiveTagInfos':
463 btag.pfDeepCMVATagInfos.clone(
464 deepNNTagInfos = cms.InputTag(btagPrefix+
'pfDeepCSVTagInfos'+labelName+postfix),
465 ipInfoSrc = cms.InputTag(btagPrefix+
"pfImpactParameterTagInfos"+labelName+postfix),
466 muInfoSrc = cms.InputTag(btagPrefix+
"softPFMuonsTagInfos"+labelName+postfix),
467 elInfoSrc = cms.InputTag(btagPrefix+
"softPFElectronsTagInfos"+labelName+postfix)),
469 if svClustering
or fatJets != cms.InputTag(
''):
470 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
471 if btagInfo ==
'pfInclusiveSecondaryVertexFinderTagInfos':
473 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
474 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
475 extSVCollection=svSource),
477 if svClustering
or fatJets != cms.InputTag(
''):
478 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
479 if btagInfo ==
'pfInclusiveSecondaryVertexFinderAK8TagInfos':
481 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
482 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterAK8TagInfos'+labelName+postfix),
483 extSVCollection=svSource),
485 if svClustering
or fatJets != cms.InputTag(
''):
486 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
487 if btagInfo ==
'pfBoostedDoubleSVAK8TagInfos':
489 btag.pfBoostedDoubleSVAK8TagInfos.clone(
490 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
492 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCA15TagInfos':
494 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
495 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterCA15TagInfos'+labelName+postfix),
496 extSVCollection=svSource),
498 if svClustering
or fatJets != cms.InputTag(
''):
499 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
500 if btagInfo ==
'pfBoostedDoubleSVCA15TagInfos':
502 btag.pfBoostedDoubleSVCA15TagInfos.clone(
503 svTagInfos = cms.InputTag(btagPrefix+
'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
505 if btagInfo ==
'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
507 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
508 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
509 extSVCollection=svSourceCvsL),
511 if svClustering
or fatJets != cms.InputTag(
''):
512 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
513 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
515 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
516 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
517 extSVCollection = btagPrefix+
'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
519 if svClustering
or fatJets != cms.InputTag(
''):
520 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
521 if btagInfo ==
'pfGhostTrackVertexTagInfos':
523 btag.pfGhostTrackVertexTagInfos.clone(
524 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
526 if btagInfo ==
'pfSecondaryVertexNegativeTagInfos':
528 btag.pfSecondaryVertexNegativeTagInfos.clone(
529 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix)),
532 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
533 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
534 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
535 if btagInfo ==
'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
537 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
538 trackIPTagInfos = cms.InputTag(btagPrefix+
'pfImpactParameterTagInfos'+labelName+postfix),
539 extSVCollection=cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
541 if svClustering
or fatJets != cms.InputTag(
''):
542 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
543 if btagInfo ==
'impactParameterTagInfos':
545 btag.impactParameterTagInfos.clone(
546 jetTracks = cms.InputTag(
'jetTracksAssociatorAtVertex'+labelName+postfix),
547 primaryVertex=pvSource),
549 if btagInfo ==
'secondaryVertexTagInfos':
551 btag.secondaryVertexTagInfos.clone(
552 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
554 if btagInfo ==
'inclusiveSecondaryVertexFinderTagInfos':
556 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
557 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
559 if svClustering
or fatJets != cms.InputTag(
''):
560 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
561 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredTagInfos':
563 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
564 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
566 if svClustering
or fatJets != cms.InputTag(
''):
567 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
568 if btagInfo ==
'secondaryVertexNegativeTagInfos':
570 btag.secondaryVertexNegativeTagInfos.clone(
571 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
573 if btagInfo ==
'inclusiveSecondaryVertexFinderNegativeTagInfos':
575 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
576 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
578 if svClustering
or fatJets != cms.InputTag(
''):
579 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
580 if btagInfo ==
'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
582 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
583 trackIPTagInfos = cms.InputTag(btagPrefix+
'impactParameterTagInfos'+labelName+postfix)),
585 if svClustering
or fatJets != cms.InputTag(
''):
586 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
587 if btagInfo ==
'softMuonTagInfos':
589 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
591 if btagInfo ==
'softPFMuonsTagInfos':
593 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
595 if btagInfo ==
'softPFElectronsTagInfos':
597 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
600 if 'DeepFlavourTagInfos' in btagInfo:
602 if btagInfo ==
'pfNegativeDeepFlavourTagInfos':
603 deep_csv_tag_infos =
'pfDeepCSVNegativeTagInfos' 604 svUsed = cms.InputTag(btagPrefix+
'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
607 deep_csv_tag_infos =
'pfDeepCSVTagInfos' 611 if not (
'limmed' in jetSource.value()):
612 puppi_value_map = cms.InputTag(
"puppi")
613 vertex_associator = cms.InputTag(
"primaryVertexAssociation",
"original")
615 puppi_value_map = cms.InputTag(
"")
616 vertex_associator = cms.InputTag(
"")
618 btag.pfDeepFlavourTagInfos.clone(
621 secondary_vertices=svUsed,
622 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
623 puppi_value_map = puppi_value_map,
624 vertex_associator = vertex_associator,
628 if btagInfo ==
'pfDeepDoubleXTagInfos':
630 btag.pfDeepDoubleXTagInfos.clone(
633 secondary_vertices=svSource,
634 shallow_tag_infos = cms.InputTag(btagPrefix+
'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
638 if btagInfo ==
'pfHiggsInteractionNetTagInfos':
640 btag.pfHiggsInteractionNetTagInfos.clone(
643 secondary_vertices = svSource,
644 pf_candidates = pfCandidates,
648 if btagInfo ==
'pfDeepBoostedJetTagInfos':
649 if pfCandidates.value() ==
'packedPFCandidates':
651 if 'updated' not in jetSource.value().lower():
652 raise ValueError(
"Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
654 vertex_associator =
"" 655 elif pfCandidates.value() ==
'particleFlow':
656 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
663 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
665 btag.pfDeepBoostedJetTagInfos.clone(
668 secondary_vertices = svSource,
669 pf_candidates = pfCandidates,
670 puppi_value_map = puppi_value_map,
671 vertex_associator = vertex_associator,
675 if btagInfo ==
'pfParticleNetTagInfos':
676 if pfCandidates.value() ==
'packedPFCandidates':
679 vertex_associator =
"" 680 elif pfCandidates.value() ==
'particleFlow':
681 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
683 puppi_value_map =
"puppi" 684 vertex_associator =
"primaryVertexAssociation:original" 686 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
688 btag.pfParticleNetTagInfos.clone(
691 secondary_vertices = svSource,
692 pf_candidates = pfCandidates,
693 puppi_value_map = puppi_value_map,
694 vertex_associator = vertex_associator,
698 if 'ParticleNetAK4TagInfos' in btagInfo:
699 if btagInfo ==
'pfNegativeParticleNetAK4TagInfos':
700 secondary_vertices = btagPrefix + \
701 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
705 secondary_vertices = svSource
708 if pfCandidates.value() ==
'packedPFCandidates':
711 vertex_associator =
"" 712 elif pfCandidates.value() ==
'particleFlow':
713 raise ValueError(
"Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
715 puppi_value_map =
"puppi" 716 vertex_associator =
"primaryVertexAssociation:original" 718 raise ValueError(
"Invalid pfCandidates collection: %s." % pfCandidates.value())
720 btag.pfParticleNetAK4TagInfos.clone(
723 secondary_vertices = secondary_vertices,
724 pf_candidates = pfCandidates,
725 puppi_value_map = puppi_value_map,
726 vertex_associator = vertex_associator,
727 flip_ip_sign = flip_ip_sign,
728 sip3dSigMax = sip3dSigMax,
732 acceptedTagInfos.append(btagInfo)
733 elif hasattr(toptag, btagInfo) :
734 acceptedTagInfos.append(btagInfo)
736 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
738 acceptedBtagDiscriminators =
list()
739 for discriminator_name
in btagDiscriminators :
740 btagDiscr = discriminator_name.split(
':')[0]
742 if hasattr(btag,btagDiscr):
743 newDiscr = btagPrefix+btagDiscr+labelName+postfix
744 if hasattr(process, newDiscr):
746 elif hasattr(getattr(btag, btagDiscr),
'tagInfos'):
749 getattr(btag, btagDiscr).
clone(
750 tagInfos = cms.VInputTag(
751 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
752 for x
in supportedBtagDiscr[discriminator_name][0] ]
758 elif hasattr(getattr(btag, btagDiscr),
'src'):
761 getattr(btag, btagDiscr).
clone(
762 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
768 raise ValueError(
'I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
769 acceptedBtagDiscriminators.append(discriminator_name)
771 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
773 for meta_tagger
in present_meta:
774 btagDiscr = meta_tagger.split(
':')[0]
776 if hasattr(btag,btagDiscr):
777 newDiscr = btagPrefix+btagDiscr+labelName+postfix
778 if hasattr(process, newDiscr):
783 getattr(btag, btagDiscr).
clone(),
787 for dependency
in supportedMetaDiscr[meta_tagger]:
788 if ':' in dependency:
789 new_dep = btagPrefix+dependency.split(
':')[0]+labelName+postfix+
':'+dependency.split(
':')[1]
791 new_dep = btagPrefix+dependency+labelName+postfix
792 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
793 replace.doIt(getattr(process, newDiscr), newDiscr)
794 acceptedBtagDiscriminators.append(meta_tagger)
796 print(
' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
799 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix)
for x
in acceptedTagInfos ] )
800 patJets.discriminatorSources = cms.VInputTag(*[
801 cms.InputTag(btagPrefix+x+labelName+postfix) \
802 if ':' not in x
else \
803 cms.InputTag(btagPrefix+x.split(
':')[0]+labelName+postfix+
':'+x.split(
':')[1]) \
804 for x
in acceptedBtagDiscriminators
806 if len(acceptedBtagDiscriminators) > 0 :
807 patJets.addBTagInfo =
True 810 if not tightBTagNTkHits:
811 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
816 ivfbTagInfos = [
'pfInclusiveSecondaryVertexFinderTagInfos',
'pfInclusiveSecondaryVertexFinderAK8TagInfos',
'pfInclusiveSecondaryVertexFinderCA15TagInfos']
817 if any(i
in acceptedTagInfos
for i
in ivfbTagInfos)
and not runIVFforCTagOnly:
818 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
819 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
821 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
822 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
823 _temp.minHits = cms.uint32(8)
825 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
826 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinder' ):
827 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinder')
828 _temp.primaryVertices = pvSource
829 _temp.tracks = pfCandidates
830 if hasattr( process, btagPrefix+
'candidateVertexArbitrator' ):
831 _temp = getattr(process, btagPrefix+
'candidateVertexArbitrator')
832 _temp.primaryVertices = pvSource
833 _temp.tracks = pfCandidates
834 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVertices' )
and not hasattr( process, svSource.getModuleLabel() ):
836 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVertices').
clone(),
838 if any(i
in acceptedTagInfos
for i
in ivfcTagInfos):
839 if not hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
840 loadWithPrefix(process,
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
842 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
843 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
844 _temp.minHits = cms.uint32(8)
846 if pvSource.getModuleLabel() ==
'offlineSlimmedPrimaryVertices':
847 if hasattr( process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL' ):
848 _temp = getattr(process, btagPrefix+
'inclusiveCandidateVertexFinderCvsL')
849 _temp.primaryVertices = pvSource
850 _temp.tracks = pfCandidates
851 if hasattr( process, btagPrefix+
'candidateVertexArbitratorCvsL' ):
852 _temp = getattr(process, btagPrefix+
'candidateVertexArbitratorCvsL')
853 _temp.primaryVertices = pvSource
854 _temp.tracks = pfCandidates
855 if hasattr( process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL' )
and not hasattr( process, svSourceCvsL.getModuleLabel() ):
857 getattr(process, btagPrefix+
'inclusiveCandidateSecondaryVerticesCvsL').
clone(),
859 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
860 if not hasattr( process,
'inclusiveVertexing' ):
861 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
862 task.add(process.inclusiveVertexingTask)
863 task.add(process.inclusiveCandidateVertexingTask)
864 task.add(process.inclusiveCandidateVertexingCvsLTask)
865 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
866 if not hasattr( process,
'inclusiveVertexing' ):
867 process.load(
'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
868 task.add(process.inclusiveVertexingTask)
869 task.add(process.inclusiveCandidateVertexingTask)
870 task.add(process.inclusiveCandidateVertexingCvsLTask)
871 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
872 if not hasattr( process,
'inclusiveSecondaryVerticesFiltered' ):
873 process.load(
'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
874 task.add(process.inclusiveSecondaryVerticesFiltered)
875 task.add(process.bVertexFilter)
876 if not hasattr( process,
'bToCharmDecayVertexMerged' ):
877 process.load(
'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
878 task.add(process.bToCharmDecayVertexMerged)
879 if 'caTopTagInfos' in acceptedTagInfos :
880 patJets.addTagInfos =
True 881 if not hasattr( process,
'caTopTagInfos' )
and not hasattr( process,
'caTopTagInfosAK8' ):
882 process.load(
'RecoJets.JetProducers.caTopTaggers_cff' )
883 task.add(process.caTopTaggersTask)
887 Tool to add a new jet collection to your PAT Tuple or to modify an existing one. 889 _label=
'addJetCollection' 890 _defaultParameters=dicttypes.SortedKeysDict()
894 Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor. 897 ConfigToolBase.__init__(self)
899 self.addParameter(self.
_defaultParameters,
'labelName',
'UNDEFINED',
"Label name of the new patJet collection.", str)
900 self.addParameter(self.
_defaultParameters,
'postfix',
'',
"Postfix from usePF2PAT.", str)
901 self.addParameter(self.
_defaultParameters,
'btagPrefix',
'',
"Prefix to be added to b-tag discriminator and TagInfo names", str)
902 self.addParameter(self.
_defaultParameters,
'jetSource',
'',
"Label of the input collection from which the new patJet collection should be created", cms.InputTag)
903 self.addParameter(self.
_defaultParameters,
'pfCandidates',cms.InputTag(
'particleFlow'),
"Label of the input collection for candidatecandidatese used in b-tagging", cms.InputTag)
904 self.addParameter(self.
_defaultParameters,
'explicitJTA',
False,
"Use explicit jet-track association")
905 self.addParameter(self.
_defaultParameters,
'pvSource',cms.InputTag(
'offlinePrimaryVertices'),
"Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
906 self.addParameter(self.
_defaultParameters,
'svSource',cms.InputTag(
'inclusiveCandidateSecondaryVertices'),
"Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
907 self.addParameter(self.
_defaultParameters,
'elSource',cms.InputTag(
'gedGsfElectrons'),
"Label of the input collection for electrons used in b-tagging", cms.InputTag)
908 self.addParameter(self.
_defaultParameters,
'muSource',cms.InputTag(
'muons'),
"Label of the input collection for muons used in b-tagging", cms.InputTag)
909 self.addParameter(self.
_defaultParameters,
'runIVF',
False,
"Re-run IVF secondary vertex reconstruction")
910 self.addParameter(self.
_defaultParameters,
'tightBTagNTkHits',
False,
"Enable legacy tight b-tag track selection")
911 self.addParameter(self.
_defaultParameters,
'loadStdRecoBTag',
False,
"Load the standard reconstruction b-tagging modules")
912 self.addParameter(self.
_defaultParameters,
'svClustering',
False,
"Secondary vertices ghost-associated to jets using jet clustering (mostly intended for subjets)")
913 self.addParameter(self.
_defaultParameters,
'fatJets', cms.InputTag(
''),
"Fat jet collection used for secondary vertex clustering", cms.InputTag)
914 self.addParameter(self.
_defaultParameters,
'groomedFatJets', cms.InputTag(
''),
"Groomed fat jet collection used for secondary vertex clustering", cms.InputTag)
915 self.addParameter(self.
_defaultParameters,
'algo',
'AK',
"Jet algorithm of the input collection from which the new patJet collection should be created")
916 self.addParameter(self.
_defaultParameters,
'rParam', 0.4,
"Jet size (distance parameter R used in jet clustering)")
917 self.addParameter(self.
_defaultParameters,
'getJetMCFlavour',
True,
"Get jet MC truth flavour")
918 self.addParameter(self.
_defaultParameters,
'genJetCollection', cms.InputTag(
"ak4GenJets"),
"GenJet collection to match to", cms.InputTag)
919 self.addParameter(self.
_defaultParameters,
'genParticles', cms.InputTag(
"genParticles"),
"GenParticle collection to be used", cms.InputTag)
920 self.addParameter(self.
_defaultParameters,
'jetCorrections',
None,
"Add all relevant information about jet energy corrections that you want to be added to your new patJet \ 921 collection. The format has to be given in a python tuple of type: (\'AK4Calo\',[\'L2Relative\', \'L3Absolute\'], patMet). Here the first argument corresponds to the payload \ 922 in the CMS Conditions database for the given jet collection; the second argument corresponds to the jet energy correction levels that you want to be embedded into your \ 923 new patJet collection. This should be given as a list of strings. Available values are L1Offset, L1FastJet, L1JPTOffset, L2Relative, L3Absolute, L5Falvour, L7Parton; the \ 924 third argument indicates whether MET(Type1/2) corrections should be applied corresponding to the new patJetCollection. If so a new patMet collection will be added to your PAT \ 925 Tuple in addition to the raw patMet. This new patMet collection will have the MET(Type1/2) corrections applied. The argument can have the following types: \'type-1\' for \ 926 type-1 corrected MET; \'type-2\' for type-1 plus type-2 corrected MET; \'\' or \'none\' if no further MET corrections should be applied to your MET. The arguments \'type-1\' \ 927 and \'type-2\' are not case sensitive.", tuple, acceptNoneValue=
True)
928 self.addParameter(self.
_defaultParameters,
'btagDiscriminators',[
'None'],
"If you are interested in btagging, in most cases just the labels of the btag discriminators that \ 929 you are interested in is all relevant information that you need for a high level analysis. Add here all btag discriminators, that you are interested in as a list of strings. \ 930 If this list is empty no btag discriminator information will be added to your new patJet collection.", allowedValues=(
list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list)
931 self.addParameter(self.
_defaultParameters,
'btagInfos',[
'None'],
"The btagInfos objects contain all relevant information from which all discriminators of a certain \ 932 type have been calculated. You might be interested in keeping this information for low level tests or to re-calculate some discriminators from hand. Note that this information \ 933 on the one hand can be very space consuming and that it is not necessary to access the pre-calculated btag discriminator information that has been derived from it. Only in very \ 934 special cases the btagInfos might really be needed in your analysis. Add here all btagInfos, that you are interested in as a list of strings. If this list is empty no btagInfos \ 935 will be added to your new patJet collection.", allowedValues=supportedBtagInfos,Type=list)
936 self.addParameter(self.
_defaultParameters,
'jetTrackAssociation',
False,
"Add JetTrackAssociation and JetCharge from reconstructed tracks to your new patJet collection. This \ 937 switch is only of relevance if you don\'t add any btag information to your new patJet collection (btagDiscriminators or btagInfos) and still want this information added to \ 938 your new patJetCollection. If btag information of any form is added to the new patJet collection this information will be added automatically.")
939 self.addParameter(self.
_defaultParameters,
'outputModules',[
'out'],
"Add a list of all output modules to which you would like the new jet collection to be added. Usually this is \ 940 just one single output module with name \'out\', which corresponds also the default configuration of the tool. There is cases though where you might want to add this collection \ 941 to more than one output module.")
945 self.
_comment =
"This is a tool to add more patJet collectinos to your PAT Tuple or to re-configure the default collection. You can add and embed additional information like jet\ 946 energy correction factors, btag information and generator match information to the new patJet collection depending on the parameters that you pass on to this function. Consult \ 947 the descriptions of each parameter for more information." 951 Return default parameters of the class 955 def __call__(self,process,labelName=None,postfix=None,btagPrefix=None,jetSource=None,pfCandidates=None,explicitJTA=None,pvSource=None,svSource=None,elSource=None,muSource=None,runIVF=None,tightBTagNTkHits=None,loadStdRecoBTag=None,svClustering=None,fatJets=None,groomedFatJets=None,algo=None,rParam=None,getJetMCFlavour=None,genJetCollection=None,genParticles=None,jetCorrections=None,btagDiscriminators=None,btagInfos=None,jetTrackAssociation=None,outputModules=None):
957 Function call wrapper. This will check the parameters and call the actual implementation that 958 can be found in toolCode via the base class function apply. 960 if labelName
is None:
962 self.setParameter(
'labelName', labelName)
965 self.setParameter(
'postfix', postfix)
966 if btagPrefix
is None:
968 self.setParameter(
'btagPrefix', btagPrefix)
969 if jetSource
is None:
971 self.setParameter(
'jetSource', jetSource)
972 if pfCandidates
is None:
974 self.setParameter(
'pfCandidates', pfCandidates)
975 if explicitJTA
is None:
977 self.setParameter(
'explicitJTA', explicitJTA)
980 self.setParameter(
'pvSource', pvSource)
983 self.setParameter(
'svSource', svSource)
986 self.setParameter(
'elSource', elSource)
989 self.setParameter(
'muSource', muSource)
992 self.setParameter(
'runIVF', runIVF)
993 if tightBTagNTkHits
is None:
995 self.setParameter(
'tightBTagNTkHits', tightBTagNTkHits)
996 if loadStdRecoBTag
is None:
998 self.setParameter(
'loadStdRecoBTag', loadStdRecoBTag)
999 if svClustering
is None:
1001 self.setParameter(
'svClustering', svClustering)
1004 self.setParameter(
'fatJets', fatJets)
1005 if groomedFatJets
is None:
1007 self.setParameter(
'groomedFatJets', groomedFatJets)
1010 self.setParameter(
'algo', algo)
1013 self.setParameter(
'rParam', rParam)
1014 if getJetMCFlavour
is None:
1016 self.setParameter(
'getJetMCFlavour', getJetMCFlavour)
1017 if genJetCollection
is None:
1019 self.setParameter(
'genJetCollection', genJetCollection)
1020 if genParticles
is None:
1022 self.setParameter(
'genParticles', genParticles)
1023 if jetCorrections
is None:
1025 self.setParameter(
'jetCorrections', jetCorrections)
1026 if btagDiscriminators
is None:
1028 self.setParameter(
'btagDiscriminators', btagDiscriminators)
1029 if btagInfos
is None:
1031 self.setParameter(
'btagInfos', btagInfos)
1032 if jetTrackAssociation
is None:
1034 self.setParameter(
'jetTrackAssociation', jetTrackAssociation)
1035 if outputModules
is None:
1037 self.setParameter(
'outputModules', outputModules)
1042 Tool code implementation 1051 pfCandidates=self.
_parameters[
'pfCandidates'].value
1058 tightBTagNTkHits=self.
_parameters[
'tightBTagNTkHits'].value
1059 loadStdRecoBTag=self.
_parameters[
'loadStdRecoBTag'].value
1060 svClustering=self.
_parameters[
'svClustering'].value
1062 groomedFatJets=self.
_parameters[
'groomedFatJets'].value
1065 getJetMCFlavour=self.
_parameters[
'getJetMCFlavour'].value
1066 genJetCollection=self.
_parameters[
'genJetCollection'].value
1067 genParticles=self.
_parameters[
'genParticles'].value
1068 jetCorrections=self.
_parameters[
'jetCorrections'].value
1071 jetTrackAssociation=self.
_parameters[
'jetTrackAssociation'].value
1075 if labelName==
'UNDEFINED':
1079 knownModules = process.producerNames().
split()
1081 if btagDiscriminators.count(
'None')>0:
1082 btagDiscriminators.remove(
'None')
1083 if btagInfos.count(
'None')>0:
1084 btagInfos.remove(
'None')
1085 bTagging=(len(btagDiscriminators)>0
or len(btagInfos)>0)
1088 for info
in btagInfos:
1089 if info.startswith(
'pf'): infos = infos + 1
1090 if 'softpf' in info.lower(): infos = infos + 1
1092 for tag
in btagDiscriminators:
1093 if tag.startswith(
'pf'): tags = tags + 1
1094 if 'softpf' in tag.lower(): tags = tags + 1
1095 bTaggingLegacy=(len(btagDiscriminators)>tags
or len(btagInfos)>infos)
1099 _labelName=labelName[:1].
upper()+labelName[1:]
1103 for x
in [
"ak",
"ca",
"kt"]:
1104 if x
in algo.lower():
1105 _algo=supportedJetAlgos[x]
1111 if 'patJets'+_labelName+postfix
in knownModules :
1112 _newPatJets=getattr(process,
'patJets'+_labelName+postfix)
1113 _newPatJets.jetSource=jetSource
1115 addToProcessAndTask(
'patJets'+_labelName+postfix, patJets.clone(jetSource=jetSource), process, task)
1116 _newPatJets=getattr(process,
'patJets'+_labelName+postfix)
1117 knownModules.append(
'patJets'+_labelName+postfix)
1120 if 'selectedPatJets'+_labelName+postfix
in knownModules :
1121 _newSelectedPatJets=getattr(process,
'selectedPatJets'+_labelName+postfix)
1122 _newSelectedPatJets.src=
'patJets'+_labelName+postfix
1125 selectedPatJets.clone(src=
'patJets'+_labelName+postfix),
1127 knownModules.append(
'selectedPatJets'+_labelName+postfix)
1131 if 'patJetPartonMatch'+_labelName+postfix
in knownModules :
1132 _newPatJetPartonMatch=getattr(process,
'patJetPartonMatch'+_labelName+postfix)
1133 _newPatJetPartonMatch.src=jetSource
1134 _newPatJetPartonMatch.matched=genParticles
1137 patJetPartonMatch.clone(src=jetSource, matched=genParticles),
1139 knownModules.append(
'patJetPartonMatch'+_labelName+postfix)
1142 if 'patJetGenJetMatch'+_labelName+postfix
in knownModules :
1143 _newPatJetGenJetMatch=getattr(process,
'patJetGenJetMatch'+_labelName+postfix)
1144 _newPatJetGenJetMatch.src=jetSource
1145 _newPatJetGenJetMatch.maxDeltaR=rParam
1146 _newPatJetGenJetMatch.matched=genJetCollection
1149 patJetGenJetMatch.clone(src=jetSource, maxDeltaR=rParam, matched=genJetCollection),
1151 knownModules.append(
'patJetGenJetMatch'+_labelName+postfix)
1153 _newPatJets.genJetMatch.setModuleLabel(
'patJetGenJetMatch'+_labelName+postfix)
1154 _newPatJets.genPartonMatch.setModuleLabel(
'patJetPartonMatch'+_labelName+postfix)
1156 if (getJetMCFlavour):
1160 if 'patJetPartonsLegacy'+postfix
not in knownModules :
1161 addToProcessAndTask(
'patJetPartonsLegacy'+postfix, patJetPartonsLegacy.clone(src=genParticles),
1163 knownModules.append(
'patJetPartonsLegacy'+postfix)
1165 getattr(process,
'patJetPartonsLegacy'+postfix).src=genParticles
1168 if 'patJetPartonAssociationLegacy'+_labelName+postfix
in knownModules :
1169 _newPatJetPartonAssociation=getattr(process,
'patJetPartonAssociationLegacy'+_labelName+postfix)
1170 _newPatJetPartonAssociation.jets=jetSource
1173 patJetPartonAssociationLegacy.clone(jets=jetSource), process, task)
1174 knownModules.append(
'patJetPartonAssociationLegacy'+_labelName+postfix)
1177 if 'patJetFlavourAssociationLegacy'+_labelName+postfix
in knownModules :
1178 _newPatJetFlavourAssociation=getattr(process,
'patJetFlavourAssociationLegacy'+_labelName+postfix)
1179 _newPatJetFlavourAssociation.srcByReference=
'patJetPartonAssociationLegacy'+_labelName+postfix
1182 patJetFlavourAssociationLegacy.clone(
1183 srcByReference=
'patJetPartonAssociationLegacy'+_labelName+postfix),
1185 knownModules.append(
'patJetFlavourAssociationLegacy'+_labelName+postfix)
1187 _newPatJets.JetPartonMapSource.setModuleLabel(
'patJetFlavourAssociationLegacy'+_labelName+postfix)
1191 if 'patJetPartons'+postfix
not in knownModules :
1192 addToProcessAndTask(
'patJetPartons'+postfix, patJetPartons.clone(particles=genParticles), process, task)
1193 knownModules.append(
'patJetPartons'+postfix)
1195 getattr(process,
'patJetPartons'+postfix).particles=genParticles
1198 if 'patJetFlavourAssociation'+_labelName+postfix
in knownModules :
1199 _newPatJetFlavourAssociation=getattr(process,
'patJetFlavourAssociation'+_labelName+postfix)
1200 _newPatJetFlavourAssociation.jets=jetSource
1201 _newPatJetFlavourAssociation.jetAlgorithm=_algo
1202 _newPatJetFlavourAssociation.rParam=rParam
1203 _newPatJetFlavourAssociation.bHadrons=cms.InputTag(
"patJetPartons"+postfix,
"bHadrons")
1204 _newPatJetFlavourAssociation.cHadrons=cms.InputTag(
"patJetPartons"+postfix,
"cHadrons")
1205 _newPatJetFlavourAssociation.partons=cms.InputTag(
"patJetPartons"+postfix,
"physicsPartons")
1206 _newPatJetFlavourAssociation.leptons=cms.InputTag(
"patJetPartons"+postfix,
"leptons")
1209 patJetFlavourAssociation.clone(
1213 bHadrons = cms.InputTag(
"patJetPartons"+postfix,
"bHadrons"),
1214 cHadrons = cms.InputTag(
"patJetPartons"+postfix,
"cHadrons"),
1215 partons = cms.InputTag(
"patJetPartons"+postfix,
"physicsPartons"),
1216 leptons = cms.InputTag(
"patJetPartons"+postfix,
"leptons")),
1219 knownModules.append(
'patJetFlavourAssociation'+_labelName+postfix)
1221 _newPatJets.JetFlavourInfoSource.setModuleLabel(
'patJetFlavourAssociation'+_labelName+postfix)
1223 if fatJets != cms.InputTag(
'')
and groomedFatJets != cms.InputTag(
''):
1224 _newPatJetFlavourAssociation=getattr(process,
'patJetFlavourAssociation'+_labelName+postfix)
1225 _newPatJetFlavourAssociation.jets=fatJets
1226 _newPatJetFlavourAssociation.groomedJets=groomedFatJets
1227 _newPatJetFlavourAssociation.subjets=jetSource
1228 _newPatJets.JetFlavourInfoSource=cms.InputTag(
'patJetFlavourAssociation'+_labelName+postfix,
'SubJets')
1230 _newPatJets.getJetMCFlavour =
False 1233 if (jetTrackAssociation
or bTaggingLegacy):
1236 if 'jetTracksAssociationAtVertex'+_labelName+postfix
in knownModules :
1237 _newJetTracksAssociationAtVertex=getattr(process,
'jetTracksAssociatorAtVertex'+_labelName+postfix)
1238 _newJetTracksAssociationAtVertex.jets=jetSource
1239 _newJetTracksAssociationAtVertex.pvSrc=pvSource
1241 jetTracksAssociator=ak4JetTracksAssociatorAtVertex
1243 jetTracksAssociator=ak4JetTracksAssociatorExplicit
1245 jetTracksAssociator.clone(jets=jetSource,pvSrc=pvSource),
1247 knownModules.append(
'jetTracksAssociationAtVertex'+_labelName+postfix)
1250 if 'patJetCharge'+_labelName+postfix
in knownModules :
1251 _newPatJetCharge=getattr(process,
'patJetCharge'+_labelName+postfix)
1252 _newPatJetCharge.src=
'jetTracksAssociatorAtVertex'+_labelName+postfix
1255 patJetCharge.clone(src =
'jetTracksAssociatorAtVertex'+_labelName+postfix),
1257 knownModules.append(
'patJetCharge'+_labelName+postfix)
1259 _newPatJets.addAssociatedTracks=
True 1260 _newPatJets.trackAssociationSource=cms.InputTag(
'jetTracksAssociatorAtVertex'+_labelName+postfix)
1261 _newPatJets.addJetCharge=
True 1262 _newPatJets.jetChargeSource=cms.InputTag(
'patJetCharge'+_labelName+postfix)
1265 _newPatJets.addAssociatedTracks=
False 1266 _newPatJets.trackAssociationSource=
'' 1267 _newPatJets.addJetCharge=
False 1268 _newPatJets.jetChargeSource=
'' 1271 setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
1272 _algo, rParam, btagDiscriminators, btagInfos, _newPatJets, _labelName, btagPrefix, postfix)
1274 _newPatJets.addBTagInfo =
False 1275 _newPatJets.addTagInfos =
False 1277 for outputModule
in outputModules:
1278 if hasattr(process,outputModule):
1279 getattr(process,outputModule).outputCommands.append(
"drop *_"+
'selected'+_labelName+postfix+
"_tagInfos_*")
1282 if (jetCorrections !=
None):
1286 setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, _newPatJets, _labelName, postfix)
1289 _newPatJets.addJetCorrFactors=
False 1295 Tool to switch parameters of the PAT jet collection to your PAT Tuple. 1297 _label=
'switchJetCollection' 1298 _defaultParameters=dicttypes.SortedKeysDict()
1302 Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor. 1305 ConfigToolBase.__init__(self)
1308 self.addParameter(self.
_defaultParameters,
'btagPrefix',
'',
"Prefix to be added to b-tag discriminator and TagInfo names", str)
1309 self.addParameter(self.
_defaultParameters,
'jetSource',
'',
"Label of the input collection from which the new patJet collection should be created", cms.InputTag)
1310 self.addParameter(self.
_defaultParameters,
'pfCandidates',cms.InputTag(
'particleFlow'),
"Label of the input collection for candidatecandidatese used in b-tagging", cms.InputTag)
1311 self.addParameter(self.
_defaultParameters,
'explicitJTA',
False,
"Use explicit jet-track association")
1312 self.addParameter(self.
_defaultParameters,
'pvSource',cms.InputTag(
'offlinePrimaryVertices'),
"Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
1313 self.addParameter(self.
_defaultParameters,
'svSource',cms.InputTag(
'inclusiveCandidateSecondaryVertices'),
"Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
1314 self.addParameter(self.
_defaultParameters,
'elSource',cms.InputTag(
'gedGsfElectrons'),
"Label of the input collection for electrons used in b-tagging", cms.InputTag)
1315 self.addParameter(self.
_defaultParameters,
'muSource',cms.InputTag(
'muons'),
"Label of the input collection for muons used in b-tagging", cms.InputTag)
1316 self.addParameter(self.
_defaultParameters,
'runIVF',
False,
"Re-run IVF secondary vertex reconstruction")
1317 self.addParameter(self.
_defaultParameters,
'tightBTagNTkHits',
False,
"Enable legacy tight b-tag track selection")
1318 self.addParameter(self.
_defaultParameters,
'loadStdRecoBTag',
False,
"Load the standard reconstruction b-tagging modules")
1319 self.addParameter(self.
_defaultParameters,
'svClustering',
False,
"Secondary vertices ghost-associated to jets using jet clustering (mostly intended for subjets)")
1320 self.addParameter(self.
_defaultParameters,
'fatJets', cms.InputTag(
''),
"Fat jet collection used for secondary vertex clustering", cms.InputTag)
1321 self.addParameter(self.
_defaultParameters,
'groomedFatJets', cms.InputTag(
''),
"Groomed fat jet collection used for secondary vertex clustering", cms.InputTag)
1322 self.addParameter(self.
_defaultParameters,
'algo',
'AK',
"Jet algorithm of the input collection from which the new patJet collection should be created")
1323 self.addParameter(self.
_defaultParameters,
'rParam', 0.4,
"Jet size (distance parameter R used in jet clustering)")
1324 self.addParameter(self.
_defaultParameters,
'getJetMCFlavour',
True,
"Get jet MC truth flavour")
1325 self.addParameter(self.
_defaultParameters,
'genJetCollection', cms.InputTag(
"ak4GenJets"),
"GenJet collection to match to")
1326 self.addParameter(self.
_defaultParameters,
'genParticles', cms.InputTag(
"genParticles"),
"GenParticle collection to be used", cms.InputTag)
1327 self.addParameter(self.
_defaultParameters,
'jetCorrections',
None,
"Add all relevant information about jet energy corrections that you want to be added to your new patJet \ 1328 collection. The format is to be passed on in a python tuple: e.g. (\'AK4Calo\',[\'L2Relative\', \'L3Absolute\'], patMet). The first argument corresponds to the payload \ 1329 in the CMS Conditions database for the given jet collection; the second argument corresponds to the jet energy correction level that you want to be embedded into your \ 1330 new patJet collection. This should be given as a list of strings. Available values are L1Offset, L1FastJet, L1JPTOffset, L2Relative, L3Absolute, L5Falvour, L7Parton; the \ 1331 third argument indicates whether MET(Type1) corrections should be applied corresponding to the new patJetCollection. If so a new patMet collection will be added to your PAT \ 1332 Tuple in addition to the raw patMet with the MET(Type1) corrections applied. The argument corresponds to the patMet collection to which the MET(Type1) corrections should be \ 1333 applied. If you are not interested in MET(Type1) corrections to this new patJet collection pass None as third argument of the python tuple.", tuple, acceptNoneValue=
True)
1334 self.addParameter(self.
_defaultParameters,
'btagDiscriminators',[
'None'],
"If you are interested in btagging in general the btag discriminators is all relevant \ 1335 information that you need for a high level analysis. Add here all btag discriminators, that you are interested in as a list of strings. If this list is empty no btag \ 1336 discriminator information will be added to your new patJet collection.", allowedValues=(
list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list)
1337 self.addParameter(self.
_defaultParameters,
'btagInfos',[
'None'],
"The btagInfos objects conatin all relevant information from which all discriminators of a certain \ 1338 type have been calculated. Note that this information on the one hand can be very space consuming and on the other hand is not necessary to access the btag discriminator \ 1339 information that has been derived from it. Only in very special cases the btagInfos might really be needed in your analysis. Add here all btagInfos, that you are interested \ 1340 in as a list of strings. If this list is empty no btagInfos will be added to your new patJet collection.", allowedValues=supportedBtagInfos,Type=list)
1341 self.addParameter(self.
_defaultParameters,
'jetTrackAssociation',
False,
"Add JetTrackAssociation and JetCharge from reconstructed tracks to your new patJet collection. This \ 1342 switch is only of relevance if you don\'t add any btag information to your new patJet collection (btagDiscriminators or btagInfos) and still want this information added to \ 1343 your new patJetCollection. If btag information is added to the new patJet collection this information will be added automatically.")
1344 self.addParameter(self.
_defaultParameters,
'outputModules',[
'out'],
"Output module labels. Add a list of all output modules to which you would like the new jet collection to \ 1345 be added, in case you use more than one output module.")
1349 self.
_comment =
"This is a tool to add more patJet collectinos to your PAT Tuple. You can add and embed additional information like jet energy correction factors, btag \ 1350 information and generator match information to the new patJet collection depending on the parameters that you pass on to this function. Consult the descriptions of each \ 1351 parameter for more information." 1355 Return default parameters of the class 1359 def __call__(self,process,postfix=None,btagPrefix=None,jetSource=None,pfCandidates=None,explicitJTA=None,pvSource=None,svSource=None,elSource=None,muSource=None,runIVF=None,tightBTagNTkHits=None,loadStdRecoBTag=None,svClustering=None,fatJets=None,groomedFatJets=None,algo=None,rParam=None,getJetMCFlavour=None,genJetCollection=None,genParticles=None,jetCorrections=None,btagDiscriminators=None,btagInfos=None,jetTrackAssociation=None,outputModules=None):
1361 Function call wrapper. This will check the parameters and call the actual implementation that 1362 can be found in toolCode via the base class function apply. 1366 self.setParameter(
'postfix', postfix)
1367 if btagPrefix
is None:
1369 self.setParameter(
'btagPrefix', btagPrefix)
1370 if jetSource
is None:
1372 self.setParameter(
'jetSource', jetSource)
1373 if pfCandidates
is None:
1375 self.setParameter(
'pfCandidates', pfCandidates)
1376 if explicitJTA
is None:
1378 self.setParameter(
'explicitJTA', explicitJTA)
1379 if pvSource
is None:
1381 self.setParameter(
'pvSource', pvSource)
1382 if svSource
is None:
1384 self.setParameter(
'svSource', svSource)
1385 if elSource
is None:
1387 self.setParameter(
'elSource', elSource)
1388 if muSource
is None:
1390 self.setParameter(
'muSource', muSource)
1393 self.setParameter(
'runIVF', runIVF)
1394 if tightBTagNTkHits
is None:
1396 self.setParameter(
'tightBTagNTkHits', tightBTagNTkHits)
1397 if loadStdRecoBTag
is None:
1399 self.setParameter(
'loadStdRecoBTag', loadStdRecoBTag)
1400 if svClustering
is None:
1402 self.setParameter(
'svClustering', svClustering)
1405 self.setParameter(
'fatJets', fatJets)
1406 if groomedFatJets
is None:
1408 self.setParameter(
'groomedFatJets', groomedFatJets)
1411 self.setParameter(
'algo', algo)
1414 self.setParameter(
'rParam', rParam)
1415 if getJetMCFlavour
is None:
1417 self.setParameter(
'getJetMCFlavour', getJetMCFlavour)
1418 if genJetCollection
is None:
1420 self.setParameter(
'genJetCollection', genJetCollection)
1421 if genParticles
is None:
1423 self.setParameter(
'genParticles', genParticles)
1424 if jetCorrections
is None:
1426 self.setParameter(
'jetCorrections', jetCorrections)
1427 if btagDiscriminators
is None:
1429 self.setParameter(
'btagDiscriminators', btagDiscriminators)
1430 if btagInfos
is None:
1432 self.setParameter(
'btagInfos', btagInfos)
1433 if jetTrackAssociation
is None:
1435 self.setParameter(
'jetTrackAssociation', jetTrackAssociation)
1436 if outputModules
is None:
1438 self.setParameter(
'outputModules', outputModules)
1443 Tool code implementation 1449 pfCandidates=self.
_parameters[
'pfCandidates'].value
1456 tightBTagNTkHits=self.
_parameters[
'tightBTagNTkHits'].value
1457 loadStdRecoBTag=self.
_parameters[
'loadStdRecoBTag'].value
1458 svClustering=self.
_parameters[
'svClustering'].value
1460 groomedFatJets=self.
_parameters[
'groomedFatJets'].value
1463 getJetMCFlavour=self.
_parameters[
'getJetMCFlavour'].value
1464 genJetCollection=self.
_parameters[
'genJetCollection'].value
1465 genParticles=self.
_parameters[
'genParticles'].value
1466 jetCorrections=self.
_parameters[
'jetCorrections'].value
1467 btagDiscriminators=self.
_parameters[
'btagDiscriminators'].value
1469 jetTrackAssociation=self.
_parameters[
'jetTrackAssociation'].value
1470 outputModules=self.
_parameters[
'outputModules'].value
1477 btagPrefix=btagPrefix,
1478 jetSource=jetSource,
1479 pfCandidates=pfCandidates,
1480 explicitJTA=explicitJTA,
1486 tightBTagNTkHits=tightBTagNTkHits,
1487 loadStdRecoBTag=loadStdRecoBTag,
1488 svClustering=svClustering,
1490 groomedFatJets=groomedFatJets,
1493 getJetMCFlavour=getJetMCFlavour,
1494 genJetCollection=genJetCollection,
1495 genParticles=genParticles,
1496 jetCorrections=jetCorrections,
1497 btagDiscriminators=btagDiscriminators,
1498 btagInfos=btagInfos,
1499 jetTrackAssociation=jetTrackAssociation,
1500 outputModules=outputModules,
1508 Tool to update a jet collection in your PAT Tuple (primarily intended for MiniAOD for which the default input argument values have been set). 1510 _label=
'updateJetCollection' 1511 _defaultParameters=dicttypes.SortedKeysDict()
1515 Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor. 1518 ConfigToolBase.__init__(self)
1520 self.addParameter(self.
_defaultParameters,
'labelName',
'',
"Label name of the new patJet collection.", str)
1521 self.addParameter(self.
_defaultParameters,
'postfix',
'',
"Postfix from usePF2PAT.", str)
1522 self.addParameter(self.
_defaultParameters,
'btagPrefix',
'',
"Prefix to be added to b-tag discriminator and TagInfo names", str)
1523 self.addParameter(self.
_defaultParameters,
'jetSource',
'',
"Label of the input collection from which the new patJet collection should be created", cms.InputTag)
1524 self.addParameter(self.
_defaultParameters,
'pfCandidates',cms.InputTag(
'packedPFCandidates'),
"Label of the input collection for candidatecandidatese used in b-tagging", cms.InputTag)
1525 self.addParameter(self.
_defaultParameters,
'explicitJTA',
False,
"Use explicit jet-track association")
1526 self.addParameter(self.
_defaultParameters,
'pvSource',cms.InputTag(
'offlineSlimmedPrimaryVertices'),
"Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
1527 self.addParameter(self.
_defaultParameters,
'svSource',cms.InputTag(
'slimmedSecondaryVertices'),
"Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
1528 self.addParameter(self.
_defaultParameters,
'elSource',cms.InputTag(
'slimmedElectrons'),
"Label of the input collection for electrons used in b-tagging", cms.InputTag)
1529 self.addParameter(self.
_defaultParameters,
'muSource',cms.InputTag(
'slimmedMuons'),
"Label of the input collection for muons used in b-tagging", cms.InputTag)
1530 self.addParameter(self.
_defaultParameters,
'runIVF',
False,
"Re-run IVF secondary vertex reconstruction")
1531 self.addParameter(self.
_defaultParameters,
'tightBTagNTkHits',
False,
"Enable legacy tight b-tag track selection")
1532 self.addParameter(self.
_defaultParameters,
'loadStdRecoBTag',
False,
"Load the standard reconstruction b-tagging modules")
1533 self.addParameter(self.
_defaultParameters,
'svClustering',
False,
"Secondary vertices ghost-associated to jets using jet clustering (mostly intended for subjets)")
1534 self.addParameter(self.
_defaultParameters,
'fatJets', cms.InputTag(
''),
"Fat jet collection used for secondary vertex clustering", cms.InputTag)
1535 self.addParameter(self.
_defaultParameters,
'groomedFatJets', cms.InputTag(
''),
"Groomed fat jet collection used for secondary vertex clustering", cms.InputTag)
1536 self.addParameter(self.
_defaultParameters,
'algo',
'AK',
"Jet algorithm of the input collection from which the new patJet collection should be created")
1537 self.addParameter(self.
_defaultParameters,
'rParam', 0.4,
"Jet size (distance parameter R used in jet clustering)")
1538 self.addParameter(self.
_defaultParameters,
'sortByPt',
True,
"Set to False to not modify incoming jet order")
1539 self.addParameter(self.
_defaultParameters,
'printWarning',
True,
"To be use as False in production to reduce log size")
1540 self.addParameter(self.
_defaultParameters,
'jetCorrections',
None,
"Add all relevant information about jet energy corrections that you want to be added to your new patJet \ 1541 collection. The format has to be given in a python tuple of type: (\'AK4Calo\',[\'L2Relative\', \'L3Absolute\'], patMet). Here the first argument corresponds to the payload \ 1542 in the CMS Conditions database for the given jet collection; the second argument corresponds to the jet energy correction levels that you want to be embedded into your \ 1543 new patJet collection. This should be given as a list of strings. Available values are L1Offset, L1FastJet, L1JPTOffset, L2Relative, L3Absolute, L5Falvour, L7Parton; the \ 1544 third argument indicates whether MET(Type1/2) corrections should be applied corresponding to the new patJetCollection. If so a new patMet collection will be added to your PAT \ 1545 Tuple in addition to the raw patMet. This new patMet collection will have the MET(Type1/2) corrections applied. The argument can have the following types: \'type-1\' for \ 1546 type-1 corrected MET; \'type-2\' for type-1 plus type-2 corrected MET; \'\' or \'none\' if no further MET corrections should be applied to your MET. The arguments \'type-1\' \ 1547 and \'type-2\' are not case sensitive.", tuple, acceptNoneValue=
True)
1548 self.addParameter(self.
_defaultParameters,
'btagDiscriminators',[
'None'],
"If you are interested in btagging, in most cases just the labels of the btag discriminators that \ 1549 you are interested in is all relevant information that you need for a high level analysis. Add here all btag discriminators, that you are interested in as a list of strings. \ 1550 If this list is empty no btag discriminator information will be added to your new patJet collection.", allowedValues=(
list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list)
1551 self.addParameter(self.
_defaultParameters,
'btagInfos',[
'None'],
"The btagInfos objects contain all relevant information from which all discriminators of a certain \ 1552 type have been calculated. You might be interested in keeping this information for low level tests or to re-calculate some discriminators from hand. Note that this information \ 1553 on the one hand can be very space consuming and that it is not necessary to access the pre-calculated btag discriminator information that has been derived from it. Only in very \ 1554 special cases the btagInfos might really be needed in your analysis. Add here all btagInfos, that you are interested in as a list of strings. If this list is empty no btagInfos \ 1555 will be added to your new patJet collection.", allowedValues=supportedBtagInfos,Type=list)
1556 self.addParameter(self.
_defaultParameters,
'outputModules',[
'out'],
"Add a list of all output modules to which you would like the new jet collection to be added. Usually this is \ 1557 just one single output module with name \'out\', which corresponds also the default configuration of the tool. There is cases though where you might want to add this collection \ 1558 to more than one output module.")
1562 self.
_comment =
"This is a tool to add more patJet collectinos to your PAT Tuple or to re-configure the default collection. You can add and embed additional information like jet\ 1563 energy correction factors, btag information and generator match information to the new patJet collection depending on the parameters that you pass on to this function. Consult \ 1564 the descriptions of each parameter for more information." 1568 Return default parameters of the class 1572 def __call__(self,process,labelName=None,postfix=None,btagPrefix=None,jetSource=None,pfCandidates=None,explicitJTA=None,pvSource=None,svSource=None,elSource=None,muSource=None,runIVF=None,tightBTagNTkHits=None,loadStdRecoBTag=None,svClustering=None,fatJets=None,groomedFatJets=None,algo=None,rParam=None,sortByPt=None,printWarning=None,jetCorrections=None,btagDiscriminators=None,btagInfos=None):
1574 Function call wrapper. This will check the parameters and call the actual implementation that 1575 can be found in toolCode via the base class function apply. 1577 if labelName
is None:
1579 self.setParameter(
'labelName', labelName)
1582 self.setParameter(
'postfix', postfix)
1583 if btagPrefix
is None:
1585 self.setParameter(
'btagPrefix', btagPrefix)
1586 if jetSource
is None:
1588 self.setParameter(
'jetSource', jetSource)
1589 if pfCandidates
is None:
1591 self.setParameter(
'pfCandidates', pfCandidates)
1592 if explicitJTA
is None:
1594 self.setParameter(
'explicitJTA', explicitJTA)
1595 if pvSource
is None:
1597 self.setParameter(
'pvSource', pvSource)
1598 if svSource
is None:
1600 self.setParameter(
'svSource', svSource)
1601 if elSource
is None:
1603 self.setParameter(
'elSource', elSource)
1604 if muSource
is None:
1606 self.setParameter(
'muSource', muSource)
1609 self.setParameter(
'runIVF', runIVF)
1610 if tightBTagNTkHits
is None:
1612 self.setParameter(
'tightBTagNTkHits', tightBTagNTkHits)
1613 if loadStdRecoBTag
is None:
1615 self.setParameter(
'loadStdRecoBTag', loadStdRecoBTag)
1616 if svClustering
is None:
1618 self.setParameter(
'svClustering', svClustering)
1621 self.setParameter(
'fatJets', fatJets)
1622 if groomedFatJets
is None:
1624 self.setParameter(
'groomedFatJets', groomedFatJets)
1627 self.setParameter(
'algo', algo)
1630 self.setParameter(
'rParam', rParam)
1631 if sortByPt
is None:
1633 self.setParameter(
'sortByPt', sortByPt)
1634 if printWarning
is None:
1636 self.setParameter(
'printWarning', printWarning)
1637 if jetCorrections
is None:
1639 self.setParameter(
'jetCorrections', jetCorrections)
1640 if btagDiscriminators
is None:
1642 self.setParameter(
'btagDiscriminators', btagDiscriminators)
1643 if btagInfos
is None:
1645 self.setParameter(
'btagInfos', btagInfos)
1650 Tool code implementation 1657 pfCandidates=self.
_parameters[
'pfCandidates'].value
1664 tightBTagNTkHits=self.
_parameters[
'tightBTagNTkHits'].value
1665 loadStdRecoBTag=self.
_parameters[
'loadStdRecoBTag'].value
1666 svClustering=self.
_parameters[
'svClustering'].value
1668 groomedFatJets=self.
_parameters[
'groomedFatJets'].value
1672 printWarning=self.
_parameters[
'printWarning'].value
1673 jetCorrections=self.
_parameters[
'jetCorrections'].value
1678 knownModules = process.producerNames().
split()
1680 if btagDiscriminators.count(
'None')>0:
1681 btagDiscriminators.remove(
'None')
1682 if btagInfos.count(
'None')>0:
1683 btagInfos.remove(
'None')
1684 bTagging=(len(btagDiscriminators)>0
or len(btagInfos)>0)
1689 _labelName=labelName[:1].
upper()+labelName[1:]
1693 for x
in [
"ak",
"ca",
"kt"]:
1694 if x
in algo.lower():
1695 _algo=supportedJetAlgos[x]
1705 updatedPatJets.sort = cms.bool(
False)
1706 if 'updatedPatJets'+_labelName+postfix
in knownModules :
1707 _newPatJets=getattr(process,
'updatedPatJets'+_labelName+postfix)
1708 _newPatJets.jetSource=jetSource
1711 updatedPatJets.clone(jetSource=jetSource,
1712 printWarning=printWarning), process, task)
1713 _newPatJets=getattr(process,
'updatedPatJets'+_labelName+postfix)
1714 knownModules.append(
'updatedPatJets'+_labelName+postfix)
1717 if 'selectedUpdatedPatJets'+_labelName+postfix
in knownModules :
1718 _newSelectedPatJets=getattr(process,
'selectedUpdatedPatJets'+_labelName+postfix)
1719 _newSelectedPatJets.src=
'updatedPatJets'+_labelName+postfix
1722 selectedPatJets.clone(src=
'updatedPatJets'+_labelName+postfix),
1724 knownModules.append(
'selectedUpdatedPatJets'+_labelName+postfix)
1729 sys.stderr.write(
"**************************************************************\n")
1730 sys.stderr.write(
"b tagging needs to be run on uncorrected jets. Hence, the JECs\n")
1731 sys.stderr.write(
"will first be undone for 'updatedPatJets%s' and then applied to\n" % (_labelName+postfix) )
1732 sys.stderr.write(
"'updatedPatJetsTransientCorrected%s'.\n" % (_labelName+postfix) )
1733 sys.stderr.write(
"**************************************************************\n")
1734 _jetSource = cms.InputTag(
'updatedPatJets'+_labelName+postfix)
1738 labelName = (
'TransientCorrected'+_labelName),
1739 jetSource = _jetSource,
1740 pfCandidates=pfCandidates,
1741 explicitJTA=explicitJTA,
1747 tightBTagNTkHits=tightBTagNTkHits,
1748 loadStdRecoBTag=loadStdRecoBTag,
1749 svClustering=svClustering,
1751 groomedFatJets=groomedFatJets,
1754 jetCorrections = jetCorrections,
1755 btagPrefix = btagPrefix,
1759 _patJets=getattr(process,
'updatedPatJetsTransientCorrected'+_labelName+postfix)
1760 setupBTagging(process, _jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
1761 _algo, rParam, btagDiscriminators, btagInfos, _patJets, _labelName, btagPrefix, postfix)
1763 _newSelectedPatJets=getattr(process,
'selectedUpdatedPatJets'+_labelName+postfix)
1764 _newSelectedPatJets.src=
'updatedPatJetsTransientCorrected'+_labelName+postfix
1766 delattr(process,
'selectedUpdatedPatJetsTransientCorrected'+_labelName+postfix)
1768 _newPatJets.addBTagInfo =
False 1769 _newPatJets.addTagInfos =
False 1772 if (jetCorrections
is not None or bTagging):
1774 if jetCorrections
is None and bTagging:
1775 raise ValueError(
"Passing jetCorrections = None while running bTagging is likely not intended.")
1779 if jetCorrections[2].lower() !=
'none' and jetCorrections[2] !=
'':
1780 sys.stderr.write(
"-------------------------------------------------------------------\n")
1781 sys.stderr.write(
" Warning: MET correction was set to " + jetCorrections[2] +
" but\n")
1782 sys.stderr.write(
" will be ignored. Please set it to \"None\" to avoid\n")
1783 sys.stderr.write(
" getting this warning.\n")
1784 sys.stderr.write(
"-------------------------------------------------------------------\n")
1785 jetCorrectionsList =
list(jetCorrections)
1786 jetCorrectionsList[2] =
'None' 1787 jetCorrections = tuple(jetCorrectionsList)
1790 jetCorrections = (
'AK4PFchs', cms.vstring([]),
'None')
1792 setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, _newPatJets, _labelName, postfix)
1795 _newPatJets.addJetCorrFactors=
False 1802 Compute jet id for process 1805 _defaultParameters=dicttypes.SortedKeysDict()
1807 ConfigToolBase.__init__(self)
1809 self.addParameter(self.
_defaultParameters,
'jetIdTag',
'',
"Tag to append to jet id map", Type=str)
1821 if jetIdTag
is None:
1823 self.setParameter(
'jetSrc',jetSrc)
1824 self.setParameter(
'jetIdTag',jetIdTag)
1831 jetIdLabel = jetIdTag +
'JetID' 1832 sys.stderr.write(
"Making new jet ID label with label " + jetIdTag +
"\n")
1836 process.load(
"RecoJets.JetProducers.ak4JetID_cfi")
1837 task.add(process.ak4JetID)
1847 Replace tag infos for collection jetSrc 1849 _label=
'setTagInfos' 1850 _defaultParameters=dicttypes.SortedKeysDict()
1852 ConfigToolBase.__init__(self)
1853 self.addParameter(self.
_defaultParameters,
'coll',
"patJets",
"jet collection to set tag infos for")
1854 self.addParameter(self.
_defaultParameters,
'tagInfos',cms.vstring( ),
"tag infos to set")
1866 if tagInfos
is None:
1868 self.setParameter(
'coll',coll)
1869 self.setParameter(
'tagInfos',tagInfos)
1877 newTags = cms.VInputTag()
1880 for j
in getattr( process, coll ).tagInfoSources :
1882 if ( vv.find(k) != -1 ):
1887 raise RuntimeError(
""" 1888 Cannot replace tag infos in jet collection""" % (coll))
1890 getattr(process,coll).tagInfoSources = newTags
1895 sys.stderr.write(
"-------------------------------------------------------\n")
1896 sys.stderr.write(
" Error: the option 'outputModule' is not supported\n")
1897 sys.stderr.write(
" anymore by:\n")
1898 sys.stderr.write(
" " + obj._label +
"\n")
1899 sys.stderr.write(
" please use 'outputModules' now and specify the\n")
1900 sys.stderr.write(
" names of all needed OutModules in there\n")
1901 sys.stderr.write(
" (default: ['out'])\n")
1902 sys.stderr.write(
"-------------------------------------------------------\n")
1903 raise KeyError(
"Unsupported option 'outputModule' used in '"+obj._label+
"'")
1906 sys.stderr.write(
"-------------------------------------------------------\n")
1907 sys.stderr.write(
" Error: the jet 'labelName' is not defined.\n")
1908 sys.stderr.write(
" All added jets must have 'labelName' defined.\n")
1909 sys.stderr.write(
"-------------------------------------------------------\n")
1910 raise KeyError(
"Undefined jet 'labelName' used in '"+obj._label+
"'")
1913 sys.stderr.write(
"-------------------------------------------------------\n")
1914 sys.stderr.write(
" Error: Unsupported jet algorithm detected.\n")
1915 sys.stderr.write(
" The supported algorithms are:\n")
1916 for key
in supportedJetAlgos.keys():
1917 sys.stderr.write(
" " + key.upper() +
", " + key.lower() +
": " + supportedJetAlgos[key] +
"\n")
1918 sys.stderr.write(
"-------------------------------------------------------\n")
1919 raise KeyError(
"Unsupported jet algorithm used in '"+obj._label+
"'")
1922 sys.stderr.write(
"-------------------------------------------------------------------\n")
1923 sys.stderr.write(
" Warning: You are attempting to remake the IVF secondary vertices\n")
1924 sys.stderr.write(
" already produced by the standard reconstruction. This\n")
1925 sys.stderr.write(
" option is not enabled by default so please use it only if\n")
1926 sys.stderr.write(
" you know what you are doing.\n")
1927 sys.stderr.write(
"-------------------------------------------------------------------\n")
1930 sys.stderr.write(
"-------------------------------------------------------------------\n")
1931 sys.stderr.write(
" Warning: You are attempting to remake IVF secondary vertices from\n")
1932 sys.stderr.write(
" MiniAOD. If that was your intention, note that secondary\n")
1933 sys.stderr.write(
" vertices remade from MiniAOD will have somewhat degraded\n")
1934 sys.stderr.write(
" performance compared to those remade from RECO/AOD.\n")
1935 sys.stderr.write(
"-------------------------------------------------------------------\n")
bool any(const std::vector< T > &v, const T &what)
def addToProcessAndTask(label, module, process, task)
S & print(S &os, JobReport::InputFile const &f)
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
def getPatAlgosToolsTask(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