def makePuppies( process ): task = getPatAlgosToolsTask(process) process.load('CommonTools.PileupAlgos.Puppi_cff') task.add(process.puppi) process.pfNoLepPUPPI = cms.EDFilter("PdgIdCandViewSelector", src = cms.InputTag("particleFlow"), pdgId = cms.vint32( 1,2,22,111,130,310,2112,211,-211,321,-321,999211,2212,-2212 ) ) task.add(process.pfNoLepPUPPI) process.pfLeptonsPUPPET = cms.EDFilter("PdgIdCandViewSelector", src = cms.InputTag("particleFlow"), pdgId = cms.vint32(-11,11,-13,13), ) task.add(process.pfLeptonsPUPPET) addToProcessAndTask('puppiNoLep', process.puppi.clone(), process, task) process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI') process.puppiMerged = cms.EDProducer("CandViewMerger",src = cms.VInputTag( 'puppiNoLep','pfLeptonsPUPPET')) task.add(process.puppiMerged) process.load('CommonTools.PileupAlgos.PhotonPuppi_cff') task.add(process.puppiPhoton) addToProcessAndTask('puppiForMET', process.puppiPhoton.clone(), process, task) #Line below replaces reference linking wiht delta R matching because the puppi references after merging are not consistent with those of the original PF collection process.puppiForMET.useRefs = False #Line below points puppi MET to puppi no lepton which increases the response process.puppiForMET.puppiCandName = 'puppiMerged'
def _add_deepMET(process): from RecoMET.METPUSubtraction.deepMETProducer_cff import deepMETsResolutionTune, deepMETsResponseTune addToProcessAndTask('deepMETsResolutionTune', deepMETsResolutionTune, process, task) addToProcessAndTask('deepMETsResponseTune', deepMETsResponseTune, process, task)
def makeRecoJetCollection(process, pfCandCollection, coneSize, useCHSAlgo, postfix): task = getPatAlgosToolsTask(process) jetColName = "ak" + str(int(coneSize * 10)) + "PFJets" internalPfCandColl = pfCandCollection if useCHSAlgo: addToProcessAndTask( "tmpPFCandCollPtr" + postfix, cms.EDProducer("PFCandidateFwdPtrProducer", src=cms.InputTag(pfCandCollection)), process, task) process.load("CommonTools.ParticleFlow.pfNoPileUpJME_cff") task.add(process.pfNoPileUpJMETask) cloneProcessingSnippet(process, getattr(process, "pfNoPileUpJMESequence"), postfix, addToTask=True) getattr(process, "pfPileUpJME" + postfix).PFCandidates = cms.InputTag("tmpPFCandCollPtr" + postfix) getattr(process, "pfNoPileUpJME" + postfix).bottomCollection = cms.InputTag("tmpPFCandCollPtr" + postfix) internalPfCandColl = "pfNoPileUpJME" + postfix jetColName += "CHS" addToProcessAndTask( jetColName + postfix, getattr(process, jetColName).clone(src=cms.InputTag(internalPfCandColl), rParam=cms.double(coneSize), doAreaFastjet=True), process, task)
def makePuppiesFromMiniAOD( process, createScheduledSequence=False ): task = getPatAlgosToolsTask(process) process.load('CommonTools.PileupAlgos.Puppi_cff') task.add(process.puppi) process.puppi.candName = cms.InputTag('packedPFCandidates') process.puppi.clonePackedCands = cms.bool(True) process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices') process.puppi.useExistingWeights = cms.bool(True) process.pfNoLepPUPPI = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("abs(pdgId) != 13 && abs(pdgId) != 11 && abs(pdgId) != 15")) task.add(process.pfNoLepPUPPI) process.pfLeptonsPUPPET = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("abs(pdgId) == 13 || abs(pdgId) == 11 || abs(pdgId) == 15")) task.add(process.pfLeptonsPUPPET) addToProcessAndTask('puppiNoLep', process.puppi.clone(), process, task) process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI') process.puppiNoLep.useWeightsNoLep = cms.bool(True) process.puppiNoLep.useExistingWeights = cms.bool(True) process.puppiMerged = cms.EDProducer("CandViewMerger",src = cms.VInputTag( 'puppiNoLep','pfLeptonsPUPPET')) task.add(process.puppiMerged) process.load('CommonTools.PileupAlgos.PhotonPuppi_cff') task.add(process.puppiPhoton) addToProcessAndTask('puppiForMET', process.puppiPhoton.clone(), process, task) process.puppiForMET.candName = cms.InputTag('packedPFCandidates') process.puppiForMET.photonName = cms.InputTag('slimmedPhotons') process.puppiForMET.runOnMiniAOD = cms.bool(True) setupPuppiPhotonMiniAOD(process) task.add(process.egmPhotonIDTask) #Line below replaces reference linking wiht delta R matching because the puppi references after merging are not consistent with those of the original packed candidate collection process.puppiForMET.useRefs = False #Line below points puppi MET to puppi no lepton which increases the response process.puppiForMET.puppiCandName = 'puppiMerged' #making a sequence for people running the MET tool in scheduled mode if createScheduledSequence: puppiMETSequence = cms.Sequence(process.puppi*process.pfLeptonsPUPPET*process.pfNoLepPUPPI*process.puppiNoLep*process.puppiMerged*process.puppiForMET) setattr(process, "puppiMETSequence", puppiMETSequence)
def _add_deepMET(process): process.load('RecoMET.METPUSubtraction.deepMETProducer_cfi') addToProcessAndTask('deepMETsResolutionTune', process.deepMETProducer.clone(), process, task) addToProcessAndTask('deepMETsResponseTune', process.deepMETProducer.clone(), process, task) process.deepMETsResponseTune.graph_path = 'RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb' from Configuration.Eras.Modifier_phase2_common_cff import phase2_common phase2_common.toModify( process.deepMETsResolutionTune, max_n_pf=12500, graph_path= "RecoMET/METPUSubtraction/data/deepmet/deepmet_v1_phase2.pb") phase2_common.toModify( process.deepMETsResponseTune, max_n_pf=12500, graph_path= "RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_phase2.pb") from Configuration.Eras.Modifier_run2_jme_2016_cff import run2_jme_2016 run2_jme_2016.toModify( process.deepMETsResponseTune, graph_path= "RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb")
def _add_jetsPuppi(process): from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection noDeepFlavourDiscriminators = [x.value() if isinstance(x, cms.InputTag) else x for x in process.patJets.discriminatorSources if not "DeepFlavour" in str(x)] addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'), jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''), pfCandidates = cms.InputTag("particleFlow"), algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators ) process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets' process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge") process.selectedPatJetsPuppi.cut = cms.string("pt > 15") from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging applyDeepBtagging( process ) addToProcessAndTask('slimmedJetsPuppi', process.slimmedJetsNoDeepFlavour.clone( src = "selectedPatJetsPuppi", packedPFCandidates = "packedPFCandidates"), process, task) task.add(process.slimmedJetsPuppi) process.slimmedJetsNoDeepFlavour.dropTagInfos = '0' process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.addTagInfos = True process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.tagInfoSources = ["pixelClusterTagInfos"] _run2_miniAOD_ANY.toModify(process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos = False )
def makeRecoJetCollection(process, pfCandCollection, coneSize, useCHSAlgo, postfix): task = getPatAlgosToolsTask(process) jetColName="ak"+str(int(coneSize*10))+"PFJets" internalPfCandColl=pfCandCollection if useCHSAlgo: addToProcessAndTask("tmpPFCandCollPtr"+postfix, cms.EDProducer("PFCandidateFwdPtrProducer", src = cms.InputTag(pfCandCollection) ), process, task ) process.load("CommonTools.ParticleFlow.pfNoPileUpJME_cff") task.add(process.pfNoPileUpJMETask) cloneProcessingSnippet(process, getattr(process,"pfNoPileUpJMESequence"), postfix, addToTask = True ) getattr(process, "pfPileUpJME"+postfix).PFCandidates = cms.InputTag("tmpPFCandCollPtr"+postfix) getattr(process, "pfNoPileUpJME"+postfix).bottomCollection = cms.InputTag("tmpPFCandCollPtr"+postfix) internalPfCandColl = "pfNoPileUpJME"+postfix jetColName+="CHS" addToProcessAndTask(jetColName+postfix, getattr(process,jetColName).clone( src = cms.InputTag(internalPfCandColl), rParam=cms.double(coneSize), doAreaFastjet = True), process, task )
def makePuppiesFromMiniAOD(process, createScheduledSequence=False): task = getPatAlgosToolsTask(process) process.load('CommonTools.PileupAlgos.Puppi_cff') task.add(process.puppi) process.puppi.candName = cms.InputTag('packedPFCandidates') process.puppi.clonePackedCands = True process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices') process.puppi.useExistingWeights = True process.pfNoLepPUPPI = cms.EDFilter( "CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string( "abs(pdgId) != 13 && abs(pdgId) != 11 && abs(pdgId) != 15")) task.add(process.pfNoLepPUPPI) process.pfLeptonsPUPPET = cms.EDFilter( "CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string( "abs(pdgId) == 13 || abs(pdgId) == 11 || abs(pdgId) == 15")) task.add(process.pfLeptonsPUPPET) addToProcessAndTask('puppiNoLep', process.puppi.clone(), process, task) process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI') process.puppiNoLep.useWeightsNoLep = True process.puppiNoLep.PtMaxPhotons = 20. process.puppiForMET = cms.EDProducer("CandViewMerger", src=cms.VInputTag( 'puppiNoLep', 'pfLeptonsPUPPET')) task.add(process.puppiForMET) #making a sequence for people running the MET tool in scheduled mode if createScheduledSequence: puppiMETSequence = cms.Sequence( process.puppi * process.pfLeptonsPUPPET * process.pfNoLepPUPPI * process.puppiNoLep * process.puppiForMET) setattr(process, "puppiMETSequence", puppiMETSequence)
def UpdatePuppiTuneV13(process): # # Adapt for re-running PUPPI # print( "customizePuppiTune_cff::UpdatePuppiTuneV13: Recomputing PUPPI with Tune v13, slimmedJetsPuppi and slimmedMETsPuppi" ) from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD makePuppiesFromMiniAOD(process, True) process.puppi.useExistingWeights = False process.puppiNoLep.useExistingWeights = False from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD runMetCorAndUncFromMiniAOD(process, isData=False, metType="Puppi", postfix="Puppi", jetFlavor="AK4PFPuppi", recoMetFromPFCs=True) from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer addToProcessAndTask( 'patPuppiJetSpecificProducer', patPuppiJetSpecificProducer.clone(src=cms.InputTag("patJetsPuppi")), process, task) from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection updateJetCollection( process, labelName='PuppiJetSpecific', jetSource=cms.InputTag('patJetsPuppi'), ) process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = [ 'patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ] addToProcessAndTask('slimmedJetsPuppi', process.updatedPatJetsPuppiJetSpecific.clone(), process, task) del process.updatedPatJetsPuppiJetSpecific process.puppiSequence = cms.Sequence(process.puppiMETSequence + process.fullPatMetSequencePuppi + process.patPuppiJetSpecificProducer + process.slimmedJetsPuppi) # # Adapt for PUPPI tune V13 # process.puppi.UseFromPVLooseTight = False process.puppi.UseDeltaZCut = False process.puppi.PtMaxCharged = 20. process.puppi.EtaMaxCharged = 2.5 process.puppi.PtMaxNeutralsStartSlope = 20. process.puppiNoLep.UseFromPVLooseTight = False process.puppiNoLep.UseDeltaZCut = False process.puppiNoLep.PtMaxCharged = 20. process.puppiNoLep.EtaMaxCharged = 2.5 process.puppiNoLep.PtMaxNeutralsStartSlope = 20.
def makeInputForPUPPIIsolationMuon(process): task = getPatAlgosToolsTask(process) addToProcessAndTask('muonPUPPIIsolation', _muonIsolationMiniAODPUPPI.clone(), process, task) process.muonPUPPIIsolation.srcToIsolate = cms.InputTag("muons") process.muonPUPPIIsolation.srcForIsolationCone = cms.InputTag("packedPFCandidates") addToProcessAndTask('muonPUPPINoLeptonsIsolation', _muonIsolationMiniAODPUPPINoLeptons.clone(), process, task) process.muonPUPPINoLeptonsIsolation.srcToIsolate = cms.InputTag("muons") process.muonPUPPINoLeptonsIsolation.srcForIsolationCone = cms.InputTag("packedPFCandidates")
def _add_slimmedMETsPuppi(process): addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task) process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi") process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi") process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi") process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi") process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi") process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi") process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi") process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi") del process.slimmedMETsPuppi.caloMET
def reduceFinalJetCollection(process, jetCollection, badMuons): task = getPatAlgosToolsTask(process) label = jetCollection.label() addToProcessAndTask(label+"AllEvents", jetCollection.clone(), process, task ) process.globalReplace(label, cms.EDProducer("PATJetCollectionReducer", writeEmptyCollection = cms.bool(False), jetCollection = cms.InputTag(label+"AllEvents"), triggeringCollections=badMuons, ) )
def reduceFinalJetCollection(process, jetCollection, badMuons): task = getPatAlgosToolsTask(process) label = jetCollection.label() addToProcessAndTask(label + "AllEvents", jetCollection.clone(), process, task) process.globalReplace( label, cms.EDProducer( "PATJetCollectionReducer", writeEmptyCollection=cms.bool(False), jetCollection=cms.InputTag(label + "AllEvents"), triggeringCollections=badMuons, ))
def toolCode(self, process): """ Tool code implementation """ ## initialize parameters labelName=self._parameters['labelName'].value metSource=self._parameters['metSource'].value ## do necessary imports from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs ## add module to the process task = getPatAlgosToolsTask(process) addToProcessAndTask(labelName, patMETs.clone(metSource = metSource, addMuonCorrections=False), process, task) ## add module to output if hasattr(process, "out"): process.out.outputCommands+=["keep *_{LABEL_NAME}_*_*".format(LABEL_NAME=labelName)]
def makeInputForPUPPIIsolationMuon(process): task = getPatAlgosToolsTask(process) addToProcessAndTask('muonPUPPIIsolation', _muonIsolationMiniAODPUPPI.clone(), process, task) process.muonPUPPIIsolation.srcToIsolate = cms.InputTag("muons") process.muonPUPPIIsolation.srcForIsolationCone = cms.InputTag( "packedPFCandidates") addToProcessAndTask('muonPUPPINoLeptonsIsolation', _muonIsolationMiniAODPUPPINoLeptons.clone(), process, task) process.muonPUPPINoLeptonsIsolation.srcToIsolate = cms.InputTag("muons") process.muonPUPPINoLeptonsIsolation.srcForIsolationCone = cms.InputTag( "packedPFCandidates")
def toolCode(self, process): label=self._parameters['label'].value tracks=self._parameters['tracks'].value particleType=self._parameters['particleType'].value candSelection=self._parameters['candSelection'].value process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi"); ## add ChargedCandidateProducer from track task = getPatAlgosToolsTask(process) addToProcessAndTask('patAOD' + label + 'Unfiltered', cms.EDProducer("ConcreteChargedCandidateProducer", src = tracks, particleType = cms.string(particleType)), process, task) ## add CandViewSelector with preselection string addToProcessAndTask('patAOD' + label, cms.EDFilter("CandViewSelector", src = cms.InputTag('patAOD' + label + 'Unfiltered'), cut = cms.string(candSelection)), process, task)
def toolCode(self, process): """ Tool code implementation """ ## initialize parameters labelName = self._parameters['labelName'].value metSource = self._parameters['metSource'].value ## do necessary imports from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs ## add module to the process task = getPatAlgosToolsTask(process) addToProcessAndTask( labelName, patMETs.clone(metSource=metSource, addMuonCorrections=False), process, task) ## add module to output if hasattr(process, "out"): process.out.outputCommands += [ "keep *_{LABEL_NAME}_*_*".format(LABEL_NAME=labelName) ]
def makeInputForPUPPIIsolationEgm(process): task = getPatAlgosToolsTask(process) addToProcessAndTask('egmPhotonPUPPIIsolation', _egmPhotonPUPPIIsolationForPhotons.clone(), process, task) process.egmPhotonPUPPIIsolation.srcToIsolate = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.egmPhotonPUPPIIsolation.srcForIsolationCone = cms.InputTag( "particleFlow") process.egmPhotonPUPPIIsolation.puppiValueMap = cms.InputTag('puppi') addToProcessAndTask('egmElectronPUPPIIsolation', _egmElectronIsolationMiniAODPUPPI.clone(), process, task) process.egmElectronPUPPIIsolation.srcToIsolate = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.egmElectronPUPPIIsolation.srcForIsolationCone = cms.InputTag( "packedPFCandidates") addToProcessAndTask('egmElectronPUPPINoLeptonsIsolation', _egmElectronIsolationMiniAODPUPPINoLeptons.clone(), process, task) process.egmElectronPUPPINoLeptonsIsolation.srcToIsolate = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.egmElectronPUPPINoLeptonsIsolation.srcForIsolationCone = cms.InputTag( "packedPFCandidates")
def makePuppies(process): task = getPatAlgosToolsTask(process) process.load('CommonTools.PileupAlgos.Puppi_cff') task.add(process.puppi) process.pfNoLepPUPPI = cms.EDFilter( "PdgIdCandViewSelector", src=cms.InputTag("particleFlow"), pdgId=cms.vint32(1, 2, 22, 111, 130, 310, 2112, 211, -211, 321, -321, 999211, 2212, -2212)) task.add(process.pfNoLepPUPPI) process.pfLeptonsPUPPET = cms.EDFilter( "PdgIdCandViewSelector", src=cms.InputTag("particleFlow"), pdgId=cms.vint32(-11, 11, -13, 13), ) task.add(process.pfLeptonsPUPPET) addToProcessAndTask('puppiNoLep', process.puppi.clone(), process, task) process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI') process.puppiNoLep.PtMaxPhotons = 20. process.puppiForMET = cms.EDProducer("CandViewMerger", src=cms.VInputTag( 'puppiNoLep', 'pfLeptonsPUPPET')) task.add(process.puppiForMET)
def makeInputForPUPPIIsolationEgm(process): task = getPatAlgosToolsTask(process) addToProcessAndTask('egmPhotonPUPPIIsolation', _egmPhotonPUPPIIsolationForPhotons.clone(), process, task) process.egmPhotonPUPPIIsolation.srcToIsolate = cms.InputTag("reducedEgamma","reducedGedPhotons") process.egmPhotonPUPPIIsolation.srcForIsolationCone = cms.InputTag("particleFlow") process.egmPhotonPUPPIIsolation.puppiValueMap = cms.InputTag('puppi') addToProcessAndTask('egmElectronPUPPIIsolation', _egmElectronIsolationMiniAODPUPPI.clone(), process, task) process.egmElectronPUPPIIsolation.srcToIsolate = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.egmElectronPUPPIIsolation.srcForIsolationCone = cms.InputTag("packedPFCandidates") addToProcessAndTask('egmElectronPUPPINoLeptonsIsolation', _egmElectronIsolationMiniAODPUPPINoLeptons.clone(), process, task) process.egmElectronPUPPINoLeptonsIsolation.srcToIsolate = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.egmElectronPUPPINoLeptonsIsolation.srcForIsolationCone = cms.InputTag("packedPFCandidates")
def addPFCandidates(process,src,patLabel='PFParticles',cut="",postfix=""): from PhysicsTools.PatAlgos.producersLayer1.pfParticleProducer_cfi import patPFParticles # make modules producer = patPFParticles.clone(pfCandidateSource = src) filter = cms.EDFilter("PATPFParticleSelector", src = cms.InputTag("pat" + patLabel), cut = cms.string(cut)) counter = cms.EDFilter("PATCandViewCountFilter", minNumber = cms.uint32(0), maxNumber = cms.uint32(999999), src = cms.InputTag("pat" + patLabel)) # add modules to process task = getPatAlgosToolsTask(process) addToProcessAndTask("pat" + patLabel, producer, process, task) addToProcessAndTask("selectedPat" + patLabel, filter, process, task) addToProcessAndTask("countPat" + patLabel, counter, process, task) # summary tables applyPostfix(process, "patCandidateSummary", postfix).candidates.append(cms.InputTag('pat' + patLabel)) applyPostfix(process, "selectedPatCandidateSummary", postfix).candidates.append(cms.InputTag('selectedPat' + patLabel))
def applySubstructure( process, postfix="" ) : task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault # Configure the RECO jets from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents setattr(process,'ak8PFJetsPuppi'+postfix,ak8PFJetsPuppi.clone()) setattr(process,'ak8PFJetsPuppiConstituents'+postfix, ak8PFJetsPuppiConstituents.clone(cut = cms.string('pt > 170.0 && abs(rapidity()) < 2.4') )) setattr(process,'ak8PFJetsPuppiSoftDrop'+postfix, ak8PFJetsPuppiSoftDrop.clone( src = 'ak8PFJetsPuppiConstituents'+postfix+':constituents' )) from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass setattr(process,'ak8PFJetsPuppiSoftDropMass'+postfix, ak8PFJetsPuppiSoftDropMass.clone()) from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL _run2_miniAOD_ANY = (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17 | run2_miniAOD_UL) from Configuration.Eras.Modifier_pA_2016_cff import pA_2016 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA if postfix=='': # Avoid recomputing the PUPPI collections that are present in AOD _rerun_puppijets_task = task.copy() _rerun_puppijets_task.add(getattr(process,'ak8PFJetsPuppi'), getattr(process,'ak8PFJetsPuppiConstituents'), getattr(process,'ak8PFJetsPuppiSoftDrop'), getattr(process,'ak8PFJetsPuppiSoftDropMass')) (_run2_miniAOD_ANY | pA_2016 | pp_on_AA).toReplaceWith(task, _rerun_puppijets_task) else: task.add(getattr(process,'ak8PFJetsPuppi'+postfix), getattr(process,'ak8PFJetsPuppiConstituents'+postfix), getattr(process,'ak8PFJetsPuppiSoftDrop'+postfix), getattr(process,'ak8PFJetsPuppiSoftDropMass'+postfix)) from RecoJets.JetProducers.ak8GenJets_cfi import ak8GenJets, ak8GenJetsSoftDrop, ak8GenJetsConstituents addToProcessAndTask('ak8GenJetsNoNuConstituents'+postfix, ak8GenJetsConstituents.clone(src='ak8GenJetsNoNu'), process, task ) addToProcessAndTask('ak8GenJetsNoNuSoftDrop'+postfix,ak8GenJetsSoftDrop.clone(src=cms.InputTag('ak8GenJetsNoNuConstituents'+postfix, 'constituents')),process,task) addToProcessAndTask('slimmedGenJetsAK8SoftDropSubJets'+postfix, cms.EDProducer("PATGenJetSlimmer", src = cms.InputTag("ak8GenJetsNoNuSoftDrop"+postfix, "SubJets"), packedGenParticles = cms.InputTag("packedGenParticles"), cut = cms.string(""), cutLoose = cms.string(""), nLoose = cms.uint32(0), clearDaughters = cms.bool(False), #False means rekeying dropSpecific = cms.bool(True), # Save space ), process, task ) pp_on_AA.toModify( getattr(process,'slimmedGenJetsAK8SoftDropSubJets'), cut = 'pt<0', nLoose = 0) ## PATify puppi soft drop fat jets addJetCollection( process, postfix=postfix, labelName = 'AK8PFPuppiSoftDrop' + postfix, jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix), btagDiscriminators = ['None'], genJetCollection = cms.InputTag('slimmedGenJetsAK8'), jetCorrections = ('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour = False # jet flavor disabled ) ## PATify soft drop subjets addJetCollection( process, postfix=postfix, labelName = 'AK8PFPuppiSoftDropSubjets', jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix,'SubJets'), algo = 'ak', # needed for subjet flavor clustering rParam = 0.8, # needed for subjet flavor clustering btagDiscriminators = ['pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probbb', 'pfCombinedInclusiveSecondaryVertexV2BJetTags','pfCombinedMVAV2BJetTags'], jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging genJetCollection = cms.InputTag('slimmedGenJetsAK8SoftDropSubJets'), fatJets=cms.InputTag('ak8PFJetsPuppi'), # needed for subjet flavor clustering groomedFatJets=cms.InputTag('ak8PFJetsPuppiSoftDrop') # needed for subjet flavor clustering ) # add groomed ECFs and N-subjettiness to soft dropped pat::Jets for fat jets and subjets process.load('RecoJets.JetProducers.ECF_cff') addToProcessAndTask('nb1AK8PuppiSoftDrop'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task) addToProcessAndTask('nb2AK8PuppiSoftDrop'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task) #too slow now ==> disable from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017 from Configuration.Eras.Modifier_phase2_common_cff import phase2_common for e in [pp_on_XeXe_2017, pp_on_AA, phase2_common]: e.toModify(getattr(process,'nb1AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) e.toModify(getattr(process,'nb2AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness addToProcessAndTask('NjettinessAK8Subjets'+postfix, Njettiness.clone(), process, task) getattr(process,"NjettinessAK8Subjets"+postfix).src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets") getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb1AK8PuppiSoftDrop'+postfix+':ecfN2','nb1AK8PuppiSoftDrop'+postfix+':ecfN3'] getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb2AK8PuppiSoftDrop'+postfix+':ecfN2','nb2AK8PuppiSoftDrop'+postfix+':ecfN3'] addToProcessAndTask('nb1AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task) addToProcessAndTask('nb2AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task) getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN3'] getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN3'] getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['NjettinessAK8Subjets'+postfix+':tau1','NjettinessAK8Subjets'+postfix+':tau2','NjettinessAK8Subjets'+postfix+':tau3','NjettinessAK8Subjets'+postfix+':tau4'] for e in [pp_on_XeXe_2017, pp_on_AA, phase2_common]: e.toModify(getattr(process,'nb1AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) e.toModify(getattr(process,'nb2AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) # Patify AK8 PF PUPPI addJetCollection(process, postfix=postfix, labelName = 'AK8Puppi', jetSource = cms.InputTag('ak8PFJetsPuppi'+postfix), algo= 'AK', rParam = 0.8, jetCorrections = ('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'), btagDiscriminators = ([ 'pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags', 'pfCombinedMVAV2BJetTags', 'pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probc', 'pfDeepCSVJetTags:probudsg', 'pfDeepCSVJetTags:probbb', 'pfBoostedDoubleSecondaryVertexAK8BJetTags']), genJetCollection = cms.InputTag('slimmedGenJetsAK8') ) getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src = [] # start with empty list of user floats getattr(process,"selectedPatJetsAK8Puppi"+postfix).cut = cms.string("pt > 100") getattr(process,"selectedPatJetsAK8Puppi"+postfix).cutLoose = cms.string("pt > 30") getattr(process,"selectedPatJetsAK8Puppi"+postfix).nLoose = cms.uint32(3) from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX addToProcessAndTask('ak8PFJetsPuppiTracksAssociatorAtVertex'+postfix, cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX.clone( coneSize = cms.double(0.8) ), jets = cms.InputTag("ak8PFJetsPuppi") ), process, task) addToProcessAndTask('patJetAK8PuppiCharge'+postfix, cms.EDProducer("JetChargeProducer", src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"), var = cms.string('Pt'), exp = cms.double(1.0) ), process, task) ## now add AK8 groomed masses and ECF getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += ['ak8PFJetsPuppiSoftDropMass'+postfix] getattr(process,"patJetsAK8Puppi"+postfix).addTagInfos = cms.bool(False) # add PUPPI Njetiness addToProcessAndTask('NjettinessAK8Puppi'+postfix, Njettiness.clone(), process, task) getattr(process,"NjettinessAK8Puppi"+postfix).src = cms.InputTag("ak8PFJetsPuppi"+postfix) getattr(process,"patJetsAK8Puppi").userData.userFloats.src += ['NjettinessAK8Puppi'+postfix+':tau1','NjettinessAK8Puppi'+postfix+':tau2','NjettinessAK8Puppi'+postfix+':tau3','NjettinessAK8Puppi'+postfix+':tau4'] addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropSubjets"+postfix, cms.EDProducer("PATJetSlimmer", src = cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"), packedPFCandidates = cms.InputTag("packedPFCandidates"), dropJetVars = cms.string("1"), dropDaughters = cms.string("0"), rekeyDaughters = cms.string("1"), dropTrackRefs = cms.string("1"), dropSpecific = cms.string("1"), dropTagInfos = cms.string("1"), modifyJets = cms.bool(True), mixedDaughters = cms.bool(False), modifierConfig = cms.PSet( modifications = cms.VPSet() ) ), process, task) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix, cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"), subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets") ), process, task ) addToProcessAndTask("packedPatJetsAK8"+postfix, cms.EDProducer("JetSubstructurePacker", jetSrc = cms.InputTag("selectedPatJetsAK8Puppi"+postfix), distMax = cms.double(0.8), algoTags = cms.VInputTag( cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix) ), algoLabels = cms.vstring( 'SoftDropPuppi' ), fixDaughters = cms.bool(True), packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix), ), process, task) # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards) process.slimmedJetsAK8.rekeyDaughters = "0" # Reconfigure the slimmedAK8 jet information to keep process.slimmedJetsAK8.dropDaughters = cms.string("pt < 170") process.slimmedJetsAK8.dropSpecific = cms.string("pt < 170") process.slimmedJetsAK8.dropTagInfos = cms.string("pt < 170")
def switchToPFJets(process, input=cms.InputTag('pfNoTauClones'), algo='AK4', postfix = "", jetCorrections=('AK4PFchs', ['L1FastJet','L2Relative', 'L3Absolute']), type1=False, outputModules=['out']): print "Switching to PFJets, ", algo print "************************ " print "input collection: ", input if algo == 'AK4': genJetCollection = cms.InputTag('ak4GenJetsNoNu'+postfix) rParam=0.4 elif algo == 'AK7': genJetCollection = cms.InputTag('ak7GenJetsNoNu'+postfix) rParam=0.7 else: print 'bad jet algorithm:', algo, '! for now, only AK4 and AK7 are allowed. If you need other algorithms, please contact Colin' sys.exit(1) # changing the jet collection in PF2PAT: from CommonTools.ParticleFlow.Tools.jetTools import jetAlgo inputCollection = getattr(process,"pfJetsPFBRECO"+postfix).src setattr(process,"pfJetsPFBRECO"+postfix,jetAlgo(algo)) # problem for cfgBrowser getattr(process,"pfJetsPFBRECO"+postfix).src = inputCollection inputJetCorrLabel=jetCorrections switchJetCollection(process, jetSource = input, algo=algo, rParam=rParam, genJetCollection=genJetCollection, postfix=postfix, jetTrackAssociation=True, jetCorrections=inputJetCorrLabel, outputModules = outputModules, ) # check whether L1FastJet is in the list of correction levels or not applyPostfix(process, "patJetCorrFactors", postfix).useRho = False task = getPatAlgosToolsTask(process) for corr in inputJetCorrLabel[1]: if corr == 'L1FastJet': applyPostfix(process, "patJetCorrFactors", postfix).useRho = True applyPostfix(process, "pfJetsPFBRECO", postfix).doAreaFastjet = True # do correct treatment for TypeI MET corrections #type1=True if type1: for mod in process.producerNames().split(' '): if mod.startswith("kt6") and mod.endswith("Jets"+postfix) and not 'GenJets' in mod: prefix = mod.replace(postfix,'') prefix = prefix.replace('kt6PFJets','') prefix = prefix.replace('kt6CaloJets','') prefix = getattr(process,'patJetCorrFactors'+prefix+postfix).payload.pythonValue().replace("'","") for essource in process.es_sources_().keys(): if essource == prefix+'L1FastJet': setattr(process,essource+postfix,getattr(process,essource).clone(srcRho=cms.InputTag(mod,'rho'))) addToProcessAndTask(prefix+'CombinedCorrector'+postfix, getattr(process,prefix+'CombinedCorrector').clone(), process, task) getattr(process,prefix+'CorMet'+postfix).corrector = prefix+'CombinedCorrector'+postfix for cor in getattr(process,prefix+'CombinedCorrector'+postfix).correctors: if cor == essource: idx = getattr(process,prefix+'CombinedCorrector'+postfix).correctors.index(essource); getattr(process,prefix+'CombinedCorrector'+postfix).correctors[idx] = essource+postfix if hasattr( getattr( process, "patJets" + postfix), 'embedCaloTowers' ): # optional parameter, which defaults to 'False' anyway applyPostfix(process, "patJets", postfix).embedCaloTowers = False applyPostfix(process, "patJets", postfix).embedPFCandidates = True
def eGammaCorrection( process, electronCollection, photonCollection, corElectronCollection, corPhotonCollection, metCollections, pfCandMatching=False, pfCandidateCollection="", #correctAlreadyExistingMET, corMetName="corEGSlimmedMET", postfix=""): task = getPatAlgosToolsTask(process) process.load("PhysicsTools.PatAlgos.cleaningLayer1.photonCleaner_cfi") task.add(process.cleanPatPhotons) #cleaning the bad collections cleanedPhotonCollection = "cleanedPhotons" + postfix cleanPhotonProducer = getattr(process, "cleanPatPhotons").clone( src=photonCollection, ) cleanPhotonProducer.checkOverlaps.electrons.src = electronCollection cleanPhotonProducer.checkOverlaps.electrons.requireNoOverlaps = cms.bool( True) #cleaning the good collections cleanedCorPhotonCollection = "cleanedCorPhotons" + postfix cleanCorPhotonProducer = getattr( process, "cleanPatPhotons").clone(src=corPhotonCollection) cleanCorPhotonProducer.checkOverlaps.electrons.src = corElectronCollection cleanCorPhotonProducer.checkOverlaps.electrons.requireNoOverlaps = cms.bool( True) #matching between objects matchPhotonCollection = "matchedPhotons" + postfix matchPhotonProducer = cms.EDProducer( "PFMatchedCandidateRefExtractor", col1=cms.InputTag(cleanedPhotonCollection), col2=cms.InputTag(cleanedCorPhotonCollection), pfCandCollection=cms.InputTag(pfCandidateCollection), extractPFCandidates=cms.bool(pfCandMatching)) matchElectronCollection = "matchedElectrons" + postfix matchElectronProducer = cms.EDProducer( "PFMatchedCandidateRefExtractor", col1=cms.InputTag(electronCollection), col2=cms.InputTag(corElectronCollection), pfCandCollection=cms.InputTag(pfCandidateCollection), extractPFCandidates=cms.bool(pfCandMatching)) #removal of old objects, and replace by the new tag1 = "pfCandCol1" if pfCandMatching else "col1" tag2 = "pfCandCol2" if pfCandMatching else "col2" correctionPhoton = "corMETPhoton" + postfix corMETPhoton = cms.EDProducer( "ShiftedParticleMETcorrInputProducer", srcOriginal=cms.InputTag(matchPhotonCollection, tag1), srcShifted=cms.InputTag(matchPhotonCollection, tag2), ) correctionElectron = "corMETElectron" + postfix corMETElectron = cms.EDProducer( "ShiftedParticleMETcorrInputProducer", srcOriginal=cms.InputTag(matchElectronCollection, tag1), srcShifted=cms.InputTag(matchElectronCollection, tag2), ) addToProcessAndTask(cleanedPhotonCollection, cleanPhotonProducer, process, task) addToProcessAndTask(cleanedCorPhotonCollection, cleanCorPhotonProducer, process, task) addToProcessAndTask(matchPhotonCollection, matchPhotonProducer, process, task) addToProcessAndTask(matchElectronCollection, matchElectronProducer, process, task) addToProcessAndTask(correctionPhoton, corMETPhoton, process, task) addToProcessAndTask(correctionElectron, corMETElectron, process, task) sequence = cms.Sequence() sequence += getattr(process, cleanedPhotonCollection) sequence += getattr(process, cleanedCorPhotonCollection) sequence += getattr(process, correctionPhoton) sequence += getattr(process, correctionElectron) #MET corrector for metCollection in metCollections: #print "---------->>>> ",metCollection, postfix if not hasattr(process, metCollection + postfix): #print " ==>> aqui" #raw met is the only one that does not have already a valid input collection inputMetCollection = metCollection.replace("Raw", "", 1) corMETModuleName = corMetName + postfix corMETModule = cms.EDProducer( "CorrectedPATMETProducer", src=cms.InputTag(inputMetCollection), #"patPFMet" if ("Raw" in metCollection )else metCollection srcCorrections=cms.VInputTag( cms.InputTag(correctionPhoton), cms.InputTag(correctionElectron), )) addToProcessAndTask(metCollection + postfix, corMETModule, process, task) #corMETModuleName sequence += getattr(process, metCollection + postfix) #corMETModuleName else: print(metCollection) getattr(process, metCollection).srcCorrections.append( cms.InputTag(correctionPhoton)) getattr(process, metCollection).srcCorrections.append( cms.InputTag(correctionElectron)) return sequence
def applySubstructure(process, postfix=""): task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault # Configure the RECO jets from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJetsPuppi from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents, ak8PFJetsCHSConstituents from RecoJets.JetProducers.ak8GenJets_cfi import ak8GenJets, ak8GenJetsSoftDrop, ak8GenJetsConstituents addToProcessAndTask('ak4PFJetsPuppi' + postfix, ak4PFJetsPuppi.clone(), process, task) addToProcessAndTask('ak8PFJetsPuppi' + postfix, ak8PFJetsPuppi.clone(), process, task) addToProcessAndTask( 'ak8PFJetsPuppiConstituents', ak8PFJetsPuppiConstituents.clone( cut=cms.string('pt > 170.0 && abs(rapidity()) < 2.4')), process, task) addToProcessAndTask('ak8PFJetsCHSConstituents', ak8PFJetsCHSConstituents.clone(), process, task) addToProcessAndTask( 'ak8PFJetsPuppiSoftDrop' + postfix, ak8PFJetsPuppiSoftDrop.clone( src=cms.InputTag('ak8PFJetsPuppiConstituents', 'constituents')), process, task) addToProcessAndTask('ak8GenJetsNoNuConstituents' + postfix, ak8GenJetsConstituents.clone(src='ak8GenJetsNoNu'), process, task) addToProcessAndTask( 'ak8GenJetsNoNuSoftDrop' + postfix, ak8GenJetsSoftDrop.clone( src=cms.InputTag('ak8GenJetsNoNuConstituents' + postfix, 'constituents')), process, task) addToProcessAndTask( 'slimmedGenJetsAK8SoftDropSubJets' + postfix, cms.EDProducer( "PATGenJetSlimmer", src=cms.InputTag("ak8GenJetsNoNuSoftDrop" + postfix, "SubJets"), packedGenParticles=cms.InputTag("packedGenParticles"), cut=cms.string(""), cutLoose=cms.string(""), nLoose=cms.uint32(0), clearDaughters=cms.bool(False), #False means rekeying dropSpecific=cms.bool(True), # Save space ), process, task) #add AK8 CHS addJetCollection( process, postfix=postfix, labelName='AK8', jetSource=cms.InputTag('ak8PFJetsCHS' + postfix), algo='AK', rParam=0.8, btagDiscriminators=['None'], jetCorrections=('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), genJetCollection=cms.InputTag('slimmedGenJetsAK8')) getattr(process, "patJetsAK8" + postfix).userData.userFloats.src = [ ] # start with empty list of user floats getattr(process, "selectedPatJetsAK8").cut = cms.string("pt > 170") ## add AK8 groomed masses with CHS from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop addToProcessAndTask('ak8PFJetsCHSPruned' + postfix, ak8PFJetsCHSPruned.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDrop' + postfix, ak8PFJetsCHSSoftDrop.clone(), process, task) from RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi import ak8PFJetsCHSPrunedMass, ak8PFJetsCHSTrimmedMass, ak8PFJetsCHSFilteredMass, ak8PFJetsCHSSoftDropMass addToProcessAndTask('ak8PFJetsCHSPrunedMass' + postfix, ak8PFJetsCHSPrunedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSTrimmedMass' + postfix, ak8PFJetsCHSTrimmedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSFilteredMass' + postfix, ak8PFJetsCHSFilteredMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDropMass' + postfix, ak8PFJetsCHSSoftDropMass.clone(), process, task) getattr(process, "patJetsAK8").userData.userFloats.src += [ 'ak8PFJetsCHSPrunedMass' + postfix, 'ak8PFJetsCHSSoftDropMass' + postfix ] getattr(process, "patJetsAK8").addTagInfos = cms.bool(False) # add Njetiness for CHS process.load('RecoJets.JetProducers.nJettinessAdder_cfi') task.add(process.Njettiness) addToProcessAndTask('NjettinessAK8' + postfix, process.Njettiness.clone(), process, task) getattr(process, "NjettinessAK8").src = cms.InputTag("ak8PFJetsCHS" + postfix) getattr(process, "NjettinessAK8").cone = cms.double(0.8) getattr(process, "patJetsAK8").userData.userFloats.src += [ 'NjettinessAK8' + postfix + ':tau1', 'NjettinessAK8' + postfix + ':tau2', 'NjettinessAK8' + postfix + ':tau3', 'NjettinessAK8' + postfix + ':tau4' ] # add Njetiness from CHS addToProcessAndTask('NjettinessAK8Subjets' + postfix, process.Njettiness.clone(), process, task) getattr(process, "NjettinessAK8Subjets" + postfix).src = cms.InputTag( "ak8PFJetsPuppiSoftDrop" + postfix, "SubJets") getattr(process, "NjettinessAK8Subjets").cone = cms.double(0.8) ## PATify CHS soft drop fat jets addJetCollection( process, postfix=postfix, labelName='AK8PFCHSSoftDrop', jetSource=cms.InputTag('ak8PFJetsCHSSoftDrop' + postfix), btagDiscriminators=['None'], jetCorrections=('AK8PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour=False # jet flavor disabled ) #add RECO AK8 from PUPPI and RECO AK8 PUPPI with soft drop... will be needed by ungroomed AK8 jets later ## PATify puppi soft drop fat jets addJetCollection( process, postfix=postfix, labelName='AK8PFPuppiSoftDrop' + postfix, jetSource=cms.InputTag('ak8PFJetsPuppiSoftDrop' + postfix), btagDiscriminators=['None'], genJetCollection=cms.InputTag('slimmedGenJetsAK8'), jetCorrections=('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour=False # jet flavor disabled ) ## PATify soft drop subjets addJetCollection( process, postfix=postfix, labelName='AK8PFPuppiSoftDropSubjets', jetSource=cms.InputTag('ak8PFJetsPuppiSoftDrop' + postfix, 'SubJets'), algo='ak', # needed for subjet flavor clustering rParam=0.8, # needed for subjet flavor clustering btagDiscriminators=[ 'pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probbb', 'pfCombinedInclusiveSecondaryVertexV2BJetTags', 'pfCombinedMVAV2BJetTags' ], jetCorrections=('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), explicitJTA=True, # needed for subjet b tagging svClustering=True, # needed for subjet b tagging genJetCollection=cms.InputTag('slimmedGenJetsAK8SoftDropSubJets'), fatJets=cms.InputTag( 'ak8PFJetsPuppi'), # needed for subjet flavor clustering groomedFatJets=cms.InputTag( 'ak8PFJetsPuppiSoftDrop') # needed for subjet flavor clustering ) # add groomed ECFs and N-subjettiness to soft dropped pat::Jets for fat jets and subjets process.load('RecoJets.JetProducers.ECF_cff') addToProcessAndTask( 'nb1AK8PuppiSoftDrop' + postfix, process.ecfNbeta1.clone( src=cms.InputTag("ak8PFJetsPuppiSoftDrop" + postfix), cuts=cms.vstring('', '', 'pt > 250')), process, task) addToProcessAndTask( 'nb2AK8PuppiSoftDrop' + postfix, process.ecfNbeta2.clone( src=cms.InputTag("ak8PFJetsPuppiSoftDrop" + postfix), cuts=cms.vstring('', '', 'pt > 250')), process, task) #too slow now ==> disable from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018 from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017 from Configuration.Eras.Modifier_phase2_common_cff import phase2_common for e in [pp_on_XeXe_2017, pp_on_AA_2018, phase2_common]: e.toModify(getattr(process, 'nb1AK8PuppiSoftDrop' + postfix), cuts=['pt > 999999', 'pt > 999999', 'pt > 999999']) e.toModify(getattr(process, 'nb2AK8PuppiSoftDrop' + postfix), cuts=['pt > 999999', 'pt > 999999', 'pt > 999999']) getattr(process, "patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += [ 'nb1AK8PuppiSoftDrop' + postfix + ':ecfN2', 'nb1AK8PuppiSoftDrop' + postfix + ':ecfN3' ] getattr(process, "patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += [ 'nb2AK8PuppiSoftDrop' + postfix + ':ecfN2', 'nb2AK8PuppiSoftDrop' + postfix + ':ecfN3' ] addToProcessAndTask( 'nb1AK8PuppiSoftDropSubjets' + postfix, process.ecfNbeta1.clone( src=cms.InputTag("ak8PFJetsPuppiSoftDrop" + postfix, "SubJets")), process, task) addToProcessAndTask( 'nb2AK8PuppiSoftDropSubjets' + postfix, process.ecfNbeta2.clone( src=cms.InputTag("ak8PFJetsPuppiSoftDrop" + postfix, "SubJets")), process, task) getattr(process, "patJetsAK8PFPuppiSoftDropSubjets" + postfix).userData.userFloats.src += [ 'nb1AK8PuppiSoftDropSubjets' + postfix + ':ecfN2', 'nb1AK8PuppiSoftDropSubjets' + postfix + ':ecfN3' ] getattr(process, "patJetsAK8PFPuppiSoftDropSubjets" + postfix).userData.userFloats.src += [ 'nb2AK8PuppiSoftDropSubjets' + postfix + ':ecfN2', 'nb2AK8PuppiSoftDropSubjets' + postfix + ':ecfN3' ] getattr(process, "patJetsAK8PFPuppiSoftDropSubjets" + postfix).userData.userFloats.src += [ 'NjettinessAK8Subjets' + postfix + ':tau1', 'NjettinessAK8Subjets' + postfix + ':tau2', 'NjettinessAK8Subjets' + postfix + ':tau3', 'NjettinessAK8Subjets' + postfix + ':tau4' ] for e in [pp_on_XeXe_2017, pp_on_AA_2018, phase2_common]: e.toModify(getattr(process, 'nb1AK8PuppiSoftDropSubjets' + postfix), cuts=['pt > 999999', 'pt > 999999', 'pt > 999999']) e.toModify(getattr(process, 'nb2AK8PuppiSoftDropSubjets' + postfix), cuts=['pt > 999999', 'pt > 999999', 'pt > 999999']) # rekey the groomed ECF value maps to the ungroomed reco jets, which will then be picked # up by PAT in the user floats. addToProcessAndTask( "ak8PFJetsPuppiSoftDropValueMap" + postfix, cms.EDProducer( "RecoJetToPatJetDeltaRValueMapProducer", src=cms.InputTag("ak8PFJetsPuppi" + postfix), matched=cms.InputTag("patJetsAK8PFPuppiSoftDrop" + postfix), distMax=cms.double(0.8), values=cms.vstring([ 'userFloat("nb1AK8PuppiSoftDrop' + postfix + ':ecfN2")', 'userFloat("nb1AK8PuppiSoftDrop' + postfix + ':ecfN3")', 'userFloat("nb2AK8PuppiSoftDrop' + postfix + ':ecfN2")', 'userFloat("nb2AK8PuppiSoftDrop' + postfix + ':ecfN3")', ]), valueLabels=cms.vstring([ 'nb1AK8PuppiSoftDropN2', 'nb1AK8PuppiSoftDropN3', 'nb2AK8PuppiSoftDropN2', 'nb2AK8PuppiSoftDropN3', ])), process, task) # Patify AK8 PF PUPPI addJetCollection(process, postfix=postfix, labelName='AK8Puppi', jetSource=cms.InputTag('ak8PFJetsPuppi' + postfix), algo='AK', rParam=0.8, jetCorrections=('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'), btagDiscriminators=([ 'pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags', 'pfCombinedMVAV2BJetTags', 'pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probc', 'pfDeepCSVJetTags:probudsg', 'pfDeepCSVJetTags:probbb', 'pfBoostedDoubleSecondaryVertexAK8BJetTags' ]), genJetCollection=cms.InputTag('slimmedGenJetsAK8')) getattr(process, "patJetsAK8Puppi" + postfix).userData.userFloats.src = [ ] # start with empty list of user floats getattr(process, "selectedPatJetsAK8Puppi" + postfix).cut = cms.string("pt > 100") getattr(process, "selectedPatJetsAK8Puppi" + postfix).cutLoose = cms.string("pt > 30") getattr(process, "selectedPatJetsAK8Puppi" + postfix).nLoose = cms.uint32(3) from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX addToProcessAndTask( 'ak8PFJetsPuppiTracksAssociatorAtVertex' + postfix, cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX.clone(coneSize=cms.double(0.8)), jets=cms.InputTag("ak8PFJetsPuppi")), process, task) addToProcessAndTask( 'patJetAK8PuppiCharge' + postfix, cms.EDProducer( "JetChargeProducer", src=cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"), var=cms.string('Pt'), exp=cms.double(1.0)), process, task) ## now add AK8 groomed masses and ECF from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass addToProcessAndTask('ak8PFJetsPuppiSoftDropMass' + postfix, ak8PFJetsPuppiSoftDropMass.clone(), process, task) getattr(process, "patJetsAK8Puppi" + postfix).userData.userFloats.src += [ 'ak8PFJetsPuppiSoftDropMass' + postfix ] getattr(process, "patJetsAK8Puppi" + postfix).addTagInfos = cms.bool(False) getattr(process, "patJetsAK8Puppi" + postfix).userData.userFloats.src += [ cms.InputTag('ak8PFJetsPuppiSoftDropValueMap' + postfix, 'nb1AK8PuppiSoftDropN2'), cms.InputTag('ak8PFJetsPuppiSoftDropValueMap' + postfix, 'nb1AK8PuppiSoftDropN3'), cms.InputTag('ak8PFJetsPuppiSoftDropValueMap' + postfix, 'nb2AK8PuppiSoftDropN2'), cms.InputTag('ak8PFJetsPuppiSoftDropValueMap' + postfix, 'nb2AK8PuppiSoftDropN3'), ] # add PUPPI Njetiness addToProcessAndTask('NjettinessAK8Puppi' + postfix, process.Njettiness.clone(), process, task) getattr(process, "NjettinessAK8Puppi" + postfix).src = cms.InputTag("ak8PFJetsPuppi" + postfix) getattr(process, "NjettinessAK8Puppi").cone = cms.double(0.8) getattr(process, "patJetsAK8Puppi").userData.userFloats.src += [ 'NjettinessAK8Puppi' + postfix + ':tau1', 'NjettinessAK8Puppi' + postfix + ':tau2', 'NjettinessAK8Puppi' + postfix + ':tau3', 'NjettinessAK8Puppi' + postfix + ':tau4' ] # Now combine the CHS and PUPPI information into the PUPPI jets via delta R value maps addToProcessAndTask( "ak8PFJetsCHSValueMap" + postfix, cms.EDProducer( "RecoJetToPatJetDeltaRValueMapProducer", src=cms.InputTag("ak8PFJetsPuppi" + postfix), matched=cms.InputTag("patJetsAK8" + postfix), distMax=cms.double(0.8), values=cms.vstring([ 'userFloat("ak8PFJetsCHSPrunedMass"' + postfix + ')', 'userFloat("ak8PFJetsCHSSoftDropMass"' + postfix + ')', 'userFloat("NjettinessAK8' + postfix + ':tau1")', 'userFloat("NjettinessAK8' + postfix + ':tau2")', 'userFloat("NjettinessAK8' + postfix + ':tau3")', 'userFloat("NjettinessAK8' + postfix + ':tau4")', 'pt', 'eta', 'phi', 'mass', 'jetArea', 'jecFactor(0)' ]), valueLabels=cms.vstring([ 'ak8PFJetsCHSPrunedMass', 'ak8PFJetsCHSSoftDropMass', 'NjettinessAK8CHSTau1', 'NjettinessAK8CHSTau2', 'NjettinessAK8CHSTau3', 'NjettinessAK8CHSTau4', 'pt', 'eta', 'phi', 'mass', 'jetArea', 'rawFactor' ])), process, task) # Now set up the user floats getattr(process, "patJetsAK8Puppi" + postfix).userData.userFloats.src += [ cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'ak8PFJetsCHSPrunedMass'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'ak8PFJetsCHSSoftDropMass'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'NjettinessAK8CHSTau1'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'NjettinessAK8CHSTau2'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'NjettinessAK8CHSTau3'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'NjettinessAK8CHSTau4'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'pt'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'eta'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'phi'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'mass'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'jetArea'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'rawFactor'), ] addToProcessAndTask( "slimmedJetsAK8PFPuppiSoftDropSubjets" + postfix, cms.EDProducer( "PATJetSlimmer", src=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"), packedPFCandidates=cms.InputTag("packedPFCandidates"), dropJetVars=cms.string("1"), dropDaughters=cms.string("0"), rekeyDaughters=cms.string("1"), dropTrackRefs=cms.string("1"), dropSpecific=cms.string("1"), dropTagInfos=cms.string("1"), modifyJets=cms.bool(True), mixedDaughters=cms.bool(False), modifierConfig=cms.PSet(modifications=cms.VPSet())), process, task) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger addToProcessAndTask( "slimmedJetsAK8PFPuppiSoftDropPacked" + postfix, cms.EDProducer( "BoostedJetMerger", jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"), subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets")), process, task) addToProcessAndTask( "packedPatJetsAK8" + postfix, cms.EDProducer( "JetSubstructurePacker", jetSrc=cms.InputTag("selectedPatJetsAK8Puppi" + postfix), distMax=cms.double(0.8), algoTags=cms.VInputTag( cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked" + postfix)), algoLabels=cms.vstring('SoftDropPuppi'), fixDaughters=cms.bool(True), packedPFCandidates=cms.InputTag("packedPFCandidates" + postfix), ), process, task) # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards) process.slimmedJetsAK8.rekeyDaughters = "0" # Reconfigure the slimmedAK8 jet information to keep process.slimmedJetsAK8.dropDaughters = cms.string("pt < 170") process.slimmedJetsAK8.dropSpecific = cms.string("pt < 170") process.slimmedJetsAK8.dropTagInfos = cms.string("pt < 170")
def reconfigurePF2PATTaus( process, tauType='shrinkingConePFTau', pf2patSelection=[ "DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut" ], selectionDependsOn=["DiscriminationByLeadingTrackFinding"], producerFromType=lambda producer: producer + "Producer", postfix=""): print "patTaus will be produced from taus of type: %s that pass %s" \ % (tauType, pf2patSelection) # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer producerName = producerFromType(tauType) # Set as the source for the pf2pat taus (pfTaus) selector applyPostfix(process, "pfTaus", postfix).src = producerName + postfix # Start our pf2pat taus base sequence oldTauSansRefs = getattr(process, 'pfTausProducerSansRefs' + postfix) oldTau = getattr(process, 'pfTausProducer' + postfix) ## copy tau and setup it properly newTauSansRefs = None newTau = getattr(process, producerName + postfix).clone() ## adapted to new structure in RecoTauProducers PLEASE CHECK!!! if tauType == 'shrinkingConePFTau': newTauSansRefs = getattr(process, producerName + "SansRefs").clone() newTauSansRefs.modifiers[1] = cms.PSet( pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix), name=cms.string('pfTauTTIworkaround' + postfix), plugin=cms.string('RecoTauTagInfoWorkaroundModifer')) newTau.modifiers[1] = newTauSansRefs.modifiers[1] newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros" + postfix newTau.piZeroSrc = newTauSansRefs.piZeroSrc newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[ 0].pfCandSrc newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc elif tauType == 'fixedConePFTau': newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros" + postfix elif tauType == 'hpsPFTau': newTau = getattr(process, 'combinatoricRecoTaus' + postfix).clone() newTau.piZeroSrc = "pfJetsLegacyHPSPiZeros" + postfix newTau.modifiers[3] = cms.PSet( pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix), name=cms.string('pfTauTTIworkaround' + postfix), plugin=cms.string('RecoTauTagInfoWorkaroundModifer')) from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet #cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix, addToTask = True) setattr( process, 'produceHPSPFTaus' + postfix, cms.Sequence( applyPostfix(process, 'hpsSelectionDiscriminator', postfix) + applyPostfix(process, 'hpsPFTauProducerSansRefs', postfix) + applyPostfix(process, 'hpsPFTauProducer', postfix))) massSearchReplaceParam(getattr(process, "produceHPSPFTaus" + postfix), "PFTauProducer", cms.InputTag("combinatoricRecoTaus" + postfix), cms.InputTag("pfTausBase" + postfix)) massSearchReplaceParam(getattr(process, "produceHPSPFTaus" + postfix), "src", cms.InputTag("combinatoricRecoTaus" + postfix), cms.InputTag("pfTausBase" + postfix)) ### Next three lines crash, oldTau does not have any of these attributes. Why?### #newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc #newTau.jetRegionSrc = oldTau.jetRegionSrc #newTau.jetSrc = oldTau.jetSrc #newTau.builders[0].pfCandSrc = cms.InputTag("pfNoElectronJME" + postfix) #newTau.jetRegionSrc = cms.InputTag("pfTauPFJets08Region" + postfix) #newTau.jetSrc = cms.InputTag("pfJetsPFBRECO" + postfix) # replace old tau producer by new one put it into baseSequence task = getPatAlgosToolsTask(process) addToProcessAndTask("pfTausBase" + postfix, newTau, process, task) if tauType == 'shrinkingConePFTau': addToProcessAndTask("pfTausBaseSansRefs" + postfix, newTauSansRefs, process, task) getattr(process, "pfTausBase" + postfix).src = "pfTausBaseSansRefs" + postfix baseSequence += getattr(process, "pfTausBaseSansRefs" + postfix) #make custom mapper to take postfix into account (could have gone with lambda of lambda but... ) def producerIsTauTypeMapperWithPostfix(tauProducer): return lambda x: producerIsTauTypeMapper(tauProducer) + x.group( 1) + postfix def recoTauTypeMapperWithGroup(tauProducer): return "%s(.*)" % recoTauTypeMapper(tauProducer) # Get our prediscriminants for predisc in selectionDependsOn: # Get the prototype originalName = tauType + predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding clonedName = "pfTausBase" + predisc + postfix clonedDisc = getattr(process, originalName).clone() addToProcessAndTask(clonedName, clonedDisc, process, task) tauCollectionToSelect = None if tauType != 'hpsPFTau': tauCollectionToSelect = "pfTausBase" + postfix #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = "hpsPFTauProducer" + postfix # Adapt this discriminator for the cloned prediscriminators adaptTauDiscriminator( clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Reconfigure the pf2pat PFTau selector discrimination sources getattr(process, "pfTaus" + postfix).discriminators = cms.VPSet() for selection in pf2patSelection: # Get our discriminator that will be used to select pfTaus originalName = tauType + selection clonedName = "pfTausBase" + selection + postfix clonedDisc = getattr(process, originalName).clone() addToProcessAndTask(clonedName, clonedDisc, process, task) tauCollectionToSelect = None if tauType != 'hpsPFTau': tauCollectionToSelect = cms.InputTag("pfTausBase" + postfix) #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = cms.InputTag("hpsPFTauProducer" + postfix) #Adapt our cloned discriminator to the new prediscriminants adaptTauDiscriminator( clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Add this selection to our pfTau selectors getattr(process, "pfTaus" + postfix).discriminators.append( cms.PSet(discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5))) # Set the input of the final selector. if tauType != 'hpsPFTau': getattr(process, "pfTaus" + postfix).src = "pfTausBase" + postfix else: # If we are using HPS taus, we need to take the output of the clenaed # collection getattr(process, "pfTaus" + postfix).src = "hpsPFTauProducer" + postfix
def nanoAOD_recalibrateMETs(process,isData): # add DeepMETs nanoAOD_DeepMET_switch = cms.PSet( nanoAOD_addDeepMET_switch = cms.untracked.bool(True), # decide if DeeMET should be included in Nano nanoAOD_produceDeepMET_switch = cms.untracked.bool(False), # decide if DeepMET should be computed on the fly ResponseTune_Graph = cms.untracked.string('RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb') ) for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1: # compute DeepMETs in these eras (before 111X) modifier.toModify(nanoAOD_DeepMET_switch, nanoAOD_produceDeepMET_switch = cms.untracked.bool(True)) for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016: modifier.toModify(nanoAOD_DeepMET_switch, ResponseTune_Graph=cms.untracked.string("RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb")) if nanoAOD_DeepMET_switch.nanoAOD_addDeepMET_switch: process = nanoAOD_addDeepMET(process, addDeepMETProducer=nanoAOD_DeepMET_switch.nanoAOD_produceDeepMET_switch, ResponseTune_Graph=nanoAOD_DeepMET_switch.ResponseTune_Graph) # if included in Nano, and not computed in the fly, then it should be extracted from minAOD extractDeepMETs = nanoAOD_DeepMET_switch.nanoAOD_addDeepMET_switch and not nanoAOD_DeepMET_switch.nanoAOD_produceDeepMET_switch runMetCorAndUncFromMiniAOD(process,isData=isData, extractDeepMETs=extractDeepMETs) process.nanoSequenceCommon.insert(2,cms.Sequence(process.fullPatMetSequence)) from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD makePuppiesFromMiniAOD(process,True) process.puppiNoLep.useExistingWeights = True process.puppi.useExistingWeights = True run2_nanoAOD_106Xv1.toModify(process.puppiNoLep, useExistingWeights = False) run2_nanoAOD_106Xv1.toModify(process.puppi, useExistingWeights = False) print("will make Puppies on top of MINIAOD") # makePuppiesFromMiniAOD(process,True) # call this before in the global customizer otherwise it would reset photon IDs in VID nanoAOD_PuppiV15_switch = cms.PSet( recoMetFromPFCs = cms.untracked.bool(False), reclusterJets = cms.untracked.bool(False), ) run2_nanoAOD_106Xv1.toModify(nanoAOD_PuppiV15_switch,recoMetFromPFCs=True,reclusterJets=True) if nanoAOD_PuppiV15_switch.reclusterJets: from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask task = getPatAlgosToolsTask(process) addToProcessAndTask('ak4PuppiJets', ak4PFJets.clone (src = 'puppi', doAreaFastjet = True, jetPtMin = 10.), process, task) from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection addJetCollection(process, labelName = 'Puppi', jetSource = cms.InputTag('ak4PuppiJets'), algo = 'AK', rParam=0.4, genJetCollection=cms.InputTag('slimmedGenJets'), jetCorrections = ('AK4PFPuppi', ['L1FastJet', 'L2Relative', 'L3Absolute','L2L3Residual'], 'None'), pfCandidates = cms.InputTag('packedPFCandidates'), pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'), svSource = cms.InputTag('slimmedSecondaryVertices'), muSource =cms.InputTag( 'slimmedMuons'), elSource = cms.InputTag('slimmedElectrons'), genParticles= cms.InputTag('prunedGenParticles'), getJetMCFlavour= False ) process.patJetsPuppi.addGenPartonMatch = cms.bool(False) process.patJetsPuppi.addGenJetMatch = cms.bool(False) print("nanoAOD_PuppiV15_switch.reclusterJets is true") runMetCorAndUncFromMiniAOD(process,isData=isData,metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi", recoMetFromPFCs=bool(nanoAOD_PuppiV15_switch.recoMetFromPFCs), reclusterJets=bool(nanoAOD_PuppiV15_switch.reclusterJets)) process.nanoSequenceCommon.insert(2,cms.Sequence(process.puppiMETSequence+process.fullPatMetSequencePuppi)) return process
def miniAOD_customizeCommon(process): process.patMuons.isoDeposits = cms.PSet() process.patElectrons.isoDeposits = cms.PSet() process.patTaus.isoDeposits = cms.PSet() process.patPhotons.isoDeposits = cms.PSet() # process.patMuons.embedTrack = True # used for IDs process.patMuons.embedCombinedMuon = True # used for IDs process.patMuons.embedMuonBestTrack = True # used for IDs process.patMuons.embedStandAloneMuon = True # maybe? process.patMuons.embedPickyMuon = False # no, use best track process.patMuons.embedTpfmsMuon = False # no, use best track process.patMuons.embedDytMuon = False # no, use best track process.patMuons.addPuppiIsolation = cms.bool(True) process.patMuons.puppiIsolationChargedHadrons = cms.InputTag( "muonPUPPIIsolation", "h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag( "muonPUPPIIsolation", "h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiIsolationPhotons = cms.InputTag( "muonPUPPIIsolation", "gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.computeMiniIso = cms.bool(True) process.patMuons.computeMuonMVA = cms.bool(True) # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer process.patElectrons.electronSource = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.patElectrons.usePfCandidateMultiMap = True process.patElectrons.pfCandidateMultiMap = cms.InputTag( "reducedEgamma", "reducedGsfElectronPfCandMap") process.patElectrons.electronIDSources = cms.PSet( # configure many IDs as InputTag <someName> = <someTag> you # can comment out those you don't want to save some disk space eidRobustLoose=cms.InputTag("reducedEgamma", "eidRobustLoose"), eidRobustTight=cms.InputTag("reducedEgamma", "eidRobustTight"), eidLoose=cms.InputTag("reducedEgamma", "eidLoose"), eidTight=cms.InputTag("reducedEgamma", "eidTight"), eidRobustHighEnergy=cms.InputTag("reducedEgamma", "eidRobustHighEnergy"), ) process.patElectrons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patElectrons.addPuppiIsolation = cms.bool(True) process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag( "egmElectronPUPPIIsolation", "h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag( "egmElectronPUPPIIsolation", "h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiIsolationPhotons = cms.InputTag( "egmElectronPUPPIIsolation", "gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.computeMiniIso = cms.bool(True) process.patElectrons.ecalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "eleEcalPFClusIso") process.patElectrons.hcalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "eleHcalPFClusIso") process.elPFIsoDepositChargedPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositChargedAllPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositNeutralPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositGammaPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma", "reducedGedGsfElectrons") # process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer process.patPhotons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patPhotons.addPuppiIsolation = cms.bool(True) process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag( "egmPhotonPUPPIIsolation", "h+-DR030-") process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag( "egmPhotonPUPPIIsolation", "h0-DR030-") process.patPhotons.puppiIsolationPhotons = cms.InputTag( "egmPhotonPUPPIIsolation", "gamma-DR030-") process.patPhotons.ecalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "phoEcalPFClusIso") process.patPhotons.hcalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "phoHcalPFClusIso") process.patPhotons.photonSource = cms.InputTag("reducedEgamma", "reducedGedPhotons") process.patPhotons.electronSource = cms.InputTag("reducedEgamma", "reducedGedGsfElectrons") process.patPhotons.photonIDSources = cms.PSet( PhotonCutBasedIDLoose=cms.InputTag('reducedEgamma', 'PhotonCutBasedIDLoose'), PhotonCutBasedIDTight=cms.InputTag('reducedEgamma', 'PhotonCutBasedIDTight')) process.phPFIsoDepositChargedPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositChargedAllPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositNeutralPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma", "reducedGedPhotons") # process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma", "reducedOOTPhotons") process.patOOTPhotons.electronSource = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string( "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))" ) from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify( process.selectedPatMuons, cut= "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )" ) process.selectedPatElectrons.cut = cms.string("") process.selectedPatTaus.cut = cms.string( "pt > 18. && tauID('decayModeFindingNewDMs')> 0.5") process.selectedPatPhotons.cut = cms.string("") from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure applySubstructure(process) # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone switchOnTriggerStandAlone(process, outputModule='') process.patTrigger.packTriggerPathNames = cms.bool(True) # # apply type I + other PFMEt corrections to pat::MET object # and estimate systematic uncertainties on MET from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets") #caloMET computation from PhysicsTools.PatAlgos.tools.metTools import addMETCollection addMETCollection(process, labelName="patCaloMet", metSource="caloMetM") #noHF pfMET ========= task = getPatAlgosToolsTask(process) process.noHFCands = cms.EDFilter( "GenericPFCandidateSelector", src=cms.InputTag("particleFlow"), cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")) task.add(process.noHFCands) runMetCorAndUncForMiniAODProduction( process, pfCandColl=cms.InputTag("noHFCands"), recoMetFromPFCs=True, #needed for HF removal jetSelection="pt>15 && abs(eta)<3.", postfix="NoHF") process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task) process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF") process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF") process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF") process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF") process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag( "patPFMetT1Smear%sNoHF") process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF") process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag( "patPFMetT0pcT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag( "patPFMetT1SmearTxyNoHF") process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag( "patPFMetT0pcT1SmearTxyNoHF") del process.slimmedMETsNoHF.caloMET # ================== NoHF pfMET # ================== CHSMET process.CHSCands = cms.EDFilter("CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("fromPV(0) > 0")) task.add(process.CHSCands) process.pfMetCHS = cms.EDProducer( "PFMETProducer", src=cms.InputTag("CHSCands"), alias=cms.string('pfMet'), globalThreshold=cms.double(0.0), calculateSignificance=cms.bool(False), ) task.add(process.pfMetCHS) addMETCollection(process, labelName="patCHSMet", metSource="pfMetCHS") process.patCHSMet.computeMETSignificance = cms.bool(False) # ================== CHSMET # ================== TrkMET process.TrkCands = cms.EDFilter( "CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string( "charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0") ) task.add(process.TrkCands) process.pfMetTrk = cms.EDProducer( "PFMETProducer", src=cms.InputTag("TrkCands"), alias=cms.string('pfMet'), globalThreshold=cms.double(0.0), calculateSignificance=cms.bool(False), ) task.add(process.pfMetTrk) addMETCollection(process, labelName="patTrkMet", metSource="pfMetTrk") process.patTrkMet.computeMETSignificance = cms.bool(False) # ================== TrkMET ## PU JetID process.load("RecoJets.JetProducers.PileupJetID_cfi") task.add(process.pileUpJetIDTask) process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ] process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ] ## Quark Gluon Likelihood process.load('RecoJets.JetProducers.QGTagger_cfi') task.add(process.QGTaggerTask) process.patJets.userData.userFloats.src += [ cms.InputTag('QGTagger:qgLikelihood'), ] ## DeepCSV meta discriminators (simple arithmethic on output probabilities) process.load('RecoBTag.Combined.deepFlavour_cff') task.add(process.pfDeepCSVDiscriminatorsJetTags) process.patJets.discriminatorSources.extend([ cms.InputTag('pfDeepCSVDiscriminatorsJetTags:BvsAll'), cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsB'), cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsL'), ]) ## CaloJets process.caloJetMap = cms.EDProducer( "RecoJetDeltaRValueMapProducer", src=process.patJets.jetSource, matched=cms.InputTag("ak4CaloJets"), distMax=cms.double(0.4), values=cms.vstring('pt', 'emEnergyFraction'), valueLabels=cms.vstring('pt', 'emEnergyFraction'), lazyParser=cms.bool(True)) task.add(process.caloJetMap) process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ] #Muon object modifications from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon makeInputForPUPPIIsolationMuon(process) #EGM object modifications from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm makeInputForPUPPIIsolationEgm(process) from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications process.slimmedElectrons.modifierConfig.modifications = egamma_modifications process.slimmedPhotons.modifierConfig.modifications = egamma_modifications #VID Electron IDs electron_ids = [ 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_PHYS14_PU20bx25_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_50ns_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV60_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_nonTrig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_Trig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_50ns_Trig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff', ] switchOnVIDElectronIdProducer(process, DataFormat.MiniAOD, task) process.egmGsfElectronIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.electronMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') process.electronRegressionValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') for idmod in electron_ids: setupAllVIDIdsInModule(process, idmod, setupVIDElectronSelection, None, False, task) #heepIDVarValueMaps only exists if HEEP V6.1 or HEEP 7.0 ID has already been loaded if hasattr(process, 'heepIDVarValueMaps'): process.heepIDVarValueMaps.elesMiniAOD = cms.InputTag( 'reducedEgamma', 'reducedGedGsfElectrons') #force HEEP to use miniAOD (otherwise it'll detect the AOD) process.heepIDVarValueMaps.dataFormat = cms.int32(2) #add the HEEP trk isol to the slimmed electron, add it to the first FromFloatValMap modifier for pset in process.slimmedElectrons.modifierConfig.modifications: if pset.hasParameter( "modifierName") and pset.modifierName == cms.string( 'EGExtraInfoModifierFromFloatValueMaps'): pset.electron_config.heepTrkPtIso = cms.InputTag( "heepIDVarValueMaps", "eleTrkPtIso") break #VID Photon IDs photon_ids = [ 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_50ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_25ns_nonTrig_V2p1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_50ns_nonTrig_V2p1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff' ] switchOnVIDPhotonIdProducer(process, DataFormat.AOD, task) process.egmPhotonIsolation.srcToIsolate = \ cms.InputTag("reducedEgamma","reducedGedPhotons") for iPSet in process.egmPhotonIsolation.isolationConeDefinitions: iPSet.particleBasedIsolation = cms.InputTag("reducedEgamma", "reducedPhotonPfCandMap") process.egmPhotonIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonRegressionValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.particleBasedIsolation = \ cms.InputTag("reducedEgamma","reducedPhotonPfCandMap") process.photonMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedPhotons') for idmod in photon_ids: setupAllVIDIdsInModule(process, idmod, setupVIDPhotonSelection, None, False, task) #add the cut base IDs bitmaps of which cuts passed from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier egamma_modifications.append( makeVIDBitsModifier(process, "egmGsfElectronIDs", "egmPhotonIDs")) #-- Adding boosted taus from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus addBoostedTaus(process) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") process.load("RecoTauTag.Configuration.HPSPFTaus_cff") #-- Adding customization for 94X 2017 legacy reMniAOD from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy() _makePatTausTaskWithRetrainedMVATauID.add( process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask) run2_miniAOD_94XFall17.toReplaceWith( process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID) #-- Adding custimization for 80X 2016 legacy reMiniAOD from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _makePatTausTaskWithTauReReco = process.makePatTausTask.copy() _makePatTausTaskWithTauReReco.add(process.PFTauTask) run2_miniAOD_80XLegacy.toReplaceWith(process.makePatTausTask, _makePatTausTaskWithTauReReco) #-- Adding LowPt taus from RecoTauTag.Configuration.LowPtHPSPFTaus_cfi import addLowPtTaus addLowPtTaus(process) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") process.load("RecoTauTag.Configuration.HPSPFTaus_cff") # Adding puppi jets if not hasattr( process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi') task.add(process.ak4PFJets) task.add(process.ak4PFJetsPuppi) process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer( "JetTracksAssociatorAtVertex", j2tParametersVX, jets=cms.InputTag("ak4PFJetsPuppi")) task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex) process.patJetPuppiCharge = cms.EDProducer( "JetChargeProducer", src=cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"), var=cms.string('Pt'), exp=cms.double(1.0)) task.add(process.patJetPuppiCharge) noDeepFlavourDiscriminators = [ x.value() for x in process.patJets.discriminatorSources if not "DeepFlavour" in x.value() ] addJetCollection( process, postfix="", labelName='Puppi', jetSource=cms.InputTag('ak4PFJetsPuppi'), jetCorrections=('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''), pfCandidates=cms.InputTag( 'puppi' ), # using Puppi candidates as input for b tagging of Puppi jets algo='AK', rParam=0.4, btagDiscriminators=noDeepFlavourDiscriminators) process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets' process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge") process.selectedPatJetsPuppi.cut = cms.string("pt > 15") process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') # update slimmed jets to include DeepFlavour (keep same name) from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection # make clone for DeepFlavour-less slimmed jets, so output name is preserved process.slimmedJetsNoDeepFlavour = process.slimmedJets.clone() task.add(process.slimmedJetsNoDeepFlavour) updateJetCollection( process, jetSource=cms.InputTag('slimmedJetsNoDeepFlavour'), # updateJetCollection defaults to MiniAOD inputs but # here it is made explicit (as in training or MINIAOD redoing) pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), pfCandidates=cms.InputTag('packedPFCandidates'), svSource=cms.InputTag('slimmedSecondaryVertices'), muSource=cms.InputTag('slimmedMuons'), elSource=cms.InputTag('slimmedElectrons'), jetCorrections=('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), btagDiscriminators=[ 'pfDeepFlavourJetTags:probb', 'pfDeepFlavourJetTags:probbb', 'pfDeepFlavourJetTags:problepb', 'pfDeepFlavourJetTags:probc', 'pfDeepFlavourJetTags:probuds', 'pfDeepFlavourJetTags:probg', ], postfix='SlimmedDeepFlavour', printWarning=False) # slimmedJets with DeepFlavour (remove DeepFlavour-less) delattr(process, 'slimmedJets') process.slimmedJets = process.selectedUpdatedPatJetsSlimmedDeepFlavour.clone( ) # delete module not used anymore (slimmedJets substitutes) delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour') task.add(process.slimmedJets) task.add(process.slimmedJetsAK8) addToProcessAndTask('slimmedJetsPuppiNoMultiplicities', process.slimmedJetsNoDeepFlavour.clone(), process, task) process.slimmedJetsPuppiNoMultiplicities.src = cms.InputTag( "selectedPatJetsPuppi") process.slimmedJetsPuppiNoMultiplicities.packedPFCandidates = cms.InputTag( "packedPFCandidates") from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer process.patPuppiJetSpecificProducer = patPuppiJetSpecificProducer.clone( src=cms.InputTag("slimmedJetsPuppiNoMultiplicities"), ) task.add(process.patPuppiJetSpecificProducer) updateJetCollection( process, labelName='PuppiJetSpecific', jetSource=cms.InputTag('slimmedJetsPuppiNoMultiplicities'), ) process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = [ 'patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ] process.slimmedJetsPuppi = process.selectedUpdatedPatJetsPuppiJetSpecific.clone( ) delattr(process, 'selectedUpdatedPatJetsPuppiJetSpecific') task.add(process.slimmedJetsPuppi) ## puppi met from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies makePuppies(process) runMetCorAndUncForMiniAODProduction(process, metType="Puppi", pfCandColl=cms.InputTag("puppiForMET"), jetCollUnskimmed="slimmedJetsPuppi", recoMetFromPFCs=True, jetFlavor="AK4PFPuppi", postfix="Puppi") process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task) process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi") process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi") process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag( "patPFMetT1%sPuppi") process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi") process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag( "patPFMetT1Smear%sPuppi") process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi") process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag( "patPFMetT0pcT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag( "patPFMetT1SmearTxyPuppi") process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag( "patPFMetT0pcT1SmearTxyPuppi") del process.slimmedMETsPuppi.caloMET # add DetIdAssociatorRecords to EventSetup (for isolatedTracks) process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
def eGammaCorrection(process, electronCollection, photonCollection, corElectronCollection, corPhotonCollection, metCollections, pfCandMatching=False, pfCandidateCollection="", #correctAlreadyExistingMET, corMetName="corEGSlimmedMET", postfix="" ): task = getPatAlgosToolsTask(process) process.load("PhysicsTools.PatAlgos.cleaningLayer1.photonCleaner_cfi") task.add(process.cleanPatPhotons) #cleaning the bad collections cleanedPhotonCollection="cleanedPhotons"+postfix cleanPhotonProducer = getattr(process, "cleanPatPhotons").clone( src = photonCollection, ) cleanPhotonProducer.checkOverlaps.electrons.src = electronCollection cleanPhotonProducer.checkOverlaps.electrons.requireNoOverlaps=cms.bool(True) #cleaning the good collections cleanedCorPhotonCollection="cleanedCorPhotons"+postfix cleanCorPhotonProducer = getattr(process, "cleanPatPhotons").clone( src = corPhotonCollection ) cleanCorPhotonProducer.checkOverlaps.electrons.src = corElectronCollection cleanCorPhotonProducer.checkOverlaps.electrons.requireNoOverlaps=cms.bool(True) #matching between objects matchPhotonCollection="matchedPhotons"+postfix matchPhotonProducer=cms.EDProducer("PFMatchedCandidateRefExtractor", col1=cms.InputTag(cleanedPhotonCollection), col2=cms.InputTag(cleanedCorPhotonCollection), pfCandCollection=cms.InputTag(pfCandidateCollection), extractPFCandidates=cms.bool(pfCandMatching) ) matchElectronCollection="matchedElectrons"+postfix matchElectronProducer=cms.EDProducer("PFMatchedCandidateRefExtractor", col1=cms.InputTag(electronCollection), col2=cms.InputTag(corElectronCollection), pfCandCollection=cms.InputTag(pfCandidateCollection), extractPFCandidates=cms.bool(pfCandMatching) ) #removal of old objects, and replace by the new tag1= "pfCandCol1" if pfCandMatching else "col1" tag2= "pfCandCol2" if pfCandMatching else "col2" correctionPhoton="corMETPhoton"+postfix corMETPhoton = cms.EDProducer("ShiftedParticleMETcorrInputProducer", srcOriginal = cms.InputTag(matchPhotonCollection,tag1), srcShifted = cms.InputTag(matchPhotonCollection,tag2), ) correctionElectron="corMETElectron"+postfix corMETElectron=cms.EDProducer("ShiftedParticleMETcorrInputProducer", srcOriginal=cms.InputTag(matchElectronCollection,tag1), srcShifted=cms.InputTag(matchElectronCollection,tag2), ) addToProcessAndTask(cleanedPhotonCollection,cleanPhotonProducer, process, task) addToProcessAndTask(cleanedCorPhotonCollection,cleanCorPhotonProducer, process, task) addToProcessAndTask(matchPhotonCollection,matchPhotonProducer, process, task) addToProcessAndTask(matchElectronCollection,matchElectronProducer, process, task) addToProcessAndTask(correctionPhoton,corMETPhoton, process, task) addToProcessAndTask(correctionElectron,corMETElectron, process, task) sequence=cms.Sequence() sequence+=getattr(process,cleanedPhotonCollection) sequence+=getattr(process,cleanedCorPhotonCollection) sequence+=getattr(process,correctionPhoton) sequence+=getattr(process,correctionElectron) #MET corrector for metCollection in metCollections: #print "---------->>>> ",metCollection, postfix if not hasattr(process, metCollection+postfix): #print " ==>> aqui" #raw met is the only one that does not have already a valid input collection inputMetCollection=metCollection.replace("Raw","",1) corMETModuleName=corMetName+postfix corMETModule = cms.EDProducer("CorrectedPATMETProducer", src = cms.InputTag( inputMetCollection ), #"patPFMet" if ("Raw" in metCollection )else metCollection srcCorrections = cms.VInputTag( cms.InputTag(correctionPhoton), cms.InputTag(correctionElectron), ) ) addToProcessAndTask(metCollection+postfix, corMETModule, process, task) #corMETModuleName sequence+=getattr(process,metCollection+postfix) #corMETModuleName else: print(metCollection) getattr(process,metCollection).srcCorrections.append(cms.InputTag(correctionPhoton)) getattr(process,metCollection).srcCorrections.append(cms.InputTag(correctionElectron)) return sequence
def miniAOD_customizeCommon(process): process.patMuons.isoDeposits = cms.PSet() process.patElectrons.isoDeposits = cms.PSet() process.patTaus.isoDeposits = cms.PSet() process.patPhotons.isoDeposits = cms.PSet() # process.patMuons.embedTrack = True # used for IDs process.patMuons.embedCombinedMuon = True # used for IDs process.patMuons.embedMuonBestTrack = True # used for IDs process.patMuons.embedStandAloneMuon = True # maybe? process.patMuons.embedPickyMuon = False # no, use best track process.patMuons.embedTpfmsMuon = False # no, use best track process.patMuons.embedDytMuon = False # no, use best track # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.patElectrons.electronIDSources = cms.PSet( # configure many IDs as InputTag <someName> = <someTag> you # can comment out those you don't want to save some disk space eidRobustLoose = cms.InputTag("reducedEgamma","eidRobustLoose"), eidRobustTight = cms.InputTag("reducedEgamma","eidRobustTight"), eidLoose = cms.InputTag("reducedEgamma","eidLoose"), eidTight = cms.InputTag("reducedEgamma","eidTight"), eidRobustHighEnergy = cms.InputTag("reducedEgamma","eidRobustHighEnergy"), ) process.patElectrons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patElectrons.addPuppiIsolation = cms.bool(True) process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso") process.patElectrons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso") process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") # process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer process.patPhotons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patPhotons.addPuppiIsolation = cms.bool(True) process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-") process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-") process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-") process.patPhotons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso") process.patPhotons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso") process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons") process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.patPhotons.photonIDSources = cms.PSet( PhotonCutBasedIDLoose = cms.InputTag('reducedEgamma', 'PhotonCutBasedIDLoose'), PhotonCutBasedIDTight = cms.InputTag('reducedEgamma', 'PhotonCutBasedIDTight') ) process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))") process.selectedPatElectrons.cut = cms.string("") process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5") process.selectedPatPhotons.cut = cms.string("") from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure applySubstructure( process ) # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone switchOnTriggerStandAlone( process, outputModule = '' ) process.patTrigger.packTriggerPathNames = cms.bool(True) # # apply type I + other PFMEt corrections to pat::MET object # and estimate systematic uncertainties on MET from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets") #caloMET computation from PhysicsTools.PatAlgos.tools.metTools import addMETCollection addMETCollection(process, labelName = "patCaloMet", metSource = "caloMetM" ) #noHF pfMET ========= task = getPatAlgosToolsTask(process) process.noHFCands = cms.EDFilter("GenericPFCandidateSelector", src=cms.InputTag("particleFlow"), cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0") ) task.add(process.noHFCands) runMetCorAndUncForMiniAODProduction(process, pfCandColl=cms.InputTag("noHFCands"), recoMetFromPFCs=True, #needed for HF removal jetSelection="pt>15 && abs(eta)<3.", postfix="NoHF" ) process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task) process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF") process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF") process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF") process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF") process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF") process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF") process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF") process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF") del process.slimmedMETsNoHF.caloMET # ================== NoHF pfMET #keep this after all addJetCollections otherwise it will attempt computing them also for stuf with no taginfos #Some useful BTAG vars if not hasattr( process, 'pfImpactParameterTagInfos' ): process.load('RecoBTag.ImpactParameter.pfImpactParameterTagInfos_cfi') task.add(process.pfImpactParameterTagInfos) if not hasattr( process, 'pfSecondaryVertexTagInfos' ): process.load('RecoBTag.SecondaryVertex.pfSecondaryVertexTagInfos_cfi') task.add(process.pfSecondaryVertexTagInfos) process.patJets.userData.userFunctions = cms.vstring( '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.M):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).numberOfSourceCandidatePtrs):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").flightDistance(0).value):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").flightDistance(0).significance):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.x):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.y):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.z):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.x):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.y):(0)', '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.z):(0)', ) process.patJets.userData.userFunctionLabels = cms.vstring('vtxMass','vtxNtracks','vtx3DVal','vtx3DSig','vtxPx','vtxPy','vtxPz','vtxPosX','vtxPosY','vtxPosZ') process.patJets.tagInfoSources = cms.VInputTag(cms.InputTag("pfSecondaryVertexTagInfos")) process.patJets.addTagInfos = cms.bool(True) ## Legacy tight b-tag track selection ## (this will run below-specified taggers with the tight b-tag track selection enabled ## and will add an extra set of b-tag discriminators to 'selectedPatJets' ## with the 'tight' prefix added to the usual discriminator names) from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection updateJetCollection( process, jetSource = cms.InputTag('selectedPatJets'), ## updateJetCollection defaults to MiniAOD inputs. Here, this needs to be changed to RECO/AOD inputs pvSource = cms.InputTag('offlinePrimaryVertices'), pfCandidates = cms.InputTag('particleFlow'), svSource = cms.InputTag('inclusiveCandidateSecondaryVertices'), muSource = cms.InputTag('muons'), elSource = cms.InputTag('gedGsfElectrons'), ## jetCorrections = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], ''), btagDiscriminators = ["pfCombinedSecondaryVertexV2BJetTags", "pfCombinedInclusiveSecondaryVertexV2BJetTags", "pfCombinedCvsLJetTags", "pfCombinedCvsBJetTags"], runIVF = True, tightBTagNTkHits = True, btagPrefix = 'tight', postfix = 'BTAG' # added to avoid problems with unrunnable schedule ) # ## PU JetID process.load("RecoJets.JetProducers.PileupJetID_cfi") task.add(process.pileupJetId) task.add(process.pileupJetIdCalculator) task.add(process.pileupJetIdEvaluator) process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ] process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ] ## CaloJets process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer", src = process.patJets.jetSource, matched = cms.InputTag("ak4CaloJets"), distMax = cms.double(0.4), values = cms.vstring('pt','emEnergyFraction'), valueLabels = cms.vstring('pt','emEnergyFraction'), lazyParser = cms.bool(True) ) task.add(process.caloJetMap) process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ] #EGM object modifications from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm makeInputForPUPPIIsolationEgm(process) from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications process.slimmedElectrons.modifierConfig.modifications = egamma_modifications process.slimmedPhotons.modifierConfig.modifications = egamma_modifications #VID Electron IDs electron_ids = ['RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_PHYS14_PU20bx25_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_50ns_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV60_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_nonTrig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_Trig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_50ns_Trig_V1_cff'] switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task) process.egmGsfElectronIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.electronMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') process.electronRegressionValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') for idmod in electron_ids: setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task) #heepIDVarValueMaps only exists if HEEP V6.1 or HEEP 7.0 ID has already been loaded if hasattr(process,'heepIDVarValueMaps'): process.heepIDVarValueMaps.elesMiniAOD = cms.InputTag('reducedEgamma','reducedGedGsfElectrons') #force HEEP to use miniAOD (otherwise it'll detect the AOD) process.heepIDVarValueMaps.dataFormat = cms.int32(2) #VID Photon IDs photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_50ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_25ns_nonTrig_V2p1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_50ns_nonTrig_V2p1_cff'] switchOnVIDPhotonIdProducer(process,DataFormat.MiniAOD, task) process.egmPhotonIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonRegressionValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.particleBasedIsolation = \ cms.InputTag("reducedEgamma","reducedPhotonPfCandMap") process.photonMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedPhotons') for idmod in photon_ids: setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task) #--------------------------------------------------------------------------- #Adding Boosted Subjets taus from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus addBoostedTaus(process) #--------------------------------------------------------------------------- # Adding puppi jets process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi') task.add(process.ak4PFJets) task.add(process.ak4PFJetsPuppi) process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX, jets = cms.InputTag("ak4PFJetsPuppi") ) task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex) process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer", src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"), var = cms.string('Pt'), exp = cms.double(1.0) ) task.add(process.patJetPuppiCharge) addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'), jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''), algo= 'AK', rParam = 0.4, btagDiscriminators = map(lambda x: x.value() ,process.patJets.discriminatorSources) ) process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets' process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge") process.selectedPatJetsPuppi.cut = cms.string("pt > 15") process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') task.add(process.slimmedJets) task.add(process.slimmedJetsAK8) addToProcessAndTask('slimmedJetsPuppi', process.slimmedJets.clone(), process, task) process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi") process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag("packedPFCandidates") ## puppi met from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies makePuppies( process ); runMetCorAndUncForMiniAODProduction(process, metType="Puppi", pfCandColl=cms.InputTag("puppiForMET"), jetCollUnskimmed="slimmedJetsPuppi", recoMetFromPFCs=True, jetFlavor="AK4PFPuppi", postfix="Puppi" ) process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task) process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi") process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi") process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi") process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi") process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi") process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi") process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi") process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi") del process.slimmedMETsPuppi.caloMET
def applySubstructure( process, postfix="" ) : task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault # Configure the RECO jets from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJetsPuppi from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents, ak8PFJetsCHSConstituents from RecoJets.JetProducers.ak8GenJets_cfi import ak8GenJets, ak8GenJetsSoftDrop, ak8GenJetsConstituents addToProcessAndTask('ak4PFJetsPuppi'+postfix,ak4PFJetsPuppi.clone(), process, task) addToProcessAndTask('ak8PFJetsPuppi'+postfix,ak8PFJetsPuppi.clone(), process, task) addToProcessAndTask('ak8PFJetsPuppiConstituents', ak8PFJetsPuppiConstituents.clone(cut = cms.string('pt > 170.0 && abs(rapidity()) < 2.4') ), process, task ) addToProcessAndTask('ak8PFJetsCHSConstituents', ak8PFJetsCHSConstituents.clone(), process, task ) addToProcessAndTask('ak8PFJetsPuppiSoftDrop'+postfix, ak8PFJetsPuppiSoftDrop.clone( src = cms.InputTag('ak8PFJetsPuppiConstituents', 'constituents') ), process, task) addToProcessAndTask('ak8GenJetsNoNuConstituents'+postfix, ak8GenJetsConstituents.clone(src='ak8GenJetsNoNu'), process, task ) addToProcessAndTask('ak8GenJetsNoNuSoftDrop'+postfix,ak8GenJetsSoftDrop.clone(src=cms.InputTag('ak8GenJetsNoNuConstituents'+postfix, 'constituents')),process,task) addToProcessAndTask('slimmedGenJetsAK8SoftDropSubJets'+postfix, cms.EDProducer("PATGenJetSlimmer", src = cms.InputTag("ak8GenJetsNoNuSoftDrop"+postfix, "SubJets"), packedGenParticles = cms.InputTag("packedGenParticles"), cut = cms.string(""), cutLoose = cms.string(""), nLoose = cms.uint32(0), clearDaughters = cms.bool(False), #False means rekeying dropSpecific = cms.bool(True), # Save space ), process, task ) #add AK8 CHS addJetCollection(process, postfix=postfix, labelName = 'AK8', jetSource = cms.InputTag('ak8PFJetsCHS'+postfix), algo= 'AK', rParam = 0.8, btagDiscriminators = ['None'], jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), genJetCollection = cms.InputTag('slimmedGenJetsAK8') ) getattr(process,"patJetsAK8"+postfix).userData.userFloats.src = [] # start with empty list of user floats getattr(process,"selectedPatJetsAK8").cut = cms.string("pt > 170") ## add AK8 groomed masses with CHS from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop addToProcessAndTask('ak8PFJetsCHSPruned'+postfix, ak8PFJetsCHSPruned.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDrop'+postfix, ak8PFJetsCHSSoftDrop.clone(), process, task) from RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi import ak8PFJetsCHSPrunedMass, ak8PFJetsCHSTrimmedMass, ak8PFJetsCHSFilteredMass, ak8PFJetsCHSSoftDropMass addToProcessAndTask('ak8PFJetsCHSPrunedMass'+postfix, ak8PFJetsCHSPrunedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSTrimmedMass'+postfix, ak8PFJetsCHSTrimmedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSFilteredMass'+postfix, ak8PFJetsCHSFilteredMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDropMass'+postfix, ak8PFJetsCHSSoftDropMass.clone(), process, task) getattr(process,"patJetsAK8").userData.userFloats.src += ['ak8PFJetsCHSPrunedMass'+postfix,'ak8PFJetsCHSSoftDropMass'+postfix] getattr(process,"patJetsAK8").addTagInfos = cms.bool(False) # add Njetiness for CHS process.load('RecoJets.JetProducers.nJettinessAdder_cfi') task.add(process.Njettiness) addToProcessAndTask('NjettinessAK8'+postfix, process.Njettiness.clone(), process, task) getattr(process,"NjettinessAK8").src = cms.InputTag("ak8PFJetsCHS"+postfix) getattr(process,"NjettinessAK8").cone = cms.double(0.8) getattr(process,"patJetsAK8").userData.userFloats.src += ['NjettinessAK8'+postfix+':tau1','NjettinessAK8'+postfix+':tau2','NjettinessAK8'+postfix+':tau3','NjettinessAK8'+postfix+':tau4'] # add Njetiness from CHS addToProcessAndTask('NjettinessAK8Subjets'+postfix, process.Njettiness.clone(), process, task) getattr(process,"NjettinessAK8Subjets"+postfix).src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets") getattr(process,"NjettinessAK8Subjets").cone = cms.double(0.8) ## PATify CHS soft drop fat jets addJetCollection( process, postfix=postfix, labelName = 'AK8PFCHSSoftDrop', jetSource = cms.InputTag('ak8PFJetsCHSSoftDrop'+postfix), btagDiscriminators = ['None'], jetCorrections = ('AK8PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour = False # jet flavor disabled ) #add RECO AK8 from PUPPI and RECO AK8 PUPPI with soft drop... will be needed by ungroomed AK8 jets later ## PATify puppi soft drop fat jets addJetCollection( process, postfix=postfix, labelName = 'AK8PFPuppiSoftDrop' + postfix, jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix), btagDiscriminators = ['None'], genJetCollection = cms.InputTag('slimmedGenJetsAK8'), jetCorrections = ('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour = False # jet flavor disabled ) ## PATify soft drop subjets addJetCollection( process, postfix=postfix, labelName = 'AK8PFPuppiSoftDropSubjets', jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix,'SubJets'), algo = 'ak', # needed for subjet flavor clustering rParam = 0.8, # needed for subjet flavor clustering btagDiscriminators = ['pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probbb', 'pfCombinedInclusiveSecondaryVertexV2BJetTags','pfCombinedMVAV2BJetTags'], jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging genJetCollection = cms.InputTag('slimmedGenJetsAK8SoftDropSubJets'), fatJets=cms.InputTag('ak8PFJetsPuppi'), # needed for subjet flavor clustering groomedFatJets=cms.InputTag('ak8PFJetsPuppiSoftDrop') # needed for subjet flavor clustering ) # add groomed ECFs and N-subjettiness to soft dropped pat::Jets for fat jets and subjets process.load('RecoJets.JetProducers.ECF_cff') addToProcessAndTask('nb1AK8PuppiSoftDrop'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task) addToProcessAndTask('nb2AK8PuppiSoftDrop'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix), cuts = cms.vstring('', '', 'pt > 250')), process, task) #too slow now ==> disable from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018 from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017 from Configuration.Eras.Modifier_phase2_common_cff import phase2_common for e in [pp_on_XeXe_2017, pp_on_AA_2018, phase2_common]: e.toModify(getattr(process,'nb1AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) e.toModify(getattr(process,'nb2AK8PuppiSoftDrop'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb1AK8PuppiSoftDrop'+postfix+':ecfN2','nb1AK8PuppiSoftDrop'+postfix+':ecfN3'] getattr(process,"patJetsAK8PFPuppiSoftDrop").userData.userFloats.src += ['nb2AK8PuppiSoftDrop'+postfix+':ecfN2','nb2AK8PuppiSoftDrop'+postfix+':ecfN3'] addToProcessAndTask('nb1AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta1.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task) addToProcessAndTask('nb2AK8PuppiSoftDropSubjets'+postfix, process.ecfNbeta2.clone(src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets")), process, task) getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb1AK8PuppiSoftDropSubjets'+postfix+':ecfN3'] getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN2','nb2AK8PuppiSoftDropSubjets'+postfix+':ecfN3'] getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['NjettinessAK8Subjets'+postfix+':tau1','NjettinessAK8Subjets'+postfix+':tau2','NjettinessAK8Subjets'+postfix+':tau3','NjettinessAK8Subjets'+postfix+':tau4'] for e in [pp_on_XeXe_2017, pp_on_AA_2018, phase2_common]: e.toModify(getattr(process,'nb1AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) e.toModify(getattr(process,'nb2AK8PuppiSoftDropSubjets'+postfix), cuts = ['pt > 999999', 'pt > 999999', 'pt > 999999'] ) # rekey the groomed ECF value maps to the ungroomed reco jets, which will then be picked # up by PAT in the user floats. addToProcessAndTask("ak8PFJetsPuppiSoftDropValueMap"+postfix, cms.EDProducer("RecoJetToPatJetDeltaRValueMapProducer", src = cms.InputTag("ak8PFJetsPuppi"+postfix), matched = cms.InputTag("patJetsAK8PFPuppiSoftDrop"+postfix), distMax = cms.double(0.8), values = cms.vstring([ 'userFloat("nb1AK8PuppiSoftDrop'+postfix+':ecfN2")', 'userFloat("nb1AK8PuppiSoftDrop'+postfix+':ecfN3")', 'userFloat("nb2AK8PuppiSoftDrop'+postfix+':ecfN2")', 'userFloat("nb2AK8PuppiSoftDrop'+postfix+':ecfN3")', ]), valueLabels = cms.vstring( [ 'nb1AK8PuppiSoftDropN2', 'nb1AK8PuppiSoftDropN3', 'nb2AK8PuppiSoftDropN2', 'nb2AK8PuppiSoftDropN3', ]) ), process, task) # Patify AK8 PF PUPPI addJetCollection(process, postfix=postfix, labelName = 'AK8Puppi', jetSource = cms.InputTag('ak8PFJetsPuppi'+postfix), algo= 'AK', rParam = 0.8, jetCorrections = ('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'), btagDiscriminators = ([ 'pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags', 'pfCombinedMVAV2BJetTags', 'pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probc', 'pfDeepCSVJetTags:probudsg', 'pfDeepCSVJetTags:probbb', 'pfBoostedDoubleSecondaryVertexAK8BJetTags']), genJetCollection = cms.InputTag('slimmedGenJetsAK8') ) getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src = [] # start with empty list of user floats getattr(process,"selectedPatJetsAK8Puppi"+postfix).cut = cms.string("pt > 100") getattr(process,"selectedPatJetsAK8Puppi"+postfix).cutLoose = cms.string("pt > 30") getattr(process,"selectedPatJetsAK8Puppi"+postfix).nLoose = cms.uint32(3) from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX addToProcessAndTask('ak8PFJetsPuppiTracksAssociatorAtVertex'+postfix, cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX.clone( coneSize = cms.double(0.8) ), jets = cms.InputTag("ak8PFJetsPuppi") ), process, task) addToProcessAndTask('patJetAK8PuppiCharge'+postfix, cms.EDProducer("JetChargeProducer", src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"), var = cms.string('Pt'), exp = cms.double(1.0) ), process, task) ## now add AK8 groomed masses and ECF from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass addToProcessAndTask('ak8PFJetsPuppiSoftDropMass'+postfix, ak8PFJetsPuppiSoftDropMass.clone(), process, task) getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += ['ak8PFJetsPuppiSoftDropMass'+postfix] getattr(process,"patJetsAK8Puppi"+postfix).addTagInfos = cms.bool(False) getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += [ cms.InputTag('ak8PFJetsPuppiSoftDropValueMap'+postfix,'nb1AK8PuppiSoftDropN2'), cms.InputTag('ak8PFJetsPuppiSoftDropValueMap'+postfix,'nb1AK8PuppiSoftDropN3'), cms.InputTag('ak8PFJetsPuppiSoftDropValueMap'+postfix,'nb2AK8PuppiSoftDropN2'), cms.InputTag('ak8PFJetsPuppiSoftDropValueMap'+postfix,'nb2AK8PuppiSoftDropN3'), ] # add PUPPI Njetiness addToProcessAndTask('NjettinessAK8Puppi'+postfix, process.Njettiness.clone(), process, task) getattr(process,"NjettinessAK8Puppi"+postfix).src = cms.InputTag("ak8PFJetsPuppi"+postfix) getattr(process,"NjettinessAK8Puppi").cone = cms.double(0.8) getattr(process,"patJetsAK8Puppi").userData.userFloats.src += ['NjettinessAK8Puppi'+postfix+':tau1','NjettinessAK8Puppi'+postfix+':tau2','NjettinessAK8Puppi'+postfix+':tau3','NjettinessAK8Puppi'+postfix+':tau4'] # Now combine the CHS and PUPPI information into the PUPPI jets via delta R value maps addToProcessAndTask("ak8PFJetsCHSValueMap"+postfix, cms.EDProducer("RecoJetToPatJetDeltaRValueMapProducer", src = cms.InputTag("ak8PFJetsPuppi"+postfix), matched = cms.InputTag("patJetsAK8"+postfix), distMax = cms.double(0.8), values = cms.vstring([ 'userFloat("ak8PFJetsCHSPrunedMass"'+postfix+')', 'userFloat("ak8PFJetsCHSSoftDropMass"'+postfix+')', 'userFloat("NjettinessAK8'+postfix+':tau1")', 'userFloat("NjettinessAK8'+postfix+':tau2")', 'userFloat("NjettinessAK8'+postfix+':tau3")', 'userFloat("NjettinessAK8'+postfix+':tau4")', 'pt','eta','phi','mass', 'jetArea', 'jecFactor(0)' ]), valueLabels = cms.vstring( [ 'ak8PFJetsCHSPrunedMass', 'ak8PFJetsCHSSoftDropMass', 'NjettinessAK8CHSTau1', 'NjettinessAK8CHSTau2', 'NjettinessAK8CHSTau3', 'NjettinessAK8CHSTau4', 'pt','eta','phi','mass', 'jetArea', 'rawFactor' ]) ), process, task) # Now set up the user floats getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += [ cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'ak8PFJetsCHSPrunedMass'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'ak8PFJetsCHSSoftDropMass'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'NjettinessAK8CHSTau1'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'NjettinessAK8CHSTau2'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'NjettinessAK8CHSTau3'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'NjettinessAK8CHSTau4'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'pt'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'eta'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'phi'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'mass'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'jetArea'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'rawFactor'), ] addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropSubjets"+postfix, cms.EDProducer("PATJetSlimmer", src = cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"), packedPFCandidates = cms.InputTag("packedPFCandidates"), dropJetVars = cms.string("1"), dropDaughters = cms.string("0"), rekeyDaughters = cms.string("1"), dropTrackRefs = cms.string("1"), dropSpecific = cms.string("1"), dropTagInfos = cms.string("1"), modifyJets = cms.bool(True), mixedDaughters = cms.bool(False), modifierConfig = cms.PSet( modifications = cms.VPSet() ) ), process, task) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix, cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"), subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets") ), process, task ) addToProcessAndTask("packedPatJetsAK8"+postfix, cms.EDProducer("JetSubstructurePacker", jetSrc = cms.InputTag("selectedPatJetsAK8Puppi"+postfix), distMax = cms.double(0.8), algoTags = cms.VInputTag( cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix) ), algoLabels = cms.vstring( 'SoftDropPuppi' ), fixDaughters = cms.bool(True), packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix), ), process, task) # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards) process.slimmedJetsAK8.rekeyDaughters = "0" # Reconfigure the slimmedAK8 jet information to keep process.slimmedJetsAK8.dropDaughters = cms.string("pt < 170") process.slimmedJetsAK8.dropSpecific = cms.string("pt < 170") process.slimmedJetsAK8.dropTagInfos = cms.string("pt < 170")
def addProcessAndTask(self, proc, label, module): task = getPatAlgosToolsTask(proc) addToProcessAndTask(label, module, proc, task)
def applyDeepBtagging(process, postfix=""): task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') # update slimmed jets to include DeepFlavour (keep same name) # make clone for DeepFlavour-less slimmed jets, so output name is preserved addToProcessAndTask('slimmedJetsNoDeepFlavour', process.slimmedJets.clone(), process, task) updateJetCollection( process, jetSource=cms.InputTag('slimmedJetsNoDeepFlavour'), # updateJetCollection defaults to MiniAOD inputs but # here it is made explicit (as in training or MINIAOD redoing) pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), pfCandidates=cms.InputTag('packedPFCandidates'), svSource=cms.InputTag('slimmedSecondaryVertices'), muSource=cms.InputTag('slimmedMuons'), elSource=cms.InputTag('slimmedElectrons'), jetCorrections=('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), btagDiscriminators=[ 'pfDeepFlavourJetTags:probb', 'pfDeepFlavourJetTags:probbb', 'pfDeepFlavourJetTags:problepb', 'pfDeepFlavourJetTags:probc', 'pfDeepFlavourJetTags:probuds', 'pfDeepFlavourJetTags:probg', ], postfix='SlimmedDeepFlavour' + postfix, printWarning=False) # slimmedJets with DeepFlavour (remove DeepFlavour-less) delattr(process, 'slimmedJets') addToProcessAndTask( 'slimmedJets', getattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour' + postfix).clone(), process, task) # delete module not used anymore (slimmedJets substitutes) delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour' + postfix) #switch to True if needed for private tests enableDoubleB = False if enableDoubleB: # update slimmed jets to include DeepFlavour (keep same name) # make clone for DeepDoubleB-less slimmed AK8 jets, so output name is preserved addToProcessAndTask('slimmedJetsAK8NoDeepDoubleB', process.slimmedJetsAK8.clone(), process, task) updateJetCollection( process, jetSource=cms.InputTag('slimmedJetsAK8NoDeepDoubleB'), # updateJetCollection defaults to MiniAOD inputs but # here it is made explicit (as in training or MINIAOD redoing) pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), pfCandidates=cms.InputTag('packedPFCandidates'), svSource=cms.InputTag('slimmedSecondaryVertices'), muSource=cms.InputTag('slimmedMuons'), elSource=cms.InputTag('slimmedElectrons'), rParam=0.8, jetCorrections=('AK8PFPuppi', cms.vstring( ['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), btagDiscriminators=[ 'pfDeepDoubleBJetTags:probQ', 'pfDeepDoubleBJetTags:probH', ], postfix='SlimmedAK8DeepDoubleB' + postfix, printWarning=False) # slimmedJetsAK8 with DeepDoubleB (remove DeepDoubleB-less) delattr(process, 'slimmedJetsAK8') addToProcessAndTask( 'slimmedJetsAK8', getattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepDoubleB' + postfix).clone(), process, task) # delete module not used anymore (slimmedJetsAK8 substitutes) delattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepDoubleB' + postfix)
def applySubstructure(process, postfix=""): task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault #add AK8 addJetCollection( process, postfix=postfix, labelName='AK8', jetSource=cms.InputTag('ak8PFJetsCHS' + postfix), algo='AK', rParam=0.8, jetCorrections=('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), genJetCollection=cms.InputTag('slimmedGenJetsAK8')) getattr(process, "patJetsAK8" + postfix).userData.userFloats.src = [ ] # start with empty list of user floats getattr(process, "selectedPatJetsAK8").cut = cms.string("pt > 170") ## AK8 groomed masses from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop addToProcessAndTask('ak8PFJetsCHSPruned' + postfix, ak8PFJetsCHSPruned.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDrop' + postfix, ak8PFJetsCHSSoftDrop.clone(), process, task) from RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi import ak8PFJetsCHSPrunedMass, ak8PFJetsCHSTrimmedMass, ak8PFJetsCHSFilteredMass, ak8PFJetsCHSSoftDropMass addToProcessAndTask('ak8PFJetsCHSPrunedMass' + postfix, ak8PFJetsCHSPrunedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSTrimmedMass' + postfix, ak8PFJetsCHSTrimmedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSFilteredMass' + postfix, ak8PFJetsCHSFilteredMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDropMass' + postfix, ak8PFJetsCHSSoftDropMass.clone(), process, task) getattr(process, "patJetsAK8").userData.userFloats.src += [ 'ak8PFJetsCHSPrunedMass' + postfix, 'ak8PFJetsCHSSoftDropMass' + postfix ] getattr(process, "patJetsAK8").addTagInfos = cms.bool(False) # add Njetiness process.load('RecoJets.JetProducers.nJettinessAdder_cfi') task.add(process.Njettiness) addToProcessAndTask('NjettinessAK8' + postfix, process.Njettiness.clone(), process, task) getattr(process, "NjettinessAK8").src = cms.InputTag("ak8PFJetsCHS" + postfix) getattr(process, "NjettinessAK8").cone = cms.double(0.8) getattr(process, "patJetsAK8").userData.userFloats.src += [ 'NjettinessAK8' + postfix + ':tau1', 'NjettinessAK8' + postfix + ':tau2', 'NjettinessAK8' + postfix + ':tau3' ] #add AK8 from PUPPI from RecoJets.JetProducers.ak8PFJetsPuppi_cfi import ak4PFJetsPuppi, ak8PFJetsPuppi addToProcessAndTask('ak4PFJetsPuppi' + postfix, ak4PFJetsPuppi.clone(), process, task) addToProcessAndTask('ak8PFJetsPuppi' + postfix, ak8PFJetsPuppi.clone(), process, task) from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsPuppiSoftDrop addToProcessAndTask('ak8PFJetsPuppiSoftDrop' + postfix, ak8PFJetsPuppiSoftDrop.clone(), process, task) getattr( process, "ak8PFJetsPuppi" ).doAreaFastjet = True # even for standard ak8PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff addJetCollection( process, postfix=postfix, labelName='AK8Puppi', jetSource=cms.InputTag('ak8PFJetsPuppi' + postfix), algo='AK', rParam=0.8, jetCorrections=('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'), btagDiscriminators=( [x.getModuleLabel() for x in patJetsDefault.discriminatorSources] + ['pfBoostedDoubleSecondaryVertexAK8BJetTags']), genJetCollection=cms.InputTag('slimmedGenJetsAK8')) getattr(process, "patJetsAK8Puppi" + postfix).userData.userFloats.src = [ ] # start with empty list of user floats getattr(process, "selectedPatJetsAK8Puppi" + postfix).cut = cms.string("pt > 170") from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX addToProcessAndTask( 'ak8PFJetsPuppiTracksAssociatorAtVertex' + postfix, cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX.clone(coneSize=cms.double(0.8)), jets=cms.InputTag("ak8PFJetsPuppi")), process, task) addToProcessAndTask( 'patJetAK8PuppiCharge' + postfix, cms.EDProducer( "JetChargeProducer", src=cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"), var=cms.string('Pt'), exp=cms.double(1.0)), process, task) ## AK8 groomed masses from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsPuppiSoftDrop addToProcessAndTask('ak8PFJetsPuppiSoftDrop' + postfix, ak8PFJetsPuppiSoftDrop.clone(), process, task) from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass addToProcessAndTask('ak8PFJetsPuppiSoftDropMass' + postfix, ak8PFJetsPuppiSoftDropMass.clone(), process, task) getattr(process, "patJetsAK8Puppi" + postfix).userData.userFloats.src += [ 'ak8PFJetsPuppiSoftDropMass' + postfix ] getattr(process, "patJetsAK8Puppi" + postfix).addTagInfos = cms.bool(False) # add Njetiness addToProcessAndTask('NjettinessAK8Puppi' + postfix, process.Njettiness.clone(), process, task) getattr(process, "NjettinessAK8Puppi" + postfix).src = cms.InputTag("ak8PFJetsPuppi" + postfix) getattr(process, "NjettinessAK8Puppi").cone = cms.double(0.8) getattr(process, "patJetsAK8Puppi").userData.userFloats.src += [ 'NjettinessAK8Puppi' + postfix + ':tau1', 'NjettinessAK8Puppi' + postfix + ':tau2', 'NjettinessAK8Puppi' + postfix + ':tau3' ] addToProcessAndTask( "ak8PFJetsCHSValueMap" + postfix, cms.EDProducer( "RecoJetToPatJetDeltaRValueMapProducer", src=cms.InputTag("ak8PFJetsPuppi" + postfix), matched=cms.InputTag("patJetsAK8" + postfix), distMax=cms.double(0.8), values=cms.vstring([ 'userFloat("ak8PFJetsCHSPrunedMass"' + postfix + ')', 'userFloat("ak8PFJetsCHSSoftDropMass"' + postfix + ')', 'userFloat("NjettinessAK8' + postfix + ':tau1")', 'userFloat("NjettinessAK8' + postfix + ':tau2")', 'userFloat("NjettinessAK8' + postfix + ':tau3")', 'pt', 'eta', 'phi', 'mass' ]), valueLabels=cms.vstring([ 'ak8PFJetsCHSPrunedMass', 'ak8PFJetsCHSSoftDropMass', 'NjettinessAK8CHSTau1', 'NjettinessAK8CHSTau2', 'NjettinessAK8CHSTau3', 'pt', 'eta', 'phi', 'mass' ])), process, task) getattr(process, "patJetsAK8Puppi" + postfix).userData.userFloats.src += [ cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'ak8PFJetsCHSPrunedMass'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'ak8PFJetsCHSSoftDropMass'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'NjettinessAK8CHSTau1'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'NjettinessAK8CHSTau2'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'NjettinessAK8CHSTau3'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'pt'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'eta'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'phi'), cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'mass'), ] # add Njetiness process.load('RecoJets.JetProducers.nJettinessAdder_cfi') task.add(process.Njettiness) addToProcessAndTask('NjettinessAK8Subjets' + postfix, process.Njettiness.clone(), process, task) getattr(process, "NjettinessAK8Subjets" + postfix).src = cms.InputTag( "ak8PFJetsPuppiSoftDrop" + postfix, "SubJets") getattr(process, "NjettinessAK8Subjets").cone = cms.double(0.8) ## PATify CHS soft drop fat jets addJetCollection( process, postfix=postfix, labelName='AK8PFCHSSoftDrop', jetSource=cms.InputTag('ak8PFJetsCHSSoftDrop' + postfix), btagDiscriminators=['None'], jetCorrections=('AK8PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour=False # jet flavor disabled ) ## PATify puppi soft drop fat jets addJetCollection( process, postfix=postfix, labelName='AK8PFPuppiSoftDrop', jetSource=cms.InputTag('ak8PFJetsPuppiSoftDrop' + postfix), btagDiscriminators=['None'], jetCorrections=('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour=False # jet flavor disabled ) ## PATify soft drop subjets addJetCollection( process, postfix=postfix, labelName='AK8PFPuppiSoftDropSubjets', jetSource=cms.InputTag('ak8PFJetsPuppiSoftDrop' + postfix, 'SubJets'), algo='ak', # needed for subjet flavor clustering rParam=0.8, # needed for subjet flavor clustering btagDiscriminators=[ 'pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags', 'pfCombinedMVAV2BJetTags' ], jetCorrections=('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), explicitJTA=True, # needed for subjet b tagging svClustering=True, # needed for subjet b tagging genJetCollection=cms.InputTag('slimmedGenJets'), fatJets=cms.InputTag( 'ak8PFJetsPuppi'), # needed for subjet flavor clustering groomedFatJets=cms.InputTag( 'ak8PFJetsPuppiSoftDrop') # needed for subjet flavor clustering ) getattr(process, "selectedPatJetsAK8PFPuppiSoftDrop" + postfix).cut = cms.string("pt > 170") getattr(process, "patJetsAK8PFPuppiSoftDropSubjets" + postfix).userData.userFloats.src += [ 'NjettinessAK8Subjets' + postfix + ':tau1', 'NjettinessAK8Subjets' + postfix + ':tau2', 'NjettinessAK8Subjets' + postfix + ':tau3' ] addToProcessAndTask( "slimmedJetsAK8PFPuppiSoftDropSubjets" + postfix, cms.EDProducer( "PATJetSlimmer", src=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"), packedPFCandidates=cms.InputTag("packedPFCandidates"), dropJetVars=cms.string("1"), dropDaughters=cms.string("0"), rekeyDaughters=cms.string("1"), dropTrackRefs=cms.string("1"), dropSpecific=cms.string("1"), dropTagInfos=cms.string("1"), modifyJets=cms.bool(True), mixedDaughters=cms.bool(False), modifierConfig=cms.PSet(modifications=cms.VPSet())), process, task) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger addToProcessAndTask( "slimmedJetsAK8PFPuppiSoftDropPacked" + postfix, cms.EDProducer( "BoostedJetMerger", jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"), subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets")), process, task) addToProcessAndTask( "packedPatJetsAK8" + postfix, cms.EDProducer( "JetSubstructurePacker", jetSrc=cms.InputTag("selectedPatJetsAK8Puppi" + postfix), distMax=cms.double(0.8), algoTags=cms.VInputTag( cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked" + postfix)), algoLabels=cms.vstring('SoftDropPuppi'), fixDaughters=cms.bool(True), packedPFCandidates=cms.InputTag("packedPFCandidates" + postfix), ), process, task) # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards) process.slimmedJetsAK8.rekeyDaughters = "0"
def applySubstructure( process, postfix="" ) : task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault #add AK8 addJetCollection(process, postfix=postfix, labelName = 'AK8', jetSource = cms.InputTag('ak8PFJetsCHS'+postfix), algo= 'AK', rParam = 0.8, jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), genJetCollection = cms.InputTag('slimmedGenJetsAK8') ) getattr(process,"patJetsAK8"+postfix).userData.userFloats.src = [] # start with empty list of user floats getattr(process,"selectedPatJetsAK8").cut = cms.string("pt > 170") ## AK8 groomed masses from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop addToProcessAndTask('ak8PFJetsCHSPruned'+postfix, ak8PFJetsCHSPruned.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDrop'+postfix, ak8PFJetsCHSSoftDrop.clone(), process, task) from RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi import ak8PFJetsCHSPrunedMass, ak8PFJetsCHSTrimmedMass, ak8PFJetsCHSFilteredMass, ak8PFJetsCHSSoftDropMass addToProcessAndTask('ak8PFJetsCHSPrunedMass'+postfix, ak8PFJetsCHSPrunedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSTrimmedMass'+postfix, ak8PFJetsCHSTrimmedMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSFilteredMass'+postfix, ak8PFJetsCHSFilteredMass.clone(), process, task) addToProcessAndTask('ak8PFJetsCHSSoftDropMass'+postfix, ak8PFJetsCHSSoftDropMass.clone(), process, task) getattr(process,"patJetsAK8").userData.userFloats.src += ['ak8PFJetsCHSPrunedMass'+postfix,'ak8PFJetsCHSSoftDropMass'+postfix] getattr(process,"patJetsAK8").addTagInfos = cms.bool(False) # add Njetiness process.load('RecoJets.JetProducers.nJettinessAdder_cfi') task.add(process.Njettiness) addToProcessAndTask('NjettinessAK8'+postfix, process.Njettiness.clone(), process, task) getattr(process,"NjettinessAK8").src = cms.InputTag("ak8PFJetsCHS"+postfix) getattr(process,"NjettinessAK8").cone = cms.double(0.8) getattr(process,"patJetsAK8").userData.userFloats.src += ['NjettinessAK8'+postfix+':tau1','NjettinessAK8'+postfix+':tau2','NjettinessAK8'+postfix+':tau3'] #add AK8 from PUPPI from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJetsPuppi from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi addToProcessAndTask('ak4PFJetsPuppi'+postfix,ak4PFJetsPuppi.clone(), process, task) addToProcessAndTask('ak8PFJetsPuppi'+postfix,ak8PFJetsPuppi.clone(), process, task) from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsPuppiSoftDrop addToProcessAndTask('ak8PFJetsPuppiSoftDrop'+postfix, ak8PFJetsPuppiSoftDrop.clone(), process, task) getattr(process,"ak8PFJetsPuppi").doAreaFastjet = True # even for standard ak8PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff #add AK8 from PUPPI from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJetsPuppi from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents, ak8PFJetsCHSConstituents #from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents, ak8PFJetsCHSConstituents addToProcessAndTask('ak4PFJetsPuppi'+postfix,ak4PFJetsPuppi.clone(), process, task) addToProcessAndTask('ak8PFJetsPuppiConstituents', ak8PFJetsPuppiConstituents.clone(), process, task ) addToProcessAndTask('ak8PFJetsCHSConstituents', ak8PFJetsCHSConstituents.clone(), process, task ) addToProcessAndTask('ak8PFJetsPuppi'+postfix,ak8PFJetsPuppi.clone(), process, task) addToProcessAndTask('ak8PFJetsPuppiSoftDrop'+postfix, ak8PFJetsPuppiSoftDrop.clone(), process, task) getattr(process,"ak8PFJetsPuppi").doAreaFastjet = True # even for standard ak8PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff addJetCollection(process, postfix=postfix, labelName = 'AK8Puppi', jetSource = cms.InputTag('ak8PFJetsPuppi'+postfix), algo= 'AK', rParam = 0.8, jetCorrections = ('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'), btagDiscriminators = ([x.value() for x in patJetsDefault.discriminatorSources] + ['pfBoostedDoubleSecondaryVertexAK8BJetTags']), genJetCollection = cms.InputTag('slimmedGenJetsAK8') ) getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src = [] # start with empty list of user floats getattr(process,"selectedPatJetsAK8Puppi"+postfix).cut = cms.string("pt > 170") from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX addToProcessAndTask('ak8PFJetsPuppiTracksAssociatorAtVertex'+postfix, cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX.clone( coneSize = cms.double(0.8) ), jets = cms.InputTag("ak8PFJetsPuppi") ), process, task) addToProcessAndTask('patJetAK8PuppiCharge'+postfix, cms.EDProducer("JetChargeProducer", src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"), var = cms.string('Pt'), exp = cms.double(1.0) ), process, task) ## AK8 groomed masses from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsPuppiSoftDrop addToProcessAndTask('ak8PFJetsPuppiSoftDrop'+postfix, ak8PFJetsPuppiSoftDrop.clone(), process, task) from RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi import ak8PFJetsPuppiSoftDropMass addToProcessAndTask('ak8PFJetsPuppiSoftDropMass'+postfix, ak8PFJetsPuppiSoftDropMass.clone(), process, task) getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += ['ak8PFJetsPuppiSoftDropMass'+postfix] getattr(process,"patJetsAK8Puppi"+postfix).addTagInfos = cms.bool(False) # add Njetiness addToProcessAndTask('NjettinessAK8Puppi'+postfix, process.Njettiness.clone(), process, task) getattr(process,"NjettinessAK8Puppi"+postfix).src = cms.InputTag("ak8PFJetsPuppi"+postfix) getattr(process,"NjettinessAK8Puppi").cone = cms.double(0.8) getattr(process,"patJetsAK8Puppi").userData.userFloats.src += ['NjettinessAK8Puppi'+postfix+':tau1','NjettinessAK8Puppi'+postfix+':tau2','NjettinessAK8Puppi'+postfix+':tau3'] addToProcessAndTask("ak8PFJetsCHSValueMap"+postfix, cms.EDProducer("RecoJetToPatJetDeltaRValueMapProducer", src = cms.InputTag("ak8PFJetsPuppi"+postfix), matched = cms.InputTag("patJetsAK8"+postfix), distMax = cms.double(0.8), values = cms.vstring([ 'userFloat("ak8PFJetsCHSPrunedMass"'+postfix+')', 'userFloat("ak8PFJetsCHSSoftDropMass"'+postfix+')', 'userFloat("NjettinessAK8'+postfix+':tau1")', 'userFloat("NjettinessAK8'+postfix+':tau2")', 'userFloat("NjettinessAK8'+postfix+':tau3")', 'pt','eta','phi','mass' ]), valueLabels = cms.vstring( [ 'ak8PFJetsCHSPrunedMass', 'ak8PFJetsCHSSoftDropMass', 'NjettinessAK8CHSTau1', 'NjettinessAK8CHSTau2', 'NjettinessAK8CHSTau3', 'pt','eta','phi','mass' ]) ), process, task) getattr(process,"patJetsAK8Puppi"+postfix).userData.userFloats.src += [ cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'ak8PFJetsCHSPrunedMass'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'ak8PFJetsCHSSoftDropMass'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'NjettinessAK8CHSTau1'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'NjettinessAK8CHSTau2'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'NjettinessAK8CHSTau3'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'pt'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'eta'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'phi'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'mass'), ] # add Njetiness process.load('RecoJets.JetProducers.nJettinessAdder_cfi') task.add(process.Njettiness) addToProcessAndTask('NjettinessAK8Subjets'+postfix, process.Njettiness.clone(), process, task) getattr(process,"NjettinessAK8Subjets"+postfix).src = cms.InputTag("ak8PFJetsPuppiSoftDrop"+postfix, "SubJets") getattr(process,"NjettinessAK8Subjets").cone = cms.double(0.8) ## PATify CHS soft drop fat jets addJetCollection( process, postfix=postfix, labelName = 'AK8PFCHSSoftDrop', jetSource = cms.InputTag('ak8PFJetsCHSSoftDrop'+postfix), btagDiscriminators = ['None'], jetCorrections = ('AK8PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour = False # jet flavor disabled ) ## PATify puppi soft drop fat jets addJetCollection( process, postfix=postfix, labelName = 'AK8PFPuppiSoftDrop', jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix), btagDiscriminators = ['None'], jetCorrections = ('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), getJetMCFlavour = False # jet flavor disabled ) ## PATify soft drop subjets addJetCollection( process, postfix=postfix, labelName = 'AK8PFPuppiSoftDropSubjets', jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'+postfix,'SubJets'), algo = 'ak', # needed for subjet flavor clustering rParam = 0.8, # needed for subjet flavor clustering btagDiscriminators = ['pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probbb', 'pfCombinedInclusiveSecondaryVertexV2BJetTags','pfCombinedMVAV2BJetTags'], jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'), explicitJTA = True, # needed for subjet b tagging svClustering = True, # needed for subjet b tagging genJetCollection = cms.InputTag('slimmedGenJets'), fatJets=cms.InputTag('ak8PFJetsPuppi'), # needed for subjet flavor clustering groomedFatJets=cms.InputTag('ak8PFJetsPuppiSoftDrop') # needed for subjet flavor clustering ) getattr(process,"selectedPatJetsAK8PFPuppiSoftDrop"+postfix).cut = cms.string("pt > 170") getattr(process,"patJetsAK8PFPuppiSoftDropSubjets"+postfix).userData.userFloats.src += ['NjettinessAK8Subjets'+postfix+':tau1','NjettinessAK8Subjets'+postfix+':tau2','NjettinessAK8Subjets'+postfix+':tau3'] addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropSubjets"+postfix, cms.EDProducer("PATJetSlimmer", src = cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropSubjets"), packedPFCandidates = cms.InputTag("packedPFCandidates"), dropJetVars = cms.string("1"), dropDaughters = cms.string("0"), rekeyDaughters = cms.string("1"), dropTrackRefs = cms.string("1"), dropSpecific = cms.string("1"), dropTagInfos = cms.string("1"), modifyJets = cms.bool(True), mixedDaughters = cms.bool(False), modifierConfig = cms.PSet( modifications = cms.VPSet() ) ), process, task) ## Establish references between PATified fat jets and subjets using the BoostedJetMerger addToProcessAndTask("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix, cms.EDProducer("BoostedJetMerger", jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"), subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets") ), process, task ) addToProcessAndTask("packedPatJetsAK8"+postfix, cms.EDProducer("JetSubstructurePacker", jetSrc = cms.InputTag("selectedPatJetsAK8Puppi"+postfix), distMax = cms.double(0.8), algoTags = cms.VInputTag( cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked"+postfix) ), algoLabels = cms.vstring( 'SoftDropPuppi' ), fixDaughters = cms.bool(True), packedPFCandidates = cms.InputTag("packedPFCandidates"+postfix), ), process, task) # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards) process.slimmedJetsAK8.rekeyDaughters = "0"
def nanoAOD_recalibrateMETs(process,isData): # add DeepMETs nanoAOD_DeepMET_switch = cms.PSet( nanoAOD_addDeepMET_switch = cms.untracked.bool(True), # decide if DeeMET should be included in Nano nanoAOD_produceDeepMET_switch = cms.untracked.bool(False), # decide if DeepMET should be computed on the fly ResponseTune_Graph = cms.untracked.string('RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb') ) for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1: # compute DeepMETs in these eras (before 111X) modifier.toModify(nanoAOD_DeepMET_switch, nanoAOD_produceDeepMET_switch = cms.untracked.bool(True)) for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016: modifier.toModify(nanoAOD_DeepMET_switch, ResponseTune_Graph=cms.untracked.string("RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb")) if nanoAOD_DeepMET_switch.nanoAOD_addDeepMET_switch: process = nanoAOD_addDeepMET(process, addDeepMETProducer=nanoAOD_DeepMET_switch.nanoAOD_produceDeepMET_switch, ResponseTune_Graph=nanoAOD_DeepMET_switch.ResponseTune_Graph) # if included in Nano, and not computed in the fly, then it should be extracted from minAOD extractDeepMETs = nanoAOD_DeepMET_switch.nanoAOD_addDeepMET_switch and not nanoAOD_DeepMET_switch.nanoAOD_produceDeepMET_switch runMetCorAndUncFromMiniAOD(process,isData=isData, extractDeepMETs=extractDeepMETs) process.nanoSequenceCommon.insert(process.nanoSequenceCommon.index(process.jetSequence),cms.Sequence(process.fullPatMetSequence)) process.basicJetsForMetForT1METNano = process.basicJetsForMet.clone( src = process.updatedJetsWithUserData.src, skipEM = False, type1JetPtThreshold = 0.0, calcMuonSubtrRawPtAsValueMap = cms.bool(True), ) process.jetSequence.insert(process.jetSequence.index(process.updatedJetsWithUserData),cms.Sequence(process.basicJetsForMetForT1METNano)) process.updatedJetsWithUserData.userFloats.muonSubtrRawPt = cms.InputTag("basicJetsForMetForT1METNano:MuonSubtrRawPt") process.corrT1METJetTable.src = process.finalJets.src process.corrT1METJetTable.cut = "pt<15 && abs(eta)<9.9" for table in process.jetTable, process.corrT1METJetTable: table.variables.muonSubtrFactor = Var("1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc="1-(muon-subtracted raw pt)/(raw pt)",precision=6) process.metTables += process.corrT1METJetTable # makePuppiesFromMiniAOD(process,True) # call this before in the global customizer otherwise it would reset photon IDs in VID nanoAOD_PuppiV15_switch = cms.PSet( recoMetFromPFCs = cms.untracked.bool(False), reclusterJets = cms.untracked.bool(False), ) run2_nanoAOD_106Xv1.toModify(nanoAOD_PuppiV15_switch,recoMetFromPFCs=True,reclusterJets=True) if nanoAOD_PuppiV15_switch.reclusterJets: from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask task = getPatAlgosToolsTask(process) addToProcessAndTask('ak4PuppiJets', ak4PFJets.clone (src = 'puppi', doAreaFastjet = True, jetPtMin = 10.), process, task) from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection addJetCollection(process, labelName = 'Puppi', jetSource = cms.InputTag('ak4PuppiJets'), algo = 'AK', rParam=0.4, genJetCollection=cms.InputTag('slimmedGenJets'), jetCorrections = ('AK4PFPuppi', ['L1FastJet', 'L2Relative', 'L3Absolute','L2L3Residual'], 'None'), pfCandidates = cms.InputTag('packedPFCandidates'), pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'), svSource = cms.InputTag('slimmedSecondaryVertices'), muSource =cms.InputTag( 'slimmedMuons'), elSource = cms.InputTag('slimmedElectrons'), genParticles= cms.InputTag('prunedGenParticles'), getJetMCFlavour= False ) process.patJetsPuppi.addGenPartonMatch = cms.bool(False) process.patJetsPuppi.addGenJetMatch = cms.bool(False) runMetCorAndUncFromMiniAOD(process,isData=isData,metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi", recoMetFromPFCs=bool(nanoAOD_PuppiV15_switch.recoMetFromPFCs), reclusterJets=bool(nanoAOD_PuppiV15_switch.reclusterJets)) process.nanoSequenceCommon.insert(process.nanoSequenceCommon.index(process.jetSequence),cms.Sequence(process.puppiMETSequence+process.fullPatMetSequencePuppi)) return process
def applyDeepBtagging( process, postfix="" ) : task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') # update slimmed jets to include DeepFlavour (keep same name) # make clone for DeepFlavour-less slimmed jets, so output name is preserved addToProcessAndTask('slimmedJetsNoDeepFlavour', process.slimmedJets.clone(), process, task) updateJetCollection( process, jetSource = cms.InputTag('slimmedJetsNoDeepFlavour'), # updateJetCollection defaults to MiniAOD inputs but # here it is made explicit (as in training or MINIAOD redoing) pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'), pfCandidates = cms.InputTag('packedPFCandidates'), svSource = cms.InputTag('slimmedSecondaryVertices'), muSource = cms.InputTag('slimmedMuons'), elSource = cms.InputTag('slimmedElectrons'), jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), btagDiscriminators = [ 'pfDeepFlavourJetTags:probb', 'pfDeepFlavourJetTags:probbb', 'pfDeepFlavourJetTags:problepb', 'pfDeepFlavourJetTags:probc', 'pfDeepFlavourJetTags:probuds', 'pfDeepFlavourJetTags:probg', ], postfix = 'SlimmedDeepFlavour'+postfix, printWarning = False ) # slimmedJets with DeepFlavour (remove DeepFlavour-less) delattr(process, 'slimmedJets') addToProcessAndTask('slimmedJets', getattr(process,'selectedUpdatedPatJetsSlimmedDeepFlavour'+postfix).clone(), process, task) # delete module not used anymore (slimmedJets substitutes) delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour'+postfix) # update slimmed jets to include DeepFlavour (keep same name) # make clone for DeepDoubleB-less slimmed AK8 jets, so output name is preserved addToProcessAndTask('slimmedJetsAK8NoDeepDoubleB', process.slimmedJetsAK8.clone(), process, task) updateJetCollection( process, jetSource = cms.InputTag('slimmedJetsAK8NoDeepDoubleB'), # updateJetCollection defaults to MiniAOD inputs but # here it is made explicit (as in training or MINIAOD redoing) pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'), pfCandidates = cms.InputTag('packedPFCandidates'), svSource = cms.InputTag('slimmedSecondaryVertices'), muSource = cms.InputTag('slimmedMuons'), elSource = cms.InputTag('slimmedElectrons'), rParam = 0.8, jetCorrections = ('AK8PFPuppi', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), btagDiscriminators = [ 'pfDeepDoubleBJetTags:probQ', 'pfDeepDoubleBJetTags:probH', ], postfix = 'SlimmedAK8DeepDoubleB'+postfix, printWarning = False ) # slimmedJetsAK8 with DeepDoubleB (remove DeepDoubleB-less) delattr(process, 'slimmedJetsAK8') addToProcessAndTask('slimmedJetsAK8', getattr(process,'selectedUpdatedPatJetsSlimmedAK8DeepDoubleB'+postfix).clone(), process, task) # delete module not used anymore (slimmedJetsAK8 substitutes) delattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepDoubleB'+postfix)
def applyDeepBtagging(process, postfix=""): task = getPatAlgosToolsTask(process) from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') # update slimmed jets to include DeepFlavour (keep same name) # make clone for DeepFlavour-less slimmed jets, so output name is preserved addToProcessAndTask('slimmedJetsNoDeepFlavour', process.slimmedJets.clone(), process, task) updateJetCollection( process, jetSource=cms.InputTag('slimmedJetsNoDeepFlavour'), # updateJetCollection defaults to MiniAOD inputs but # here it is made explicit (as in training or MINIAOD redoing) pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), pfCandidates=cms.InputTag('packedPFCandidates'), svSource=cms.InputTag('slimmedSecondaryVertices'), muSource=cms.InputTag('slimmedMuons'), elSource=cms.InputTag('slimmedElectrons'), jetCorrections=('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), btagDiscriminators=[ 'pfDeepFlavourJetTags:probb', 'pfDeepFlavourJetTags:probbb', 'pfDeepFlavourJetTags:problepb', 'pfDeepFlavourJetTags:probc', 'pfDeepFlavourJetTags:probuds', 'pfDeepFlavourJetTags:probg', ], postfix='SlimmedDeepFlavour' + postfix, printWarning=False) # slimmedJets with DeepFlavour (remove DeepFlavour-less) delattr(process, 'slimmedJets') addToProcessAndTask( 'slimmedJets', getattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour' + postfix).clone(), process, task) # delete module not used anymore (slimmedJets substitutes) delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour' + postfix) from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsAll as pfDeepBoostedJetTagsAll from RecoBTag.ONNXRuntime.pfHiggsInteractionNet_cff import _pfHiggsInteractionNetTagsProbs as pfHiggsInteractionNetTagsProbs from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetJetTagsAll as pfParticleNetJetTagsAll # update slimmed jets to include particle-based deep taggers (keep same name) # make clone for DeepTags-less slimmed AK8 jets, so output name is preserved addToProcessAndTask('slimmedJetsAK8NoDeepTags', process.slimmedJetsAK8.clone(), process, task) _btagDiscriminators = cms.PSet(names=cms.vstring( 'pfDeepDoubleBvLJetTags:probQCD', 'pfDeepDoubleBvLJetTags:probHbb', 'pfDeepDoubleCvLJetTags:probQCD', 'pfDeepDoubleCvLJetTags:probHcc', 'pfDeepDoubleCvBJetTags:probHbb', 'pfDeepDoubleCvBJetTags:probHcc', 'pfMassIndependentDeepDoubleBvLJetTags:probQCD', 'pfMassIndependentDeepDoubleBvLJetTags:probHbb', 'pfMassIndependentDeepDoubleCvLJetTags:probQCD', 'pfMassIndependentDeepDoubleCvLJetTags:probHcc', 'pfMassIndependentDeepDoubleCvBJetTags:probHbb', 'pfMassIndependentDeepDoubleCvBJetTags:probHcc', ) + pfDeepBoostedJetTagsAll + pfParticleNetJetTagsAll + pfHiggsInteractionNetTagsProbs) updateJetCollection( process, jetSource=cms.InputTag('slimmedJetsAK8NoDeepTags'), # updateJetCollection defaults to MiniAOD inputs but # here it is made explicit (as in training or MINIAOD redoing) pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), pfCandidates=cms.InputTag('packedPFCandidates'), svSource=cms.InputTag('slimmedSecondaryVertices'), muSource=cms.InputTag('slimmedMuons'), elSource=cms.InputTag('slimmedElectrons'), rParam=0.8, jetCorrections=('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'), btagDiscriminators=_btagDiscriminators.names.value(), postfix='SlimmedAK8DeepTags' + postfix, printWarning=False) # slimmedJetsAK8 with DeepTags (remove DeepTags-less) delattr(process, 'slimmedJetsAK8') addToProcessAndTask( 'slimmedJetsAK8', getattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepTags' + postfix).clone(), process, task) # delete module not used anymore (slimmedJetsAK8 substitutes) delattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepTags' + postfix)
def reconfigurePF2PATTaus(process, tauType='shrinkingConePFTau', pf2patSelection=["DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut"], selectionDependsOn=["DiscriminationByLeadingTrackFinding"], producerFromType=lambda producer: producer+"Producer", postfix = ""): print "patTaus will be produced from taus of type: %s that pass %s" \ % (tauType, pf2patSelection) # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer producerName = producerFromType(tauType) # Set as the source for the pf2pat taus (pfTaus) selector applyPostfix(process,"pfTaus", postfix).src = producerName+postfix # Start our pf2pat taus base sequence oldTauSansRefs = getattr(process,'pfTausProducerSansRefs'+postfix) oldTau = getattr(process,'pfTausProducer'+postfix) ## copy tau and setup it properly newTauSansRefs = None newTau = getattr(process,producerName+postfix).clone() ## adapted to new structure in RecoTauProducers PLEASE CHECK!!! if tauType=='shrinkingConePFTau': newTauSansRefs = getattr(process,producerName+"SansRefs").clone() newTauSansRefs.modifiers[1] = cms.PSet( pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), name = cms.string('pfTauTTIworkaround'+postfix), plugin = cms.string('RecoTauTagInfoWorkaroundModifer') ) newTau.modifiers[1] = newTauSansRefs.modifiers[1] newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix newTau.piZeroSrc = newTauSansRefs.piZeroSrc newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[0].pfCandSrc newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc elif tauType=='fixedConePFTau': newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix elif tauType=='hpsPFTau': newTau = getattr(process,'combinatoricRecoTaus'+postfix).clone() newTau.piZeroSrc="pfJetsLegacyHPSPiZeros"+postfix newTau.modifiers[3] = cms.PSet( pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), name = cms.string('pfTauTTIworkaround'+postfix), plugin = cms.string('RecoTauTagInfoWorkaroundModifer') ) from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet #cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix, addToTask = True) setattr(process,'produceHPSPFTaus'+postfix,cms.Sequence(applyPostfix(process,'hpsSelectionDiscriminator',postfix)+applyPostfix(process,'hpsPFTauProducerSansRefs',postfix)+applyPostfix(process,'hpsPFTauProducer',postfix))) massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix), "PFTauProducer", cms.InputTag("combinatoricRecoTaus"+postfix), cms.InputTag("pfTausBase"+postfix) ) massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix), "src", cms.InputTag("combinatoricRecoTaus"+postfix), cms.InputTag("pfTausBase"+postfix) ) ### Next three lines crash, oldTau does not have any of these attributes. Why?### #newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc #newTau.jetRegionSrc = oldTau.jetRegionSrc #newTau.jetSrc = oldTau.jetSrc #newTau.builders[0].pfCandSrc = cms.InputTag("pfNoElectronJME" + postfix) #newTau.jetRegionSrc = cms.InputTag("pfTauPFJets08Region" + postfix) #newTau.jetSrc = cms.InputTag("pfJetsPFBRECO" + postfix) # replace old tau producer by new one put it into baseSequence task = getPatAlgosToolsTask(process) addToProcessAndTask("pfTausBase"+postfix, newTau, process, task) if tauType=='shrinkingConePFTau': addToProcessAndTask("pfTausBaseSansRefs"+postfix, newTauSansRefs, process, task) getattr(process,"pfTausBase"+postfix).src = "pfTausBaseSansRefs"+postfix baseSequence += getattr(process,"pfTausBaseSansRefs"+postfix) #make custom mapper to take postfix into account (could have gone with lambda of lambda but... ) def producerIsTauTypeMapperWithPostfix(tauProducer): return lambda x: producerIsTauTypeMapper(tauProducer)+x.group(1)+postfix def recoTauTypeMapperWithGroup(tauProducer): return "%s(.*)"%recoTauTypeMapper(tauProducer) # Get our prediscriminants for predisc in selectionDependsOn: # Get the prototype originalName = tauType+predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding clonedName = "pfTausBase"+predisc+postfix clonedDisc = getattr(process, originalName).clone() addToProcessAndTask(clonedName, clonedDisc, process, task) tauCollectionToSelect = None if tauType != 'hpsPFTau' : tauCollectionToSelect = "pfTausBase"+postfix #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = "hpsPFTauProducer"+postfix # Adapt this discriminator for the cloned prediscriminators adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Reconfigure the pf2pat PFTau selector discrimination sources getattr(process,"pfTaus" + postfix).discriminators = cms.VPSet() for selection in pf2patSelection: # Get our discriminator that will be used to select pfTaus originalName = tauType+selection clonedName = "pfTausBase"+selection+postfix clonedDisc = getattr(process, originalName).clone() addToProcessAndTask(clonedName, clonedDisc, process, task) tauCollectionToSelect = None if tauType != 'hpsPFTau' : tauCollectionToSelect = cms.InputTag("pfTausBase"+postfix) #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = cms.InputTag("hpsPFTauProducer"+postfix) #Adapt our cloned discriminator to the new prediscriminants adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Add this selection to our pfTau selectors getattr(process,"pfTaus" + postfix).discriminators.append(cms.PSet( discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5))) # Set the input of the final selector. if tauType != 'hpsPFTau': getattr(process,"pfTaus" + postfix).src = "pfTausBase"+postfix else: # If we are using HPS taus, we need to take the output of the clenaed # collection getattr(process,"pfTaus" + postfix).src = "hpsPFTauProducer"+postfix
def miniAOD_customizeCommon(process): process.patMuons.isoDeposits = cms.PSet() process.patElectrons.isoDeposits = cms.PSet() process.patTaus.isoDeposits = cms.PSet() process.patPhotons.isoDeposits = cms.PSet() # process.patMuons.embedTrack = True # used for IDs process.patMuons.embedCombinedMuon = True # used for IDs process.patMuons.embedMuonBestTrack = True # used for IDs process.patMuons.embedStandAloneMuon = True # maybe? process.patMuons.embedPickyMuon = False # no, use best track process.patMuons.embedTpfmsMuon = False # no, use best track process.patMuons.embedDytMuon = False # no, use best track process.patMuons.addPuppiIsolation = cms.bool(True) process.patMuons.puppiIsolationChargedHadrons = cms.InputTag("muonPUPPIIsolation","h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag("muonPUPPIIsolation","h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiIsolationPhotons = cms.InputTag("muonPUPPIIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.computeMiniIso = cms.bool(True) process.patMuons.computeMuonMVA = cms.bool(True) # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.patElectrons.usePfCandidateMultiMap = True process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap") process.patElectrons.electronIDSources = cms.PSet( # configure many IDs as InputTag <someName> = <someTag> you # can comment out those you don't want to save some disk space eidRobustLoose = cms.InputTag("reducedEgamma","eidRobustLoose"), eidRobustTight = cms.InputTag("reducedEgamma","eidRobustTight"), eidLoose = cms.InputTag("reducedEgamma","eidLoose"), eidTight = cms.InputTag("reducedEgamma","eidTight"), eidRobustHighEnergy = cms.InputTag("reducedEgamma","eidRobustHighEnergy"), ) process.patElectrons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patElectrons.addPuppiIsolation = cms.bool(True) process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.computeMiniIso = cms.bool(True) process.patElectrons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso") process.patElectrons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso") process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") # process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer process.patPhotons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patPhotons.addPuppiIsolation = cms.bool(True) process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-") process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-") process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-") process.patPhotons.ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso") process.patPhotons.hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso") process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons") process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.patPhotons.photonIDSources = cms.PSet( PhotonCutBasedIDLoose = cms.InputTag('reducedEgamma', 'PhotonCutBasedIDLoose'), PhotonCutBasedIDTight = cms.InputTag('reducedEgamma', 'PhotonCutBasedIDTight') ) process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") # process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons") process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))") from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )") process.selectedPatElectrons.cut = cms.string("") process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5") process.selectedPatPhotons.cut = cms.string("") from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure applySubstructure( process ) # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone switchOnTriggerStandAlone( process, outputModule = '' ) process.patTrigger.packTriggerPathNames = cms.bool(True) # # apply type I + other PFMEt corrections to pat::MET object # and estimate systematic uncertainties on MET from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets") #caloMET computation from PhysicsTools.PatAlgos.tools.metTools import addMETCollection addMETCollection(process, labelName = "patCaloMet", metSource = "caloMetM" ) #noHF pfMET ========= task = getPatAlgosToolsTask(process) process.noHFCands = cms.EDFilter("GenericPFCandidateSelector", src=cms.InputTag("particleFlow"), cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0") ) task.add(process.noHFCands) runMetCorAndUncForMiniAODProduction(process, pfCandColl=cms.InputTag("noHFCands"), recoMetFromPFCs=True, #needed for HF removal jetSelection="pt>15 && abs(eta)<3.", postfix="NoHF" ) process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task) process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF") process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF") process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF") process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF") process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF") process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF") process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF") process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF") del process.slimmedMETsNoHF.caloMET # ================== NoHF pfMET # ================== CHSMET process.CHSCands = cms.EDFilter("CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("fromPV(0) > 0") ) task.add(process.CHSCands) process.pfMetCHS = cms.EDProducer("PFMETProducer", src = cms.InputTag("CHSCands"), alias = cms.string('pfMet'), globalThreshold = cms.double(0.0), calculateSignificance = cms.bool(False), ) task.add(process.pfMetCHS) addMETCollection(process, labelName = "patCHSMet", metSource = "pfMetCHS" ) process.patCHSMet.computeMETSignificance = cms.bool(False) # ================== CHSMET # ================== TrkMET process.TrkCands = cms.EDFilter("CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0") ) task.add(process.TrkCands) process.pfMetTrk = cms.EDProducer("PFMETProducer", src = cms.InputTag("TrkCands"), alias = cms.string('pfMet'), globalThreshold = cms.double(0.0), calculateSignificance = cms.bool(False), ) task.add(process.pfMetTrk) addMETCollection(process, labelName = "patTrkMet", metSource = "pfMetTrk" ) process.patTrkMet.computeMETSignificance = cms.bool(False) # ================== TrkMET ## PU JetID process.load("RecoJets.JetProducers.PileupJetID_cfi") task.add(process.pileUpJetIDTask) process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ] process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ] ## Quark Gluon Likelihood process.load('RecoJets.JetProducers.QGTagger_cfi') task.add(process.QGTaggerTask) process.patJets.userData.userFloats.src += [ cms.InputTag('QGTagger:qgLikelihood'), ] ## CaloJets process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer", src = process.patJets.jetSource, matched = cms.InputTag("ak4CaloJets"), distMax = cms.double(0.4), values = cms.vstring('pt','emEnergyFraction'), valueLabels = cms.vstring('pt','emEnergyFraction'), lazyParser = cms.bool(True) ) task.add(process.caloJetMap) process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ] #Muon object modifications from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon makeInputForPUPPIIsolationMuon(process) #EGM object modifications from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm makeInputForPUPPIIsolationEgm(process) from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications process.slimmedElectrons.modifierConfig.modifications = egamma_modifications process.slimmedPhotons.modifierConfig.modifications = egamma_modifications #VID Electron IDs electron_ids = ['RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_PHYS14_PU20bx25_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_50ns_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV60_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_nonTrig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_Trig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_50ns_Trig_V1_cff'] switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task) process.egmGsfElectronIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.electronMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') process.electronRegressionValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') for idmod in electron_ids: setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task) #heepIDVarValueMaps only exists if HEEP V6.1 or HEEP 7.0 ID has already been loaded if hasattr(process,'heepIDVarValueMaps'): process.heepIDVarValueMaps.elesMiniAOD = cms.InputTag('reducedEgamma','reducedGedGsfElectrons') #force HEEP to use miniAOD (otherwise it'll detect the AOD) process.heepIDVarValueMaps.dataFormat = cms.int32(2) #VID Photon IDs photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_50ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_25ns_nonTrig_V2p1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_50ns_nonTrig_V2p1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff'] switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task) process.egmPhotonIsolation.srcToIsolate = \ cms.InputTag("reducedEgamma","reducedGedPhotons") for iPSet in process.egmPhotonIsolation.isolationConeDefinitions: iPSet.particleBasedIsolation = cms.InputTag("reducedEgamma","reducedPhotonPfCandMap") process.egmPhotonIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonRegressionValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.particleBasedIsolation = \ cms.InputTag("reducedEgamma","reducedPhotonPfCandMap") process.photonMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedPhotons') for idmod in photon_ids: setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task) #--------------------------------------------------------------------------- #Adding Boosted Subjets taus from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus addBoostedTaus(process) #--------------------------------------------------------------------------- #Adding tau reco for 80X legacy reMiniAOD #make a copy of makePatTauTask to avoid labels and substitution problems _makePatTausTaskWithTauReReco = process.makePatTausTask.copy() #add PFTau reco modules to cloned makePatTauTask process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") _makePatTausTaskWithTauReReco.add(process.PFTauTask) #replace original task by extended one for the miniAOD_80XLegacy era from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy run2_miniAOD_80XLegacy.toReplaceWith( process.makePatTausTask, _makePatTausTaskWithTauReReco) #--------------------------------------------------------------------------- # Adding puppi jets if not hasattr(process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi') task.add(process.ak4PFJets) task.add(process.ak4PFJetsPuppi) process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX, jets = cms.InputTag("ak4PFJetsPuppi") ) task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex) process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer", src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"), var = cms.string('Pt'), exp = cms.double(1.0) ) task.add(process.patJetPuppiCharge) addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'), jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''), pfCandidates = cms.InputTag('puppi'), # using Puppi candidates as input for b tagging of Puppi jets algo= 'AK', rParam = 0.4, btagDiscriminators = map(lambda x: x.value() ,process.patJets.discriminatorSources) ) process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets' process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge") process.selectedPatJetsPuppi.cut = cms.string("pt > 15") process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') task.add(process.slimmedJets) task.add(process.slimmedJetsAK8) addToProcessAndTask('slimmedJetsPuppi', process.slimmedJets.clone(), process, task) process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi") process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag("packedPFCandidates") ## puppi met from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies makePuppies( process ); runMetCorAndUncForMiniAODProduction(process, metType="Puppi", pfCandColl=cms.InputTag("puppiForMET"), jetCollUnskimmed="slimmedJetsPuppi", recoMetFromPFCs=True, jetFlavor="AK4PFPuppi", postfix="Puppi" ) process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task) process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi") process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi") process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi") process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi") process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi") process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi") process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi") process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi") del process.slimmedMETsPuppi.caloMET # add DetIdAssociatorRecords to EventSetup (for isolatedTracks) process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
def switchToPFJets(process, input=cms.InputTag('pfNoTauClones'), algo='AK4', postfix="", jetCorrections=('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute']), type1=False, outputModules=['out']): print "Switching to PFJets, ", algo print "************************ " print "input collection: ", input if algo == 'AK4': genJetCollection = cms.InputTag('ak4GenJetsNoNu' + postfix) rParam = 0.4 elif algo == 'AK7': genJetCollection = cms.InputTag('ak7GenJetsNoNu' + postfix) rParam = 0.7 else: print 'bad jet algorithm:', algo, '! for now, only AK4 and AK7 are allowed. If you need other algorithms, please contact Colin' sys.exit(1) # changing the jet collection in PF2PAT: from CommonTools.ParticleFlow.Tools.jetTools import jetAlgo inputCollection = getattr(process, "pfJetsPFBRECO" + postfix).src setattr(process, "pfJetsPFBRECO" + postfix, jetAlgo(algo)) # problem for cfgBrowser getattr(process, "pfJetsPFBRECO" + postfix).src = inputCollection inputJetCorrLabel = jetCorrections switchJetCollection( process, jetSource=input, algo=algo, rParam=rParam, genJetCollection=genJetCollection, postfix=postfix, jetTrackAssociation=True, jetCorrections=inputJetCorrLabel, outputModules=outputModules, ) # check whether L1FastJet is in the list of correction levels or not applyPostfix(process, "patJetCorrFactors", postfix).useRho = False task = getPatAlgosToolsTask(process) for corr in inputJetCorrLabel[1]: if corr == 'L1FastJet': applyPostfix(process, "patJetCorrFactors", postfix).useRho = True applyPostfix(process, "pfJetsPFBRECO", postfix).doAreaFastjet = True # do correct treatment for TypeI MET corrections #type1=True if type1: for mod in process.producerNames().split(' '): if mod.startswith("kt6") and mod.endswith( "Jets" + postfix) and not 'GenJets' in mod: prefix = mod.replace(postfix, '') prefix = prefix.replace('kt6PFJets', '') prefix = prefix.replace('kt6CaloJets', '') prefix = getattr( process, 'patJetCorrFactors' + prefix + postfix).payload.pythonValue().replace("'", "") for essource in process.es_sources_().keys(): if essource == prefix + 'L1FastJet': setattr( process, essource + postfix, getattr(process, essource).clone( srcRho=cms.InputTag(mod, 'rho'))) addToProcessAndTask( prefix + 'CombinedCorrector' + postfix, getattr(process, prefix + 'CombinedCorrector').clone(), process, task) getattr( process, prefix + 'CorMet' + postfix ).corrector = prefix + 'CombinedCorrector' + postfix for cor in getattr( process, prefix + 'CombinedCorrector' + postfix).correctors: if cor == essource: idx = getattr( process, prefix + 'CombinedCorrector' + postfix).correctors.index(essource) getattr( process, prefix + 'CombinedCorrector' + postfix ).correctors[idx] = essource + postfix if hasattr(getattr(process, "patJets" + postfix), 'embedCaloTowers' ): # optional parameter, which defaults to 'False' anyway applyPostfix(process, "patJets", postfix).embedCaloTowers = False applyPostfix(process, "patJets", postfix).embedPFCandidates = True
def toolCode(self, process): label=self._parameters['label'].value input=self._parameters['input'].value selection=self._parameters['selection'].value isolation=self._parameters['isolation'].value isoDeposits=self._parameters['isoDeposits'].value mcAs=self._parameters['mcAs'].value ## add patTracks to the process from PhysicsTools.PatAlgos.producersLayer1.genericParticleProducer_cfi import patGenericParticles task = getPatAlgosToolsTask(process) addToProcessAndTask('pat' + label, patGenericParticles.clone(src = input), process, task) ## add selectedPatTracks to the process addToProcessAndTask('selectedPat' + label, cms.EDFilter("PATGenericParticleSelector", src = cms.InputTag("pat"+label), cut = cms.string(selection)), process, task) ## add cleanPatTracks to the process from PhysicsTools.PatAlgos.cleaningLayer1.genericTrackCleaner_cfi import cleanPatTracks addToProcessAndTask('cleanPat' + label, cleanPatTracks.clone(src = cms.InputTag('selectedPat' + label)), process, task) ## get them as variables, so we can put them in the sequences and/or configure them l1cands = getattr(process, 'pat' + label) selectedL1cands = getattr(process, 'selectedPat' + label) cleanL1cands = getattr(process, 'cleanPat' + label) ### add them to the Summary Tables #process.patCandidateSummary.candidates += [ cms.InputTag("allPat"+label) ] #process.selectedPatCandidateSummary.candidates += [ cms.InputTag("selectedPat"+label) ] #process.cleanPatCandidateSummary.candidates += [ cms.InputTag("cleanPat"+label) ] ## isolation: start with empty config if(isolation or isoDeposits): process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi") process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi") runIsoDeps = {'tracker':False, 'caloTowers':False} for source,deltaR in isolation.items(): ## loop items in isolation if(source == 'tracker'): runIsoDeps['tracker'] = True l1cands.userIsolation.tracker = cms.PSet( src = cms.InputTag('pat'+label+'IsoDepositTracks'), deltaR = cms.double(deltaR), ) elif(source == 'ecalTowers'): runIsoDeps['caloTowers'] = True l1cands.userIsolation.ecal = cms.PSet( src = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'ecal'), deltaR = cms.double(deltaR), ) elif(source == 'hcalTowers'): runIsoDeps['caloTowers'] = True l1cands.userIsolation.hcal = cms.PSet( src = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'hcal'), deltaR = cms.double(deltaR), ) for source in isoDeposits: ## loop items in isoDeposits if(source == 'tracker'): runIsoDeps['tracker'] = True l1cands.isoDeposits.tracker = cms.InputTag('pat'+label+'IsoDepositTracks') elif(source == 'ecalTowers'): runIsoDeps['caloTowers'] = True l1cands.isoDeposits.ecal = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'ecal') elif(source == 'hcalTowers'): runIsoDeps['caloTowers'] = True l1cands.isoDeposits.hcal = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'hcal') for dep in [ dep for dep,runme in runIsoDeps.items() if runme == True ]: if(dep == 'tracker'): from RecoMuon.MuonIsolationProducers.trackExtractorBlocks_cff import MIsoTrackExtractorCtfBlock addToProcessAndTask('pat'+label+'IsoDepositTracks', cms.EDProducer("CandIsoDepositProducer", src = input, trackType = cms.string('best'), MultipleDepositsFlag = cms.bool(False), ExtractorPSet = cms.PSet( MIsoTrackExtractorCtfBlock )), process, task) elif(dep == 'caloTowers'): from RecoMuon.MuonIsolationProducers.caloExtractorByAssociatorBlocks_cff import MIsoCaloExtractorByAssociatorTowersBlock addToProcessAndTask('pat'+label+'IsoDepositCaloTowers', cms.EDProducer("CandIsoDepositProducer", src = input, trackType = cms.string('best'), MultipleDepositsFlag = cms.bool(True), ExtractorPSet = cms.PSet( MIsoCaloExtractorByAssociatorTowersBlock )), process, task) # ES process.load( 'TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff' ) # MC from PhysicsTools.PatAlgos.tools.helpers import MassSearchParamVisitor if(type(mcAs) != type(None)): findMatch= [] findMatch.append(getattr(process, mcAs+'Match')) ## clone mc matchiong module of object mcAs and add it to the path addToProcessAndTask('pat'+label+'MCMatch', findMatch[0].clone(src = input), process, task) l1cands.addGenMatch = True l1cands.genParticleMatch = cms.InputTag('pat'+label+'MCMatch')
def miniAOD_customizeCommon(process): process.patMuons.isoDeposits = cms.PSet() process.patElectrons.isoDeposits = cms.PSet() process.patTaus.isoDeposits = cms.PSet() process.patPhotons.isoDeposits = cms.PSet() # process.patMuons.embedTrack = True # used for IDs process.patMuons.embedCombinedMuon = True # used for IDs process.patMuons.embedMuonBestTrack = True # used for IDs process.patMuons.embedStandAloneMuon = True # maybe? process.patMuons.embedPickyMuon = False # no, use best track process.patMuons.embedTpfmsMuon = False # no, use best track process.patMuons.embedDytMuon = False # no, use best track process.patMuons.addPuppiIsolation = cms.bool(True) process.patMuons.puppiIsolationChargedHadrons = cms.InputTag( "muonPUPPIIsolation", "h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag( "muonPUPPIIsolation", "h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiIsolationPhotons = cms.InputTag( "muonPUPPIIsolation", "gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.computeMiniIso = True process.patMuons.computeMuonMVA = True process.patMuons.computeSoftMuonMVA = True process.patMuons.addTriggerMatching = True from Configuration.Eras.Modifier_run2_muon_2016_cff import run2_muon_2016 from Configuration.Eras.Modifier_run2_muon_2017_cff import run2_muon_2017 from Configuration.Eras.Modifier_run2_muon_2018_cff import run2_muon_2018 run2_muon_2016.toModify( process.patMuons, effectiveAreaVec=[0.0735, 0.0619, 0.0465, 0.0433, 0.0577]) run2_muon_2017.toModify( process.patMuons, effectiveAreaVec=[0.0566, 0.0562, 0.0363, 0.0119, 0.0064]) run2_muon_2018.toModify( process.patMuons, effectiveAreaVec=[0.0566, 0.0562, 0.0363, 0.0119, 0.0064]) run2_muon_2016.toModify( process.patMuons, mvaTrainingFile= "RecoMuon/MuonIdentification/data/mu_2016_BDTG.weights.xml") process.patMuons.computePuppiCombinedIso = True # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer process.patElectrons.electronSource = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.patElectrons.usePfCandidateMultiMap = True process.patElectrons.pfCandidateMultiMap = cms.InputTag( "reducedEgamma", "reducedGsfElectronPfCandMap") process.patElectrons.electronIDSources = cms.PSet() from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify( process.patElectrons, addPFClusterIso=True, ecalPFClusterIsoMap="reducedEgamma:eleEcalPFClusIso", hcalPFClusterIsoMap="reducedEgamma:eleHcalPFClusIso") #add puppi isolation in miniAOD process.patElectrons.addPuppiIsolation = cms.bool(True) process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag( "egmElectronPUPPIIsolation", "h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag( "egmElectronPUPPIIsolation", "h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiIsolationPhotons = cms.InputTag( "egmElectronPUPPIIsolation", "gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.computeMiniIso = cms.bool(True) process.elPFIsoDepositChargedPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositChargedAllPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositNeutralPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositGammaPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma", "reducedGedGsfElectrons") # process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer #add puppi isolation in miniAOD process.patPhotons.addPuppiIsolation = cms.bool(True) process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag( "egmPhotonPUPPIIsolation", "h+-DR030-") process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag( "egmPhotonPUPPIIsolation", "h0-DR030-") process.patPhotons.puppiIsolationPhotons = cms.InputTag( "egmPhotonPUPPIIsolation", "gamma-DR030-") (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17).toModify( process.patPhotons, addPFClusterIso=True, ecalPFClusterIsoMap="reducedEgamma:phoEcalPFClusIso", hcalPFClusterIsoMap="reducedEgamma:phoHcalPFClusIso") #the 80X legacy customsations are done in ootPhotonProducer for OOT photons run2_miniAOD_94XFall17.toModify( process.patOOTPhotons, addPFClusterIso=True, ecalPFClusterIsoMap="reducedEgamma:ootPhoEcalPFClusIso", hcalPFClusterIsoMap="reducedEgamma:ootPhoHcalPFClusIso") process.patPhotons.photonSource = cms.InputTag("reducedEgamma", "reducedGedPhotons") process.patPhotons.electronSource = cms.InputTag("reducedEgamma", "reducedGedGsfElectrons") process.phPFIsoDepositChargedPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositChargedAllPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositNeutralPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma", "reducedGedPhotons") # process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma", "reducedOOTPhotons") process.patOOTPhotons.electronSource = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string( "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))" ) from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify( process.selectedPatMuons, cut= "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )" ) from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018 from Configuration.Eras.Modifier_pp_on_PbPb_run3_cff import pp_on_PbPb_run3 (pp_on_AA_2018 | pp_on_PbPb_run3).toModify( process.selectedPatMuons, cut= "pt > 5 || isPFMuon || (pt > 1.2 && (isGlobalMuon || isStandAloneMuon) )" ) process.selectedPatElectrons.cut = cms.string("") process.selectedPatTaus.cut = cms.string( "pt > 18. && tauID('decayModeFindingNewDMs')> 0.5") process.selectedPatPhotons.cut = cms.string("") from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure applySubstructure(process) # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone switchOnTriggerStandAlone(process, outputModule='') process.patTrigger.packTriggerPathNames = cms.bool(True) # # apply type I + other PFMEt corrections to pat::MET object # and estimate systematic uncertainties on MET from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets") #caloMET computation from PhysicsTools.PatAlgos.tools.metTools import addMETCollection addMETCollection(process, labelName="patCaloMet", metSource="caloMetM") #noHF pfMET ========= task = getPatAlgosToolsTask(process) process.noHFCands = cms.EDFilter( "GenericPFCandidateSelector", src=cms.InputTag("particleFlow"), cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")) task.add(process.noHFCands) runMetCorAndUncForMiniAODProduction( process, pfCandColl=cms.InputTag("noHFCands"), recoMetFromPFCs=True, #needed for HF removal jetSelection="pt>15 && abs(eta)<3.", postfix="NoHF") process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) process.slimmedMETs.addDeepMETs = True addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task) process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF") process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF") process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF") process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF") process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag( "patPFMetT1Smear%sNoHF") process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF") process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag( "patPFMetT0pcT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag( "patPFMetT1SmearTxyNoHF") process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag( "patPFMetT0pcT1SmearTxyNoHF") del process.slimmedMETsNoHF.caloMET # ================== NoHF pfMET # ================== CHSMET process.CHSCands = cms.EDFilter("CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("fromPV(0) > 0")) task.add(process.CHSCands) from RecoMET.METProducers.pfMet_cfi import pfMet process.pfMetCHS = pfMet.clone(src='CHSCands') task.add(process.pfMetCHS) addMETCollection(process, labelName="patCHSMet", metSource="pfMetCHS") process.patCHSMet.computeMETSignificance = cms.bool(False) # ================== CHSMET # ================== TrkMET process.TrkCands = cms.EDFilter( "CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string( "charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0") ) task.add(process.TrkCands) process.pfMetTrk = pfMet.clone(src='TrkCands') task.add(process.pfMetTrk) addMETCollection(process, labelName="patTrkMet", metSource="pfMetTrk") process.patTrkMet.computeMETSignificance = cms.bool(False) # ================== TrkMET ## PU JetID process.load("RecoJets.JetProducers.PileupJetID_cfi") task.add(process.pileUpJetIDTask) process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ] process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ] ## Quark Gluon Likelihood process.load('RecoJets.JetProducers.QGTagger_cfi') task.add(process.QGTaggerTask) process.patJets.userData.userFloats.src += [ cms.InputTag('QGTagger:qgLikelihood'), ] ## DeepCSV meta discriminators (simple arithmethic on output probabilities) process.load('RecoBTag.Combined.deepFlavour_cff') task.add(process.pfDeepCSVDiscriminatorsJetTags) process.patJets.discriminatorSources.extend([ cms.InputTag('pfDeepCSVDiscriminatorsJetTags:BvsAll'), cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsB'), cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsL'), ]) ## CaloJets process.caloJetMap = cms.EDProducer( "RecoJetDeltaRValueMapProducer", src=process.patJets.jetSource, matched=cms.InputTag("ak4CaloJets"), distMax=cms.double(0.4), values=cms.vstring('pt', 'emEnergyFraction'), valueLabels=cms.vstring('pt', 'emEnergyFraction'), lazyParser=cms.bool(True)) task.add(process.caloJetMap) process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ] #Muon object modifications from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon makeInputForPUPPIIsolationMuon(process) #EGM object modifications from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm makeInputForPUPPIIsolationEgm(process) from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications process.slimmedElectrons.modifierConfig.modifications = egamma_modifications process.slimmedPhotons.modifierConfig.modifications = egamma_modifications #VID Electron IDs process.patElectrons.addElectronID = cms.bool(True) electron_ids = [ 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff', 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV71_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff', ] switchOnVIDElectronIdProducer(process, DataFormat.MiniAOD, task) process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.electronMVAValueMapProducer.src = cms.InputTag( 'reducedEgamma', 'reducedGedGsfElectrons') # To use older DataFormats, the electronMVAValueMapProducer MUST take a updated electron collection # such that the conversion variables are filled correctly. process.load("RecoEgamma.EgammaTools.gedGsfElectronsTo106X_cff") run2_miniAOD_80XLegacy.toModify( task, func=lambda t: t.add(process.gedGsfElectronsFrom80XTo106XTask)) run2_miniAOD_80XLegacy.toModify( process.electronMVAValueMapProducer, keysForValueMaps=cms.InputTag('reducedEgamma', 'reducedGedGsfElectrons'), src=cms.InputTag("gedGsfElectronsFrom80XTo106X")) run2_miniAOD_94XFall17.toModify( task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask)) run2_miniAOD_94XFall17.toModify( process.electronMVAValueMapProducer, keysForValueMaps=cms.InputTag('reducedEgamma', 'reducedGedGsfElectrons'), src=cms.InputTag("gedGsfElectronsFrom94XTo106X")) from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018 pp_on_AA_2018.toModify( task, func=lambda t: t.add(process.gedGsfElectronsFrom94XTo106XTask)) pp_on_AA_2018.toModify(process.electronMVAValueMapProducer, keysForValueMaps=cms.InputTag( 'reducedEgamma', 'reducedGedGsfElectrons'), src="gedGsfElectronsFrom94XTo106X") for idmod in electron_ids: setupAllVIDIdsInModule(process, idmod, setupVIDElectronSelection, None, False, task) #VID Photon IDs process.patPhotons.addPhotonID = cms.bool(True) photon_ids = [ 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V2_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V2_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff' ] switchOnVIDPhotonIdProducer(process, DataFormat.AOD, task) process.egmPhotonIDs.physicsObjectSrc = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.photonMVAValueMapProducer.src = cms.InputTag( 'reducedEgamma', 'reducedGedPhotons') for idmod in photon_ids: setupAllVIDIdsInModule(process, idmod, setupVIDPhotonSelection, None, False, task) #add the cut base IDs bitmaps of which cuts passed from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier egamma_modifications.append( makeVIDBitsModifier(process, "egmGsfElectronIDs", "egmPhotonIDs")) #-- Adding boosted taus from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus addBoostedTaus(process) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") process.load("RecoTauTag.Configuration.HPSPFTaus_cff") #-- Adding customization for 94X 2017 legacy reMniAOD _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy() _makePatTausTaskWithRetrainedMVATauID.add( process.hpsPFTauBasicDiscriminatorsTask, process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask, process.hpsPFTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask, process.hpsPFTauBasicDiscriminatorsdR03Task, process.hpsPFTauDiscriminationByIsolationMVArun2v1DBdR03oldDMwLTTask, process.hpsPFTauDiscriminationByMVA6rawElectronRejection, process.hpsPFTauDiscriminationByMVA6ElectronRejection, process.hpsPFTauDiscriminationByMuonRejection3) from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL (run2_miniAOD_94XFall17 | run2_miniAOD_UL).toReplaceWith( process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID) #-- Adding DeepTauID # deepTau v2p1 _updatedTauName = 'slimmedTausDeepIDsv2p1' _noUpdatedTauName = 'slimmedTausNoDeepIDs' import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig tauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug=False, updatedTauName=_updatedTauName, toKeep=['deepTau2017v2p1']) from Configuration.Eras.Modifier_phase2_common_cff import phase2_common #Phase2 Tau MVA phase2_common.toModify( tauIdEmbedder.toKeep, func=lambda t: t.append('newDMPhase2v1')) #Phase2 Tau MVA tauIdEmbedder.runTauID() addToProcessAndTask(_noUpdatedTauName, process.slimmedTaus.clone(), process, task) delattr(process, 'slimmedTaus') process.deepTau2017v2p1.taus = _noUpdatedTauName process.slimmedTaus = getattr(process, _updatedTauName).clone(src=_noUpdatedTauName) process.deepTauIDTask = cms.Task(process.deepTau2017v2p1, process.slimmedTaus) task.add(process.deepTauIDTask) if 'newDMPhase2v1' in tauIdEmbedder.toKeep: process.rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw.PATTauProducer = _noUpdatedTauName process.rerunDiscriminationByIsolationMVADBnewDMwLTPhase2.PATTauProducer = _noUpdatedTauName task.add(process.rerunIsolationMVADBnewDMwLTPhase2Task) #-- Rerun tauID against dead ECal towers to taus for the various re-MiniAOD eras # to enable default behoviour with leading track extrapolation to ECAL _makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy() _makePatTausTaskWithDeadECalVeto.add( process.hpsPFTauDiscriminationByDeadECALElectronRejection) _run2_miniAOD_ANY = (run2_miniAOD_80XLegacy | run2_miniAOD_94XFall17 | run2_miniAOD_UL) _run2_miniAOD_ANY.toReplaceWith(process.makePatTausTask, _makePatTausTaskWithDeadECalVeto) #-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions _makePatTausTaskWithTauReReco = process.makePatTausTask.copy() _makePatTausTaskWithTauReReco.add(process.PFTauTask) (run2_miniAOD_80XLegacy | pp_on_AA_2018).toReplaceWith( process.makePatTausTask, _makePatTausTaskWithTauReReco) # Adding puppi jets process.load('CommonTools.PileupAlgos.Puppi_cff') process.load('RecoJets.JetProducers.ak4PFJets_cfi') from Configuration.Eras.Modifier_pA_2016_cff import pA_2016 _rerun_puppijets_task = task.copy() _rerun_puppijets_task.add(process.puppi, process.ak4PFJetsPuppi) (_run2_miniAOD_ANY | pA_2016 | pp_on_AA_2018).toReplaceWith( task, _rerun_puppijets_task) from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer( "JetTracksAssociatorAtVertex", j2tParametersVX, jets=cms.InputTag("ak4PFJetsPuppi")) task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex) process.patJetPuppiCharge = cms.EDProducer( "JetChargeProducer", src=cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"), var=cms.string('Pt'), exp=cms.double(1.0)) task.add(process.patJetPuppiCharge) noDeepFlavourDiscriminators = [ x.value() for x in process.patJets.discriminatorSources if not "DeepFlavour" in x.value() ] addJetCollection(process, postfix="", labelName='Puppi', jetSource=cms.InputTag('ak4PFJetsPuppi'), jetCorrections=('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''), pfCandidates=cms.InputTag("particleFlow"), algo='AK', rParam=0.4, btagDiscriminators=noDeepFlavourDiscriminators) process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets' process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge") process.selectedPatJetsPuppi.cut = cms.string("pt > 15") from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging applyDeepBtagging(process) addToProcessAndTask( 'slimmedJetsPuppi', process.slimmedJetsNoDeepFlavour.clone( src="selectedPatJetsPuppi", packedPFCandidates="packedPFCandidates"), process, task) task.add(process.slimmedJetsPuppi) # Embed pixelClusterTagInfos in slimmedJets process.patJets.addTagInfos = True process.patJets.tagInfoSources = ["pixelClusterTagInfos"] process.slimmedJetsNoDeepFlavour.dropTagInfos = '0' process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.addTagInfos = True process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour.tagInfoSources = [ "pixelClusterTagInfos" ] _run2_miniAOD_ANY.toModify(process.patJets, addTagInfos=False) _run2_miniAOD_ANY.toModify( process.updatedPatJetsTransientCorrectedSlimmedDeepFlavour, addTagInfos=False) ## puppi met process.load('RecoMET.METProducers.pfMetPuppi_cfi') _rerun_puppimet_task = task.copy() _rerun_puppimet_task.add(process.puppiNoLep, process.pfMetPuppi) (_run2_miniAOD_ANY | pA_2016 | pp_on_AA_2018).toReplaceWith( task, _rerun_puppimet_task) runMetCorAndUncForMiniAODProduction(process, metType="Puppi", jetCollUnskimmed="slimmedJetsPuppi", recoMetFromPFCs=True, jetFlavor="AK4PFPuppi", postfix="Puppi") process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task) process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi") process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi") process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag( "patPFMetT1%sPuppi") process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi") process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag( "patPFMetT1Smear%sPuppi") process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi") process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag( "patPFMetT0pcT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag( "patPFMetT1SmearTxyPuppi") process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag( "patPFMetT0pcT1SmearTxyPuppi") del process.slimmedMETsPuppi.caloMET process.load('RecoMET.METPUSubtraction.deepMETProducer_cfi') addToProcessAndTask('deepMETsResolutionTune', process.deepMETProducer.clone(), process, task) addToProcessAndTask('deepMETsResponseTune', process.deepMETProducer.clone(), process, task) process.deepMETsResponseTune.graph_path = 'RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb' from Configuration.Eras.Modifier_phase2_common_cff import phase2_common phase2_common.toModify( process.deepMETsResolutionTune, max_n_pf=12500, graph_path="RecoMET/METPUSubtraction/data/deepmet/deepmet_v1_phase2.pb" ) phase2_common.toModify( process.deepMETsResponseTune, max_n_pf=12500, graph_path= "RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_phase2.pb") from Configuration.Eras.Modifier_run2_jme_2016_cff import run2_jme_2016 run2_jme_2016.toModify( process.deepMETsResponseTune, graph_path= "RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb") # add DetIdAssociatorRecords to EventSetup (for isolatedTracks) process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff") # EGamma objects from HGCal are not yet in GED # so add companion collections for Phase-II MiniAOD production from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal process.load("RecoEgamma.EgammaTools.slimmedEgammaFromMultiCl_cff") phase2_hgcal.toModify( task, func=lambda t: t.add(process.slimmedEgammaFromMultiClTask)) # L1 pre-firing weights for 2016 and 2017 from Configuration.Eras.Modifier_run2_L1prefiring_cff import run2_L1prefiring from Configuration.Eras.Modifier_stage1L1Trigger_cff import stage1L1Trigger from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017 process.load("PhysicsTools.PatUtils.L1ECALPrefiringWeightProducer_cff") stage1L1Trigger.toModify(process.prefiringweight, DataEra="2016BtoH") stage2L1Trigger_2017.toModify(process.prefiringweight, DataEra="2017BtoF") run2_L1prefiring.toModify(task, func=lambda t: t.add(process.prefiringweight))
def miniAOD_customizeCommon(process): process.patMuons.isoDeposits = cms.PSet() process.patElectrons.isoDeposits = cms.PSet() process.patTaus.isoDeposits = cms.PSet() process.patPhotons.isoDeposits = cms.PSet() # process.patMuons.embedTrack = True # used for IDs process.patMuons.embedCombinedMuon = True # used for IDs process.patMuons.embedMuonBestTrack = True # used for IDs process.patMuons.embedStandAloneMuon = True # maybe? process.patMuons.embedPickyMuon = False # no, use best track process.patMuons.embedTpfmsMuon = False # no, use best track process.patMuons.embedDytMuon = False # no, use best track process.patMuons.addPuppiIsolation = cms.bool(True) process.patMuons.puppiIsolationChargedHadrons = cms.InputTag( "muonPUPPIIsolation", "h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag( "muonPUPPIIsolation", "h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiIsolationPhotons = cms.InputTag( "muonPUPPIIsolation", "gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag( "muonPUPPINoLeptonsIsolation", "gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.computeMiniIso = cms.bool(True) # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer process.patElectrons.electronSource = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.patElectrons.electronIDSources = cms.PSet( # configure many IDs as InputTag <someName> = <someTag> you # can comment out those you don't want to save some disk space eidRobustLoose=cms.InputTag("reducedEgamma", "eidRobustLoose"), eidRobustTight=cms.InputTag("reducedEgamma", "eidRobustTight"), eidLoose=cms.InputTag("reducedEgamma", "eidLoose"), eidTight=cms.InputTag("reducedEgamma", "eidTight"), eidRobustHighEnergy=cms.InputTag("reducedEgamma", "eidRobustHighEnergy"), ) process.patElectrons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patElectrons.addPuppiIsolation = cms.bool(True) process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag( "egmElectronPUPPIIsolation", "h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag( "egmElectronPUPPIIsolation", "h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiIsolationPhotons = cms.InputTag( "egmElectronPUPPIIsolation", "gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag( "egmElectronPUPPINoLeptonsIsolation", "gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.computeMiniIso = cms.bool(True) process.patElectrons.ecalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "eleEcalPFClusIso") process.patElectrons.hcalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "eleHcalPFClusIso") process.elPFIsoDepositChargedPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositChargedAllPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositNeutralPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositGammaPAT.src = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma", "reducedGedGsfElectrons") # process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer process.patPhotons.addPFClusterIso = cms.bool(True) #add puppi isolation in miniAOD process.patPhotons.addPuppiIsolation = cms.bool(True) process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag( "egmPhotonPUPPIIsolation", "h+-DR030-") process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag( "egmPhotonPUPPIIsolation", "h0-DR030-") process.patPhotons.puppiIsolationPhotons = cms.InputTag( "egmPhotonPUPPIIsolation", "gamma-DR030-") process.patPhotons.ecalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "phoEcalPFClusIso") process.patPhotons.hcalPFClusterIsoMap = cms.InputTag( "reducedEgamma", "phoHcalPFClusIso") process.patPhotons.photonSource = cms.InputTag("reducedEgamma", "reducedGedPhotons") process.patPhotons.electronSource = cms.InputTag("reducedEgamma", "reducedGedGsfElectrons") process.patPhotons.photonIDSources = cms.PSet( PhotonCutBasedIDLoose=cms.InputTag('reducedEgamma', 'PhotonCutBasedIDLoose'), PhotonCutBasedIDTight=cms.InputTag('reducedEgamma', 'PhotonCutBasedIDTight')) process.phPFIsoDepositChargedPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositChargedAllPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositNeutralPAT.src = cms.InputTag( "reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma", "reducedGedPhotons") process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma", "reducedGedPhotons") # process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma", "reducedOOTPhotons") process.patOOTPhotons.electronSource = cms.InputTag( "reducedEgamma", "reducedGedGsfElectrons") # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string( "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))" ) from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify( process.selectedPatMuons, cut= "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )" ) process.selectedPatElectrons.cut = cms.string("") process.selectedPatTaus.cut = cms.string( "pt > 18. && tauID('decayModeFindingNewDMs')> 0.5") process.selectedPatPhotons.cut = cms.string("") from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure applySubstructure(process) # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone switchOnTriggerStandAlone(process, outputModule='') process.patTrigger.packTriggerPathNames = cms.bool(True) # # apply type I + other PFMEt corrections to pat::MET object # and estimate systematic uncertainties on MET from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets") #caloMET computation from PhysicsTools.PatAlgos.tools.metTools import addMETCollection addMETCollection(process, labelName="patCaloMet", metSource="caloMetM") #noHF pfMET ========= task = getPatAlgosToolsTask(process) process.noHFCands = cms.EDFilter( "GenericPFCandidateSelector", src=cms.InputTag("particleFlow"), cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")) task.add(process.noHFCands) runMetCorAndUncForMiniAODProduction( process, pfCandColl=cms.InputTag("noHFCands"), recoMetFromPFCs=True, #needed for HF removal jetSelection="pt>15 && abs(eta)<3.", postfix="NoHF") process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task) process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF") process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF") process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF") process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF") process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag( "patPFMetT1Smear%sNoHF") process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF") process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag( "patPFMetT0pcT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag( "patPFMetT1SmearTxyNoHF") process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag( "patPFMetT0pcT1SmearTxyNoHF") del process.slimmedMETsNoHF.caloMET # ================== NoHF pfMET ## PU JetID process.load("RecoJets.JetProducers.PileupJetID_cfi") task.add(process.pileUpJetIDTask) process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ] process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ] ## Quark Gluon Likelihood process.load('RecoJets.JetProducers.QGTagger_cfi') task.add(process.QGTaggerTask) process.patJets.userData.userFloats.src += [ cms.InputTag('QGTagger:qgLikelihood'), ] ## CaloJets process.caloJetMap = cms.EDProducer( "RecoJetDeltaRValueMapProducer", src=process.patJets.jetSource, matched=cms.InputTag("ak4CaloJets"), distMax=cms.double(0.4), values=cms.vstring('pt', 'emEnergyFraction'), valueLabels=cms.vstring('pt', 'emEnergyFraction'), lazyParser=cms.bool(True)) task.add(process.caloJetMap) process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ] #Muon object modifications from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon makeInputForPUPPIIsolationMuon(process) #EGM object modifications from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm makeInputForPUPPIIsolationEgm(process) from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications process.slimmedElectrons.modifierConfig.modifications = egamma_modifications process.slimmedPhotons.modifierConfig.modifications = egamma_modifications #VID Electron IDs electron_ids = [ 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_PHYS14_PU20bx25_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_50ns_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV60_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_nonTrig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_Trig_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_50ns_Trig_V1_cff' ] switchOnVIDElectronIdProducer(process, DataFormat.MiniAOD, task) process.egmGsfElectronIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.electronMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') process.electronRegressionValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') for idmod in electron_ids: setupAllVIDIdsInModule(process, idmod, setupVIDElectronSelection, None, False, task) #heepIDVarValueMaps only exists if HEEP V6.1 or HEEP 7.0 ID has already been loaded if hasattr(process, 'heepIDVarValueMaps'): process.heepIDVarValueMaps.elesMiniAOD = cms.InputTag( 'reducedEgamma', 'reducedGedGsfElectrons') #force HEEP to use miniAOD (otherwise it'll detect the AOD) process.heepIDVarValueMaps.dataFormat = cms.int32(2) #VID Photon IDs photon_ids = [ 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_50ns_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_25ns_nonTrig_V2p1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_50ns_nonTrig_V2p1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff' ] switchOnVIDPhotonIdProducer(process, DataFormat.AOD, task) process.egmPhotonIsolation.srcToIsolate = \ cms.InputTag("reducedEgamma","reducedGedPhotons") for iPSet in process.egmPhotonIsolation.isolationConeDefinitions: iPSet.particleBasedIsolation = cms.InputTag("reducedEgamma", "reducedPhotonPfCandMap") process.egmPhotonIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonRegressionValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.particleBasedIsolation = \ cms.InputTag("reducedEgamma","reducedPhotonPfCandMap") process.photonMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedPhotons') for idmod in photon_ids: setupAllVIDIdsInModule(process, idmod, setupVIDPhotonSelection, None, False, task) #--------------------------------------------------------------------------- #Adding Boosted Subjets taus from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus addBoostedTaus(process) #--------------------------------------------------------------------------- # Adding puppi jets if not hasattr( process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi') task.add(process.ak4PFJets) task.add(process.ak4PFJetsPuppi) process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer( "JetTracksAssociatorAtVertex", j2tParametersVX, jets=cms.InputTag("ak4PFJetsPuppi")) task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex) process.patJetPuppiCharge = cms.EDProducer( "JetChargeProducer", src=cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"), var=cms.string('Pt'), exp=cms.double(1.0)) task.add(process.patJetPuppiCharge) addJetCollection( process, postfix="", labelName='Puppi', jetSource=cms.InputTag('ak4PFJetsPuppi'), jetCorrections=('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''), pfCandidates=cms.InputTag( 'puppi' ), # using Puppi candidates as input for b tagging of Puppi jets algo='AK', rParam=0.4, btagDiscriminators=map(lambda x: x.value(), process.patJets.discriminatorSources)) process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets' process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge") process.selectedPatJetsPuppi.cut = cms.string("pt > 15") process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') task.add(process.slimmedJets) task.add(process.slimmedJetsAK8) addToProcessAndTask('slimmedJetsPuppi', process.slimmedJets.clone(), process, task) process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi") process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag( "packedPFCandidates") ## puppi met from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies makePuppies(process) runMetCorAndUncForMiniAODProduction(process, metType="Puppi", pfCandColl=cms.InputTag("puppiForMET"), jetCollUnskimmed="slimmedJetsPuppi", recoMetFromPFCs=True, jetFlavor="AK4PFPuppi", postfix="Puppi") process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task) process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi") process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi") process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag( "patPFMetT1%sPuppi") process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi") process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag( "patPFMetT1Smear%sPuppi") process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi") process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag( "patPFMetT0pcT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag( "patPFMetT1SmearTxyPuppi") process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag( "patPFMetT0pcT1SmearTxyPuppi") del process.slimmedMETsPuppi.caloMET # add DetIdAssociatorRecords to EventSetup (for isolatedTracks) process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
def miniAOD_customizeCommon(process): process.patMuons.isoDeposits = cms.PSet() process.patElectrons.isoDeposits = cms.PSet() process.patTaus.isoDeposits = cms.PSet() process.patPhotons.isoDeposits = cms.PSet() # process.patMuons.embedTrack = True # used for IDs process.patMuons.embedCombinedMuon = True # used for IDs process.patMuons.embedMuonBestTrack = True # used for IDs process.patMuons.embedStandAloneMuon = True # maybe? process.patMuons.embedPickyMuon = False # no, use best track process.patMuons.embedTpfmsMuon = False # no, use best track process.patMuons.embedDytMuon = False # no, use best track process.patMuons.addPuppiIsolation = cms.bool(True) process.patMuons.puppiIsolationChargedHadrons = cms.InputTag("muonPUPPIIsolation","h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiIsolationNeutralHadrons = cms.InputTag("muonPUPPIIsolation","h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiIsolationPhotons = cms.InputTag("muonPUPPIIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h+-DR040-ThresholdVeto000-ConeVeto000") process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.computeMiniIso = cms.bool(True) process.patMuons.computeMuonMVA = cms.bool(True) process.patMuons.computeSoftMuonMVA = cms.bool(True) # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core process.patElectrons.embedSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedPflowSuperCluster = False ## process.patElectrons.embed in AOD externally stored supercluster process.patElectrons.embedSeedCluster = False ## process.patElectrons.embed in AOD externally stored the electron's seedcluster process.patElectrons.embedBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's basic clusters process.patElectrons.embedPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's preshower clusters process.patElectrons.embedPflowBasicClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow basic clusters process.patElectrons.embedPflowPreshowerClusters = False ## process.patElectrons.embed in AOD externally stored the electron's pflow preshower clusters process.patElectrons.embedRecHits = False ## process.patElectrons.embed in AOD externally stored the RecHits - can be called from the PATElectronProducer process.patElectrons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.patElectrons.usePfCandidateMultiMap = True process.patElectrons.pfCandidateMultiMap = cms.InputTag("reducedEgamma","reducedGsfElectronPfCandMap") process.patElectrons.electronIDSources = cms.PSet() from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy run2_miniAOD_80XLegacy.toModify(process.patElectrons, addPFClusterIso = cms.bool(True), ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso"), hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso")) from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 run2_miniAOD_94XFall17.toModify(process.patElectrons, addPFClusterIso = cms.bool(True), ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleEcalPFClusIso"), hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "eleHcalPFClusIso")) #add puppi isolation in miniAOD process.patElectrons.addPuppiIsolation = cms.bool(True) process.patElectrons.puppiIsolationChargedHadrons = cms.InputTag("egmElectronPUPPIIsolation","h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPIIsolation","h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiIsolationPhotons = cms.InputTag("egmElectronPUPPIIsolation","gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.puppiNoLeptonsIsolationChargedHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h+-DR030-BarVeto000-EndVeto001") process.patElectrons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","h0-DR030-BarVeto000-EndVeto000") process.patElectrons.puppiNoLeptonsIsolationPhotons = cms.InputTag("egmElectronPUPPINoLeptonsIsolation","gamma-DR030-BarVeto000-EndVeto008") process.patElectrons.computeMiniIso = cms.bool(True) process.elPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.elPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") # process.patPhotons.embedSuperCluster = False ## whether to process.patPhotons.embed in AOD externally stored supercluster process.patPhotons.embedSeedCluster = False ## process.patPhotons.embed in AOD externally stored the photon's seedcluster process.patPhotons.embedBasicClusters = False ## process.patPhotons.embed in AOD externally stored the photon's basic clusters process.patPhotons.embedPreshowerClusters = False ## process.patPhotons.embed in AOD externally stored the photon's preshower clusters process.patPhotons.embedRecHits = False ## process.patPhotons.embed in AOD externally stored the RecHits - can be called from the PATPhotonProducer #add puppi isolation in miniAOD process.patPhotons.addPuppiIsolation = cms.bool(True) process.patPhotons.puppiIsolationChargedHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h+-DR030-") process.patPhotons.puppiIsolationNeutralHadrons = cms.InputTag("egmPhotonPUPPIIsolation","h0-DR030-") process.patPhotons.puppiIsolationPhotons = cms.InputTag("egmPhotonPUPPIIsolation","gamma-DR030-") from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy run2_miniAOD_80XLegacy.toModify(process.patPhotons, addPFClusterIso = cms.bool(True), ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso"), hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso")) from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 run2_miniAOD_94XFall17.toModify(process.patPhotons, addPFClusterIso = cms.bool(True), ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoEcalPFClusIso"), hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "phoHcalPFClusIso")) #the 80X legacy customsations are done in ootPhotonProducer for OOT photons run2_miniAOD_94XFall17.toModify(process.patOOTPhotons, addPFClusterIso = cms.bool(True), ecalPFClusterIsoMap = cms.InputTag("reducedEgamma", "ootPhoEcalPFClusIso"), hcalPFClusterIsoMap = cms.InputTag("reducedEgamma", "ootPhoHcalPFClusIso")) process.patPhotons.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons") process.patPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.phPFIsoDepositChargedPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositChargedAllPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositNeutralPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositGammaPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") process.phPFIsoDepositPUPAT.src = cms.InputTag("reducedEgamma","reducedGedPhotons") # process.patOOTPhotons.photonSource = cms.InputTag("reducedEgamma","reducedOOTPhotons") process.patOOTPhotons.electronSource = cms.InputTag("reducedEgamma","reducedGedGsfElectrons") # process.selectedPatJets.cut = cms.string("pt > 10") process.selectedPatMuons.cut = cms.string("pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose')))") from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify(process.selectedPatMuons, cut = "pt > 5 || isPFMuon || (pt > 3 && (isGlobalMuon || isStandAloneMuon || numberOfMatches > 0 || muonID('RPCMuLoose') || muonID('ME0MuonArbitrated') || muonID('GEMMuonArbitrated')) )") process.selectedPatElectrons.cut = cms.string("") process.selectedPatTaus.cut = cms.string("pt > 18. && tauID('decayModeFindingNewDMs')> 0.5") process.selectedPatPhotons.cut = cms.string("") from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection from PhysicsTools.PatAlgos.slimming.applySubstructure_cff import applySubstructure applySubstructure( process ) # from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone switchOnTriggerStandAlone( process, outputModule = '' ) process.patTrigger.packTriggerPathNames = cms.bool(True) # # apply type I + other PFMEt corrections to pat::MET object # and estimate systematic uncertainties on MET from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction runMetCorAndUncForMiniAODProduction(process, metType="PF", jetCollUnskimmed="patJets") #caloMET computation from PhysicsTools.PatAlgos.tools.metTools import addMETCollection addMETCollection(process, labelName = "patCaloMet", metSource = "caloMetM" ) #noHF pfMET ========= task = getPatAlgosToolsTask(process) process.noHFCands = cms.EDFilter("GenericPFCandidateSelector", src=cms.InputTag("particleFlow"), cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0") ) task.add(process.noHFCands) runMetCorAndUncForMiniAODProduction(process, pfCandColl=cms.InputTag("noHFCands"), recoMetFromPFCs=True, #needed for HF removal jetSelection="pt>15 && abs(eta)<3.", postfix="NoHF" ) process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsNoHF', process.slimmedMETs.clone(), process, task) process.slimmedMETsNoHF.src = cms.InputTag("patMETsNoHF") process.slimmedMETsNoHF.rawVariation = cms.InputTag("patPFMetNoHF") process.slimmedMETsNoHF.t1Uncertainties = cms.InputTag("patPFMetT1%sNoHF") process.slimmedMETsNoHF.t01Variation = cms.InputTag("patPFMetT0pcT1NoHF") process.slimmedMETsNoHF.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sNoHF") process.slimmedMETsNoHF.tXYUncForRaw = cms.InputTag("patPFMetTxyNoHF") process.slimmedMETsNoHF.tXYUncForT1 = cms.InputTag("patPFMetT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyNoHF") process.slimmedMETsNoHF.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyNoHF") process.slimmedMETsNoHF.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyNoHF") del process.slimmedMETsNoHF.caloMET # ================== NoHF pfMET # ================== CHSMET process.CHSCands = cms.EDFilter("CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("fromPV(0) > 0") ) task.add(process.CHSCands) process.pfMetCHS = cms.EDProducer("PFMETProducer", src = cms.InputTag("CHSCands"), alias = cms.string('pfMet'), globalThreshold = cms.double(0.0), calculateSignificance = cms.bool(False), ) task.add(process.pfMetCHS) addMETCollection(process, labelName = "patCHSMet", metSource = "pfMetCHS" ) process.patCHSMet.computeMETSignificance = cms.bool(False) # ================== CHSMET # ================== TrkMET process.TrkCands = cms.EDFilter("CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("charge()!=0 && pvAssociationQuality()>=4 && vertexRef().key()==0") ) task.add(process.TrkCands) process.pfMetTrk = cms.EDProducer("PFMETProducer", src = cms.InputTag("TrkCands"), alias = cms.string('pfMet'), globalThreshold = cms.double(0.0), calculateSignificance = cms.bool(False), ) task.add(process.pfMetTrk) addMETCollection(process, labelName = "patTrkMet", metSource = "pfMetTrk" ) process.patTrkMet.computeMETSignificance = cms.bool(False) # ================== TrkMET ## PU JetID process.load("RecoJets.JetProducers.PileupJetID_cfi") task.add(process.pileUpJetIDTask) process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ] process.patJets.userData.userInts.src = [ cms.InputTag("pileupJetId:fullId"), ] ## Quark Gluon Likelihood process.load('RecoJets.JetProducers.QGTagger_cfi') task.add(process.QGTaggerTask) process.patJets.userData.userFloats.src += [ cms.InputTag('QGTagger:qgLikelihood'), ] ## DeepCSV meta discriminators (simple arithmethic on output probabilities) process.load('RecoBTag.Combined.deepFlavour_cff') task.add(process.pfDeepCSVDiscriminatorsJetTags) process.patJets.discriminatorSources.extend([ cms.InputTag('pfDeepCSVDiscriminatorsJetTags:BvsAll' ), cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsB' ), cms.InputTag('pfDeepCSVDiscriminatorsJetTags:CvsL' ), ]) ## CaloJets process.caloJetMap = cms.EDProducer("RecoJetDeltaRValueMapProducer", src = process.patJets.jetSource, matched = cms.InputTag("ak4CaloJets"), distMax = cms.double(0.4), values = cms.vstring('pt','emEnergyFraction'), valueLabels = cms.vstring('pt','emEnergyFraction'), lazyParser = cms.bool(True) ) task.add(process.caloJetMap) process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ] #Muon object modifications from PhysicsTools.PatAlgos.slimming.muonIsolationsPUPPI_cfi import makeInputForPUPPIIsolationMuon makeInputForPUPPIIsolationMuon(process) #EGM object modifications from PhysicsTools.PatAlgos.slimming.egmIsolationsPUPPI_cfi import makeInputForPUPPIIsolationEgm makeInputForPUPPIIsolationEgm(process) from RecoEgamma.EgammaTools.egammaObjectModificationsInMiniAOD_cff import egamma_modifications process.slimmedElectrons.modifierConfig.modifications = egamma_modifications process.slimmedPhotons.modifierConfig.modifications = egamma_modifications #VID Electron IDs process.patElectrons.addElectronID = cms.bool(True) electron_ids = ['RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_GeneralPurpose_V1_cff', 'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring16_HZZ_V1_cff', ] switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD, task) process.egmGsfElectronIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedGsfElectrons") process.electronMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') process.electronRegressionValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedGsfElectrons') for idmod in electron_ids: setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False,task) #heepIDVarValueMaps only exists if HEEP V6.1 or HEEP 7.0 ID has already been loaded if hasattr(process,'heepIDVarValueMaps'): process.heepIDVarValueMaps.elesMiniAOD = cms.InputTag('reducedEgamma','reducedGedGsfElectrons') #force HEEP to use miniAOD (otherwise it'll detect the AOD) process.heepIDVarValueMaps.dataFormat = cms.int32(2) #add the HEEP trk isol to the slimmed electron, add it to the first FromFloatValMap modifier for pset in process.slimmedElectrons.modifierConfig.modifications: if pset.hasParameter("modifierName") and pset.modifierName == cms.string('EGExtraInfoModifierFromFloatValueMaps'): pset.electron_config.heepTrkPtIso = cms.InputTag("heepIDVarValueMaps","eleTrkPtIso") break #VID Photon IDs process.patPhotons.addPhotonID = cms.bool(True) photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Fall17_94X_V1_TrueVtx_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Fall17_94X_V1p1_cff', 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff', 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff'] switchOnVIDPhotonIdProducer(process,DataFormat.AOD, task) process.egmPhotonIsolation.srcToIsolate = \ cms.InputTag("reducedEgamma","reducedGedPhotons") for iPSet in process.egmPhotonIsolation.isolationConeDefinitions: iPSet.particleBasedIsolation = cms.InputTag("reducedEgamma","reducedPhotonPfCandMap") process.egmPhotonIDs.physicsObjectSrc = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonRegressionValueMapProducer.src = \ cms.InputTag("reducedEgamma","reducedGedPhotons") process.photonIDValueMapProducer.particleBasedIsolation = \ cms.InputTag("reducedEgamma","reducedPhotonPfCandMap") process.photonMVAValueMapProducer.src = \ cms.InputTag('reducedEgamma','reducedGedPhotons') for idmod in photon_ids: setupAllVIDIdsInModule(process,idmod,setupVIDPhotonSelection,None,False,task) #add the cut base IDs bitmaps of which cuts passed from RecoEgamma.EgammaTools.egammaObjectModifications_tools import makeVIDBitsModifier egamma_modifications.append(makeVIDBitsModifier(process,"egmGsfElectronIDs","egmPhotonIDs")) #-- Adding boosted taus from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus addBoostedTaus(process) process.load("RecoTauTag.Configuration.RecoPFTauTag_cff") process.load("RecoTauTag.Configuration.HPSPFTaus_cff") #-- Adding customization for 94X 2017 legacy reMniAOD from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17 _makePatTausTaskWithRetrainedMVATauID = process.makePatTausTask.copy() _makePatTausTaskWithRetrainedMVATauID.add(process.hpsPFTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask) run2_miniAOD_94XFall17.toReplaceWith( process.makePatTausTask, _makePatTausTaskWithRetrainedMVATauID ) #-- Adding customization for 80X 2016 legacy reMiniAOD from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy _makePatTausTaskWithTauReReco = process.makePatTausTask.copy() _makePatTausTaskWithTauReReco.add(process.PFTauTask) run2_miniAOD_80XLegacy.toReplaceWith( process.makePatTausTask, _makePatTausTaskWithTauReReco ) # Adding puppi jets if not hasattr(process, 'ak4PFJetsPuppi'): #MM: avoid confilct with substructure call process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi') task.add(process.ak4PFJets) task.add(process.ak4PFJetsPuppi) process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex", j2tParametersVX, jets = cms.InputTag("ak4PFJetsPuppi") ) task.add(process.ak4PFJetsPuppiTracksAssociatorAtVertex) process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer", src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"), var = cms.string('Pt'), exp = cms.double(1.0) ) task.add(process.patJetPuppiCharge) noDeepFlavourDiscriminators = [x.value() for x in process.patJets.discriminatorSources if not "DeepFlavour" in x.value()] addJetCollection(process, postfix = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'), jetCorrections = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], ''), pfCandidates = cms.InputTag("particleFlow"), algo= 'AK', rParam = 0.4, btagDiscriminators = noDeepFlavourDiscriminators ) process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets' process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge") process.selectedPatJetsPuppi.cut = cms.string("pt > 15") from PhysicsTools.PatAlgos.slimming.applyDeepBtagging_cff import applyDeepBtagging applyDeepBtagging( process ) addToProcessAndTask('slimmedJetsPuppiNoMultiplicities', process.slimmedJetsNoDeepFlavour.clone(), process, task) process.slimmedJetsPuppiNoMultiplicities.src = cms.InputTag("selectedPatJetsPuppi") process.slimmedJetsPuppiNoMultiplicities.packedPFCandidates = cms.InputTag("packedPFCandidates") from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection process.patPuppiJetSpecificProducer = patPuppiJetSpecificProducer.clone( src=cms.InputTag("slimmedJetsPuppiNoMultiplicities"), ) task.add(process.patPuppiJetSpecificProducer) updateJetCollection( process, labelName = 'PuppiJetSpecific', jetSource = cms.InputTag('slimmedJetsPuppiNoMultiplicities'), ) process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = ['patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ] process.slimmedJetsPuppi = process.selectedUpdatedPatJetsPuppiJetSpecific.clone() delattr(process, 'selectedUpdatedPatJetsPuppiJetSpecific') task.add(process.slimmedJetsPuppi) ## puppi met from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppies makePuppies( process ); runMetCorAndUncForMiniAODProduction(process, metType="Puppi", pfCandColl=cms.InputTag("puppiForMET"), jetCollUnskimmed="slimmedJetsPuppi", recoMetFromPFCs=True, jetFlavor="AK4PFPuppi", postfix="Puppi" ) process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi') task.add(process.slimmedMETs) addToProcessAndTask('slimmedMETsPuppi', process.slimmedMETs.clone(), process, task) process.slimmedMETsPuppi.src = cms.InputTag("patMETsPuppi") process.slimmedMETsPuppi.rawVariation = cms.InputTag("patPFMetPuppi") process.slimmedMETsPuppi.t1Uncertainties = cms.InputTag("patPFMetT1%sPuppi") process.slimmedMETsPuppi.t01Variation = cms.InputTag("patPFMetT0pcT1Puppi") process.slimmedMETsPuppi.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sPuppi") process.slimmedMETsPuppi.tXYUncForRaw = cms.InputTag("patPFMetTxyPuppi") process.slimmedMETsPuppi.tXYUncForT1 = cms.InputTag("patPFMetT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyPuppi") process.slimmedMETsPuppi.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyPuppi") process.slimmedMETsPuppi.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyPuppi") del process.slimmedMETsPuppi.caloMET # add DetIdAssociatorRecords to EventSetup (for isolatedTracks) process.load("TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff") # EGamma objects from HGCal are not yet in GED # so add companion collections for Phase-II MiniAOD production from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal process.load("RecoEgamma.EgammaTools.slimmedEgammaFromMultiCl_cff") phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaFromMultiClTask))