Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-23 02:25:54

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 
0004 from PhysicsTools.PatAlgos.tools.helpers import MassSearchReplaceAnyInputTagVisitor, addKeepStatement
0005 from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask
0006 
0007 def loadJetMETBTag(process):
0008 
0009     task = getPatAlgosToolsTask(process)
0010 
0011     import RecoParticleFlow.PFProducer.pfLinker_cff
0012     process.particleFlowPtrs = RecoParticleFlow.PFProducer.pfLinker_cff.particleFlowPtrs.clone()
0013     task.add(process.particleFlowPtrs)
0014 
0015     process.load("CommonTools.ParticleFlow.pfNoPileUpIso_cff")
0016     task.add(process.pfNoPileUpIsoTask)
0017     process.load("CommonTools.ParticleFlow.ParticleSelectors.pfSortByType_cff")
0018     task.add(process.pfSortByTypeTask)
0019 
0020     import RecoJets.Configuration.RecoPFJets_cff
0021     process.ak4PFJetsCHS = RecoJets.Configuration.RecoPFJets_cff.ak4PFJetsCHS.clone()
0022     task.add(process.ak4PFJetsCHS)
0023     # need also the non-CHS ones as they are used to seed taus
0024     process.ak4PFJets = RecoJets.Configuration.RecoPFJets_cff.ak4PFJets.clone()
0025     task.add(process.ak4PFJets)
0026     process.ak8PFJetsCHS = RecoJets.Configuration.RecoPFJets_cff.ak8PFJetsCHS.clone()
0027     task.add(process.ak8PFJetsCHS)
0028 
0029     process.fixedGridRhoAll = RecoJets.Configuration.RecoPFJets_cff.fixedGridRhoAll.clone()
0030     process.fixedGridRhoFastjetAll = RecoJets.Configuration.RecoPFJets_cff.fixedGridRhoFastjetAll.clone()
0031     process.fixedGridRhoFastjetCentral = RecoJets.Configuration.RecoPFJets_cff.fixedGridRhoFastjetCentral.clone()
0032     process.fixedGridRhoFastjetCentralChargedPileUp = RecoJets.Configuration.RecoPFJets_cff.fixedGridRhoFastjetCentralChargedPileUp.clone()
0033     process.fixedGridRhoFastjetCentralNeutral = RecoJets.Configuration.RecoPFJets_cff.fixedGridRhoFastjetCentralNeutral.clone()
0034     task.add( process.fixedGridRhoAll,
0035               process.fixedGridRhoFastjetAll,
0036               process.fixedGridRhoFastjetCentral,
0037               process.fixedGridRhoFastjetCentralChargedPileUp,
0038               process.fixedGridRhoFastjetCentralNeutral )
0039 
0040     process.load("RecoJets.JetAssociationProducers.ak4JTA_cff")
0041     task.add(process.ak4JTATask)
0042 
0043     process.load('RecoBTag.Configuration.RecoBTag_cff')
0044     task.add(process.btaggingTask)
0045 
0046     process.load("RecoMET.METProducers.pfMet_cfi")
0047     task.add(process.pfMet)
0048 
0049 
0050 def cleanPfCandidates(process, verbose=False):
0051     task = getPatAlgosToolsTask(process)
0052 
0053     #add producer at the beginning of the schedule
0054     process.load("CommonTools.ParticleFlow.pfCandidateRecalibrator_cfi")
0055     task.add(process.pfCandidateRecalibrator)
0056 
0057     replacePFCandidates = MassSearchReplaceAnyInputTagVisitor("particleFlow", "pfCandidateRecalibrator", verbose=verbose)
0058     replacePFTmpPtrs = MassSearchReplaceAnyInputTagVisitor("particleFlowTmpPtrs", "particleFlowPtrs", verbose=verbose)
0059     for everywhere in [ process.producers, process.filters, process.analyzers, process.psets, process.vpsets ]:
0060         for name,obj in everywhere.items():
0061             if obj != process.pfCandidateRecalibrator:
0062                 replacePFCandidates.doIt(obj, name)
0063                 replacePFTmpPtrs.doIt(obj, name)
0064 
0065 
0066     process.load("CommonTools.ParticleFlow.pfEGammaToCandidateRemapper_cfi")
0067     task.add(process.pfEGammaToCandidateRemapper)
0068     process.pfEGammaToCandidateRemapper.pf2pf = cms.InputTag("pfCandidateRecalibrator")
0069     process.reducedEgamma.gsfElectronsPFValMap = cms.InputTag("pfEGammaToCandidateRemapper","electrons")
0070     process.reducedEgamma.photonsPFValMap      = cms.InputTag("pfEGammaToCandidateRemapper","photons")
0071 
0072 
0073 def addDiscardedPFCandidates(process, inputCollection, verbose=False):
0074 
0075     task = getPatAlgosToolsTask(process)
0076 
0077     process.primaryVertexAssociationDiscardedCandidates = process.primaryVertexAssociation.clone(
0078         particles = inputCollection,
0079         )
0080     task.add(process.primaryVertexAssociationDiscardedCandidates)
0081 
0082     process.packedPFCandidatesDiscarded = process.packedPFCandidates.clone(
0083         inputCollection = inputCollection,
0084         PuppiNoLepSrc = cms.InputTag(""),
0085         PuppiSrc = cms.InputTag(""),
0086         secondaryVerticesForWhiteList = cms.VInputTag(),
0087         vertexAssociator = cms.InputTag("primaryVertexAssociationDiscardedCandidates","original")
0088         )
0089     task.add(process.packedPFCandidatesDiscarded)
0090 
0091     addKeepStatement(process, "keep patPackedCandidates_packedPFCandidates_*_*",
0092                              ["keep patPackedCandidates_packedPFCandidatesDiscarded_*_*"],
0093                               verbose=verbose)
0094 
0095 
0096 def customizeAll(process, verbose=False):
0097 
0098     if verbose:
0099         print("===>>> customizing the process for legacy rereco 2016")
0100 
0101     loadJetMETBTag(process)
0102 
0103     cleanPfCandidates(process, verbose)
0104     addDiscardedPFCandidates(process, cms.InputTag("pfCandidateRecalibrator","discarded"), verbose=verbose)
0105 
0106     return process