CMS 3D CMS Logo

jetTools.py
Go to the documentation of this file.
1 from __future__ import print_function
3 from FWCore.ParameterSet.Mixins import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase
4 from FWCore.ParameterSet.SequenceTypes import _ModuleSequenceType, _Sequenceable
8 import sys
9 from FWCore.ParameterSet.MassReplace import MassSearchReplaceAnyInputTagVisitor
10 
11 ## dictionary with supported jet clustering algorithms
12 supportedJetAlgos = {
13  'ak' : 'AntiKt'
14  , 'ca' : 'CambridgeAachen'
15  , 'kt' : 'Kt'
16 }
17 
18 def checkJetCorrectionsFormat(jetCorrections):
19  ## check for the correct format
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) \
23  corrections.")
24 
25 
26 def setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix):
27 
28  task = getPatAlgosToolsTask(process)
29 
30  ## determine type of jet constituents from jetSource; supported
31  ## jet constituent types are calo, pf, jpt, for pf also particleflow
32  ## is aloowed as part of the jetSource label, which might be used
33  ## in CommonTools.ParticleFlow
34  _type="NONE"
35  if jetCorrections[0].count('PF')>0:
36  _type='PF'
37  elif jetCorrections[0].count('Calo')>0:
38  _type='Calo'
39  elif jetCorrections[0].count('JPT')>0:
40  _type='JPT'
41  else:
42  raise TypeError("In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets.")
43  from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
44  if 'patJetCorrFactors'+labelName+postfix in knownModules :
45  _newPatJetCorrFactors=getattr(process, 'patJetCorrFactors'+labelName+postfix)
46  _newPatJetCorrFactors.src=jetSource
47  _newPatJetCorrFactors.primaryVertices=pvSource
48  else:
49  addToProcessAndTask('patJetCorrFactors'+labelName+postfix,
50  patJetCorrFactors.clone(src=jetSource, primaryVertices=pvSource),
51  process, task)
52  _newPatJetCorrFactors=getattr(process, "patJetCorrFactors"+labelName+postfix)
53  _newPatJetCorrFactors.payload=jetCorrections[0]
54  _newPatJetCorrFactors.levels=jetCorrections[1]
55  ## check whether L1Offset or L1FastJet is part of levels
56  error=False
57  for x in jetCorrections[1]:
58  if x == 'L1Offset' :
59  if not error :
60  _newPatJetCorrFactors.useNPV=True
61  _newPatJetCorrFactors.primaryVertices='offlinePrimaryVertices'
62  _newPatJetCorrFactors.useRho=False
63  ## we set this to True now as a L1 correction type should appear only once
64  ## otherwise levels is miss configured
65  error=True
66  else:
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])
69  if x == 'L1FastJet' :
70  if not error :
71  if _type == "JPT" :
72  raise TypeError("In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets.")
73  ## configure module
74  _newPatJetCorrFactors.useRho=True
75  if "PF" in _type :
76  _newPatJetCorrFactors.rho=cms.InputTag('fixedGridRhoFastjetAll')
77  else :
78  _newPatJetCorrFactors.rho=cms.InputTag('fixedGridRhoFastjetAllCalo')
79  ## we set this to True now as a L1 correction type should appear only once
80  ## otherwise levels is miss configured
81  error=True
82  else:
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))
86  ## configure MET(Type1) corrections
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])
91  if _type == "JPT":
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.")
94  ## set up jet correctors for MET corrections
95  process.load( "JetMETCorrections.Configuration.JetCorrectorsAllAlgos_cff") # FIXME: This adds a lot of garbage
96  # I second the FIXME comment on the last line. When I counted it, this brought in 344 EDProducers
97  # to be available to run unscheduled. All jet correctors, probably some small fraction of which
98  # are actually used.
99  task.add(process.jetCorrectorsAllAlgosTask)
100  _payloadType = jetCorrections[0].split(_type)[0].lower()+_type
101  if "PF" in _type :
102  addToProcessAndTask(jetCorrections[0]+'L1FastJet',
103  getattr(process, _payloadType+'L1FastjetCorrector').clone(srcRho=cms.InputTag('fixedGridRhoFastjetAll')),
104  process, task)
105  else :
106  addToProcessAndTask(jetCorrections[0]+'L1FastJet',
107  getattr(process, _payloadType+'L1FastjetCorrector').clone(srcRho=cms.InputTag('fixedGridRhoFastjetAllCalo')),
108  process, task)
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)
113  addToProcessAndTask(jetCorrections[0]+'CombinedCorrector',
114  cms.EDProducer( 'ChainedJetCorrectorProducer', correctors = cms.VInputTag()),
115  process, task)
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))
119  else:
120  _corrector = _payloadType
121  if x == 'L1FastJet':
122  _corrector += 'L1Fastjet'
123  elif x == 'L2L3Residual':
124  _corrector += 'Residual'
125  else:
126  _corrector += x
127  _corrector += 'Corrector'
128  getattr(process, jetCorrections[0]+'CombinedCorrector').correctors.append(cms.InputTag(_corrector))
129 
130  ## set up MET(Type1) correction modules
131  _labelCorrName = labelName
132  if labelName != '':
133  _labelCorrName = 'For' + labelName
134  if _type == 'Calo':
135  from JetMETCorrections.Type1MET.correctionTermsCaloMet_cff import corrCaloMetType1
136  from JetMETCorrections.Type1MET.correctionTermsCaloMet_cff import corrCaloMetType2
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')),
142  process, task)
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'))),
149  process, task)
151  jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix,
152  caloMetT1.clone(src = "caloMetM", srcCorrections = cms.VInputTag(
153  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'))),
154  process, task)
155  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix,
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))),
159  process, task)
160  elif _type == 'PF':
162  from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfCandsNotInJetsPtrForMetCorr
163  from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfCandsNotInJetsForMetCorr
167  from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1
168  from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1T2
169  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'pfJetsPtrForMetCorr'+postfix,
170  pfJetsPtrForMetCorr.clone(src = jetSource), process, task)
172  jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsPtrForMetCorr'+postfix,
173  pfCandsNotInJetsPtrForMetCorr.clone(topCollection = jetCorrections[0]+_labelCorrName+'pfJetsPtrForMetCorr'+postfix),
174  process, task)
176  jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsForMetCorr'+postfix,
177  pfCandsNotInJetsForMetCorr.clone(src = jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsPtrForMetCorr'+postfix),
178  process, task)
180  jetCorrections[0]+_labelCorrName+'CandMETcorr'+postfix,
181  pfCandMETcorr.clone(src = cms.InputTag(jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsForMetCorr'+postfix)),
182  process, task)
184  jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix,
185  corrPfMetType1.clone(src = jetSource, jetCorrLabel = cms.InputTag(jetCorrections[0]+'CombinedCorrector')),
186  process, task) # FIXME: Originally w/o jet corrections?
187  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'corrPfMetType2'+postfix,
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))),
192  process, task)
193  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix,
194  pfMetT1.clone(srcCorrections = cms.VInputTag(
195  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'))),
196  process, task)
197  addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix,
198  pfMetT1T2.clone(srcCorrections = cms.VInputTag(
199  cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'),
200  jetCorrections[0]+_labelCorrName+'corrPfMetType2'+postfix)),
201  process, task)
202 
203  ## common configuration for Calo and PF
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')
206  #FIXME: What is wrong here?
207  #elif ('L1Offset' in jetCorrections[1]):
208  #getattr(process,jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag(jetCorrections[0]+'L1Offset')
209  else:
210  getattr(process,jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag('')
211 
213  if jetCorrections[2].lower() == 'type-1':
214  addToProcessAndTask('patMETs'+labelName+postfix,
215  patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix),
216  addMuonCorrections = False),
217  process, task)
218  elif jetCorrections[2].lower() == 'type-2':
219  addToProcessAndTask('patMETs'+labelName+postfix,
220  patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix),
221  addMuonCorrections = False),
222  process, task)
223 
224 
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)
229  ## if the jet is actually a subjet
230  if fatJets != cms.InputTag(''):
231  btagInfo.fatJets = fatJets
232  if groomedFatJets != cms.InputTag(''):
233  btagInfo.groomedFatJets = groomedFatJets
234 
235 
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):
238 
239  task = getPatAlgosToolsTask(process)
240 
241  ## expand the btagDiscriminators to remove the meta taggers and substitute the equivalent sources
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)
249 
250  ## expand tagInfos to what is explicitly required by user + implicit
251  ## requirements that come in from one or the other discriminator
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
260  break
261  if not tagInfoCovered :
262  requiredTagInfos.append(requiredTagInfo)
263  ## load sequences and setups needed for btagging
264  if hasattr( process, 'candidateJetProbabilityComputer' ) == False :
265  if loadStdRecoBTag: # also loading modules already run in the standard reconstruction
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)
276  else: # to prevent loading of modules already run in the standard reconstruction
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
284 
285  if tightBTagNTkHits:
286  if not runIVF:
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")
291  if btagPrefix == '':
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")
298 
299  ## define c tagging CvsL SV source (for now tied to the default SV source
300  ## in the first part of the module label, product instance label and process name)
301  svSourceCvsL = copy.deepcopy(svSource)
302  svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+'CvsL')
303 
304  ## check if and under what conditions to re-run IVF
305  runIVFforCTagOnly = False
306  ivfcTagInfos = ['pfInclusiveSecondaryVertexFinderCvsLTagInfos', 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
307  ## if MiniAOD and running c tagging
308  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices' and any(i in requiredTagInfos for i in ivfcTagInfos) and not runIVF:
309  runIVFforCTagOnly = True
310  runIVF = 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")
315  ## adjust svSources
316  if runIVF and btagPrefix != '':
317  if runIVFforCTagOnly:
318  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
319  else:
320  svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
321  svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
322 
323  ## setup all required btagInfos : we give a dedicated treatment for different
324  ## types of tagInfos here. A common treatment is possible but might require a more
325  ## general approach anyway in coordination with the btagging POG.
326 
327  runNegativeVertexing = False
328  runNegativeCvsLVertexing = False
329  for btagInfo in requiredTagInfos:
330  if btagInfo in (
331  'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
332  'pfNegativeDeepFlavourTagInfos',
333  'pfNegativeParticleNetAK4TagInfos',
334  ):
335  runNegativeVertexing = True
336  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
337  runNegativeCvsLVertexing = True
338 
339  if runNegativeVertexing or runNegativeCvsLVertexing:
340  import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff as NegVertex
341 
342  if runNegativeVertexing:
343  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix,
344  NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
345  process, task)
346  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix,
347  NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
348  process, task)
349  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix,
350  NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix)
351  ,primaryVertices = pvSource
352  ,tracks=pfCandidates),
353  process, task)
354  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
355  NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix)),
356  process, task)
357 
358  if runNegativeCvsLVertexing:
359  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
360  NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
361  process, task)
362  addToProcessAndTask(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix,
363  NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
364  process, task)
365  addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix,
366  NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix)
367  ,primaryVertices = pvSource
368  ,tracks=pfCandidates),
369  process, task)
370  addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
371  NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
372  process, task)
373 
374 
375  acceptedTagInfos = list()
376  for btagInfo in requiredTagInfos:
377  if hasattr(btag,btagInfo):
378  if btagInfo == 'pfImpactParameterTagInfos':
379  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
380  btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
381  process, task)
382  if explicitJTA:
383  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
384  _btagInfo.explicitJTA = cms.bool(explicitJTA)
385  if tightBTagNTkHits:
386  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
387  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
388  _btagInfo.minimumNumberOfHits = cms.int32(8)
389  if btagInfo == 'pfImpactParameterAK8TagInfos':
390  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
391  btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
392  process, task)
393  if explicitJTA:
394  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
395  _btagInfo.explicitJTA = cms.bool(explicitJTA)
396  if tightBTagNTkHits:
397  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
398  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
399  _btagInfo.minimumNumberOfHits = cms.int32(8)
400  if btagInfo == 'pfImpactParameterCA15TagInfos':
401  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
402  btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
403  process, task)
404  if explicitJTA:
405  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
406  _btagInfo.explicitJTA = cms.bool(explicitJTA)
407  if tightBTagNTkHits:
408  _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
409  _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
410  _btagInfo.minimumNumberOfHits = cms.int32(8)
411  if btagInfo == 'pfSecondaryVertexTagInfos':
412  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
413  btag.pfSecondaryVertexTagInfos.clone(
414  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
415  process, task)
416  if tightBTagNTkHits:
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':
421  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
422  btag.pfDeepCSVTagInfos.clone(
423  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
424  process, task)
425  if svClustering or fatJets != cms.InputTag(''):
426  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
427  if btagInfo == 'pfDeepCSVNegativeTagInfos':
428  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
429  btag.pfDeepCSVNegativeTagInfos.clone(
430  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
431  process, task)
432  if svClustering or fatJets != cms.InputTag(''):
433  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
434  if btagInfo == 'pfDeepCSVPositiveTagInfos':
435  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
436  btag.pfDeepCSVPositiveTagInfos.clone(
437  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
438  process, task)
439  if svClustering or fatJets != cms.InputTag(''):
440  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
441  if btagInfo == 'pfDeepCMVATagInfos':
442  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
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)),
448  process, task)
449  if svClustering or fatJets != cms.InputTag(''):
450  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
451  if btagInfo == 'pfDeepCMVANegativeTagInfos':
452  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
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)),
458  process, task)
459  if svClustering or fatJets != cms.InputTag(''):
460  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
461  if btagInfo == 'pfDeepCMVAPositiveTagInfos':
462  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
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)),
468  process, task)
469  if svClustering or fatJets != cms.InputTag(''):
470  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
471  if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
472  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
473  btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
474  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
475  extSVCollection=svSource),
476  process, task)
477  if svClustering or fatJets != cms.InputTag(''):
478  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
479  if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
480  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
481  btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
482  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
483  extSVCollection=svSource),
484  process, task)
485  if svClustering or fatJets != cms.InputTag(''):
486  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
487  if btagInfo == 'pfBoostedDoubleSVAK8TagInfos':
488  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
489  btag.pfBoostedDoubleSVAK8TagInfos.clone(
490  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
491  process, task)
492  if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
493  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
494  btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
495  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
496  extSVCollection=svSource),
497  process, task)
498  if svClustering or fatJets != cms.InputTag(''):
499  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
500  if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
501  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
502  btag.pfBoostedDoubleSVCA15TagInfos.clone(
503  svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
504  process, task)
505  if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
506  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
507  btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
508  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
509  extSVCollection=svSourceCvsL),
510  process, task)
511  if svClustering or fatJets != cms.InputTag(''):
512  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
513  if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
514  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
515  btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
516  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
517  extSVCollection = btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
518  process, task)
519  if svClustering or fatJets != cms.InputTag(''):
520  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
521  if btagInfo == 'pfGhostTrackVertexTagInfos':
522  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
523  btag.pfGhostTrackVertexTagInfos.clone(
524  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
525  process, task)
526  if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
527  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
528  btag.pfSecondaryVertexNegativeTagInfos.clone(
529  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
530  process, task)
531  if tightBTagNTkHits:
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':
536  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
537  btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
538  trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
539  extSVCollection=cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
540  process, task)
541  if svClustering or fatJets != cms.InputTag(''):
542  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
543  if btagInfo == 'impactParameterTagInfos':
544  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
545  btag.impactParameterTagInfos.clone(
546  jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
547  primaryVertex=pvSource),
548  process, task)
549  if btagInfo == 'secondaryVertexTagInfos':
550  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
551  btag.secondaryVertexTagInfos.clone(
552  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
553  process, task)
554  if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
555  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
556  btag.inclusiveSecondaryVertexFinderTagInfos.clone(
557  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
558  process, task)
559  if svClustering or fatJets != cms.InputTag(''):
560  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
561  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
562  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
563  btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
564  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
565  process, task)
566  if svClustering or fatJets != cms.InputTag(''):
567  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
568  if btagInfo == 'secondaryVertexNegativeTagInfos':
569  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
570  btag.secondaryVertexNegativeTagInfos.clone(
571  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
572  process, task)
573  if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
574  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
575  btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
576  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
577  process, task)
578  if svClustering or fatJets != cms.InputTag(''):
579  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
580  if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
581  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
582  btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
583  trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
584  process, task)
585  if svClustering or fatJets != cms.InputTag(''):
586  setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
587  if btagInfo == 'softMuonTagInfos':
588  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
589  btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
590  process, task)
591  if btagInfo == 'softPFMuonsTagInfos':
592  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
593  btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
594  process, task)
595  if btagInfo == 'softPFElectronsTagInfos':
596  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
597  btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
598  process, task)
599 
600  if 'DeepFlavourTagInfos' in btagInfo:
601  svUsed = svSource
602  if btagInfo == 'pfNegativeDeepFlavourTagInfos':
603  deep_csv_tag_infos = 'pfDeepCSVNegativeTagInfos'
604  svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
605  flip = True
606  else:
607  deep_csv_tag_infos = 'pfDeepCSVTagInfos'
608  flip = False
609  # use right input tags when running with RECO PF candidates, which actually
610  # depens of wether jets were slimmed or not (check for s/S-limmed in name)
611  if not ('limmed' in jetSource.value()):
612  puppi_value_map = cms.InputTag("puppi")
613  vertex_associator = cms.InputTag("primaryVertexAssociation","original")
614  else:
615  puppi_value_map = cms.InputTag("")
616  vertex_associator = cms.InputTag("")
617  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
618  btag.pfDeepFlavourTagInfos.clone(
619  jets = jetSource,
620  vertices=pvSource,
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,
625  flip = flip),
626  process, task)
627 
628  if btagInfo == 'pfDeepDoubleXTagInfos':
629  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
630  btag.pfDeepDoubleXTagInfos.clone(
631  jets = jetSource,
632  vertices=pvSource,
633  secondary_vertices=svSource,
634  shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
635  ),
636  process, task)
637 
638  if btagInfo == 'pfHiggsInteractionNetTagInfos':
639  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
640  btag.pfHiggsInteractionNetTagInfos.clone(
641  jets = jetSource,
642  vertices = pvSource,
643  secondary_vertices = svSource,
644  pf_candidates = pfCandidates,
645  ),
646  process, task)
647 
648  if btagInfo == 'pfDeepBoostedJetTagInfos':
649  if pfCandidates.value() == 'packedPFCandidates':
650  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
651  if 'updated' not in jetSource.value().lower():
652  raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
653  puppi_value_map = ""
654  vertex_associator = ""
655  elif pfCandidates.value() == 'particleFlow':
656  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
657  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
658  # daughters are the particles used in jet clustering, so already scaled by their puppi weights
659  # Uncomment the lines below after running pfDeepBoostedJetTagInfos with reco::PFCandidates becomes supported
660 # puppi_value_map = "puppi"
661 # vertex_associator = "primaryVertexAssociation:original"
662  else:
663  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
664  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
665  btag.pfDeepBoostedJetTagInfos.clone(
666  jets = jetSource,
667  vertices = pvSource,
668  secondary_vertices = svSource,
669  pf_candidates = pfCandidates,
670  puppi_value_map = puppi_value_map,
671  vertex_associator = vertex_associator,
672  ),
673  process, task)
674 
675  if btagInfo == 'pfParticleNetTagInfos':
676  if pfCandidates.value() == 'packedPFCandidates':
677  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
678  puppi_value_map = ""
679  vertex_associator = ""
680  elif pfCandidates.value() == 'particleFlow':
681  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
682  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
683  puppi_value_map = "puppi"
684  vertex_associator = "primaryVertexAssociation:original"
685  else:
686  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
687  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
688  btag.pfParticleNetTagInfos.clone(
689  jets = jetSource,
690  vertices = pvSource,
691  secondary_vertices = svSource,
692  pf_candidates = pfCandidates,
693  puppi_value_map = puppi_value_map,
694  vertex_associator = vertex_associator,
695  ),
696  process, task)
697 
698  if 'ParticleNetAK4TagInfos' in btagInfo:
699  if btagInfo == 'pfNegativeParticleNetAK4TagInfos':
700  secondary_vertices = btagPrefix + \
701  'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
702  flip_ip_sign = True
703  sip3dSigMax = 10
704  else:
705  secondary_vertices = svSource
706  flip_ip_sign = False
707  sip3dSigMax = -1
708  if pfCandidates.value() == 'packedPFCandidates':
709  # case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
710  puppi_value_map = ""
711  vertex_associator = ""
712  elif pfCandidates.value() == 'particleFlow':
713  raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
714  # case 2: running on new jet collection whose daughters are PFCandidates (e.g., cluster jets in RECO/AOD)
715  puppi_value_map = "puppi"
716  vertex_associator = "primaryVertexAssociation:original"
717  else:
718  raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
719  addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
720  btag.pfParticleNetAK4TagInfos.clone(
721  jets = jetSource,
722  vertices = pvSource,
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,
729  ),
730  process, task)
731 
732  acceptedTagInfos.append(btagInfo)
733  elif hasattr(toptag, btagInfo) :
734  acceptedTagInfos.append(btagInfo)
735  else:
736  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
737  ## setup all required btagDiscriminators
738  acceptedBtagDiscriminators = list()
739  for discriminator_name in btagDiscriminators :
740  btagDiscr = discriminator_name.split(':')[0] #split input tag to get the producer label
741  #print discriminator_name, '-->', btagDiscr
742  if hasattr(btag,btagDiscr):
743  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
744  if hasattr(process, newDiscr):
745  pass
746  elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
748  newDiscr,
749  getattr(btag, btagDiscr).clone(
750  tagInfos = cms.VInputTag(
751  *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
752  for x in supportedBtagDiscr[discriminator_name][0] ]
753  )
754  ),
755  process,
756  task
757  )
758  elif hasattr(getattr(btag, btagDiscr), 'src'):
760  newDiscr,
761  getattr(btag, btagDiscr).clone(
762  src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
763  ),
764  process,
765  task
766  )
767  else:
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)
770  else:
771  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
772  #update meta-taggers, if any
773  for meta_tagger in present_meta:
774  btagDiscr = meta_tagger.split(':')[0] #split input tag to get the producer label
775  #print discriminator_name, '-->', btagDiscr
776  if hasattr(btag,btagDiscr):
777  newDiscr = btagPrefix+btagDiscr+labelName+postfix #new discriminator name
778  if hasattr(process, newDiscr):
779  pass
780  else:
782  newDiscr,
783  getattr(btag, btagDiscr).clone(),
784  process,
785  task
786  )
787  for dependency in supportedMetaDiscr[meta_tagger]:
788  if ':' in dependency:
789  new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
790  else:
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)
795  else:
796  print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
797 
798  ## replace corresponding tags for pat jet production
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
805  ])
806  if len(acceptedBtagDiscriminators) > 0 :
807  patJets.addBTagInfo = True
808  ## if re-running IVF
809  if runIVF:
810  if not tightBTagNTkHits:
811  if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices': ## MiniAOD case
812  if not runIVFforCTagOnly: rerunningIVFMiniAOD()
813  else:
814  rerunningIVF()
815  from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
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())
820  if tightBTagNTkHits:
821  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
822  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
823  _temp.minHits = cms.uint32(8)
824  ## MiniAOD case
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() ):
835  addToProcessAndTask(svSource.getModuleLabel(),
836  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
837  process, task)
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())
841  if tightBTagNTkHits:
842  if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
843  _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
844  _temp.minHits = cms.uint32(8)
845  ## MiniAOD case
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() ):
856  addToProcessAndTask(svSourceCvsL.getModuleLabel(),
857  getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
858  process, task)
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)
884 
886  """
887  Tool to add a new jet collection to your PAT Tuple or to modify an existing one.
888  """
889  _label='addJetCollection'
890  _defaultParameters=dicttypes.SortedKeysDict()
891 
892  def __init__(self):
893  """
894  Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.
895  """
896  ## initialization of the base class
897  ConfigToolBase.__init__(self)
898  ## add all parameters that should be known to the class
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.")
942  ## set defaults
943  self._parameters=copy.deepcopy(self._defaultParameters)
944  ## add comments
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."
948 
950  """
951  Return default parameters of the class
952  """
953  return self._defaultParameters
954 
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):
956  """
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.
959  """
960  if labelName is None:
961  labelName=self._defaultParameters['labelName'].value
962  self.setParameter('labelName', labelName)
963  if postfix is None:
964  postfix=self._defaultParameters['postfix'].value
965  self.setParameter('postfix', postfix)
966  if btagPrefix is None:
967  btagPrefix=self._defaultParameters['btagPrefix'].value
968  self.setParameter('btagPrefix', btagPrefix)
969  if jetSource is None:
970  jetSource=self._defaultParameters['jetSource'].value
971  self.setParameter('jetSource', jetSource)
972  if pfCandidates is None:
973  pfCandidates=self._defaultParameters['pfCandidates'].value
974  self.setParameter('pfCandidates', pfCandidates)
975  if explicitJTA is None:
976  explicitJTA=self._defaultParameters['explicitJTA'].value
977  self.setParameter('explicitJTA', explicitJTA)
978  if pvSource is None:
979  pvSource=self._defaultParameters['pvSource'].value
980  self.setParameter('pvSource', pvSource)
981  if svSource is None:
982  svSource=self._defaultParameters['svSource'].value
983  self.setParameter('svSource', svSource)
984  if elSource is None:
985  elSource=self._defaultParameters['elSource'].value
986  self.setParameter('elSource', elSource)
987  if muSource is None:
988  muSource=self._defaultParameters['muSource'].value
989  self.setParameter('muSource', muSource)
990  if runIVF is None:
991  runIVF=self._defaultParameters['runIVF'].value
992  self.setParameter('runIVF', runIVF)
993  if tightBTagNTkHits is None:
994  tightBTagNTkHits=self._defaultParameters['tightBTagNTkHits'].value
995  self.setParameter('tightBTagNTkHits', tightBTagNTkHits)
996  if loadStdRecoBTag is None:
997  loadStdRecoBTag=self._defaultParameters['loadStdRecoBTag'].value
998  self.setParameter('loadStdRecoBTag', loadStdRecoBTag)
999  if svClustering is None:
1000  svClustering=self._defaultParameters['svClustering'].value
1001  self.setParameter('svClustering', svClustering)
1002  if fatJets is None:
1003  fatJets=self._defaultParameters['fatJets'].value
1004  self.setParameter('fatJets', fatJets)
1005  if groomedFatJets is None:
1006  groomedFatJets=self._defaultParameters['groomedFatJets'].value
1007  self.setParameter('groomedFatJets', groomedFatJets)
1008  if algo is None:
1009  algo=self._defaultParameters['algo'].value
1010  self.setParameter('algo', algo)
1011  if rParam is None:
1012  rParam=self._defaultParameters['rParam'].value
1013  self.setParameter('rParam', rParam)
1014  if getJetMCFlavour is None:
1015  getJetMCFlavour=self._defaultParameters['getJetMCFlavour'].value
1016  self.setParameter('getJetMCFlavour', getJetMCFlavour)
1017  if genJetCollection is None:
1018  genJetCollection=self._defaultParameters['genJetCollection'].value
1019  self.setParameter('genJetCollection', genJetCollection)
1020  if genParticles is None:
1021  genParticles=self._defaultParameters['genParticles'].value
1022  self.setParameter('genParticles', genParticles)
1023  if jetCorrections is None:
1024  jetCorrections=self._defaultParameters['jetCorrections'].value
1025  self.setParameter('jetCorrections', jetCorrections)
1026  if btagDiscriminators is None:
1027  btagDiscriminators=self._defaultParameters['btagDiscriminators'].value
1028  self.setParameter('btagDiscriminators', btagDiscriminators)
1029  if btagInfos is None:
1030  btagInfos=self._defaultParameters['btagInfos'].value
1031  self.setParameter('btagInfos', btagInfos)
1032  if jetTrackAssociation is None:
1033  jetTrackAssociation=self._defaultParameters['jetTrackAssociation'].value
1034  self.setParameter('jetTrackAssociation', jetTrackAssociation)
1035  if outputModules is None:
1036  outputModules=self._defaultParameters['outputModules'].value
1037  self.setParameter('outputModules', outputModules)
1038  self.apply(process)
1039 
1040  def toolCode(self, process):
1041  """
1042  Tool code implementation
1043  """
1044  task = getPatAlgosToolsTask(process)
1045 
1046  ## initialize parameters
1047  labelName=self._parameters['labelName'].value
1048  postfix=self._parameters['postfix'].value
1049  btagPrefix=self._parameters['btagPrefix'].value
1050  jetSource=self._parameters['jetSource'].value
1051  pfCandidates=self._parameters['pfCandidates'].value
1052  explicitJTA=self._parameters['explicitJTA'].value
1053  pvSource=self._parameters['pvSource'].value
1054  svSource=self._parameters['svSource'].value
1055  elSource=self._parameters['elSource'].value
1056  muSource=self._parameters['muSource'].value
1057  runIVF=self._parameters['runIVF'].value
1058  tightBTagNTkHits=self._parameters['tightBTagNTkHits'].value
1059  loadStdRecoBTag=self._parameters['loadStdRecoBTag'].value
1060  svClustering=self._parameters['svClustering'].value
1061  fatJets=self._parameters['fatJets'].value
1062  groomedFatJets=self._parameters['groomedFatJets'].value
1063  algo=self._parameters['algo'].value
1064  rParam=self._parameters['rParam'].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
1069  btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
1070  btagInfos=list(self._parameters['btagInfos'].value)
1071  jetTrackAssociation=self._parameters['jetTrackAssociation'].value
1072  outputModules=list(self._parameters['outputModules'].value)
1073 
1074  ## added jets must have a defined 'labelName'
1075  if labelName=='UNDEFINED':
1076  undefinedLabelName(self)
1077 
1078  ## a list of all producer modules, which are already known to process
1079  knownModules = process.producerNames().split()
1080  ## determine whether btagging information is required or not
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)
1086  ## check if any legacy btag discriminators are being used
1087  infos = 0
1088  for info in btagInfos:
1089  if info.startswith('pf'): infos = infos + 1
1090  if 'softpf' in info.lower(): infos = infos + 1
1091  tags = 0
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)
1096  ## construct postfix label for auxiliary modules; this postfix
1097  ## label will start with a capitalized first letter following
1098  ## the CMS naming conventions and for improved readablility
1099  _labelName=labelName[:1].upper()+labelName[1:]
1100 
1101  ## supported algo types are ak, ca, and kt
1102  _algo=''
1103  for x in ["ak", "ca", "kt"]:
1104  if x in algo.lower():
1105  _algo=supportedJetAlgos[x]
1106  break
1107  if _algo=='':
1109  ## add new patJets to process (keep instance for later further modifications)
1110  from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJets
1111  if 'patJets'+_labelName+postfix in knownModules :
1112  _newPatJets=getattr(process, 'patJets'+_labelName+postfix)
1113  _newPatJets.jetSource=jetSource
1114  else :
1115  addToProcessAndTask('patJets'+_labelName+postfix, patJets.clone(jetSource=jetSource), process, task)
1116  _newPatJets=getattr(process, 'patJets'+_labelName+postfix)
1117  knownModules.append('patJets'+_labelName+postfix)
1118  ## add new selectedPatJets to process
1119  from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
1120  if 'selectedPatJets'+_labelName+postfix in knownModules :
1121  _newSelectedPatJets=getattr(process, 'selectedPatJets'+_labelName+postfix)
1122  _newSelectedPatJets.src='patJets'+_labelName+postfix
1123  else :
1124  addToProcessAndTask('selectedPatJets'+_labelName+postfix,
1125  selectedPatJets.clone(src='patJets'+_labelName+postfix),
1126  process, task)
1127  knownModules.append('selectedPatJets'+_labelName+postfix)
1128 
1129  ## add new patJetPartonMatch to process
1130  from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch
1131  if 'patJetPartonMatch'+_labelName+postfix in knownModules :
1132  _newPatJetPartonMatch=getattr(process, 'patJetPartonMatch'+_labelName+postfix)
1133  _newPatJetPartonMatch.src=jetSource
1134  _newPatJetPartonMatch.matched=genParticles
1135  else :
1136  addToProcessAndTask('patJetPartonMatch'+_labelName+postfix,
1137  patJetPartonMatch.clone(src=jetSource, matched=genParticles),
1138  process, task)
1139  knownModules.append('patJetPartonMatch'+_labelName+postfix)
1140  ## add new patJetGenJetMatch to process
1141  from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
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
1147  else :
1148  addToProcessAndTask('patJetGenJetMatch'+_labelName+postfix,
1149  patJetGenJetMatch.clone(src=jetSource, maxDeltaR=rParam, matched=genJetCollection),
1150  process, task)
1151  knownModules.append('patJetGenJetMatch'+_labelName+postfix)
1152  ## modify new patJets collection accordingly
1153  _newPatJets.genJetMatch.setModuleLabel('patJetGenJetMatch'+_labelName+postfix)
1154  _newPatJets.genPartonMatch.setModuleLabel('patJetPartonMatch'+_labelName+postfix)
1155  ## get jet MC truth flavour if required by user
1156  if (getJetMCFlavour):
1157  ## legacy jet flavour (see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideBTagMCTools)
1158  ## add new patJetPartonsLegacy to process
1159  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonsLegacy
1160  if 'patJetPartonsLegacy'+postfix not in knownModules :
1161  addToProcessAndTask('patJetPartonsLegacy'+postfix, patJetPartonsLegacy.clone(src=genParticles),
1162  process, task)
1163  knownModules.append('patJetPartonsLegacy'+postfix)
1164  else:
1165  getattr(process, 'patJetPartonsLegacy'+postfix).src=genParticles
1166  ## add new patJetPartonAssociationLegacy to process
1167  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonAssociationLegacy
1168  if 'patJetPartonAssociationLegacy'+_labelName+postfix in knownModules :
1169  _newPatJetPartonAssociation=getattr(process, 'patJetPartonAssociationLegacy'+_labelName+postfix)
1170  _newPatJetPartonAssociation.jets=jetSource
1171  else :
1172  addToProcessAndTask('patJetPartonAssociationLegacy'+_labelName+postfix,
1173  patJetPartonAssociationLegacy.clone(jets=jetSource), process, task)
1174  knownModules.append('patJetPartonAssociationLegacy'+_labelName+postfix)
1175  ## add new patJetPartonAssociationLegacy to process
1176  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociationLegacy
1177  if 'patJetFlavourAssociationLegacy'+_labelName+postfix in knownModules :
1178  _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociationLegacy'+_labelName+postfix)
1179  _newPatJetFlavourAssociation.srcByReference='patJetPartonAssociationLegacy'+_labelName+postfix
1180  else:
1181  addToProcessAndTask('patJetFlavourAssociationLegacy'+_labelName+postfix,
1182  patJetFlavourAssociationLegacy.clone(
1183  srcByReference='patJetPartonAssociationLegacy'+_labelName+postfix),
1184  process, task)
1185  knownModules.append('patJetFlavourAssociationLegacy'+_labelName+postfix)
1186  ## modify new patJets collection accordingly
1187  _newPatJets.JetPartonMapSource.setModuleLabel('patJetFlavourAssociationLegacy'+_labelName+postfix)
1188  ## new jet flavour (see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideBTagMCTools)
1189  ## add new patJetPartons to process
1191  if 'patJetPartons'+postfix not in knownModules :
1192  addToProcessAndTask('patJetPartons'+postfix, patJetPartons.clone(particles=genParticles), process, task)
1193  knownModules.append('patJetPartons'+postfix)
1194  else:
1195  getattr(process, 'patJetPartons'+postfix).particles=genParticles
1196  ## add new patJetFlavourAssociation to process
1197  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation
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")
1207  else :
1208  addToProcessAndTask('patJetFlavourAssociation'+_labelName+postfix,
1209  patJetFlavourAssociation.clone(
1210  jets=jetSource,
1211  jetAlgorithm=_algo,
1212  rParam=rParam,
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")),
1217  process, task)
1218 
1219  knownModules.append('patJetFlavourAssociation'+_labelName+postfix)
1220  ## modify new patJets collection accordingly
1221  _newPatJets.JetFlavourInfoSource.setModuleLabel('patJetFlavourAssociation'+_labelName+postfix)
1222  ## if the jets is actually a subjet
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')
1229  else:
1230  _newPatJets.getJetMCFlavour = False
1231 
1232  ## add jetTrackAssociation for legacy btagging (or jetTracksAssociation only) if required by user
1233  if (jetTrackAssociation or bTaggingLegacy):
1234  ## add new jetTracksAssociationAtVertex to process
1235  from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertex, ak4JetTracksAssociatorExplicit
1236  if 'jetTracksAssociationAtVertex'+_labelName+postfix in knownModules :
1237  _newJetTracksAssociationAtVertex=getattr(process, 'jetTracksAssociatorAtVertex'+_labelName+postfix)
1238  _newJetTracksAssociationAtVertex.jets=jetSource
1239  _newJetTracksAssociationAtVertex.pvSrc=pvSource
1240  else:
1241  jetTracksAssociator=ak4JetTracksAssociatorAtVertex
1242  if explicitJTA:
1243  jetTracksAssociator=ak4JetTracksAssociatorExplicit
1244  addToProcessAndTask('jetTracksAssociatorAtVertex'+_labelName+postfix,
1245  jetTracksAssociator.clone(jets=jetSource,pvSrc=pvSource),
1246  process, task)
1247  knownModules.append('jetTracksAssociationAtVertex'+_labelName+postfix)
1248  ## add new patJetCharge to process
1250  if 'patJetCharge'+_labelName+postfix in knownModules :
1251  _newPatJetCharge=getattr(process, 'patJetCharge'+_labelName+postfix)
1252  _newPatJetCharge.src='jetTracksAssociatorAtVertex'+_labelName+postfix
1253  else:
1254  addToProcessAndTask('patJetCharge'+_labelName+postfix,
1255  patJetCharge.clone(src = 'jetTracksAssociatorAtVertex'+_labelName+postfix),
1256  process, task)
1257  knownModules.append('patJetCharge'+_labelName+postfix)
1258  ## modify new patJets collection accordingly
1259  _newPatJets.addAssociatedTracks=True
1260  _newPatJets.trackAssociationSource=cms.InputTag('jetTracksAssociatorAtVertex'+_labelName+postfix)
1261  _newPatJets.addJetCharge=True
1262  _newPatJets.jetChargeSource=cms.InputTag('patJetCharge'+_labelName+postfix)
1263  else:
1264  ## modify new patJets collection accordingly
1265  _newPatJets.addAssociatedTracks=False
1266  _newPatJets.trackAssociationSource=''
1267  _newPatJets.addJetCharge=False
1268  _newPatJets.jetChargeSource=''
1269  ## run btagging if required by user
1270  if (bTagging):
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)
1273  else:
1274  _newPatJets.addBTagInfo = False
1275  _newPatJets.addTagInfos = False
1276  ## adjust output module; these collections will be empty anyhow, but we do it to stay clean
1277  for outputModule in outputModules:
1278  if hasattr(process,outputModule):
1279  getattr(process,outputModule).outputCommands.append("drop *_"+'selected'+_labelName+postfix+"_tagInfos_*")
1280 
1281  ## add jet correction factors if required by user
1282  if (jetCorrections != None):
1283  ## check the jet corrections format
1284  checkJetCorrectionsFormat(jetCorrections)
1285  ## setup jet energy corrections and MET corrections
1286  setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, _newPatJets, _labelName, postfix)
1287  else:
1288  ## switch jetCorrFactors off
1289  _newPatJets.addJetCorrFactors=False
1290 
1291 addJetCollection=AddJetCollection()
1292 
1294  """
1295  Tool to switch parameters of the PAT jet collection to your PAT Tuple.
1296  """
1297  _label='switchJetCollection'
1298  _defaultParameters=dicttypes.SortedKeysDict()
1299 
1300  def __init__(self):
1301  """
1302  Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.
1303  """
1304  ## initialization of the base class
1305  ConfigToolBase.__init__(self)
1306  ## add all parameters that should be known to the class
1307  self.addParameter(self._defaultParameters,'postfix','', "postfix from usePF2PAT")
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.")
1346  ## set defaults
1347  self._parameters=copy.deepcopy(self._defaultParameters)
1348  ## add comments
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."
1352 
1354  """
1355  Return default parameters of the class
1356  """
1357  return self._defaultParameters
1358 
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):
1360  """
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.
1363  """
1364  if postfix is None:
1365  postfix=self._defaultParameters['postfix'].value
1366  self.setParameter('postfix', postfix)
1367  if btagPrefix is None:
1368  btagPrefix=self._defaultParameters['btagPrefix'].value
1369  self.setParameter('btagPrefix', btagPrefix)
1370  if jetSource is None:
1371  jetSource=self._defaultParameters['jetSource'].value
1372  self.setParameter('jetSource', jetSource)
1373  if pfCandidates is None:
1374  pfCandidates=self._defaultParameters['pfCandidates'].value
1375  self.setParameter('pfCandidates', pfCandidates)
1376  if explicitJTA is None:
1377  explicitJTA=self._defaultParameters['explicitJTA'].value
1378  self.setParameter('explicitJTA', explicitJTA)
1379  if pvSource is None:
1380  pvSource=self._defaultParameters['pvSource'].value
1381  self.setParameter('pvSource', pvSource)
1382  if svSource is None:
1383  svSource=self._defaultParameters['svSource'].value
1384  self.setParameter('svSource', svSource)
1385  if elSource is None:
1386  elSource=self._defaultParameters['elSource'].value
1387  self.setParameter('elSource', elSource)
1388  if muSource is None:
1389  muSource=self._defaultParameters['muSource'].value
1390  self.setParameter('muSource', muSource)
1391  if runIVF is None:
1392  runIVF=self._defaultParameters['runIVF'].value
1393  self.setParameter('runIVF', runIVF)
1394  if tightBTagNTkHits is None:
1395  tightBTagNTkHits=self._defaultParameters['tightBTagNTkHits'].value
1396  self.setParameter('tightBTagNTkHits', tightBTagNTkHits)
1397  if loadStdRecoBTag is None:
1398  loadStdRecoBTag=self._defaultParameters['loadStdRecoBTag'].value
1399  self.setParameter('loadStdRecoBTag', loadStdRecoBTag)
1400  if svClustering is None:
1401  svClustering=self._defaultParameters['svClustering'].value
1402  self.setParameter('svClustering', svClustering)
1403  if fatJets is None:
1404  fatJets=self._defaultParameters['fatJets'].value
1405  self.setParameter('fatJets', fatJets)
1406  if groomedFatJets is None:
1407  groomedFatJets=self._defaultParameters['groomedFatJets'].value
1408  self.setParameter('groomedFatJets', groomedFatJets)
1409  if algo is None:
1410  algo=self._defaultParameters['algo'].value
1411  self.setParameter('algo', algo)
1412  if rParam is None:
1413  rParam=self._defaultParameters['rParam'].value
1414  self.setParameter('rParam', rParam)
1415  if getJetMCFlavour is None:
1416  getJetMCFlavour=self._defaultParameters['getJetMCFlavour'].value
1417  self.setParameter('getJetMCFlavour', getJetMCFlavour)
1418  if genJetCollection is None:
1419  genJetCollection=self._defaultParameters['genJetCollection'].value
1420  self.setParameter('genJetCollection', genJetCollection)
1421  if genParticles is None:
1422  genParticles=self._defaultParameters['genParticles'].value
1423  self.setParameter('genParticles', genParticles)
1424  if jetCorrections is None:
1425  jetCorrections=self._defaultParameters['jetCorrections'].value
1426  self.setParameter('jetCorrections', jetCorrections)
1427  if btagDiscriminators is None:
1428  btagDiscriminators=self._defaultParameters['btagDiscriminators'].value
1429  self.setParameter('btagDiscriminators', btagDiscriminators)
1430  if btagInfos is None:
1431  btagInfos=self._defaultParameters['btagInfos'].value
1432  self.setParameter('btagInfos', btagInfos)
1433  if jetTrackAssociation is None:
1434  jetTrackAssociation=self._defaultParameters['jetTrackAssociation'].value
1435  self.setParameter('jetTrackAssociation', jetTrackAssociation)
1436  if outputModules is None:
1437  outputModules=self._defaultParameters['outputModules'].value
1438  self.setParameter('outputModules', outputModules)
1439  self.apply(process)
1440 
1441  def toolCode(self, process):
1442  """
1443  Tool code implementation
1444  """
1445  ## initialize parameters
1446  postfix=self._parameters['postfix'].value
1447  btagPrefix=self._parameters['btagPrefix'].value
1448  jetSource=self._parameters['jetSource'].value
1449  pfCandidates=self._parameters['pfCandidates'].value
1450  explicitJTA=self._parameters['explicitJTA'].value
1451  pvSource=self._parameters['pvSource'].value
1452  svSource=self._parameters['svSource'].value
1453  elSource=self._parameters['elSource'].value
1454  muSource=self._parameters['muSource'].value
1455  runIVF=self._parameters['runIVF'].value
1456  tightBTagNTkHits=self._parameters['tightBTagNTkHits'].value
1457  loadStdRecoBTag=self._parameters['loadStdRecoBTag'].value
1458  svClustering=self._parameters['svClustering'].value
1459  fatJets=self._parameters['fatJets'].value
1460  groomedFatJets=self._parameters['groomedFatJets'].value
1461  algo=self._parameters['algo'].value
1462  rParam=self._parameters['rParam'].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
1468  btagInfos=self._parameters['btagInfos'].value
1469  jetTrackAssociation=self._parameters['jetTrackAssociation'].value
1470  outputModules=self._parameters['outputModules'].value
1471 
1472  ## call addJetCollections w/o labelName; this will act on the default patJets collection
1473  addJetCollection(
1474  process,
1475  labelName='',
1476  postfix=postfix,
1477  btagPrefix=btagPrefix,
1478  jetSource=jetSource,
1479  pfCandidates=pfCandidates,
1480  explicitJTA=explicitJTA,
1481  pvSource=pvSource,
1482  svSource=svSource,
1483  elSource=elSource,
1484  muSource=muSource,
1485  runIVF=runIVF,
1486  tightBTagNTkHits=tightBTagNTkHits,
1487  loadStdRecoBTag=loadStdRecoBTag,
1488  svClustering=svClustering,
1489  fatJets=fatJets,
1490  groomedFatJets=groomedFatJets,
1491  algo=algo,
1492  rParam=rParam,
1493  getJetMCFlavour=getJetMCFlavour,
1494  genJetCollection=genJetCollection,
1495  genParticles=genParticles,
1496  jetCorrections=jetCorrections,
1497  btagDiscriminators=btagDiscriminators,
1498  btagInfos=btagInfos,
1499  jetTrackAssociation=jetTrackAssociation,
1500  outputModules=outputModules,
1501  )
1502 
1503 switchJetCollection=SwitchJetCollection()
1504 
1505 
1507  """
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).
1509  """
1510  _label='updateJetCollection'
1511  _defaultParameters=dicttypes.SortedKeysDict()
1512 
1513  def __init__(self):
1514  """
1515  Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.
1516  """
1517  ## initialization of the base class
1518  ConfigToolBase.__init__(self)
1519  ## add all parameters that should be known to the class
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.")
1559  ## set defaults
1560  self._parameters=copy.deepcopy(self._defaultParameters)
1561  ## add comments
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."
1565 
1567  """
1568  Return default parameters of the class
1569  """
1570  return self._defaultParameters
1571 
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):
1573  """
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.
1576  """
1577  if labelName is None:
1578  labelName=self._defaultParameters['labelName'].value
1579  self.setParameter('labelName', labelName)
1580  if postfix is None:
1581  postfix=self._defaultParameters['postfix'].value
1582  self.setParameter('postfix', postfix)
1583  if btagPrefix is None:
1584  btagPrefix=self._defaultParameters['btagPrefix'].value
1585  self.setParameter('btagPrefix', btagPrefix)
1586  if jetSource is None:
1587  jetSource=self._defaultParameters['jetSource'].value
1588  self.setParameter('jetSource', jetSource)
1589  if pfCandidates is None:
1590  pfCandidates=self._defaultParameters['pfCandidates'].value
1591  self.setParameter('pfCandidates', pfCandidates)
1592  if explicitJTA is None:
1593  explicitJTA=self._defaultParameters['explicitJTA'].value
1594  self.setParameter('explicitJTA', explicitJTA)
1595  if pvSource is None:
1596  pvSource=self._defaultParameters['pvSource'].value
1597  self.setParameter('pvSource', pvSource)
1598  if svSource is None:
1599  svSource=self._defaultParameters['svSource'].value
1600  self.setParameter('svSource', svSource)
1601  if elSource is None:
1602  elSource=self._defaultParameters['elSource'].value
1603  self.setParameter('elSource', elSource)
1604  if muSource is None:
1605  muSource=self._defaultParameters['muSource'].value
1606  self.setParameter('muSource', muSource)
1607  if runIVF is None:
1608  runIVF=self._defaultParameters['runIVF'].value
1609  self.setParameter('runIVF', runIVF)
1610  if tightBTagNTkHits is None:
1611  tightBTagNTkHits=self._defaultParameters['tightBTagNTkHits'].value
1612  self.setParameter('tightBTagNTkHits', tightBTagNTkHits)
1613  if loadStdRecoBTag is None:
1614  loadStdRecoBTag=self._defaultParameters['loadStdRecoBTag'].value
1615  self.setParameter('loadStdRecoBTag', loadStdRecoBTag)
1616  if svClustering is None:
1617  svClustering=self._defaultParameters['svClustering'].value
1618  self.setParameter('svClustering', svClustering)
1619  if fatJets is None:
1620  fatJets=self._defaultParameters['fatJets'].value
1621  self.setParameter('fatJets', fatJets)
1622  if groomedFatJets is None:
1623  groomedFatJets=self._defaultParameters['groomedFatJets'].value
1624  self.setParameter('groomedFatJets', groomedFatJets)
1625  if algo is None:
1626  algo=self._defaultParameters['algo'].value
1627  self.setParameter('algo', algo)
1628  if rParam is None:
1629  rParam=self._defaultParameters['rParam'].value
1630  self.setParameter('rParam', rParam)
1631  if sortByPt is None:
1632  sortByPt=self._defaultParameters['sortByPt'].value
1633  self.setParameter('sortByPt', sortByPt)
1634  if printWarning is None:
1635  printWarning=self._defaultParameters['printWarning'].value
1636  self.setParameter('printWarning', printWarning)
1637  if jetCorrections is None:
1638  jetCorrections=self._defaultParameters['jetCorrections'].value
1639  self.setParameter('jetCorrections', jetCorrections)
1640  if btagDiscriminators is None:
1641  btagDiscriminators=self._defaultParameters['btagDiscriminators'].value
1642  self.setParameter('btagDiscriminators', btagDiscriminators)
1643  if btagInfos is None:
1644  btagInfos=self._defaultParameters['btagInfos'].value
1645  self.setParameter('btagInfos', btagInfos)
1646  self.apply(process)
1647 
1648  def toolCode(self, process):
1649  """
1650  Tool code implementation
1651  """
1652  ## initialize parameters
1653  labelName=self._parameters['labelName'].value
1654  postfix=self._parameters['postfix'].value
1655  btagPrefix=self._parameters['btagPrefix'].value
1656  jetSource=self._parameters['jetSource'].value
1657  pfCandidates=self._parameters['pfCandidates'].value
1658  explicitJTA=self._parameters['explicitJTA'].value
1659  pvSource=self._parameters['pvSource'].value
1660  svSource=self._parameters['svSource'].value
1661  elSource=self._parameters['elSource'].value
1662  muSource=self._parameters['muSource'].value
1663  runIVF=self._parameters['runIVF'].value
1664  tightBTagNTkHits=self._parameters['tightBTagNTkHits'].value
1665  loadStdRecoBTag=self._parameters['loadStdRecoBTag'].value
1666  svClustering=self._parameters['svClustering'].value
1667  fatJets=self._parameters['fatJets'].value
1668  groomedFatJets=self._parameters['groomedFatJets'].value
1669  algo=self._parameters['algo'].value
1670  rParam=self._parameters['rParam'].value
1671  sortByPt=self._parameters['sortByPt'].value
1672  printWarning=self._parameters['printWarning'].value
1673  jetCorrections=self._parameters['jetCorrections'].value
1674  btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
1675  btagInfos=list(self._parameters['btagInfos'].value)
1676 
1677  ## a list of all producer modules, which are already known to process
1678  knownModules = process.producerNames().split()
1679  ## determine whether btagging information is required or not
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)
1685 
1686  ## construct postfix label for auxiliary modules; this postfix
1687  ## label will start with a capitalized first letter following
1688  ## the CMS naming conventions and for improved readablility
1689  _labelName=labelName[:1].upper()+labelName[1:]
1690 
1691  ## supported algo types are ak, ca, and kt
1692  _algo=''
1693  for x in ["ak", "ca", "kt"]:
1694  if x in algo.lower():
1695  _algo=supportedJetAlgos[x]
1696  break
1697  if _algo=='':
1699 
1700  task = getPatAlgosToolsTask(process)
1701 
1702  ## add new updatedPatJets to process (keep instance for later further modifications)
1703  from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cfi import updatedPatJets
1704  if not sortByPt: # default is True
1705  updatedPatJets.sort = cms.bool(False)
1706  if 'updatedPatJets'+_labelName+postfix in knownModules :
1707  _newPatJets=getattr(process, 'updatedPatJets'+_labelName+postfix)
1708  _newPatJets.jetSource=jetSource
1709  else :
1710  addToProcessAndTask('updatedPatJets'+_labelName+postfix,
1711  updatedPatJets.clone(jetSource=jetSource,
1712  printWarning=printWarning), process, task)
1713  _newPatJets=getattr(process, 'updatedPatJets'+_labelName+postfix)
1714  knownModules.append('updatedPatJets'+_labelName+postfix)
1715  ## add new selectedUpdatedPatJets to process
1716  from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
1717  if 'selectedUpdatedPatJets'+_labelName+postfix in knownModules :
1718  _newSelectedPatJets=getattr(process, 'selectedUpdatedPatJets'+_labelName+postfix)
1719  _newSelectedPatJets.src='updatedPatJets'+_labelName+postfix
1720  else :
1721  addToProcessAndTask('selectedUpdatedPatJets'+_labelName+postfix,
1722  selectedPatJets.clone(src='updatedPatJets'+_labelName+postfix),
1723  process, task)
1724  knownModules.append('selectedUpdatedPatJets'+_labelName+postfix)
1725 
1726  ## run btagging if required by user
1727  if (bTagging):
1728  if printWarning:
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)
1735  ## insert new jet collection with jet corrections applied and btag info added
1736  self(
1737  process,
1738  labelName = ('TransientCorrected'+_labelName),
1739  jetSource = _jetSource,
1740  pfCandidates=pfCandidates,
1741  explicitJTA=explicitJTA,
1742  pvSource=pvSource,
1743  svSource=svSource,
1744  elSource=elSource,
1745  muSource=muSource,
1746  runIVF=runIVF,
1747  tightBTagNTkHits=tightBTagNTkHits,
1748  loadStdRecoBTag=loadStdRecoBTag,
1749  svClustering=svClustering,
1750  fatJets=fatJets,
1751  groomedFatJets=groomedFatJets,
1752  algo=algo,
1753  rParam=rParam,
1754  jetCorrections = jetCorrections,
1755  btagPrefix = btagPrefix,
1756  postfix = postfix
1757  )
1758  ## setup btagging
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)
1762  ## update final selected jets
1763  _newSelectedPatJets=getattr(process, 'selectedUpdatedPatJets'+_labelName+postfix)
1764  _newSelectedPatJets.src='updatedPatJetsTransientCorrected'+_labelName+postfix
1765  ## remove automatically added but redundant 'TransientCorrected' selected jets
1766  delattr(process, 'selectedUpdatedPatJetsTransientCorrected'+_labelName+postfix)
1767  else:
1768  _newPatJets.addBTagInfo = False
1769  _newPatJets.addTagInfos = False
1770 
1771  ## add jet correction factors if required by user
1772  if (jetCorrections is not None or bTagging):
1773  ## check the jet corrections format
1774  if jetCorrections is None and bTagging:
1775  raise ValueError("Passing jetCorrections = None while running bTagging is likely not intended.")
1776  else:
1777  checkJetCorrectionsFormat(jetCorrections)
1778  ## reset MET corrrection
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)
1788  ## if running b tagging, need to use uncorrected jets
1789  if (bTagging):
1790  jetCorrections = ('AK4PFchs', cms.vstring([]), 'None')
1791  ## setup jet energy corrections
1792  setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, _newPatJets, _labelName, postfix)
1793  else:
1794  ## switch jetCorrFactors off
1795  _newPatJets.addJetCorrFactors=False
1796 
1797 updateJetCollection=UpdateJetCollection()
1798 
1799 
1801  """
1802  Compute jet id for process
1803  """
1804  _label='addJetID'
1805  _defaultParameters=dicttypes.SortedKeysDict()
1806  def __init__(self):
1807  ConfigToolBase.__init__(self)
1808  self.addParameter(self._defaultParameters,'jetSrc','', "", Type=cms.InputTag)
1809  self.addParameter(self._defaultParameters,'jetIdTag','', "Tag to append to jet id map", Type=str)
1810  self._parameters=copy.deepcopy(self._defaultParameters)
1811  self._comment = ""
1812 
1814  return self._defaultParameters
1815 
1816  def __call__(self,process,
1817  jetSrc = None,
1818  jetIdTag = None) :
1819  if jetSrc is None:
1820  jetSrc=self._defaultParameters['jetSrc'].value
1821  if jetIdTag is None:
1822  jetIdTag=self._defaultParameters['jetIdTag'].value
1823  self.setParameter('jetSrc',jetSrc)
1824  self.setParameter('jetIdTag',jetIdTag)
1825  self.apply(process)
1826 
1827  def toolCode(self, process):
1828  jetSrc=self._parameters['jetSrc'].value
1829  jetIdTag=self._parameters['jetIdTag'].value
1830 
1831  jetIdLabel = jetIdTag + 'JetID'
1832  sys.stderr.write("Making new jet ID label with label " + jetIdTag + "\n")
1833 
1834  ## replace jet id sequence
1835  task = getPatAlgosToolsTask(process)
1836  process.load("RecoJets.JetProducers.ak4JetID_cfi")
1837  task.add(process.ak4JetID)
1838  addToProcessAndTask(jetIdLabel, process.ak4JetID.clone(src = jetSrc),
1839  process, task)
1840 
1841 
1842 addJetID=AddJetID()
1843 
1844 
1846  """
1847  Replace tag infos for collection jetSrc
1848  """
1849  _label='setTagInfos'
1850  _defaultParameters=dicttypes.SortedKeysDict()
1851  def __init__(self):
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")
1855  self._parameters=copy.deepcopy(self._defaultParameters)
1856  self._comment = ""
1857 
1859  return self._defaultParameters
1860 
1861  def __call__(self,process,
1862  coll = None,
1863  tagInfos = None) :
1864  if coll is None:
1865  coll=self._defaultParameters['coll'].value
1866  if tagInfos is None:
1867  tagInfos=self._defaultParameters['tagInfos'].value
1868  self.setParameter('coll',coll)
1869  self.setParameter('tagInfos',tagInfos)
1870  self.apply(process)
1871 
1872  def toolCode(self, process):
1873  coll=self._parameters['coll'].value
1874  tagInfos=self._parameters['tagInfos'].value
1875 
1876  found = False
1877  newTags = cms.VInputTag()
1878  iNewTags = 0
1879  for k in tagInfos :
1880  for j in getattr( process, coll ).tagInfoSources :
1881  vv = j.value();
1882  if ( vv.find(k) != -1 ):
1883  found = True
1884  newTags.append( j )
1885 
1886  if not found:
1887  raise RuntimeError("""
1888  Cannot replace tag infos in jet collection""" % (coll))
1889  else :
1890  getattr(process,coll).tagInfoSources = newTags
1891 
1892 setTagInfos=SetTagInfos()
1893 
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+"'")
1904 
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+"'")
1911 
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+"'")
1920 
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")
1928 
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")
def getDefaultParameters(self)
Definition: jetTools.py:1858
def undefinedLabelName(obj)
Definition: jetTools.py:1905
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def toolCode(self, process)
Definition: jetTools.py:1040
def toolCode(self, process)
Definition: jetTools.py:1827
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:29
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)
Definition: jetTools.py:1572
def deprecatedOptionOutputModule(obj)
Definition: jetTools.py:1894
def setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix)
Definition: jetTools.py:26
def __init__(self)
Definition: jetTools.py:1806
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def __init__(self)
Definition: jetTools.py:1851
def __call__(self, process, coll=None, tagInfos=None)
Definition: jetTools.py:1863
def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag(''))
Definition: jetTools.py:225
_parameters
initialization of the base class
Definition: jetTools.py:943
_parameters
initialization of the base class
Definition: jetTools.py:1560
def toolCode(self, process)
Definition: jetTools.py:1441
def getDefaultParameters(self)
Definition: jetTools.py:949
_comment
add comments
Definition: jetTools.py:945
def toolCode(self, process)
Definition: jetTools.py:1648
def loadWithPrefix(process, moduleName, prefix='', loadedProducersAndFilters=None)
Definition: helpers.py:44
def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets, algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix)
Definition: jetTools.py:237
def rerunningIVF()
Definition: jetTools.py:1921
def checkJetCorrectionsFormat(jetCorrections)
Definition: jetTools.py:18
_parameters
initialization of the base class
Definition: jetTools.py:1347
def __call__(self, process, jetSrc=None, jetIdTag=None)
Definition: jetTools.py:1818
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def rerunningIVFMiniAOD()
Definition: jetTools.py:1929
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)
Definition: jetTools.py:1359
def getPatAlgosToolsTask(process)
Definition: helpers.py:14
def getDefaultParameters(self)
Definition: jetTools.py:1813
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)
Definition: jetTools.py:955
double split
Definition: MVATrainer.cc:139
def toolCode(self, process)
Definition: jetTools.py:1872
def unsupportedJetAlgorithm(obj)
Definition: jetTools.py:1912
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