File indexing completed on 2021-07-09 23:01:36
0001 from __future__ import print_function
0002 from PhysicsTools.PatAlgos.tools.ConfigToolBase import *
0003 from FWCore.ParameterSet.Mixins import PrintOptions,_ParameterTypeBase,_SimpleParameterTypeBase, _Parameterizable, _ConfigureComponent, _TypedParameterizable, _Labelable, _Unlabelable, _ValidatingListBase
0004 from FWCore.ParameterSet.SequenceTypes import _ModuleSequenceType, _Sequenceable
0005 from FWCore.ParameterSet.SequenceTypes import *
0006 from PhysicsTools.PatAlgos.tools.helpers import *
0007 from PhysicsTools.PatAlgos.recoLayer0.bTagging_cff import *
0008 import sys
0009 from FWCore.ParameterSet.MassReplace import MassSearchReplaceAnyInputTagVisitor
0010
0011
0012 supportedJetAlgos = {
0013 'ak' : 'AntiKt'
0014 , 'ca' : 'CambridgeAachen'
0015 , 'kt' : 'Kt'
0016 }
0017
0018 def checkJetCorrectionsFormat(jetCorrections):
0019
0020 if not isinstance(jetCorrections, type(('PAYLOAD-LABEL',['CORRECTION-LEVEL-A','CORRECTION-LEVEL-B'], 'MET-LABEL'))):
0021 raise ValueError("In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
0022 '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) \
0023 corrections.")
0024
0025
0026 def setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, patJets, labelName, postfix):
0027
0028 task = getPatAlgosToolsTask(process)
0029
0030
0031
0032
0033
0034 _type="NONE"
0035 if jetCorrections[0].count('PF')>0:
0036 _type='PF'
0037 elif jetCorrections[0].count('Calo')>0:
0038 _type='Calo'
0039 elif jetCorrections[0].count('JPT')>0:
0040 _type='JPT'
0041 else:
0042 raise TypeError("In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets.")
0043 from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
0044 if 'patJetCorrFactors'+labelName+postfix in knownModules :
0045 _newPatJetCorrFactors=getattr(process, 'patJetCorrFactors'+labelName+postfix)
0046 _newPatJetCorrFactors.src=jetSource
0047 _newPatJetCorrFactors.primaryVertices=pvSource
0048 else:
0049 addToProcessAndTask('patJetCorrFactors'+labelName+postfix,
0050 patJetCorrFactors.clone(src=jetSource, primaryVertices=pvSource),
0051 process, task)
0052 _newPatJetCorrFactors=getattr(process, "patJetCorrFactors"+labelName+postfix)
0053 _newPatJetCorrFactors.payload=jetCorrections[0]
0054 _newPatJetCorrFactors.levels=jetCorrections[1]
0055
0056 error=False
0057 for x in jetCorrections[1]:
0058 if x == 'L1Offset' :
0059 if not error :
0060 _newPatJetCorrFactors.useNPV=True
0061 _newPatJetCorrFactors.primaryVertices='offlinePrimaryVertices'
0062 _newPatJetCorrFactors.useRho=False
0063
0064
0065 error=True
0066 else:
0067 raise ValueError("In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
0068 once. Check the list of correction levels you requested to be applied: "+ jetCorrections[1])
0069 if x == 'L1FastJet' :
0070 if not error :
0071 if _type == "JPT" :
0072 raise TypeError("In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets.")
0073
0074 _newPatJetCorrFactors.useRho=True
0075 if "PF" in _type :
0076 _newPatJetCorrFactors.rho=cms.InputTag('fixedGridRhoFastjetAll')
0077 else :
0078 _newPatJetCorrFactors.rho=cms.InputTag('fixedGridRhoFastjetAllCalo')
0079
0080
0081 error=True
0082 else:
0083 raise ValueError("In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
0084 once. Check the list of correction levels you requested to be applied: "+ jetCorrections[1])
0085 patJets.jetCorrFactorsSource=cms.VInputTag(cms.InputTag('patJetCorrFactors'+labelName+postfix))
0086
0087 if jetCorrections[2].lower() != 'none' and jetCorrections[2] != '':
0088 if not jetCorrections[2].lower() == 'type-1' and not jetCorrections[2].lower() == 'type-2':
0089 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.\
0090 Type-1 and Type-2 corrections applied). This choice is not case sensitive. Your choice was: "+ jetCorrections[2])
0091 if _type == "JPT":
0092 raise ValueError("In addJecCollection: MET(type1) corrections are not supported for JPTJets. Please set the MET-LABEL to \"None\" (as string in quatiation \
0093 marks) and use raw tcMET together with JPTJets.")
0094
0095 process.load( "JetMETCorrections.Configuration.JetCorrectorsAllAlgos_cff")
0096
0097
0098
0099 task.add(process.jetCorrectorsAllAlgosTask)
0100 _payloadType = jetCorrections[0].split(_type)[0].lower()+_type
0101 if "PF" in _type :
0102 addToProcessAndTask(jetCorrections[0]+'L1FastJet',
0103 getattr(process, _payloadType+'L1FastjetCorrector').clone(srcRho=cms.InputTag('fixedGridRhoFastjetAll')),
0104 process, task)
0105 else :
0106 addToProcessAndTask(jetCorrections[0]+'L1FastJet',
0107 getattr(process, _payloadType+'L1FastjetCorrector').clone(srcRho=cms.InputTag('fixedGridRhoFastjetAllCalo')),
0108 process, task)
0109 addToProcessAndTask(jetCorrections[0]+'L1Offset', getattr(process, _payloadType+'L1OffsetCorrector').clone(), process, task)
0110 addToProcessAndTask(jetCorrections[0]+'L2Relative', getattr(process, _payloadType+'L2RelativeCorrector').clone(), process, task)
0111 addToProcessAndTask(jetCorrections[0]+'L3Absolute', getattr(process, _payloadType+'L3AbsoluteCorrector').clone(), process, task)
0112 addToProcessAndTask(jetCorrections[0]+'L2L3Residual', getattr(process, _payloadType+'ResidualCorrector').clone(), process, task)
0113 addToProcessAndTask(jetCorrections[0]+'CombinedCorrector',
0114 cms.EDProducer( 'ChainedJetCorrectorProducer', correctors = cms.VInputTag()),
0115 process, task)
0116 for x in jetCorrections[1]:
0117 if x != 'L1FastJet' and x != 'L1Offset' and x != 'L2Relative' and x != 'L3Absolute' and x != 'L2L3Residual':
0118 raise ValueError('In addJetCollection: Unsupported JEC for MET(Type1). Currently supported jet correction levels are L1FastJet, L1Offset, L2Relative, L3Asolute, L2L3Residual. Requested was: %s'%(x))
0119 else:
0120 _corrector = _payloadType
0121 if x == 'L1FastJet':
0122 _corrector += 'L1Fastjet'
0123 elif x == 'L2L3Residual':
0124 _corrector += 'Residual'
0125 else:
0126 _corrector += x
0127 _corrector += 'Corrector'
0128 getattr(process, jetCorrections[0]+'CombinedCorrector').correctors.append(cms.InputTag(_corrector))
0129
0130
0131 _labelCorrName = labelName
0132 if labelName != '':
0133 _labelCorrName = 'For' + labelName
0134 if _type == 'Calo':
0135 from JetMETCorrections.Type1MET.correctionTermsCaloMet_cff import corrCaloMetType1
0136 from JetMETCorrections.Type1MET.correctionTermsCaloMet_cff import corrCaloMetType2
0137 from JetMETCorrections.Type1MET.correctedMet_cff import caloMetT1
0138 from JetMETCorrections.Type1MET.correctedMet_cff import caloMetT1T2
0139 addToProcessAndTask(
0140 jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix,
0141 corrCaloMetType1.clone(src=jetSource,srcMET = "caloMetM",jetCorrLabel = cms.InputTag(jetCorrections[0]+'CombinedCorrector')),
0142 process, task)
0143 addToProcessAndTask(
0144 jetCorrections[0]+_labelCorrName+'JetMETcorr2'+postfix,
0145 corrCaloMetType2.clone(srcUnclEnergySums = cms.VInputTag(
0146 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type2'),
0147 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'offset'),
0148 cms.InputTag('muCaloMetCorr'))),
0149 process, task)
0150 addToProcessAndTask(
0151 jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix,
0152 caloMetT1.clone(src = "caloMetM", srcCorrections = cms.VInputTag(
0153 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'))),
0154 process, task)
0155 addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix,
0156 caloMetT1T2.clone(src = "caloMetM", srcCorrections = cms.VInputTag(
0157 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'),
0158 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr2'+postfix))),
0159 process, task)
0160 elif _type == 'PF':
0161 from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfJetsPtrForMetCorr
0162 from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfCandsNotInJetsPtrForMetCorr
0163 from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfCandsNotInJetsForMetCorr
0164 from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import pfCandMETcorr
0165 from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import corrPfMetType1
0166 from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import corrPfMetType2
0167 from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1
0168 from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1T2
0169 addToProcessAndTask(jetCorrections[0]+_labelCorrName+'pfJetsPtrForMetCorr'+postfix,
0170 pfJetsPtrForMetCorr.clone(src = jetSource), process, task)
0171 addToProcessAndTask(
0172 jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsPtrForMetCorr'+postfix,
0173 pfCandsNotInJetsPtrForMetCorr.clone(topCollection = jetCorrections[0]+_labelCorrName+'pfJetsPtrForMetCorr'+postfix),
0174 process, task)
0175 addToProcessAndTask(
0176 jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsForMetCorr'+postfix,
0177 pfCandsNotInJetsForMetCorr.clone(src = jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsPtrForMetCorr'+postfix),
0178 process, task)
0179 addToProcessAndTask(
0180 jetCorrections[0]+_labelCorrName+'CandMETcorr'+postfix,
0181 pfCandMETcorr.clone(src = cms.InputTag(jetCorrections[0]+_labelCorrName+'pfCandsNotInJetsForMetCorr'+postfix)),
0182 process, task)
0183 addToProcessAndTask(
0184 jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix,
0185 corrPfMetType1.clone(src = jetSource, jetCorrLabel = cms.InputTag(jetCorrections[0]+'CombinedCorrector')),
0186 process, task)
0187 addToProcessAndTask(jetCorrections[0]+_labelCorrName+'corrPfMetType2'+postfix,
0188 corrPfMetType2.clone(srcUnclEnergySums = cms.VInputTag(
0189 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type2'),
0190 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'offset'),
0191 cms.InputTag(jetCorrections[0]+_labelCorrName+'CandMETcorr'+postfix))),
0192 process, task)
0193 addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix,
0194 pfMetT1.clone(srcCorrections = cms.VInputTag(
0195 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'))),
0196 process, task)
0197 addToProcessAndTask(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix,
0198 pfMetT1T2.clone(srcCorrections = cms.VInputTag(
0199 cms.InputTag(jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix, 'type1'),
0200 jetCorrections[0]+_labelCorrName+'corrPfMetType2'+postfix)),
0201 process, task)
0202 if 'Puppi' in jetSource.value() and pfCandidates.value() == 'particleFlow':
0203 getattr(process,jetCorrections[0]+_labelCorrName+'CandMETcorr'+postfix).srcWeights = "puppiNoLep"
0204
0205
0206 if ('L1FastJet' in jetCorrections[1] or 'L1Fastjet' in jetCorrections[1]):
0207 getattr(process,jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag(jetCorrections[0]+'L1FastJet')
0208
0209
0210
0211 else:
0212 getattr(process,jetCorrections[0]+_labelCorrName+'JetMETcorr'+postfix).offsetCorrLabel = cms.InputTag('')
0213
0214 from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs
0215 if jetCorrections[2].lower() == 'type-1':
0216 addToProcessAndTask('patMETs'+labelName+postfix,
0217 patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+'Type1CorMet'+postfix),
0218 addMuonCorrections = False),
0219 process, task)
0220 elif jetCorrections[2].lower() == 'type-2':
0221 addToProcessAndTask('patMETs'+labelName+postfix,
0222 patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+_labelCorrName+'Type1p2CorMet'+postfix),
0223 addMuonCorrections = False),
0224 process, task)
0225
0226
0227 def setupSVClustering(btagInfo, svClustering, algo, rParam, fatJets=cms.InputTag(''), groomedFatJets=cms.InputTag('')):
0228 btagInfo.useSVClustering = cms.bool(svClustering)
0229 btagInfo.jetAlgorithm = cms.string(algo)
0230 btagInfo.rParam = cms.double(rParam)
0231
0232 if fatJets != cms.InputTag(''):
0233 btagInfo.fatJets = fatJets
0234 if groomedFatJets != cms.InputTag(''):
0235 btagInfo.groomedFatJets = groomedFatJets
0236
0237
0238 def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
0239 algo, rParam, btagDiscriminators, btagInfos, patJets, labelName, btagPrefix, postfix):
0240
0241 task = getPatAlgosToolsTask(process)
0242
0243
0244 discriminators = set(btagDiscriminators)
0245 present_metaSet = discriminators.intersection(set(supportedMetaDiscr.keys()))
0246 discriminators -= present_metaSet
0247 for meta_tagger in present_metaSet:
0248 for src in supportedMetaDiscr[meta_tagger]:
0249 discriminators.add(src)
0250 present_meta = sorted(present_metaSet)
0251 btagDiscriminators = sorted(discriminators)
0252
0253
0254
0255 requiredTagInfos = list(btagInfos)
0256 for btagDiscr in btagDiscriminators :
0257 for tagInfoList in supportedBtagDiscr[btagDiscr] :
0258 for requiredTagInfo in tagInfoList :
0259 tagInfoCovered = False
0260 for tagInfo in requiredTagInfos :
0261 if requiredTagInfo == tagInfo :
0262 tagInfoCovered = True
0263 break
0264 if not tagInfoCovered :
0265 requiredTagInfos.append(requiredTagInfo)
0266
0267 if hasattr( process, 'candidateJetProbabilityComputer' ) == False :
0268 if loadStdRecoBTag:
0269 process.load("RecoBTag.ImpactParameter.impactParameter_cff")
0270 task.add(process.impactParameterTask)
0271 process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
0272 task.add(process.secondaryVertexTask)
0273 process.load("RecoBTag.SoftLepton.softLepton_cff")
0274 task.add(process.softLeptonTask)
0275 process.load("RecoBTag.Combined.combinedMVA_cff")
0276 task.add(process.combinedMVATask)
0277 process.load("RecoBTag.CTagging.cTagging_cff")
0278 task.add(process.cTaggingTask)
0279 else:
0280 process.load("RecoBTag.ImpactParameter.impactParameter_EventSetup_cff")
0281 process.load("RecoBTag.SecondaryVertex.secondaryVertex_EventSetup_cff")
0282 process.load("RecoBTag.SoftLepton.softLepton_EventSetup_cff")
0283 process.load("RecoBTag.Combined.combinedMVA_EventSetup_cff")
0284 process.load("RecoBTag.CTagging.cTagging_EventSetup_cff")
0285 import RecoBTag.Configuration.RecoBTag_cff as btag
0286 import RecoJets.JetProducers.caTopTaggers_cff as toptag
0287
0288 if tightBTagNTkHits:
0289 if not runIVF:
0290 sys.stderr.write("-------------------------------------------------------------------\n")
0291 sys.stderr.write(" Warning: For a complete switch to the legacy tight b-tag track\n")
0292 sys.stderr.write(" selection, please also enable the \'runIVF\' switch.\n")
0293 sys.stderr.write("-------------------------------------------------------------------\n")
0294 if btagPrefix == '':
0295 sys.stderr.write("-------------------------------------------------------------------\n")
0296 sys.stderr.write(" Warning: With the tight b-tag track selection enabled, it is\n")
0297 sys.stderr.write(" advisable to set \'btagPrefix\' to a non-empty string to\n")
0298 sys.stderr.write(" avoid unintentional modifications to the default\n")
0299 sys.stderr.write(" b tagging setup that might be loaded in the same job.\n")
0300 sys.stderr.write("-------------------------------------------------------------------\n")
0301
0302
0303
0304 svSourceCvsL = copy.deepcopy(svSource)
0305 svSourceCvsL.setModuleLabel(svSource.getModuleLabel()+'CvsL')
0306
0307
0308 runIVFforCTagOnly = False
0309 ivfcTagInfos = ['pfInclusiveSecondaryVertexFinderCvsLTagInfos', 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos']
0310
0311 if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices' and any(i in requiredTagInfos for i in ivfcTagInfos) and not runIVF:
0312 runIVFforCTagOnly = True
0313 runIVF = True
0314 sys.stderr.write("-------------------------------------------------------------------\n")
0315 sys.stderr.write(" Info: To run c tagging on MiniAOD, c-tag-specific IVF secondary\n")
0316 sys.stderr.write(" vertices will be remade.\n")
0317 sys.stderr.write("-------------------------------------------------------------------\n")
0318
0319 if runIVF and btagPrefix != '':
0320 if runIVFforCTagOnly:
0321 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
0322 else:
0323 svSource.setModuleLabel(btagPrefix+svSource.getModuleLabel())
0324 svSourceCvsL.setModuleLabel(btagPrefix+svSourceCvsL.getModuleLabel())
0325
0326
0327
0328
0329
0330 runNegativeVertexing = False
0331 runNegativeCvsLVertexing = False
0332 for btagInfo in requiredTagInfos:
0333 if btagInfo in (
0334 'pfInclusiveSecondaryVertexFinderNegativeTagInfos',
0335 'pfNegativeDeepFlavourTagInfos',
0336 'pfNegativeParticleNetAK4TagInfos',
0337 ):
0338 runNegativeVertexing = True
0339 if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
0340 runNegativeCvsLVertexing = True
0341
0342 if runNegativeVertexing or runNegativeCvsLVertexing:
0343 import RecoVertex.AdaptiveVertexFinder.inclusiveNegativeVertexing_cff as NegVertex
0344
0345 if runNegativeVertexing:
0346 addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix,
0347 NegVertex.inclusiveCandidateNegativeVertexFinder.clone(primaryVertices = pvSource,tracks=pfCandidates),
0348 process, task)
0349 addToProcessAndTask(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix,
0350 NegVertex.candidateNegativeVertexMerger.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinder'+labelName+postfix)),
0351 process, task)
0352 addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix,
0353 NegVertex.candidateNegativeVertexArbitrator.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMerger'+labelName+postfix)
0354 ,primaryVertices = pvSource
0355 ,tracks=pfCandidates),
0356 process, task)
0357 addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix,
0358 NegVertex.inclusiveCandidateNegativeSecondaryVertices.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitrator'+labelName+postfix)),
0359 process, task)
0360
0361 if runNegativeCvsLVertexing:
0362 addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix,
0363 NegVertex.inclusiveCandidateNegativeVertexFinderCvsL.clone(primaryVertices = pvSource,tracks=pfCandidates),
0364 process, task)
0365 addToProcessAndTask(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix,
0366 NegVertex.candidateNegativeVertexMergerCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeVertexFinderCvsL'+labelName+postfix)),
0367 process, task)
0368 addToProcessAndTask(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix,
0369 NegVertex.candidateNegativeVertexArbitratorCvsL.clone( secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexMergerCvsL'+labelName+postfix)
0370 ,primaryVertices = pvSource
0371 ,tracks=pfCandidates),
0372 process, task)
0373 addToProcessAndTask(btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix,
0374 NegVertex.inclusiveCandidateNegativeSecondaryVerticesCvsL.clone(secondaryVertices = cms.InputTag(btagPrefix+'candidateNegativeVertexArbitratorCvsL'+labelName+postfix)),
0375 process, task)
0376
0377
0378 acceptedTagInfos = list()
0379 for btagInfo in requiredTagInfos:
0380 if hasattr(btag,btagInfo):
0381 if btagInfo == 'pfImpactParameterTagInfos':
0382 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0383 btag.pfImpactParameterTagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
0384 process, task)
0385 if explicitJTA:
0386 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0387 _btagInfo.explicitJTA = cms.bool(explicitJTA)
0388 if tightBTagNTkHits:
0389 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0390 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
0391 _btagInfo.minimumNumberOfHits = cms.int32(8)
0392 if btagInfo == 'pfImpactParameterAK8TagInfos':
0393 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0394 btag.pfImpactParameterAK8TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
0395 process, task)
0396 if explicitJTA:
0397 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0398 _btagInfo.explicitJTA = cms.bool(explicitJTA)
0399 if tightBTagNTkHits:
0400 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0401 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
0402 _btagInfo.minimumNumberOfHits = cms.int32(8)
0403 if btagInfo == 'pfImpactParameterCA15TagInfos':
0404 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0405 btag.pfImpactParameterCA15TagInfos.clone(jets = jetSource,primaryVertex=pvSource,candidates=pfCandidates),
0406 process, task)
0407 if explicitJTA:
0408 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0409 _btagInfo.explicitJTA = cms.bool(explicitJTA)
0410 if tightBTagNTkHits:
0411 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0412 _btagInfo.minimumNumberOfPixelHits = cms.int32(2)
0413 _btagInfo.minimumNumberOfHits = cms.int32(8)
0414 if btagInfo == 'pfSecondaryVertexTagInfos':
0415 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0416 btag.pfSecondaryVertexTagInfos.clone(
0417 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
0418 process, task)
0419 if tightBTagNTkHits:
0420 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0421 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
0422 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
0423 if btagInfo == 'pfDeepCSVTagInfos':
0424 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0425 btag.pfDeepCSVTagInfos.clone(
0426 svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
0427 process, task)
0428 if svClustering or fatJets != cms.InputTag(''):
0429 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0430 if btagInfo == 'pfDeepCSVNegativeTagInfos':
0431 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0432 btag.pfDeepCSVNegativeTagInfos.clone(
0433 svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderNegativeTagInfos'+labelName+postfix)),
0434 process, task)
0435 if svClustering or fatJets != cms.InputTag(''):
0436 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0437 if btagInfo == 'pfDeepCSVPositiveTagInfos':
0438 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0439 btag.pfDeepCSVPositiveTagInfos.clone(
0440 svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderTagInfos'+labelName+postfix)),
0441 process, task)
0442 if svClustering or fatJets != cms.InputTag(''):
0443 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0444 if btagInfo == 'pfDeepCMVATagInfos':
0445 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0446 btag.pfDeepCMVATagInfos.clone(
0447 deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
0448 ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
0449 muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
0450 elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
0451 process, task)
0452 if svClustering or fatJets != cms.InputTag(''):
0453 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0454 if btagInfo == 'pfDeepCMVANegativeTagInfos':
0455 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0456 btag.pfDeepCMVATagInfos.clone(
0457 deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
0458 ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
0459 muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
0460 elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
0461 process, task)
0462 if svClustering or fatJets != cms.InputTag(''):
0463 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0464 if btagInfo == 'pfDeepCMVAPositiveTagInfos':
0465 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0466 btag.pfDeepCMVATagInfos.clone(
0467 deepNNTagInfos = cms.InputTag(btagPrefix+'pfDeepCSVTagInfos'+labelName+postfix),
0468 ipInfoSrc = cms.InputTag(btagPrefix+"pfImpactParameterTagInfos"+labelName+postfix),
0469 muInfoSrc = cms.InputTag(btagPrefix+"softPFMuonsTagInfos"+labelName+postfix),
0470 elInfoSrc = cms.InputTag(btagPrefix+"softPFElectronsTagInfos"+labelName+postfix)),
0471 process, task)
0472 if svClustering or fatJets != cms.InputTag(''):
0473 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0474 if btagInfo == 'pfInclusiveSecondaryVertexFinderTagInfos':
0475 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0476 btag.pfInclusiveSecondaryVertexFinderTagInfos.clone(
0477 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
0478 extSVCollection=svSource),
0479 process, task)
0480 if svClustering or fatJets != cms.InputTag(''):
0481 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0482 if btagInfo == 'pfInclusiveSecondaryVertexFinderAK8TagInfos':
0483 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0484 btag.pfInclusiveSecondaryVertexFinderAK8TagInfos.clone(
0485 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterAK8TagInfos'+labelName+postfix),
0486 extSVCollection=svSource),
0487 process, task)
0488 if svClustering or fatJets != cms.InputTag(''):
0489 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0490 if btagInfo == 'pfBoostedDoubleSVAK8TagInfos':
0491 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0492 btag.pfBoostedDoubleSVAK8TagInfos.clone(
0493 svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderAK8TagInfos'+labelName+postfix)),
0494 process, task)
0495 if btagInfo == 'pfInclusiveSecondaryVertexFinderCA15TagInfos':
0496 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0497 btag.pfInclusiveSecondaryVertexFinderCA15TagInfos.clone(
0498 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterCA15TagInfos'+labelName+postfix),
0499 extSVCollection=svSource),
0500 process, task)
0501 if svClustering or fatJets != cms.InputTag(''):
0502 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0503 if btagInfo == 'pfBoostedDoubleSVCA15TagInfos':
0504 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0505 btag.pfBoostedDoubleSVCA15TagInfos.clone(
0506 svTagInfos = cms.InputTag(btagPrefix+'pfInclusiveSecondaryVertexFinderCA15TagInfos'+labelName+postfix)),
0507 process, task)
0508 if btagInfo == 'pfInclusiveSecondaryVertexFinderCvsLTagInfos':
0509 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0510 btag.pfInclusiveSecondaryVertexFinderCvsLTagInfos.clone(
0511 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
0512 extSVCollection=svSourceCvsL),
0513 process, task)
0514 if svClustering or fatJets != cms.InputTag(''):
0515 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0516 if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos':
0517 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0518 btag.pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos.clone(
0519 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
0520 extSVCollection = btagPrefix+'inclusiveCandidateNegativeSecondaryVerticesCvsL'+labelName+postfix),
0521 process, task)
0522 if svClustering or fatJets != cms.InputTag(''):
0523 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0524 if btagInfo == 'pfGhostTrackVertexTagInfos':
0525 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0526 btag.pfGhostTrackVertexTagInfos.clone(
0527 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
0528 process, task)
0529 if btagInfo == 'pfSecondaryVertexNegativeTagInfos':
0530 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0531 btag.pfSecondaryVertexNegativeTagInfos.clone(
0532 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix)),
0533 process, task)
0534 if tightBTagNTkHits:
0535 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0536 _btagInfo.trackSelection.pixelHitsMin = cms.uint32(2)
0537 _btagInfo.trackSelection.totalHitsMin = cms.uint32(8)
0538 if btagInfo == 'pfInclusiveSecondaryVertexFinderNegativeTagInfos':
0539 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0540 btag.pfInclusiveSecondaryVertexFinderNegativeTagInfos.clone(
0541 trackIPTagInfos = cms.InputTag(btagPrefix+'pfImpactParameterTagInfos'+labelName+postfix),
0542 extSVCollection=cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)),
0543 process, task)
0544 if svClustering or fatJets != cms.InputTag(''):
0545 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0546 if btagInfo == 'impactParameterTagInfos':
0547 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0548 btag.impactParameterTagInfos.clone(
0549 jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+labelName+postfix),
0550 primaryVertex=pvSource),
0551 process, task)
0552 if btagInfo == 'secondaryVertexTagInfos':
0553 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0554 btag.secondaryVertexTagInfos.clone(
0555 trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
0556 process, task)
0557 if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
0558 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0559 btag.inclusiveSecondaryVertexFinderTagInfos.clone(
0560 trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
0561 process, task)
0562 if svClustering or fatJets != cms.InputTag(''):
0563 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0564 if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
0565 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0566 btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(
0567 trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
0568 process, task)
0569 if svClustering or fatJets != cms.InputTag(''):
0570 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0571 if btagInfo == 'secondaryVertexNegativeTagInfos':
0572 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0573 btag.secondaryVertexNegativeTagInfos.clone(
0574 trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
0575 process, task)
0576 if btagInfo == 'inclusiveSecondaryVertexFinderNegativeTagInfos':
0577 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0578 btag.inclusiveSecondaryVertexFinderNegativeTagInfos.clone(
0579 trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
0580 process, task)
0581 if svClustering or fatJets != cms.InputTag(''):
0582 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0583 if btagInfo == 'inclusiveSecondaryVertexFinderFilteredNegativeTagInfos':
0584 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0585 btag.inclusiveSecondaryVertexFinderFilteredNegativeTagInfos.clone(
0586 trackIPTagInfos = cms.InputTag(btagPrefix+'impactParameterTagInfos'+labelName+postfix)),
0587 process, task)
0588 if svClustering or fatJets != cms.InputTag(''):
0589 setupSVClustering(getattr(process, btagPrefix+btagInfo+labelName+postfix), svClustering, algo, rParam, fatJets, groomedFatJets)
0590 if btagInfo == 'softMuonTagInfos':
0591 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0592 btag.softMuonTagInfos.clone(jets = jetSource, primaryVertex=pvSource),
0593 process, task)
0594 if btagInfo == 'softPFMuonsTagInfos':
0595 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0596 btag.softPFMuonsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, muons=muSource),
0597 process, task)
0598 if btagInfo == 'softPFElectronsTagInfos':
0599 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0600 btag.softPFElectronsTagInfos.clone(jets = jetSource, primaryVertex=pvSource, electrons=elSource),
0601 process, task)
0602 if btagInfo == 'pixelClusterTagInfos':
0603 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0604 btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
0605 process, task)
0606
0607 if 'pfBoostedDouble' in btagInfo or 'SecondaryVertex' in btagInfo:
0608 _btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
0609 if pfCandidates.value() == 'packedPFCandidates':
0610 _btagInfo.weights = cms.InputTag("packedpuppi")
0611 if not hasattr(process,"packedpuppi"):
0612 from CommonTools.PileupAlgos.Puppi_cff import puppi
0613 addToProcessAndTask('packedpuppi', puppi.clone(
0614 useExistingWeights = True,
0615 candName = 'packedPFCandidates',
0616 vertexName = 'offlineSlimmedPrimaryVertices') , process, task)
0617 else:
0618 _btagInfo.weights = cms.InputTag("puppi")
0619
0620 if 'DeepFlavourTagInfos' in btagInfo:
0621 svUsed = svSource
0622 if btagInfo == 'pfNegativeDeepFlavourTagInfos':
0623 deep_csv_tag_infos = 'pfDeepCSVNegativeTagInfos'
0624 svUsed = cms.InputTag(btagPrefix+'inclusiveCandidateNegativeSecondaryVertices'+labelName+postfix)
0625 flip = True
0626 else:
0627 deep_csv_tag_infos = 'pfDeepCSVTagInfos'
0628 flip = False
0629
0630
0631 if not ('limmed' in jetSource.value()):
0632 puppi_value_map = cms.InputTag("puppi")
0633 vertex_associator = cms.InputTag("primaryVertexAssociation","original")
0634 else:
0635 puppi_value_map = cms.InputTag("")
0636 vertex_associator = cms.InputTag("")
0637 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0638 btag.pfDeepFlavourTagInfos.clone(
0639 jets = jetSource,
0640 vertices=pvSource,
0641 secondary_vertices=svUsed,
0642 shallow_tag_infos = cms.InputTag(btagPrefix+deep_csv_tag_infos+labelName+postfix),
0643 puppi_value_map = puppi_value_map,
0644 vertex_associator = vertex_associator,
0645 flip = flip),
0646 process, task)
0647
0648 if btagInfo == 'pfDeepDoubleXTagInfos':
0649 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0650 btag.pfDeepDoubleXTagInfos.clone(
0651 jets = jetSource,
0652 vertices=pvSource,
0653 secondary_vertices=svSource,
0654 shallow_tag_infos = cms.InputTag(btagPrefix+'pfBoostedDoubleSVAK8TagInfos'+labelName+postfix),
0655 ),
0656 process, task)
0657
0658 if btagInfo == 'pfHiggsInteractionNetTagInfos':
0659 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0660 btag.pfHiggsInteractionNetTagInfos.clone(
0661 jets = jetSource,
0662 vertices = pvSource,
0663 secondary_vertices = svSource,
0664 pf_candidates = pfCandidates,
0665 ),
0666 process, task)
0667
0668 if btagInfo == 'pfDeepBoostedJetTagInfos':
0669 if pfCandidates.value() == 'packedPFCandidates':
0670
0671 if 'updated' not in jetSource.value().lower():
0672 raise ValueError("Invalid jet collection: %s. pfDeepBoostedJetTagInfos only supports running via updateJetCollection." % jetSource.value())
0673 puppi_value_map = ""
0674 vertex_associator = ""
0675 elif pfCandidates.value() == 'particleFlow':
0676 raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
0677
0678
0679
0680
0681
0682 else:
0683 raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
0684 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0685 btag.pfDeepBoostedJetTagInfos.clone(
0686 jets = jetSource,
0687 vertices = pvSource,
0688 secondary_vertices = svSource,
0689 pf_candidates = pfCandidates,
0690 puppi_value_map = puppi_value_map,
0691 vertex_associator = vertex_associator,
0692 ),
0693 process, task)
0694
0695 if btagInfo == 'pfParticleNetTagInfos':
0696 if pfCandidates.value() == 'packedPFCandidates':
0697
0698 puppi_value_map = ""
0699 vertex_associator = ""
0700 elif pfCandidates.value() == 'particleFlow':
0701 raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
0702
0703 puppi_value_map = "puppi"
0704 vertex_associator = "primaryVertexAssociation:original"
0705 else:
0706 raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
0707 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0708 btag.pfParticleNetTagInfos.clone(
0709 jets = jetSource,
0710 vertices = pvSource,
0711 secondary_vertices = svSource,
0712 pf_candidates = pfCandidates,
0713 puppi_value_map = puppi_value_map,
0714 vertex_associator = vertex_associator,
0715 ),
0716 process, task)
0717
0718 if 'ParticleNetAK4TagInfos' in btagInfo:
0719 if btagInfo == 'pfNegativeParticleNetAK4TagInfos':
0720 secondary_vertices = btagPrefix + \
0721 'inclusiveCandidateNegativeSecondaryVertices' + labelName + postfix
0722 flip_ip_sign = True
0723 sip3dSigMax = 10
0724 else:
0725 secondary_vertices = svSource
0726 flip_ip_sign = False
0727 sip3dSigMax = -1
0728 if pfCandidates.value() == 'packedPFCandidates':
0729
0730 puppi_value_map = ""
0731 vertex_associator = ""
0732 elif pfCandidates.value() == 'particleFlow':
0733 raise ValueError("Running pfDeepBoostedJetTagInfos with reco::PFCandidates is currently not supported.")
0734
0735 puppi_value_map = "puppi"
0736 vertex_associator = "primaryVertexAssociation:original"
0737 else:
0738 raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
0739 addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
0740 btag.pfParticleNetAK4TagInfos.clone(
0741 jets = jetSource,
0742 vertices = pvSource,
0743 secondary_vertices = secondary_vertices,
0744 pf_candidates = pfCandidates,
0745 puppi_value_map = puppi_value_map,
0746 vertex_associator = vertex_associator,
0747 flip_ip_sign = flip_ip_sign,
0748 sip3dSigMax = sip3dSigMax,
0749 ),
0750 process, task)
0751
0752 acceptedTagInfos.append(btagInfo)
0753 elif hasattr(toptag, btagInfo) :
0754 acceptedTagInfos.append(btagInfo)
0755 else:
0756 print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagInfo))
0757
0758 acceptedBtagDiscriminators = list()
0759 for discriminator_name in btagDiscriminators :
0760 btagDiscr = discriminator_name.split(':')[0]
0761
0762 if hasattr(btag,btagDiscr):
0763 newDiscr = btagPrefix+btagDiscr+labelName+postfix
0764 if hasattr(process, newDiscr):
0765 pass
0766 elif hasattr(getattr(btag, btagDiscr), 'tagInfos'):
0767 addToProcessAndTask(
0768 newDiscr,
0769 getattr(btag, btagDiscr).clone(
0770 tagInfos = cms.VInputTag(
0771 *[ cms.InputTag(btagPrefix+x+labelName+postfix) \
0772 for x in supportedBtagDiscr[discriminator_name][0] ]
0773 )
0774 ),
0775 process,
0776 task
0777 )
0778 elif hasattr(getattr(btag, btagDiscr), 'src'):
0779 addToProcessAndTask(
0780 newDiscr,
0781 getattr(btag, btagDiscr).clone(
0782 src = cms.InputTag(btagPrefix+supportedBtagDiscr[discriminator_name][0][0]+labelName+postfix)
0783 ),
0784 process,
0785 task
0786 )
0787 else:
0788 raise ValueError('I do not know how to update %s it does not have neither "tagInfos" nor "src" attributes' % btagDiscr)
0789 acceptedBtagDiscriminators.append(discriminator_name)
0790 else:
0791 print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
0792
0793 for meta_tagger in present_meta:
0794 btagDiscr = meta_tagger.split(':')[0]
0795
0796 if hasattr(btag,btagDiscr):
0797 newDiscr = btagPrefix+btagDiscr+labelName+postfix
0798 if hasattr(process, newDiscr):
0799 pass
0800 else:
0801 addToProcessAndTask(
0802 newDiscr,
0803 getattr(btag, btagDiscr).clone(),
0804 process,
0805 task
0806 )
0807 for dependency in supportedMetaDiscr[meta_tagger]:
0808 if ':' in dependency:
0809 new_dep = btagPrefix+dependency.split(':')[0]+labelName+postfix+':'+dependency.split(':')[1]
0810 else:
0811 new_dep = btagPrefix+dependency+labelName+postfix
0812 replace = MassSearchReplaceAnyInputTagVisitor(dependency, new_dep)
0813 replace.doIt(getattr(process, newDiscr), newDiscr)
0814 acceptedBtagDiscriminators.append(meta_tagger)
0815 else:
0816 print(' --> %s ignored, since not available via RecoBTag.Configuration.RecoBTag_cff!'%(btagDiscr))
0817
0818
0819 patJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(btagPrefix+x+labelName+postfix) for x in acceptedTagInfos ] )
0820 patJets.discriminatorSources = cms.VInputTag(*[
0821 cms.InputTag(btagPrefix+x+labelName+postfix) \
0822 if ':' not in x else \
0823 cms.InputTag(btagPrefix+x.split(':')[0]+labelName+postfix+':'+x.split(':')[1]) \
0824 for x in acceptedBtagDiscriminators
0825 ])
0826 if len(acceptedBtagDiscriminators) > 0 :
0827 patJets.addBTagInfo = True
0828
0829 if runIVF:
0830 if not tightBTagNTkHits:
0831 if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
0832 if not runIVFforCTagOnly: rerunningIVFMiniAOD()
0833 else:
0834 rerunningIVF()
0835 from PhysicsTools.PatAlgos.tools.helpers import loadWithPrefix
0836 ivfbTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos', 'pfInclusiveSecondaryVertexFinderAK8TagInfos', 'pfInclusiveSecondaryVertexFinderCA15TagInfos']
0837 if any(i in acceptedTagInfos for i in ivfbTagInfos) and not runIVFforCTagOnly:
0838 if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
0839 loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
0840 if tightBTagNTkHits:
0841 if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
0842 _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
0843 _temp.minHits = cms.uint32(8)
0844
0845 if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
0846 if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinder' ):
0847 _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinder')
0848 _temp.primaryVertices = pvSource
0849 _temp.tracks = pfCandidates
0850 if hasattr( process, btagPrefix+'candidateVertexArbitrator' ):
0851 _temp = getattr(process, btagPrefix+'candidateVertexArbitrator')
0852 _temp.primaryVertices = pvSource
0853 _temp.tracks = pfCandidates
0854 if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVertices' ) and not hasattr( process, svSource.getModuleLabel() ):
0855 addToProcessAndTask(svSource.getModuleLabel(),
0856 getattr(process, btagPrefix+'inclusiveCandidateSecondaryVertices').clone(),
0857 process, task)
0858 if any(i in acceptedTagInfos for i in ivfcTagInfos):
0859 if not hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
0860 loadWithPrefix(process, 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff', btagPrefix, task.label())
0861 if tightBTagNTkHits:
0862 if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
0863 _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
0864 _temp.minHits = cms.uint32(8)
0865
0866 if pvSource.getModuleLabel() == 'offlineSlimmedPrimaryVertices':
0867 if hasattr( process, btagPrefix+'inclusiveCandidateVertexFinderCvsL' ):
0868 _temp = getattr(process, btagPrefix+'inclusiveCandidateVertexFinderCvsL')
0869 _temp.primaryVertices = pvSource
0870 _temp.tracks = pfCandidates
0871 if hasattr( process, btagPrefix+'candidateVertexArbitratorCvsL' ):
0872 _temp = getattr(process, btagPrefix+'candidateVertexArbitratorCvsL')
0873 _temp.primaryVertices = pvSource
0874 _temp.tracks = pfCandidates
0875 if hasattr( process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL' ) and not hasattr( process, svSourceCvsL.getModuleLabel() ):
0876 addToProcessAndTask(svSourceCvsL.getModuleLabel(),
0877 getattr(process, btagPrefix+'inclusiveCandidateSecondaryVerticesCvsL').clone(),
0878 process, task)
0879 if 'inclusiveSecondaryVertexFinderTagInfos' in acceptedTagInfos:
0880 if not hasattr( process, 'inclusiveVertexing' ):
0881 process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
0882 task.add(process.inclusiveVertexingTask)
0883 task.add(process.inclusiveCandidateVertexingTask)
0884 task.add(process.inclusiveCandidateVertexingCvsLTask)
0885 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
0886 if not hasattr( process, 'inclusiveVertexing' ):
0887 process.load( 'RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff' )
0888 task.add(process.inclusiveVertexingTask)
0889 task.add(process.inclusiveCandidateVertexingTask)
0890 task.add(process.inclusiveCandidateVertexingCvsLTask)
0891 if 'inclusiveSecondaryVertexFinderFilteredTagInfos' in acceptedTagInfos:
0892 if not hasattr( process, 'inclusiveSecondaryVerticesFiltered' ):
0893 process.load( 'RecoBTag.SecondaryVertex.inclusiveSecondaryVerticesFiltered_cfi' )
0894 task.add(process.inclusiveSecondaryVerticesFiltered)
0895 task.add(process.bVertexFilter)
0896 if not hasattr( process, 'bToCharmDecayVertexMerged' ):
0897 process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
0898 task.add(process.bToCharmDecayVertexMerged)
0899 if 'caTopTagInfos' in acceptedTagInfos :
0900 patJets.addTagInfos = True
0901 if not hasattr( process, 'caTopTagInfos' ) and not hasattr( process, 'caTopTagInfosAK8' ):
0902 process.load( 'RecoJets.JetProducers.caTopTaggers_cff' )
0903 task.add(process.caTopTaggersTask)
0904
0905 class AddJetCollection(ConfigToolBase):
0906 """
0907 Tool to add a new jet collection to your PAT Tuple or to modify an existing one.
0908 """
0909 _label='addJetCollection'
0910 _defaultParameters=dicttypes.SortedKeysDict()
0911
0912 def __init__(self):
0913 """
0914 Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.
0915 """
0916
0917 ConfigToolBase.__init__(self)
0918
0919 self.addParameter(self._defaultParameters,'labelName', 'UNDEFINED', "Label name of the new patJet collection.", str)
0920 self.addParameter(self._defaultParameters,'postfix','', "Postfix from usePF2PAT.", str)
0921 self.addParameter(self._defaultParameters,'btagPrefix','', "Prefix to be added to b-tag discriminator and TagInfo names", str)
0922 self.addParameter(self._defaultParameters,'jetSource','', "Label of the input collection from which the new patJet collection should be created", cms.InputTag)
0923 self.addParameter(self._defaultParameters,'pfCandidates',cms.InputTag('particleFlow'), "Label of the input collection for candidatecandidatese used in b-tagging", cms.InputTag)
0924 self.addParameter(self._defaultParameters,'explicitJTA', False, "Use explicit jet-track association")
0925 self.addParameter(self._defaultParameters,'pvSource',cms.InputTag('offlinePrimaryVertices'), "Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
0926 self.addParameter(self._defaultParameters,'svSource',cms.InputTag('inclusiveCandidateSecondaryVertices'), "Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
0927 self.addParameter(self._defaultParameters,'elSource',cms.InputTag('gedGsfElectrons'), "Label of the input collection for electrons used in b-tagging", cms.InputTag)
0928 self.addParameter(self._defaultParameters,'muSource',cms.InputTag('muons'), "Label of the input collection for muons used in b-tagging", cms.InputTag)
0929 self.addParameter(self._defaultParameters,'runIVF', False, "Re-run IVF secondary vertex reconstruction")
0930 self.addParameter(self._defaultParameters,'tightBTagNTkHits', False, "Enable legacy tight b-tag track selection")
0931 self.addParameter(self._defaultParameters,'loadStdRecoBTag', False, "Load the standard reconstruction b-tagging modules")
0932 self.addParameter(self._defaultParameters,'svClustering', False, "Secondary vertices ghost-associated to jets using jet clustering (mostly intended for subjets)")
0933 self.addParameter(self._defaultParameters,'fatJets', cms.InputTag(''), "Fat jet collection used for secondary vertex clustering", cms.InputTag)
0934 self.addParameter(self._defaultParameters,'groomedFatJets', cms.InputTag(''), "Groomed fat jet collection used for secondary vertex clustering", cms.InputTag)
0935 self.addParameter(self._defaultParameters,'algo', 'AK', "Jet algorithm of the input collection from which the new patJet collection should be created")
0936 self.addParameter(self._defaultParameters,'rParam', 0.4, "Jet size (distance parameter R used in jet clustering)")
0937 self.addParameter(self._defaultParameters,'getJetMCFlavour', True, "Get jet MC truth flavour")
0938 self.addParameter(self._defaultParameters,'genJetCollection', cms.InputTag("ak4GenJets"), "GenJet collection to match to", cms.InputTag)
0939 self.addParameter(self._defaultParameters,'genParticles', cms.InputTag("genParticles"), "GenParticle collection to be used", cms.InputTag)
0940 self.addParameter(self._defaultParameters,'jetCorrections',None, "Add all relevant information about jet energy corrections that you want to be added to your new patJet \
0941 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 \
0942 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 \
0943 new patJet collection. This should be given as a list of strings. Available values are L1Offset, L1FastJet, L1JPTOffset, L2Relative, L3Absolute, L5Falvour, L7Parton; the \
0944 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 \
0945 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 \
0946 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\' \
0947 and \'type-2\' are not case sensitive.", tuple, acceptNoneValue=True)
0948 self.addParameter(self._defaultParameters,'btagDiscriminators',['None'], "If you are interested in btagging, in most cases just the labels of the btag discriminators that \
0949 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. \
0950 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)
0951 self.addParameter(self._defaultParameters,'btagInfos',['None'], "The btagInfos objects contain all relevant information from which all discriminators of a certain \
0952 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 \
0953 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 \
0954 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 \
0955 will be added to your new patJet collection.", allowedValues=supportedBtagInfos,Type=list)
0956 self.addParameter(self._defaultParameters,'jetTrackAssociation',False, "Add JetTrackAssociation and JetCharge from reconstructed tracks to your new patJet collection. This \
0957 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 \
0958 your new patJetCollection. If btag information of any form is added to the new patJet collection this information will be added automatically.")
0959 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 \
0960 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 \
0961 to more than one output module.")
0962
0963 self._parameters=copy.deepcopy(self._defaultParameters)
0964
0965 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\
0966 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 \
0967 the descriptions of each parameter for more information."
0968
0969 def getDefaultParameters(self):
0970 """
0971 Return default parameters of the class
0972 """
0973 return self._defaultParameters
0974
0975 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):
0976 """
0977 Function call wrapper. This will check the parameters and call the actual implementation that
0978 can be found in toolCode via the base class function apply.
0979 """
0980 if labelName is None:
0981 labelName=self._defaultParameters['labelName'].value
0982 self.setParameter('labelName', labelName)
0983 if postfix is None:
0984 postfix=self._defaultParameters['postfix'].value
0985 self.setParameter('postfix', postfix)
0986 if btagPrefix is None:
0987 btagPrefix=self._defaultParameters['btagPrefix'].value
0988 self.setParameter('btagPrefix', btagPrefix)
0989 if jetSource is None:
0990 jetSource=self._defaultParameters['jetSource'].value
0991 self.setParameter('jetSource', jetSource)
0992 if pfCandidates is None:
0993 pfCandidates=self._defaultParameters['pfCandidates'].value
0994 self.setParameter('pfCandidates', pfCandidates)
0995 if explicitJTA is None:
0996 explicitJTA=self._defaultParameters['explicitJTA'].value
0997 self.setParameter('explicitJTA', explicitJTA)
0998 if pvSource is None:
0999 pvSource=self._defaultParameters['pvSource'].value
1000 self.setParameter('pvSource', pvSource)
1001 if svSource is None:
1002 svSource=self._defaultParameters['svSource'].value
1003 self.setParameter('svSource', svSource)
1004 if elSource is None:
1005 elSource=self._defaultParameters['elSource'].value
1006 self.setParameter('elSource', elSource)
1007 if muSource is None:
1008 muSource=self._defaultParameters['muSource'].value
1009 self.setParameter('muSource', muSource)
1010 if runIVF is None:
1011 runIVF=self._defaultParameters['runIVF'].value
1012 self.setParameter('runIVF', runIVF)
1013 if tightBTagNTkHits is None:
1014 tightBTagNTkHits=self._defaultParameters['tightBTagNTkHits'].value
1015 self.setParameter('tightBTagNTkHits', tightBTagNTkHits)
1016 if loadStdRecoBTag is None:
1017 loadStdRecoBTag=self._defaultParameters['loadStdRecoBTag'].value
1018 self.setParameter('loadStdRecoBTag', loadStdRecoBTag)
1019 if svClustering is None:
1020 svClustering=self._defaultParameters['svClustering'].value
1021 self.setParameter('svClustering', svClustering)
1022 if fatJets is None:
1023 fatJets=self._defaultParameters['fatJets'].value
1024 self.setParameter('fatJets', fatJets)
1025 if groomedFatJets is None:
1026 groomedFatJets=self._defaultParameters['groomedFatJets'].value
1027 self.setParameter('groomedFatJets', groomedFatJets)
1028 if algo is None:
1029 algo=self._defaultParameters['algo'].value
1030 self.setParameter('algo', algo)
1031 if rParam is None:
1032 rParam=self._defaultParameters['rParam'].value
1033 self.setParameter('rParam', rParam)
1034 if getJetMCFlavour is None:
1035 getJetMCFlavour=self._defaultParameters['getJetMCFlavour'].value
1036 self.setParameter('getJetMCFlavour', getJetMCFlavour)
1037 if genJetCollection is None:
1038 genJetCollection=self._defaultParameters['genJetCollection'].value
1039 self.setParameter('genJetCollection', genJetCollection)
1040 if genParticles is None:
1041 genParticles=self._defaultParameters['genParticles'].value
1042 self.setParameter('genParticles', genParticles)
1043 if jetCorrections is None:
1044 jetCorrections=self._defaultParameters['jetCorrections'].value
1045 self.setParameter('jetCorrections', jetCorrections)
1046 if btagDiscriminators is None:
1047 btagDiscriminators=self._defaultParameters['btagDiscriminators'].value
1048 self.setParameter('btagDiscriminators', btagDiscriminators)
1049 if btagInfos is None:
1050 btagInfos=self._defaultParameters['btagInfos'].value
1051 self.setParameter('btagInfos', btagInfos)
1052 if jetTrackAssociation is None:
1053 jetTrackAssociation=self._defaultParameters['jetTrackAssociation'].value
1054 self.setParameter('jetTrackAssociation', jetTrackAssociation)
1055 if outputModules is None:
1056 outputModules=self._defaultParameters['outputModules'].value
1057 self.setParameter('outputModules', outputModules)
1058 self.apply(process)
1059
1060 def toolCode(self, process):
1061 """
1062 Tool code implementation
1063 """
1064 task = getPatAlgosToolsTask(process)
1065
1066
1067 labelName=self._parameters['labelName'].value
1068 postfix=self._parameters['postfix'].value
1069 btagPrefix=self._parameters['btagPrefix'].value
1070 jetSource=self._parameters['jetSource'].value
1071 pfCandidates=self._parameters['pfCandidates'].value
1072 explicitJTA=self._parameters['explicitJTA'].value
1073 pvSource=self._parameters['pvSource'].value
1074 svSource=self._parameters['svSource'].value
1075 elSource=self._parameters['elSource'].value
1076 muSource=self._parameters['muSource'].value
1077 runIVF=self._parameters['runIVF'].value
1078 tightBTagNTkHits=self._parameters['tightBTagNTkHits'].value
1079 loadStdRecoBTag=self._parameters['loadStdRecoBTag'].value
1080 svClustering=self._parameters['svClustering'].value
1081 fatJets=self._parameters['fatJets'].value
1082 groomedFatJets=self._parameters['groomedFatJets'].value
1083 algo=self._parameters['algo'].value
1084 rParam=self._parameters['rParam'].value
1085 getJetMCFlavour=self._parameters['getJetMCFlavour'].value
1086 genJetCollection=self._parameters['genJetCollection'].value
1087 genParticles=self._parameters['genParticles'].value
1088 jetCorrections=self._parameters['jetCorrections'].value
1089 btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
1090 btagInfos=list(self._parameters['btagInfos'].value)
1091 jetTrackAssociation=self._parameters['jetTrackAssociation'].value
1092 outputModules=list(self._parameters['outputModules'].value)
1093
1094
1095 if labelName=='UNDEFINED':
1096 undefinedLabelName(self)
1097
1098
1099 knownModules = process.producerNames().split()
1100
1101 if btagDiscriminators.count('None')>0:
1102 btagDiscriminators.remove('None')
1103 if btagInfos.count('None')>0:
1104 btagInfos.remove('None')
1105 bTagging=(len(btagDiscriminators)>0 or len(btagInfos)>0)
1106
1107 infos = 0
1108 for info in btagInfos:
1109 if info.startswith('pf'): infos = infos + 1
1110 if 'softpf' in info.lower(): infos = infos + 1
1111 tags = 0
1112 for tag in btagDiscriminators:
1113 if tag.startswith('pf'): tags = tags + 1
1114 if 'softpf' in tag.lower(): tags = tags + 1
1115 bTaggingLegacy=(len(btagDiscriminators)>tags or len(btagInfos)>infos)
1116
1117
1118
1119 _labelName=labelName[:1].upper()+labelName[1:]
1120
1121
1122 _algo=''
1123 for x in ["ak", "ca", "kt"]:
1124 if x in algo.lower():
1125 _algo=supportedJetAlgos[x]
1126 break
1127 if _algo=='':
1128 unsupportedJetAlgorithm(self)
1129
1130 from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJets
1131 if 'patJets'+_labelName+postfix in knownModules :
1132 _newPatJets=getattr(process, 'patJets'+_labelName+postfix)
1133 _newPatJets.jetSource=jetSource
1134 else :
1135 addToProcessAndTask('patJets'+_labelName+postfix, patJets.clone(jetSource=jetSource), process, task)
1136 _newPatJets=getattr(process, 'patJets'+_labelName+postfix)
1137 knownModules.append('patJets'+_labelName+postfix)
1138
1139 from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
1140 if 'selectedPatJets'+_labelName+postfix in knownModules :
1141 _newSelectedPatJets=getattr(process, 'selectedPatJets'+_labelName+postfix)
1142 _newSelectedPatJets.src='patJets'+_labelName+postfix
1143 else :
1144 addToProcessAndTask('selectedPatJets'+_labelName+postfix,
1145 selectedPatJets.clone(src='patJets'+_labelName+postfix),
1146 process, task)
1147 knownModules.append('selectedPatJets'+_labelName+postfix)
1148
1149
1150 from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch
1151 if 'patJetPartonMatch'+_labelName+postfix in knownModules :
1152 _newPatJetPartonMatch=getattr(process, 'patJetPartonMatch'+_labelName+postfix)
1153 _newPatJetPartonMatch.src=jetSource
1154 _newPatJetPartonMatch.matched=genParticles
1155 else :
1156 addToProcessAndTask('patJetPartonMatch'+_labelName+postfix,
1157 patJetPartonMatch.clone(src=jetSource, matched=genParticles),
1158 process, task)
1159 knownModules.append('patJetPartonMatch'+_labelName+postfix)
1160
1161 from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
1162 if 'patJetGenJetMatch'+_labelName+postfix in knownModules :
1163 _newPatJetGenJetMatch=getattr(process, 'patJetGenJetMatch'+_labelName+postfix)
1164 _newPatJetGenJetMatch.src=jetSource
1165 _newPatJetGenJetMatch.maxDeltaR=rParam
1166 _newPatJetGenJetMatch.matched=genJetCollection
1167 else :
1168 addToProcessAndTask('patJetGenJetMatch'+_labelName+postfix,
1169 patJetGenJetMatch.clone(src=jetSource, maxDeltaR=rParam, matched=genJetCollection),
1170 process, task)
1171 knownModules.append('patJetGenJetMatch'+_labelName+postfix)
1172
1173 _newPatJets.genJetMatch.setModuleLabel('patJetGenJetMatch'+_labelName+postfix)
1174 _newPatJets.genPartonMatch.setModuleLabel('patJetPartonMatch'+_labelName+postfix)
1175
1176 if (getJetMCFlavour):
1177
1178
1179 from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonsLegacy
1180 if 'patJetPartonsLegacy'+postfix not in knownModules :
1181 addToProcessAndTask('patJetPartonsLegacy'+postfix, patJetPartonsLegacy.clone(src=genParticles),
1182 process, task)
1183 knownModules.append('patJetPartonsLegacy'+postfix)
1184 else:
1185 getattr(process, 'patJetPartonsLegacy'+postfix).src=genParticles
1186
1187 from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonAssociationLegacy
1188 if 'patJetPartonAssociationLegacy'+_labelName+postfix in knownModules :
1189 _newPatJetPartonAssociation=getattr(process, 'patJetPartonAssociationLegacy'+_labelName+postfix)
1190 _newPatJetPartonAssociation.jets=jetSource
1191 else :
1192 addToProcessAndTask('patJetPartonAssociationLegacy'+_labelName+postfix,
1193 patJetPartonAssociationLegacy.clone(jets=jetSource), process, task)
1194 knownModules.append('patJetPartonAssociationLegacy'+_labelName+postfix)
1195
1196 from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociationLegacy
1197 if 'patJetFlavourAssociationLegacy'+_labelName+postfix in knownModules :
1198 _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociationLegacy'+_labelName+postfix)
1199 _newPatJetFlavourAssociation.srcByReference='patJetPartonAssociationLegacy'+_labelName+postfix
1200 else:
1201 addToProcessAndTask('patJetFlavourAssociationLegacy'+_labelName+postfix,
1202 patJetFlavourAssociationLegacy.clone(
1203 srcByReference='patJetPartonAssociationLegacy'+_labelName+postfix),
1204 process, task)
1205 knownModules.append('patJetFlavourAssociationLegacy'+_labelName+postfix)
1206
1207 _newPatJets.JetPartonMapSource.setModuleLabel('patJetFlavourAssociationLegacy'+_labelName+postfix)
1208
1209
1210 from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartons
1211 if 'patJetPartons'+postfix not in knownModules :
1212 addToProcessAndTask('patJetPartons'+postfix, patJetPartons.clone(particles=genParticles), process, task)
1213 knownModules.append('patJetPartons'+postfix)
1214 else:
1215 getattr(process, 'patJetPartons'+postfix).particles=genParticles
1216
1217 from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation
1218 if 'patJetFlavourAssociation'+_labelName+postfix in knownModules :
1219 _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix)
1220 _newPatJetFlavourAssociation.jets=jetSource
1221 _newPatJetFlavourAssociation.jetAlgorithm=_algo
1222 _newPatJetFlavourAssociation.rParam=rParam
1223 _newPatJetFlavourAssociation.bHadrons=cms.InputTag("patJetPartons"+postfix,"bHadrons")
1224 _newPatJetFlavourAssociation.cHadrons=cms.InputTag("patJetPartons"+postfix,"cHadrons")
1225 _newPatJetFlavourAssociation.partons=cms.InputTag("patJetPartons"+postfix,"physicsPartons")
1226 _newPatJetFlavourAssociation.leptons=cms.InputTag("patJetPartons"+postfix,"leptons")
1227 else :
1228 addToProcessAndTask('patJetFlavourAssociation'+_labelName+postfix,
1229 patJetFlavourAssociation.clone(
1230 jets=jetSource,
1231 jetAlgorithm=_algo,
1232 rParam=rParam,
1233 bHadrons = cms.InputTag("patJetPartons"+postfix,"bHadrons"),
1234 cHadrons = cms.InputTag("patJetPartons"+postfix,"cHadrons"),
1235 partons = cms.InputTag("patJetPartons"+postfix,"physicsPartons"),
1236 leptons = cms.InputTag("patJetPartons"+postfix,"leptons")),
1237 process, task)
1238
1239 knownModules.append('patJetFlavourAssociation'+_labelName+postfix)
1240 if 'Puppi' in jetSource.value() and pfCandidates.value() == 'particleFlow':
1241 _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix)
1242 _newPatJetFlavourAssociation.weights = cms.InputTag("puppi")
1243
1244 _newPatJets.JetFlavourInfoSource.setModuleLabel('patJetFlavourAssociation'+_labelName+postfix)
1245
1246 if fatJets != cms.InputTag('') and groomedFatJets != cms.InputTag(''):
1247 _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix)
1248 _newPatJetFlavourAssociation.jets=fatJets
1249 _newPatJetFlavourAssociation.groomedJets=groomedFatJets
1250 _newPatJetFlavourAssociation.subjets=jetSource
1251 _newPatJets.JetFlavourInfoSource=cms.InputTag('patJetFlavourAssociation'+_labelName+postfix,'SubJets')
1252 else:
1253 _newPatJets.getJetMCFlavour = False
1254 _newPatJets.addJetFlavourInfo = False
1255
1256
1257 if (jetTrackAssociation or bTaggingLegacy):
1258
1259 from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertex, ak4JetTracksAssociatorExplicit
1260 if 'jetTracksAssociationAtVertex'+_labelName+postfix in knownModules :
1261 _newJetTracksAssociationAtVertex=getattr(process, 'jetTracksAssociatorAtVertex'+_labelName+postfix)
1262 _newJetTracksAssociationAtVertex.jets=jetSource
1263 _newJetTracksAssociationAtVertex.pvSrc=pvSource
1264 else:
1265 jetTracksAssociator=ak4JetTracksAssociatorAtVertex
1266 if explicitJTA:
1267 jetTracksAssociator=ak4JetTracksAssociatorExplicit
1268 addToProcessAndTask('jetTracksAssociatorAtVertex'+_labelName+postfix,
1269 jetTracksAssociator.clone(jets=jetSource,pvSrc=pvSource),
1270 process, task)
1271 knownModules.append('jetTracksAssociationAtVertex'+_labelName+postfix)
1272
1273 from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge
1274 if 'patJetCharge'+_labelName+postfix in knownModules :
1275 _newPatJetCharge=getattr(process, 'patJetCharge'+_labelName+postfix)
1276 _newPatJetCharge.src='jetTracksAssociatorAtVertex'+_labelName+postfix
1277 else:
1278 addToProcessAndTask('patJetCharge'+_labelName+postfix,
1279 patJetCharge.clone(src = 'jetTracksAssociatorAtVertex'+_labelName+postfix),
1280 process, task)
1281 knownModules.append('patJetCharge'+_labelName+postfix)
1282
1283 _newPatJets.addAssociatedTracks=True
1284 _newPatJets.trackAssociationSource=cms.InputTag('jetTracksAssociatorAtVertex'+_labelName+postfix)
1285 _newPatJets.addJetCharge=True
1286 _newPatJets.jetChargeSource=cms.InputTag('patJetCharge'+_labelName+postfix)
1287 else:
1288
1289 _newPatJets.addAssociatedTracks=False
1290 _newPatJets.trackAssociationSource=''
1291 _newPatJets.addJetCharge=False
1292 _newPatJets.jetChargeSource=''
1293
1294 if (bTagging):
1295 setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
1296 _algo, rParam, btagDiscriminators, btagInfos, _newPatJets, _labelName, btagPrefix, postfix)
1297 else:
1298 _newPatJets.addBTagInfo = False
1299 _newPatJets.addTagInfos = False
1300
1301 for outputModule in outputModules:
1302 if hasattr(process,outputModule):
1303 getattr(process,outputModule).outputCommands.append("drop *_"+'selected'+_labelName+postfix+"_tagInfos_*")
1304
1305
1306 if (jetCorrections != None):
1307
1308 checkJetCorrectionsFormat(jetCorrections)
1309
1310 setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, _newPatJets, _labelName, postfix)
1311 else:
1312
1313 _newPatJets.addJetCorrFactors=False
1314
1315 addJetCollection=AddJetCollection()
1316
1317 class SwitchJetCollection(ConfigToolBase):
1318 """
1319 Tool to switch parameters of the PAT jet collection to your PAT Tuple.
1320 """
1321 _label='switchJetCollection'
1322 _defaultParameters=dicttypes.SortedKeysDict()
1323
1324 def __init__(self):
1325 """
1326 Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.
1327 """
1328
1329 ConfigToolBase.__init__(self)
1330
1331 self.addParameter(self._defaultParameters,'postfix','', "postfix from usePF2PAT")
1332 self.addParameter(self._defaultParameters,'btagPrefix','', "Prefix to be added to b-tag discriminator and TagInfo names", str)
1333 self.addParameter(self._defaultParameters,'jetSource','', "Label of the input collection from which the new patJet collection should be created", cms.InputTag)
1334 self.addParameter(self._defaultParameters,'pfCandidates',cms.InputTag('particleFlow'), "Label of the input collection for candidatecandidatese used in b-tagging", cms.InputTag)
1335 self.addParameter(self._defaultParameters,'explicitJTA', False, "Use explicit jet-track association")
1336 self.addParameter(self._defaultParameters,'pvSource',cms.InputTag('offlinePrimaryVertices'), "Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
1337 self.addParameter(self._defaultParameters,'svSource',cms.InputTag('inclusiveCandidateSecondaryVertices'), "Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
1338 self.addParameter(self._defaultParameters,'elSource',cms.InputTag('gedGsfElectrons'), "Label of the input collection for electrons used in b-tagging", cms.InputTag)
1339 self.addParameter(self._defaultParameters,'muSource',cms.InputTag('muons'), "Label of the input collection for muons used in b-tagging", cms.InputTag)
1340 self.addParameter(self._defaultParameters,'runIVF', False, "Re-run IVF secondary vertex reconstruction")
1341 self.addParameter(self._defaultParameters,'tightBTagNTkHits', False, "Enable legacy tight b-tag track selection")
1342 self.addParameter(self._defaultParameters,'loadStdRecoBTag', False, "Load the standard reconstruction b-tagging modules")
1343 self.addParameter(self._defaultParameters,'svClustering', False, "Secondary vertices ghost-associated to jets using jet clustering (mostly intended for subjets)")
1344 self.addParameter(self._defaultParameters,'fatJets', cms.InputTag(''), "Fat jet collection used for secondary vertex clustering", cms.InputTag)
1345 self.addParameter(self._defaultParameters,'groomedFatJets', cms.InputTag(''), "Groomed fat jet collection used for secondary vertex clustering", cms.InputTag)
1346 self.addParameter(self._defaultParameters,'algo', 'AK', "Jet algorithm of the input collection from which the new patJet collection should be created")
1347 self.addParameter(self._defaultParameters,'rParam', 0.4, "Jet size (distance parameter R used in jet clustering)")
1348 self.addParameter(self._defaultParameters,'getJetMCFlavour', True, "Get jet MC truth flavour")
1349 self.addParameter(self._defaultParameters,'genJetCollection', cms.InputTag("ak4GenJets"), "GenJet collection to match to")
1350 self.addParameter(self._defaultParameters,'genParticles', cms.InputTag("genParticles"), "GenParticle collection to be used", cms.InputTag)
1351 self.addParameter(self._defaultParameters,'jetCorrections',None, "Add all relevant information about jet energy corrections that you want to be added to your new patJet \
1352 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 \
1353 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 \
1354 new patJet collection. This should be given as a list of strings. Available values are L1Offset, L1FastJet, L1JPTOffset, L2Relative, L3Absolute, L5Falvour, L7Parton; the \
1355 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 \
1356 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 \
1357 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)
1358 self.addParameter(self._defaultParameters,'btagDiscriminators',['None'], "If you are interested in btagging in general the btag discriminators is all relevant \
1359 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 \
1360 discriminator information will be added to your new patJet collection.", allowedValues=(list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list)
1361 self.addParameter(self._defaultParameters,'btagInfos',['None'], "The btagInfos objects conatin all relevant information from which all discriminators of a certain \
1362 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 \
1363 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 \
1364 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)
1365 self.addParameter(self._defaultParameters,'jetTrackAssociation',False, "Add JetTrackAssociation and JetCharge from reconstructed tracks to your new patJet collection. This \
1366 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 \
1367 your new patJetCollection. If btag information is added to the new patJet collection this information will be added automatically.")
1368 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 \
1369 be added, in case you use more than one output module.")
1370
1371 self._parameters=copy.deepcopy(self._defaultParameters)
1372
1373 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 \
1374 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 \
1375 parameter for more information."
1376
1377 def getDefaultParameters(self):
1378 """
1379 Return default parameters of the class
1380 """
1381 return self._defaultParameters
1382
1383 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):
1384 """
1385 Function call wrapper. This will check the parameters and call the actual implementation that
1386 can be found in toolCode via the base class function apply.
1387 """
1388 if postfix is None:
1389 postfix=self._defaultParameters['postfix'].value
1390 self.setParameter('postfix', postfix)
1391 if btagPrefix is None:
1392 btagPrefix=self._defaultParameters['btagPrefix'].value
1393 self.setParameter('btagPrefix', btagPrefix)
1394 if jetSource is None:
1395 jetSource=self._defaultParameters['jetSource'].value
1396 self.setParameter('jetSource', jetSource)
1397 if pfCandidates is None:
1398 pfCandidates=self._defaultParameters['pfCandidates'].value
1399 self.setParameter('pfCandidates', pfCandidates)
1400 if explicitJTA is None:
1401 explicitJTA=self._defaultParameters['explicitJTA'].value
1402 self.setParameter('explicitJTA', explicitJTA)
1403 if pvSource is None:
1404 pvSource=self._defaultParameters['pvSource'].value
1405 self.setParameter('pvSource', pvSource)
1406 if svSource is None:
1407 svSource=self._defaultParameters['svSource'].value
1408 self.setParameter('svSource', svSource)
1409 if elSource is None:
1410 elSource=self._defaultParameters['elSource'].value
1411 self.setParameter('elSource', elSource)
1412 if muSource is None:
1413 muSource=self._defaultParameters['muSource'].value
1414 self.setParameter('muSource', muSource)
1415 if runIVF is None:
1416 runIVF=self._defaultParameters['runIVF'].value
1417 self.setParameter('runIVF', runIVF)
1418 if tightBTagNTkHits is None:
1419 tightBTagNTkHits=self._defaultParameters['tightBTagNTkHits'].value
1420 self.setParameter('tightBTagNTkHits', tightBTagNTkHits)
1421 if loadStdRecoBTag is None:
1422 loadStdRecoBTag=self._defaultParameters['loadStdRecoBTag'].value
1423 self.setParameter('loadStdRecoBTag', loadStdRecoBTag)
1424 if svClustering is None:
1425 svClustering=self._defaultParameters['svClustering'].value
1426 self.setParameter('svClustering', svClustering)
1427 if fatJets is None:
1428 fatJets=self._defaultParameters['fatJets'].value
1429 self.setParameter('fatJets', fatJets)
1430 if groomedFatJets is None:
1431 groomedFatJets=self._defaultParameters['groomedFatJets'].value
1432 self.setParameter('groomedFatJets', groomedFatJets)
1433 if algo is None:
1434 algo=self._defaultParameters['algo'].value
1435 self.setParameter('algo', algo)
1436 if rParam is None:
1437 rParam=self._defaultParameters['rParam'].value
1438 self.setParameter('rParam', rParam)
1439 if getJetMCFlavour is None:
1440 getJetMCFlavour=self._defaultParameters['getJetMCFlavour'].value
1441 self.setParameter('getJetMCFlavour', getJetMCFlavour)
1442 if genJetCollection is None:
1443 genJetCollection=self._defaultParameters['genJetCollection'].value
1444 self.setParameter('genJetCollection', genJetCollection)
1445 if genParticles is None:
1446 genParticles=self._defaultParameters['genParticles'].value
1447 self.setParameter('genParticles', genParticles)
1448 if jetCorrections is None:
1449 jetCorrections=self._defaultParameters['jetCorrections'].value
1450 self.setParameter('jetCorrections', jetCorrections)
1451 if btagDiscriminators is None:
1452 btagDiscriminators=self._defaultParameters['btagDiscriminators'].value
1453 self.setParameter('btagDiscriminators', btagDiscriminators)
1454 if btagInfos is None:
1455 btagInfos=self._defaultParameters['btagInfos'].value
1456 self.setParameter('btagInfos', btagInfos)
1457 if jetTrackAssociation is None:
1458 jetTrackAssociation=self._defaultParameters['jetTrackAssociation'].value
1459 self.setParameter('jetTrackAssociation', jetTrackAssociation)
1460 if outputModules is None:
1461 outputModules=self._defaultParameters['outputModules'].value
1462 self.setParameter('outputModules', outputModules)
1463 self.apply(process)
1464
1465 def toolCode(self, process):
1466 """
1467 Tool code implementation
1468 """
1469
1470 postfix=self._parameters['postfix'].value
1471 btagPrefix=self._parameters['btagPrefix'].value
1472 jetSource=self._parameters['jetSource'].value
1473 pfCandidates=self._parameters['pfCandidates'].value
1474 explicitJTA=self._parameters['explicitJTA'].value
1475 pvSource=self._parameters['pvSource'].value
1476 svSource=self._parameters['svSource'].value
1477 elSource=self._parameters['elSource'].value
1478 muSource=self._parameters['muSource'].value
1479 runIVF=self._parameters['runIVF'].value
1480 tightBTagNTkHits=self._parameters['tightBTagNTkHits'].value
1481 loadStdRecoBTag=self._parameters['loadStdRecoBTag'].value
1482 svClustering=self._parameters['svClustering'].value
1483 fatJets=self._parameters['fatJets'].value
1484 groomedFatJets=self._parameters['groomedFatJets'].value
1485 algo=self._parameters['algo'].value
1486 rParam=self._parameters['rParam'].value
1487 getJetMCFlavour=self._parameters['getJetMCFlavour'].value
1488 genJetCollection=self._parameters['genJetCollection'].value
1489 genParticles=self._parameters['genParticles'].value
1490 jetCorrections=self._parameters['jetCorrections'].value
1491 btagDiscriminators=self._parameters['btagDiscriminators'].value
1492 btagInfos=self._parameters['btagInfos'].value
1493 jetTrackAssociation=self._parameters['jetTrackAssociation'].value
1494 outputModules=self._parameters['outputModules'].value
1495
1496
1497 addJetCollection(
1498 process,
1499 labelName='',
1500 postfix=postfix,
1501 btagPrefix=btagPrefix,
1502 jetSource=jetSource,
1503 pfCandidates=pfCandidates,
1504 explicitJTA=explicitJTA,
1505 pvSource=pvSource,
1506 svSource=svSource,
1507 elSource=elSource,
1508 muSource=muSource,
1509 runIVF=runIVF,
1510 tightBTagNTkHits=tightBTagNTkHits,
1511 loadStdRecoBTag=loadStdRecoBTag,
1512 svClustering=svClustering,
1513 fatJets=fatJets,
1514 groomedFatJets=groomedFatJets,
1515 algo=algo,
1516 rParam=rParam,
1517 getJetMCFlavour=getJetMCFlavour,
1518 genJetCollection=genJetCollection,
1519 genParticles=genParticles,
1520 jetCorrections=jetCorrections,
1521 btagDiscriminators=btagDiscriminators,
1522 btagInfos=btagInfos,
1523 jetTrackAssociation=jetTrackAssociation,
1524 outputModules=outputModules,
1525 )
1526
1527 switchJetCollection=SwitchJetCollection()
1528
1529
1530 class UpdateJetCollection(ConfigToolBase):
1531 """
1532 Tool to update a jet collection in your PAT Tuple (primarily intended for MiniAOD for which the default input argument values have been set).
1533 """
1534 _label='updateJetCollection'
1535 _defaultParameters=dicttypes.SortedKeysDict()
1536
1537 def __init__(self):
1538 """
1539 Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.
1540 """
1541
1542 ConfigToolBase.__init__(self)
1543
1544 self.addParameter(self._defaultParameters,'labelName', '', "Label name of the new patJet collection.", str)
1545 self.addParameter(self._defaultParameters,'postfix','', "Postfix from usePF2PAT.", str)
1546 self.addParameter(self._defaultParameters,'btagPrefix','', "Prefix to be added to b-tag discriminator and TagInfo names", str)
1547 self.addParameter(self._defaultParameters,'jetSource','', "Label of the input collection from which the new patJet collection should be created", cms.InputTag)
1548 self.addParameter(self._defaultParameters,'pfCandidates',cms.InputTag('packedPFCandidates'), "Label of the input collection for candidatecandidatese used in b-tagging", cms.InputTag)
1549 self.addParameter(self._defaultParameters,'explicitJTA', False, "Use explicit jet-track association")
1550 self.addParameter(self._defaultParameters,'pvSource',cms.InputTag('offlineSlimmedPrimaryVertices'), "Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
1551 self.addParameter(self._defaultParameters,'svSource',cms.InputTag('slimmedSecondaryVertices'), "Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
1552 self.addParameter(self._defaultParameters,'elSource',cms.InputTag('slimmedElectrons'), "Label of the input collection for electrons used in b-tagging", cms.InputTag)
1553 self.addParameter(self._defaultParameters,'muSource',cms.InputTag('slimmedMuons'), "Label of the input collection for muons used in b-tagging", cms.InputTag)
1554 self.addParameter(self._defaultParameters,'runIVF', False, "Re-run IVF secondary vertex reconstruction")
1555 self.addParameter(self._defaultParameters,'tightBTagNTkHits', False, "Enable legacy tight b-tag track selection")
1556 self.addParameter(self._defaultParameters,'loadStdRecoBTag', False, "Load the standard reconstruction b-tagging modules")
1557 self.addParameter(self._defaultParameters,'svClustering', False, "Secondary vertices ghost-associated to jets using jet clustering (mostly intended for subjets)")
1558 self.addParameter(self._defaultParameters,'fatJets', cms.InputTag(''), "Fat jet collection used for secondary vertex clustering", cms.InputTag)
1559 self.addParameter(self._defaultParameters,'groomedFatJets', cms.InputTag(''), "Groomed fat jet collection used for secondary vertex clustering", cms.InputTag)
1560 self.addParameter(self._defaultParameters,'algo', 'AK', "Jet algorithm of the input collection from which the new patJet collection should be created")
1561 self.addParameter(self._defaultParameters,'rParam', 0.4, "Jet size (distance parameter R used in jet clustering)")
1562 self.addParameter(self._defaultParameters,'sortByPt', True, "Set to False to not modify incoming jet order")
1563 self.addParameter(self._defaultParameters,'printWarning', True, "To be use as False in production to reduce log size")
1564 self.addParameter(self._defaultParameters,'jetCorrections',None, "Add all relevant information about jet energy corrections that you want to be added to your new patJet \
1565 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 \
1566 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 \
1567 new patJet collection. This should be given as a list of strings. Available values are L1Offset, L1FastJet, L1JPTOffset, L2Relative, L3Absolute, L5Falvour, L7Parton; the \
1568 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 \
1569 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 \
1570 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\' \
1571 and \'type-2\' are not case sensitive.", tuple, acceptNoneValue=True)
1572 self.addParameter(self._defaultParameters,'btagDiscriminators',['None'], "If you are interested in btagging, in most cases just the labels of the btag discriminators that \
1573 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. \
1574 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)
1575 self.addParameter(self._defaultParameters,'btagInfos',['None'], "The btagInfos objects contain all relevant information from which all discriminators of a certain \
1576 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 \
1577 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 \
1578 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 \
1579 will be added to your new patJet collection.", allowedValues=supportedBtagInfos,Type=list)
1580 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 \
1581 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 \
1582 to more than one output module.")
1583
1584 self._parameters=copy.deepcopy(self._defaultParameters)
1585
1586 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\
1587 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 \
1588 the descriptions of each parameter for more information."
1589
1590 def getDefaultParameters(self):
1591 """
1592 Return default parameters of the class
1593 """
1594 return self._defaultParameters
1595
1596 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):
1597 """
1598 Function call wrapper. This will check the parameters and call the actual implementation that
1599 can be found in toolCode via the base class function apply.
1600 """
1601 if labelName is None:
1602 labelName=self._defaultParameters['labelName'].value
1603 self.setParameter('labelName', labelName)
1604 if postfix is None:
1605 postfix=self._defaultParameters['postfix'].value
1606 self.setParameter('postfix', postfix)
1607 if btagPrefix is None:
1608 btagPrefix=self._defaultParameters['btagPrefix'].value
1609 self.setParameter('btagPrefix', btagPrefix)
1610 if jetSource is None:
1611 jetSource=self._defaultParameters['jetSource'].value
1612 self.setParameter('jetSource', jetSource)
1613 if pfCandidates is None:
1614 pfCandidates=self._defaultParameters['pfCandidates'].value
1615 self.setParameter('pfCandidates', pfCandidates)
1616 if explicitJTA is None:
1617 explicitJTA=self._defaultParameters['explicitJTA'].value
1618 self.setParameter('explicitJTA', explicitJTA)
1619 if pvSource is None:
1620 pvSource=self._defaultParameters['pvSource'].value
1621 self.setParameter('pvSource', pvSource)
1622 if svSource is None:
1623 svSource=self._defaultParameters['svSource'].value
1624 self.setParameter('svSource', svSource)
1625 if elSource is None:
1626 elSource=self._defaultParameters['elSource'].value
1627 self.setParameter('elSource', elSource)
1628 if muSource is None:
1629 muSource=self._defaultParameters['muSource'].value
1630 self.setParameter('muSource', muSource)
1631 if runIVF is None:
1632 runIVF=self._defaultParameters['runIVF'].value
1633 self.setParameter('runIVF', runIVF)
1634 if tightBTagNTkHits is None:
1635 tightBTagNTkHits=self._defaultParameters['tightBTagNTkHits'].value
1636 self.setParameter('tightBTagNTkHits', tightBTagNTkHits)
1637 if loadStdRecoBTag is None:
1638 loadStdRecoBTag=self._defaultParameters['loadStdRecoBTag'].value
1639 self.setParameter('loadStdRecoBTag', loadStdRecoBTag)
1640 if svClustering is None:
1641 svClustering=self._defaultParameters['svClustering'].value
1642 self.setParameter('svClustering', svClustering)
1643 if fatJets is None:
1644 fatJets=self._defaultParameters['fatJets'].value
1645 self.setParameter('fatJets', fatJets)
1646 if groomedFatJets is None:
1647 groomedFatJets=self._defaultParameters['groomedFatJets'].value
1648 self.setParameter('groomedFatJets', groomedFatJets)
1649 if algo is None:
1650 algo=self._defaultParameters['algo'].value
1651 self.setParameter('algo', algo)
1652 if rParam is None:
1653 rParam=self._defaultParameters['rParam'].value
1654 self.setParameter('rParam', rParam)
1655 if sortByPt is None:
1656 sortByPt=self._defaultParameters['sortByPt'].value
1657 self.setParameter('sortByPt', sortByPt)
1658 if printWarning is None:
1659 printWarning=self._defaultParameters['printWarning'].value
1660 self.setParameter('printWarning', printWarning)
1661 if jetCorrections is None:
1662 jetCorrections=self._defaultParameters['jetCorrections'].value
1663 self.setParameter('jetCorrections', jetCorrections)
1664 if btagDiscriminators is None:
1665 btagDiscriminators=self._defaultParameters['btagDiscriminators'].value
1666 self.setParameter('btagDiscriminators', btagDiscriminators)
1667 if btagInfos is None:
1668 btagInfos=self._defaultParameters['btagInfos'].value
1669 self.setParameter('btagInfos', btagInfos)
1670 self.apply(process)
1671
1672 def toolCode(self, process):
1673 """
1674 Tool code implementation
1675 """
1676
1677 labelName=self._parameters['labelName'].value
1678 postfix=self._parameters['postfix'].value
1679 btagPrefix=self._parameters['btagPrefix'].value
1680 jetSource=self._parameters['jetSource'].value
1681 pfCandidates=self._parameters['pfCandidates'].value
1682 explicitJTA=self._parameters['explicitJTA'].value
1683 pvSource=self._parameters['pvSource'].value
1684 svSource=self._parameters['svSource'].value
1685 elSource=self._parameters['elSource'].value
1686 muSource=self._parameters['muSource'].value
1687 runIVF=self._parameters['runIVF'].value
1688 tightBTagNTkHits=self._parameters['tightBTagNTkHits'].value
1689 loadStdRecoBTag=self._parameters['loadStdRecoBTag'].value
1690 svClustering=self._parameters['svClustering'].value
1691 fatJets=self._parameters['fatJets'].value
1692 groomedFatJets=self._parameters['groomedFatJets'].value
1693 algo=self._parameters['algo'].value
1694 rParam=self._parameters['rParam'].value
1695 sortByPt=self._parameters['sortByPt'].value
1696 printWarning=self._parameters['printWarning'].value
1697 jetCorrections=self._parameters['jetCorrections'].value
1698 btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
1699 btagInfos=list(self._parameters['btagInfos'].value)
1700
1701
1702 knownModules = process.producerNames().split()
1703
1704 if btagDiscriminators.count('None')>0:
1705 btagDiscriminators.remove('None')
1706 if btagInfos.count('None')>0:
1707 btagInfos.remove('None')
1708 bTagging=(len(btagDiscriminators)>0 or len(btagInfos)>0)
1709
1710
1711
1712
1713 _labelName=labelName[:1].upper()+labelName[1:]
1714
1715
1716 _algo=''
1717 for x in ["ak", "ca", "kt"]:
1718 if x in algo.lower():
1719 _algo=supportedJetAlgos[x]
1720 break
1721 if _algo=='':
1722 unsupportedJetAlgorithm(self)
1723
1724 task = getPatAlgosToolsTask(process)
1725
1726
1727 from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cfi import updatedPatJets
1728 if not sortByPt:
1729 updatedPatJets.sort = cms.bool(False)
1730 if 'updatedPatJets'+_labelName+postfix in knownModules :
1731 _newPatJets=getattr(process, 'updatedPatJets'+_labelName+postfix)
1732 _newPatJets.jetSource=jetSource
1733 else :
1734 addToProcessAndTask('updatedPatJets'+_labelName+postfix,
1735 updatedPatJets.clone(jetSource=jetSource,
1736 printWarning=printWarning), process, task)
1737 _newPatJets=getattr(process, 'updatedPatJets'+_labelName+postfix)
1738 knownModules.append('updatedPatJets'+_labelName+postfix)
1739
1740 from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
1741 if 'selectedUpdatedPatJets'+_labelName+postfix in knownModules :
1742 _newSelectedPatJets=getattr(process, 'selectedUpdatedPatJets'+_labelName+postfix)
1743 _newSelectedPatJets.src='updatedPatJets'+_labelName+postfix
1744 else :
1745 addToProcessAndTask('selectedUpdatedPatJets'+_labelName+postfix,
1746 selectedPatJets.clone(src='updatedPatJets'+_labelName+postfix),
1747 process, task)
1748 knownModules.append('selectedUpdatedPatJets'+_labelName+postfix)
1749
1750
1751 if (bTagging):
1752 if printWarning:
1753 sys.stderr.write("**************************************************************\n")
1754 sys.stderr.write("b tagging needs to be run on uncorrected jets. Hence, the JECs\n")
1755 sys.stderr.write("will first be undone for 'updatedPatJets%s' and then applied to\n" % (_labelName+postfix) )
1756 sys.stderr.write("'updatedPatJetsTransientCorrected%s'.\n" % (_labelName+postfix) )
1757 sys.stderr.write("**************************************************************\n")
1758 _jetSource = cms.InputTag('updatedPatJets'+_labelName+postfix)
1759
1760 self(
1761 process,
1762 labelName = ('TransientCorrected'+_labelName),
1763 jetSource = _jetSource,
1764 pfCandidates=pfCandidates,
1765 explicitJTA=explicitJTA,
1766 pvSource=pvSource,
1767 svSource=svSource,
1768 elSource=elSource,
1769 muSource=muSource,
1770 runIVF=runIVF,
1771 tightBTagNTkHits=tightBTagNTkHits,
1772 loadStdRecoBTag=loadStdRecoBTag,
1773 svClustering=svClustering,
1774 fatJets=fatJets,
1775 groomedFatJets=groomedFatJets,
1776 algo=algo,
1777 rParam=rParam,
1778 jetCorrections = jetCorrections,
1779 btagPrefix = btagPrefix,
1780 postfix = postfix
1781 )
1782
1783 _patJets=getattr(process, 'updatedPatJetsTransientCorrected'+_labelName+postfix)
1784 setupBTagging(process, _jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
1785 _algo, rParam, btagDiscriminators, btagInfos, _patJets, _labelName, btagPrefix, postfix)
1786
1787 _newSelectedPatJets=getattr(process, 'selectedUpdatedPatJets'+_labelName+postfix)
1788 _newSelectedPatJets.src='updatedPatJetsTransientCorrected'+_labelName+postfix
1789
1790 delattr(process, 'selectedUpdatedPatJetsTransientCorrected'+_labelName+postfix)
1791 else:
1792 _newPatJets.addBTagInfo = False
1793 _newPatJets.addTagInfos = False
1794
1795
1796 if (jetCorrections is not None or bTagging):
1797
1798 if jetCorrections is None and bTagging:
1799 raise ValueError("Passing jetCorrections = None while running bTagging is likely not intended.")
1800 else:
1801 checkJetCorrectionsFormat(jetCorrections)
1802
1803 if jetCorrections[2].lower() != 'none' and jetCorrections[2] != '':
1804 sys.stderr.write("-------------------------------------------------------------------\n")
1805 sys.stderr.write(" Warning: MET correction was set to " + jetCorrections[2] + " but\n")
1806 sys.stderr.write(" will be ignored. Please set it to \"None\" to avoid\n")
1807 sys.stderr.write(" getting this warning.\n")
1808 sys.stderr.write("-------------------------------------------------------------------\n")
1809 jetCorrectionsList = list(jetCorrections)
1810 jetCorrectionsList[2] = 'None'
1811 jetCorrections = tuple(jetCorrectionsList)
1812
1813 if (bTagging):
1814 jetCorrections = ('AK4PFchs', cms.vstring([]), 'None')
1815
1816 setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, _newPatJets, _labelName, postfix)
1817 else:
1818
1819 _newPatJets.addJetCorrFactors=False
1820
1821 updateJetCollection=UpdateJetCollection()
1822
1823
1824 class AddJetID(ConfigToolBase):
1825 """
1826 Compute jet id for process
1827 """
1828 _label='addJetID'
1829 _defaultParameters=dicttypes.SortedKeysDict()
1830 def __init__(self):
1831 ConfigToolBase.__init__(self)
1832 self.addParameter(self._defaultParameters,'jetSrc','', "", Type=cms.InputTag)
1833 self.addParameter(self._defaultParameters,'jetIdTag','', "Tag to append to jet id map", Type=str)
1834 self._parameters=copy.deepcopy(self._defaultParameters)
1835 self._comment = ""
1836
1837 def getDefaultParameters(self):
1838 return self._defaultParameters
1839
1840 def __call__(self,process,
1841 jetSrc = None,
1842 jetIdTag = None) :
1843 if jetSrc is None:
1844 jetSrc=self._defaultParameters['jetSrc'].value
1845 if jetIdTag is None:
1846 jetIdTag=self._defaultParameters['jetIdTag'].value
1847 self.setParameter('jetSrc',jetSrc)
1848 self.setParameter('jetIdTag',jetIdTag)
1849 self.apply(process)
1850
1851 def toolCode(self, process):
1852 jetSrc=self._parameters['jetSrc'].value
1853 jetIdTag=self._parameters['jetIdTag'].value
1854
1855 jetIdLabel = jetIdTag + 'JetID'
1856 sys.stderr.write("Making new jet ID label with label " + jetIdTag + "\n")
1857
1858
1859 task = getPatAlgosToolsTask(process)
1860 process.load("RecoJets.JetProducers.ak4JetID_cfi")
1861 task.add(process.ak4JetID)
1862 addToProcessAndTask(jetIdLabel, process.ak4JetID.clone(src = jetSrc),
1863 process, task)
1864
1865
1866 addJetID=AddJetID()
1867
1868
1869 class SetTagInfos(ConfigToolBase):
1870 """
1871 Replace tag infos for collection jetSrc
1872 """
1873 _label='setTagInfos'
1874 _defaultParameters=dicttypes.SortedKeysDict()
1875 def __init__(self):
1876 ConfigToolBase.__init__(self)
1877 self.addParameter(self._defaultParameters,'coll',"patJets","jet collection to set tag infos for")
1878 self.addParameter(self._defaultParameters,'tagInfos',cms.vstring( ), "tag infos to set")
1879 self._parameters=copy.deepcopy(self._defaultParameters)
1880 self._comment = ""
1881
1882 def getDefaultParameters(self):
1883 return self._defaultParameters
1884
1885 def __call__(self,process,
1886 coll = None,
1887 tagInfos = None) :
1888 if coll is None:
1889 coll=self._defaultParameters['coll'].value
1890 if tagInfos is None:
1891 tagInfos=self._defaultParameters['tagInfos'].value
1892 self.setParameter('coll',coll)
1893 self.setParameter('tagInfos',tagInfos)
1894 self.apply(process)
1895
1896 def toolCode(self, process):
1897 coll=self._parameters['coll'].value
1898 tagInfos=self._parameters['tagInfos'].value
1899
1900 found = False
1901 newTags = cms.VInputTag()
1902 iNewTags = 0
1903 for k in tagInfos :
1904 for j in getattr( process, coll ).tagInfoSources :
1905 vv = j.value();
1906 if ( vv.find(k) != -1 ):
1907 found = True
1908 newTags.append( j )
1909
1910 if not found:
1911 raise RuntimeError("""
1912 Cannot replace tag infos in jet collection""" % (coll))
1913 else :
1914 getattr(process,coll).tagInfoSources = newTags
1915
1916 setTagInfos=SetTagInfos()
1917
1918 def deprecatedOptionOutputModule(obj):
1919 sys.stderr.write("-------------------------------------------------------\n")
1920 sys.stderr.write(" Error: the option 'outputModule' is not supported\n")
1921 sys.stderr.write(" anymore by:\n")
1922 sys.stderr.write(" " + obj._label + "\n")
1923 sys.stderr.write(" please use 'outputModules' now and specify the\n")
1924 sys.stderr.write(" names of all needed OutModules in there\n")
1925 sys.stderr.write(" (default: ['out'])\n")
1926 sys.stderr.write("-------------------------------------------------------\n")
1927 raise KeyError("Unsupported option 'outputModule' used in '"+obj._label+"'")
1928
1929 def undefinedLabelName(obj):
1930 sys.stderr.write("-------------------------------------------------------\n")
1931 sys.stderr.write(" Error: the jet 'labelName' is not defined.\n")
1932 sys.stderr.write(" All added jets must have 'labelName' defined.\n")
1933 sys.stderr.write("-------------------------------------------------------\n")
1934 raise KeyError("Undefined jet 'labelName' used in '"+obj._label+"'")
1935
1936 def unsupportedJetAlgorithm(obj):
1937 sys.stderr.write("-------------------------------------------------------\n")
1938 sys.stderr.write(" Error: Unsupported jet algorithm detected.\n")
1939 sys.stderr.write(" The supported algorithms are:\n")
1940 for key in supportedJetAlgos.keys():
1941 sys.stderr.write(" " + key.upper() + ", " + key.lower() + ": " + supportedJetAlgos[key] + "\n")
1942 sys.stderr.write("-------------------------------------------------------\n")
1943 raise KeyError("Unsupported jet algorithm used in '"+obj._label+"'")
1944
1945 def rerunningIVF():
1946 sys.stderr.write("-------------------------------------------------------------------\n")
1947 sys.stderr.write(" Warning: You are attempting to remake the IVF secondary vertices\n")
1948 sys.stderr.write(" already produced by the standard reconstruction. This\n")
1949 sys.stderr.write(" option is not enabled by default so please use it only if\n")
1950 sys.stderr.write(" you know what you are doing.\n")
1951 sys.stderr.write("-------------------------------------------------------------------\n")
1952
1953 def rerunningIVFMiniAOD():
1954 sys.stderr.write("-------------------------------------------------------------------\n")
1955 sys.stderr.write(" Warning: You are attempting to remake IVF secondary vertices from\n")
1956 sys.stderr.write(" MiniAOD. If that was your intention, note that secondary\n")
1957 sys.stderr.write(" vertices remade from MiniAOD will have somewhat degraded\n")
1958 sys.stderr.write(" performance compared to those remade from RECO/AOD.\n")
1959 sys.stderr.write("-------------------------------------------------------------------\n")