Exemplo n.º 1
0
def addFlashggPF(process):
  print "JET PRODUCER :: Flashgg PF producer ::"
  from RecoJets.JetProducers.ak4PFJets_cfi  import ak4PFJets
  from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets
  
  process.ak4PFJets  = ak4PFJets.clone (src = 'packedPFCandidates', doAreaFastjet = True)
  process.ak4GenJets = ak4GenJets.clone(src = 'packedGenParticles')
  ## cluster the jets
  addJetCollection(
    process,
    labelName      = 'AK4PF',
    jetSource      = cms.InputTag('ak4PFJets'),
    pvSource       = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates   = cms.InputTag('packedPFCandidates'),
    svSource       = cms.InputTag('slimmedSecondaryVertices'),
    btagDiscriminators = [ flashggBTag ],
    jetCorrections = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
    
    genJetCollection = cms.InputTag('ak4GenJets'),
    genParticles     = cms.InputTag('prunedGenParticles'),
    # jet param
    algo = 'AK', rParam = 0.4
  )
  ## adjust MC matching
  process.patJetGenJetMatchAK4PF.matched = "ak4GenJets"
  process.patJetPartonMatchAK4PF.matched = "prunedGenParticles"
  #process.patJetPartons.particles        = "prunedGenParticles"
  
  #adjust PV used for Jet Corrections
  process.patJetCorrFactorsAK4PF.primaryVertices = "offlineSlimmedPrimaryVertices"
def convertPFToPATJet(proc, inputColl, outputColl, alg, r, corrAlgo, corrLevels):

	addJetCollection(
		proc,
		labelName = outputColl,
		jetSource = cms.InputTag(inputColl),
		algo = alg,
		rParam = r,
		# jetCorrections = None,
		trackSource = cms.InputTag('unpackedTracksAndVertices'),
		pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'),
		jetCorrections = (corrAlgo, cms.vstring(corrLevels), 'None')
		#btagDiscriminators = ['combinedSecondaryVertexBJetTags'],
	)

	for module in [getattr(proc,'patJets'+outputColl)]:
		module.addJetCharge = False
		module.addBTagInfo = False
		module.getJetMCFlavour = False
		module.addAssociatedTracks = False
		module.addGenPartonMatch = False
		module.addGenJetMatch = True
		
		if 'Puppi' in inputColl: module.addJetCorrFactors = False
		else: module.addJetCorrFactors = True

	getattr(proc, 'patJetGenJetMatch'+inputColl).matched = cms.InputTag(alg.upper()+'GenJets');
def make_patjet_collection(process, sequence, pfjet_tag, gnjet_tag, tags_dict, algo, tag, matching=True):
	# "addJetCollection" makes two sets of PF and GN jets each: "patJets" + tag and "selectedPatJets" + tag.
#	print tags_dict
	addJetCollection(process,
		labelName=tag,
		jetSource=cms.InputTag(pfjet_tag),
		algo=algo.name,
		rParam=algo.r,
		jetCorrections=None,
		genJetCollection=cms.InputTag(gnjet_tag),
		pfCandidates=cms.InputTag(tags_dict["pf"]),
		genParticles=cms.InputTag(tags_dict["gn_reco"]),
		pvSource=cms.InputTag(tags_dict["vp"]),
		svSource=cms.InputTag(tags_dict["vs"]),
		elSource=cms.InputTag(tags_dict["le"]),
		muSource=cms.InputTag(tags_dict["lm"]),
#		btagDiscriminators=bTagDiscriminators,
#		btagInfos=bTagInfos,
#		getJetMCFlavour=GetJetMCFlavour,
		outputModules = ['outputFile'],
		getJetMCFlavour=matching,
	)
	tag = "patJets" + tag
	getattr(process, tag).addTagInfos = cms.bool(True)
	return tag
Exemplo n.º 4
0
def addFlashggPFCHSLegJets(process):
  #process.load("Configuration.StandardSequences.Geometry_cff")
	#process.myPrefer = cms.ESPrefer("CaloSubdetectorGeometry" [,"ZDC"
	#                                   [,ZdcGeometryFromDBEP = cms.vstring("<C++ data type>[/<data label>]"[,...])]
	#																	                                   )
	# load various necessary plugins.
  process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff")
  process.load('PhysicsTools.PatAlgos.slimming.unpackedTracksAndVertices_cfi')
	# leptons to remove as per default CHS workflow
  process.selectedMuons = cms.EDFilter("CandPtrSelector", src = cms.InputTag("slimmedMuons"), cut = cms.string('''abs(eta)<2.5 && pt>10. &&
				(pfIsolationR04().sumChargedHadronPt+
				 max(0.,pfIsolationR04().sumNeutralHadronEt+
					 pfIsolationR04().sumPhotonEt-
					 0.50*pfIsolationR04().sumPUPt))/pt < 0.20 && 
				(isPFMuon && (isGlobalMuon || isTrackerMuon) )'''))
  process.selectedElectrons = cms.EDFilter("CandPtrSelector", src = cms.InputTag("slimmedElectrons"), cut = cms.string('''abs(eta)<2.5 && pt>20. &&
				gsfTrack.isAvailable() &&
				gsfTrack.hitPattern().numberOfLostHits(\'MISSING_INNER_HITS\') < 2 &&
				(pfIsolationVariables().sumChargedHadronPt+
				 max(0.,pfIsolationVariables().sumNeutralHadronEt+
					 pfIsolationVariables().sumPhotonEt-
					 0.5*pfIsolationVariables().sumPUPt))/pt < 0.15'''))
	# Simple producer which just removes the Candidates which don't come from the legacy vertex according to the Flashgg Vertex Map
  process.flashggCHSLegacyVertexCandidates = cms.EDProducer('FlashggCHSLegacyVertexCandidateProducer',
                                                          PFCandidatesTag=cms.untracked.InputTag('packedPFCandidates'),
                                                          DiPhotonTag=cms.untracked.InputTag('flashggDiPhotons'),
                                                          VertexCandidateMapTag = cms.InputTag("flashggVertexMapForCHS"),
                                                          VertexTag=cms.untracked.InputTag('offlineSlimmedPrimaryVertices')
                                                  )
  process.pfCHSLeg = cms.EDFilter("CandPtrSelector", src = cms.InputTag("flashggCHSLegacyVertexCandidates"), cut = cms.string(""))
  # then remove the previously selected muons
  process.pfNoMuonCHSLeg =  cms.EDProducer("CandPtrProjector", src = cms.InputTag("pfCHSLeg"), veto = cms.InputTag("selectedMuons"))
  # then remove the previously selected electrons
  process.pfNoElectronsCHSLeg = cms.EDProducer("CandPtrProjector", src = cms.InputTag("pfNoMuonCHSLeg"), veto =  cms.InputTag("selectedElectrons"))
  #Import RECO jet producer for ak4 PF and GEN jet
  from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets
  from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets
  process.ak4PFJetsCHSLeg = ak4PFJets.clone(src = 'pfNoElectronsCHSLeg', doAreaFastjet = True)
  process.ak4GenJetsLeg = ak4GenJets.clone(src = 'packedGenParticles')
	# cluster the jets
  addJetCollection(
      process,
      postfix   = "",
      labelName = 'AK4PFCHSLeg',
		  pfCandidates = cms.InputTag('packedPFCandidates'),
      jetSource = cms.InputTag('ak4PFJetsCHSLeg'),
      #trackSource = cms.InputTag('unpackedTracksAndVertices'), 
      pvSource = cms.InputTag('unpackedTracksAndVertices'), 
      jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
      #btagDiscriminators = [      'combinedSecondaryVertexBJetTags'     ]
      btagDiscriminators = [      'pfJetProbabilityBJetTags'     ]
      ,algo= 'AK', rParam = 0.4
      )
  # adjust MC matching
  process.patJetGenJetMatchAK4PFCHSLeg.matched = "ak4GenJetsLeg"
  process.patJetPartonMatchAK4PFCHSLeg.matched = "prunedGenParticles"
  process.patJetPartons.particles = "prunedGenParticles"
  # adjust PV collection used for Jet Corrections
  process.patJetCorrFactorsAK4PFCHSLeg.primaryVertices = "offlineSlimmedPrimaryVertices"
Exemplo n.º 5
0
def addAK4Jets(process, addPAT=False):
    process.ak4PFJets = ak4PF.clone(src='packedPFCandidates')
    process.ak4PFJets.doAreaFastjet = cms.bool(True)
    if addPAT:
        addJetCollection(
           process,
           postfix  = "",
           labelName = 'AK4PF',
           jetSource = cms.InputTag('ak4PFJets'),
           # trackSource = cms.InputTag('unpackedTracksAndVertices'),
           pvSource = cms.InputTag('unpackedTracksAndVertices'),
           jetCorrections = ('AK4PF', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
           btagDiscriminators = ['combinedSecondaryVertexBJetTags'],
           algo = 'AK',
           rParam = 0.4
           )
    
        process.patJetGenJetMatchAK4PF.matched = "slimmedGenJets"
        process.patJetPartonMatchAK4PF.matched = "prunedGenParticles"
        process.patJetPartons.particles = "prunedGenParticles"
        process.patJetPartonsLegacy.src = "prunedGenParticles"
        process.patJetCorrFactorsAK4PF.primaryVertices = "offlineSlimmedPrimaryVertices"

        process.impactParameterTagInfosAK4PF.primaryVertex = cms.InputTag("unpackedTracksAndVertices")
        # process.inclusiveSecondaryVertexFinderTagInfosAK4PF.extSVCollection = cms.InputTag("unpackedTracksAndVertices","secondary","")
        # process.combinedSecondaryVertexBJetTagsAK4PF.trackMultiplicityMin = 1
        process.jetTracksAssociatorAtVertexAK4PF.tracks = cms.InputTag("unpackedTracksAndVertices")

        process.pileupJetIdMET = pileupJetIdMET.clone()
        process.pileupJetIdFull = pileupJetIdFull.clone()

        process.patJetsAK4PF.userData.userFloats.src = [ cms.InputTag("pileupJetIdMET:met53xDiscriminant"), cms.InputTag("pileupJetIdFull:full53xDiscriminant")]

        process.jetSequenceAK4 = cms.Sequence(
            process.ak4PFJets +
            process.unpackedTracksAndVertices +
            process.jetTracksAssociatorAtVertexAK4PF +
            process.patJetCorrFactorsAK4PF +
            process.pileupJetIdMET +
            process.pileupJetIdFull +
            process.patJetChargeAK4PF +
            process.patJetPartons +
            process.patJetPartonMatchAK4PF +
            process.patJetGenJetMatchAK4PF +
            process.patJetFlavourAssociationAK4PF +
            process.patJetPartonsLegacy +
            process.patJetPartonAssociationLegacyAK4PF +
            process.patJetFlavourAssociationLegacyAK4PF +
            # process.inclusiveSecondaryVertexFinderTagInfosAK4PF +
            process.impactParameterTagInfosAK4PF +
            process.secondaryVertexTagInfosAK4PF +
            process.combinedSecondaryVertexBJetTagsAK4PF +
            process.patJetsAK4PF
            )
    else:
        process.jetSequenceAK4 = cms.Sequence(
            process.ak4PFJets
            )
    return process.jetSequenceAK4
Exemplo n.º 6
0
def addFlashggPF(process, doQGTagging =  True, label ='', debug = False):
  
  from RecoJets.JetProducers.ak4PFJets_cfi  import ak4PFJets
  # process.ak4PFJets  = ak4PFJets.clone (src = 'packedPFCandidates', doAreaFastjet = True)
  setattr(process, 'ak4PFJets' + label, ak4PFJets.clone (src = 'packedPFCandidates', doAreaFastjet = True))
  
  # cluster the jets
  addJetCollection(
    process,
    postfix            = label,
    labelName          = 'AK4PF' ,
    jetSource          = cms.InputTag('ak4PFJets'+label),
    pvSource           = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates       = cms.InputTag('packedPFCandidates'),
    svSource           = cms.InputTag('slimmedSecondaryVertices'),
    elSource       = cms.InputTag("slimmedElectrons"),
    muSource       = cms.InputTag("slimmedMuons"),
    runIVF         = True,
    btagDiscriminators = [ flashggBTag, flashggCMVABTag , flashggDeepCSVb, flashggDeepCSVbb, flashggDeepCSVc, flashggDeepCSVudsg, ],
    jetCorrections     = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
    genJetCollection   = cms.InputTag('slimmedGenJets'),
    genParticles       = cms.InputTag('prunedGenParticles'),
    algo = 'AK', rParam = 0.4
  )

  # adjust PV used for Jet Corrections
  # getattr(process, 'patJetCorrFactors'+_labelName+label)
  getattr(process, 'patJetCorrFactorsAK4PF' + label).primaryVertices = "offlineSlimmedPrimaryVertices"
  #process.patJetCorrFactorsAK4PF.primaryVertices = "offlineSlimmedPrimaryVertices"
  print ' --> patJetCorrFactorsAK4PF == ',  getattr(process, 'patJetCorrFactorsAK4PF' + label)
  print ' --> patJetsAK4PF           == ',  getattr(process, 'patJetsAK4PF' + label)
  flashggJetsPF = cms.EDProducer('FlashggJetProducer',
                                 DiPhotonTag=cms.InputTag('flashggDiPhotons'),
                                 VertexTag=cms.InputTag('offlineSlimmedPrimaryVertices'),
                                 JetTag=cms.InputTag('patJetsAK4PF' + label ),
                                 VertexCandidateMapTag = cms.InputTag("flashggVertexMapForCHS"),
#                                 PileupJetIdParameters=cms.PSet(pu_jetid),
  )
  setattr(process, 'flashggJetsPF' + label, flashggJetsPF)
  if doQGTagging:
    from RecoJets.JetProducers.QGTagger_cfi import QGTagger
    setattr(process, 'QGTaggerPF' + label, QGTagger.clone( srcJets   = 'flashggJetsPF' + label ,jetsLabel = 'QGL_AK4PF'))
    
  return getattr(process, 'flashggJetsPF' + label)  
def addSUSYJetCollection(process,jetMetCorrections,jets = 'IC5Calo',mcVersion='',doJTA=True,doType1MET=True,doJetID=True,jetIdLabel=None):
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
    algorithm = jets[0:3]
    type = jets[3:len(jets)]
    jetCorrLabel = (jets,cms.vstring(jetMetCorrections))
    if 'IC' in algorithm: collection = algorithm.replace('IC','iterativeCone')
    elif 'SC' in algorithm: collection = algorithm.replace('SC','sisCone')
    elif 'AK' in algorithm: collection = algorithm.replace('AK','ak')
    elif 'KT' in algorithm: collection = algorithm.replace('KT','kt')
    else: raise ValueError, "Unknown jet algorithm: %s" % (jets)
    jetIdLabel = algorithm.lower()
    if type == 'Calo':
	jetCollection = '%(collection)sCaloJets' % locals()
	if not 'AK7' in algorithm:
		doType1MET = True
    elif type == 'PF':
	jetCollection = '%(collection)sPFJets' % locals()
	doJetID = False
    elif type == 'JPT':
        if 'IC' in algorithm: collectionJPT = algorithm.replace('IC','Icone')
        elif 'SC' in algorithm: collectionJPT = algorithm.replace('SC','Siscone')
        elif 'AK' in algorithm: collectionJPT = algorithm.replace('AK','AntiKt')
        else: raise ValueError, "Unknown jet algorithm: %s" % (jets)
        jetCollection = 'JetPlusTrackZSPCorJet%(collectionJPT)s' % locals()
    elif type == 'Track':
	jetCollection = '%(collection)sTrackJets' % locals()
    	jetCorrLabel = None
	doJetID = False
    else: raise ValueError, "Unknown jet type: %s" % (jets)
    
    addJetCollection(process, cms.InputTag(jetCollection),
                     algorithm, type,
                     doJTA            = doJTA,
                     doBTagging       = True,
                     jetCorrLabel     = jetCorrLabel,
                     doType1MET       = doType1MET,
                     doL1Cleaning     = True,
                     doL1Counters     = True,
                     doJetID          = doJetID,
		             jetIdLabel       = jetIdLabel,
                     genJetCollection = cms.InputTag('%(collection)sGenJets' % locals())
                     )
Exemplo n.º 8
0
    def Pat(self) :

        from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching,removeCleaning,restrictInputToAOD,removeAllPATObjectsBut
        from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection 
        from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection 

        if self.options.isData: removeMCMatching(self.process, ['All'])
        restrictInputToAOD(self.process)
        removeCleaning(self.process)
        removeAllPATObjectsBut(self.process, ['Jets','METs','Muons'])
        addJetCollection(self.process,
	    		    cms.InputTag('ak5CaloJets'),
			    'AK5',
			    'Calo',
			    jetCorrLabel = ('AK5Calo',self.options.jetCorrections),
			    genJetCollection = cms.InputTag('ak5GenJets'),
			    doType1MET = False,
                       )
        switchJetCollection(self.process,
	    		    cms.InputTag('ak5PFJets'),
			    doJTA = True,
		  	    doBTagging = True,
			    doJetID = True,
			    jetCorrLabel = ('AK5PF',self.options.jetCorrections),
			    genJetCollection = cms.InputTag('ak5GenJets'),
			    doType1MET = False,
			    jetIdLabel = 'ak5pf'
                       )

        self.process.selectedPatJets.cut = cms.string("pt > 30 && \
                                                       abs(eta) < 3.0 && \
                                                       neutralHadronEnergyFraction < 0.9 && \
                                                       neutralEmEnergyFraction < 0.90 && \
                                                       nConstituents > 1 && \
                                                       (? abs(eta)<2.4 ? chargedHadronEnergyFraction : 1) > 0 && \
                                                       (? abs(eta)<2.4 ? chargedHadronMultiplicity : 1) > 0 && \
                                                       (? abs(eta)<2.4 ? chargedEmEnergyFraction : 0) < 0.99")

        del self.process.out
        del self.process.outpath
	return self.process.patDefaultSequence
Exemplo n.º 9
0
  def addC8Jets(p, runOnMC):
    p2 = p.replace('AK5', 'CA8')

    ###############################
    ###### Bare CA 0.8 jets #######
    ###############################
    setattr(process, "ca8PFJets" + p2, ca4PFJets.clone(
            rParam = cms.double(0.8),
            src = cms.InputTag('pfNoElectron' + p),
            doAreaFastjet = cms.bool(True),
            doRhoFastjet = cms.bool(True),
            Rho_EtaMax = cms.double(6.0),
            Ghost_EtaMax = cms.double(7.0),
            srcPVs = cms.InputTag("goodOfflinePrimaryVertices")
            ))

    # Add ca8PFJets to the main process path
    getattr(process, "patPF2PATSequence" + p).replace(
            getattr(process, "pfNoElectron" + p), getattr(process, "pfNoElectron" + p) * getattr(process, "ca8PFJets" + p2)
            )

    addJetCollection(process, 
            cms.InputTag('ca8PFJets' + p2),
            'CA8', 'PFchs' if 'chs' in p else 'PF',
            doJTA = True,
            doBTagging = True,
            jetCorrLabel = ('AK7PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute']),
            doType1MET = True,
            doL1Cleaning = False,
            doL1Counters = False,
            genJetCollection = cms.InputTag("ca8GenJetsNoNu"),
            doJetID = True,
            )
    if not runOnMC:
      # Remove MC Matching
      removeMCMatching(process, names = ["All"])
Exemplo n.º 10
0
def nanoAOD_recalibrateMETs(process, isData):
    # add DeepMETs
    nanoAOD_DeepMET_switch = cms.PSet(ResponseTune_Graph=cms.untracked.string(
        'RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb'))
    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"
            ))

    print("add DeepMET Producers")
    process.load('RecoMET.METPUSubtraction.deepMETProducer_cfi')
    process.deepMETsResolutionTune = process.deepMETProducer.clone()
    process.deepMETsResponseTune = process.deepMETProducer.clone()
    process.deepMETsResponseTune.graph_path = nanoAOD_DeepMET_switch.ResponseTune_Graph.value(
    )

    runMetCorAndUncFromMiniAOD(process, isData=isData)
    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
Exemplo n.º 11
0
def reSetJet(process):
    ## Filter out neutrinos from packed GenParticles
    process.packedGenParticlesForJetsNoNu = cms.EDFilter(
        "CandPtrSelector",
        src=cms.InputTag("packedGenParticles"),
        cut=cms.string(
            "abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16"))
    ## Define GenJets
    from RecoJets.JetProducers.ak5GenJets_cfi import ak5GenJets
    process.ak5GenJetsNoNu = ak5GenJets.clone(
        src='packedGenParticlesForJetsNoNu')

    ## Select charged hadron subtracted packed PF candidates
    process.pfCHS = cms.EDFilter("CandPtrSelector",
                                 src=cms.InputTag("packedPFCandidates"),
                                 cut=cms.string("fromPV"))
    from RecoJets.JetProducers.ak5PFJets_cfi import ak5PFJets
    ## Define PFJetsCHS
    process.ak5PFJetsCHS = ak5PFJets.clone(src='pfCHS', doAreaFastjet=True)

    #################################################
    ## Remake PAT jets
    #################################################

    ## b-tag discriminators
    bTagDiscriminators = ['pfCombinedInclusiveSecondaryVertexV2BJetTags']
    #################################################################
    slimmedAddPileupInfo = cms.EDProducer(
        'PileupSummaryInfoSlimmer',
        #src = cms.InputTag('addPileupInfo'),
        keepDetailedInfoFor=cms.vint32(0))
    #######################################################
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection

    ## Add PAT jet collection based on the above-defined ak5PFJetsCHS
    addJetCollection(
        process,
        labelName='AK5PFCHS',
        jetSource=cms.InputTag('ak5PFJetsCHS'),
        pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
        bsSource=cms.InputTag('offlineBeamSpot'),
        pfCandidates=cms.InputTag('packedPFCandidates'),
        svSource=cms.InputTag('slimmedSecondaryVertices'),
        btagDiscriminators=bTagDiscriminators,
        #jetCorrections = ('AK5PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),  #commented before adding jet corrections
        genJetCollection=cms.InputTag('ak5GenJetsNoNu'),
        genParticles=cms.InputTag('prunedGenParticles'),
        algo='AK',
        rParam=0.5)

    getattr(process, 'selectedPatJetsAK5PFCHS').cut = cms.string('pt > 20.')

    process.rejet = cms.Path(
        process.packedGenParticlesForJetsNoNu * process.ak5GenJetsNoNu *
        process.pfCHS * process.ak5PFJetsCHS *
        process.patJetCorrFactorsAK5PFCHS * process.patJetPartons *
        process.patJetFlavourAssociationAK5PFCHS *
        process.patJetPartonMatchAK5PFCHS * process.patJetGenJetMatchAK5PFCHS *
        process.pfImpactParameterTagInfosAK5PFCHS *
        process.pfInclusiveSecondaryVertexFinderTagInfosAK5PFCHS *
        process.pfCombinedInclusiveSecondaryVertexV2BJetTagsAK5PFCHS *
        process.patJetsAK5PFCHS * process.selectedPatJetsAK5PFCHS)

    from PhysicsTools.PatAlgos.tools.pfTools import adaptPVs
    ## Adapt primary vertex collection and BeamSpot
    adaptPVs(process,
             pvCollection=cms.InputTag('offlineSlimmedPrimaryVertices'))
    adaptBSs(process, bsCollection=cms.InputTag('offlineBeamSpot'))

    from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
    updateJetCollection(
        process,
        jetSource=cms.InputTag('slimmedJets'),
        labelName='UpdatedJEC',
        jetCorrections=('AK5PFchs',
                        cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']),
                        'None')  # Do not forget 'L2L3Residual' on data
    )

    process.load('Configuration.StandardSequences.Services_cff'
                 )  #Added info from now onwards
    process.load("JetMETCorrections.Modules.JetResolutionESProducer_cfi")

    from CondCore.DBCommon.CondDBSetup_cfi import *
    import os
    process.jer = cms.ESSource(
        "PoolDBESSource",
        CondDBSetup,
        toGet=cms.VPSet(
            # Resolution
            cms.PSet(
                record=cms.string('JetResolutionRcd'),
                tag=cms.string('JR_Fall15_25nsV2_MC_PtResolution_AK5PFchs'),
                label=cms.untracked.string('AK5PFchs_pt')),

            # Scale factors
            cms.PSet(record=cms.string('JetResolutionScaleFactorRcd'),
                     tag=cms.string('JR_Fall15_25nsV2_MC_SF_AK4PFchs'),
                     label=cms.untracked.string('AK5PFchs')),
        ),
        connect=cms.string('sqlite:Fall15_25nsV2_MC.db'))
    process.es_prefer_jer = cms.ESPrefer('PoolDBESSource', 'jer')
Exemplo n.º 12
0
def JetSubstructure(process,
                    isMC,
                    coneSize=0.8,
                    algo="AK",
                    pileupMethod="chs",
                    selection="pt > 175 && abs(eta) < 2.5",
                    addPruning=True,
                    addPrunedSubjets=True,
                    addSoftDrop=True,
                    addSoftDropSubjets=True,
                    addTrimming=False,
                    addTrimmedSubjets=False,
                    addFiltering=False,
                    addFilteredSubjets=False,
                    addNsubjettiness=True,
                    addEnergyCorrelation=True,
                    addQJets=False,
                    addQGLikelihood=True):

    print "############################"
    print "add substructure information"
    print "isMC             = ", isMC
    print "coneSize         = ", coneSize
    print "algo             = ", algo
    print "pileupMethod     = ", pileupMethod
    print "selection        = ", selection
    print "addPruning       = ", addPruning
    print "addPrunedSubjets = ", addPrunedSubjets
    print "addSoftDrop      = ", addSoftDrop
    print "addSoftDropSubjets = ", addSoftDropSubjets
    print "addTrimming        = ", addTrimming
    print "addTrimmedSubjets  = ", addTrimmedSubjets
    print "addFiltering       = ", addFiltering
    print "addFilteredSubjets = ", addFilteredSubjets
    print "addNsubjettiness   = ", addNsubjettiness
    print "addEnergyCorrelation = ", addEnergyCorrelation
    print "addQJets             = ", addQJets
    print "addQGLikelihood      = ", addQGLikelihood
    print "############################"

    ## build jet algo name for jet clustering
    coneSizeStr = str(coneSize).replace("0", "").replace(".", "")
    jetAlgo = algo + coneSizeStr
    if algo == "AK":
        ALGO = "AntiKt"
    elif algo == "CA":
        ALGO = "CambridgeAachen"

    if isMC:
        ## run gen jet clustering from genParticles
        if not hasattr(process, "genParticlesForJetsNoNu"):
            setattr(
                process, 'genParticlesForJetsNoNu',
                cms.EDFilter(
                    "CandPtrSelector",
                    src=cms.InputTag("packedGenParticles"),
                    cut=cms.string(
                        "abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16 && abs(pdgId) != 1000022 && abs(pdgId) != 1000012 &&"
                        +
                        "abs(pdgId) != 1000014 && abs(pdgId) != 1000016 && abs(pdgId) != 2000012 && abs(pdgId) != 2000014 &&"
                        +
                        "abs(pdgId) != 2000016 && abs(pdgId) != 1000039 && abs(pdgId) != 5100039 && abs(pdgId) != 4000012 &&"
                        +
                        "abs(pdgId) != 4000014 && abs(pdgId) != 4000016 && abs(pdgId) != 9900012 && abs(pdgId) != 9900014 &&"
                        +
                        "abs(pdgId) != 9900016 && abs(pdgId) != 39 && abs(pdgId) != 9100012"
                    )))  ## skip all the possible invisible particles

        if not hasattr(process, "genJets" + jetAlgo):
            setattr(
                process, "genJets" + jetAlgo,
                ak4GenJets.clone(src='genParticlesForJetsNoNu',
                                 rParam=coneSize,
                                 jetAlgorithm=ALGO,
                                 jetPtMin=cms.double(50.))
            )  ## fix a lower reasonable threshold give the jet response

        ## filter only hadronically decaying W/Z and Higgs at generator level
        if not hasattr(process, "genBosons"):
            setattr(
                process, "genBosons",
                cms.EDFilter(
                    "CandPtrSelector",
                    src=cms.InputTag("prunedGenParticles"),
                    cut=cms.string(
                        "(abs(pdgId) == 23 || abs(pdgId) == 24 || abs(pdgId) == 25) &&"
                        +
                        "numberOfDaughters > 1 && abs(daughter(0).pdgId) <= 5 && abs(daughter(1).pdgId) <= 5"
                    )))

    ## b-tag discriminators to be considered
    bTagDiscriminators = [
        #'pfCombinedInclusiveSecondaryVertexV2BJetTags', ## don't run b-tagging on the whole large cone jet
        'pfBoostedDoubleSecondaryVertexAK8BJetTags'  ## new tag for Boosted double b-tagging
    ]

    ## jet energy corrections already loaded in JECLevels
    if pileupMethod != "chs" and pileupMethod != "Puppi" and pileupMethod != "":
        sys.exit(
            "Invalid pileupMethod setup --> only recognized options are 'chs' and 'Puppi'"
        )

    ## JEC
    JECLevel = copy.deepcopy(process.JECLevels.labels)
    payloadName = ""
    payloadNameSubJet = ""
    jetCollection = ""
    pfCand = ""

    ## in case of CHS select particles and re-cluster jets
    if pileupMethod == "chs":
        ## obtain chs candidates
        if not hasattr(process, "chs"):
            setattr(
                process, 'chs',
                cms.EDFilter('CandPtrSelector',
                             src=cms.InputTag("packedPFCandidates"),
                             cut=cms.string('fromPV')))
        ## cluster basic jets given rParameter and algorithm
        if not hasattr(process, jetAlgo + 'PFJets' + pileupMethod.upper()):
            setattr(
                process, jetAlgo + 'PFJets' + pileupMethod.upper(),
                ak4PFJetsCHS.clone(src=cms.InputTag('chs'),
                                   doAreaFastjet=True,
                                   rParam=coneSize,
                                   jetAlgorithm=ALGO))

        payloadName = jetAlgo + 'PF' + pileupMethod
        payloadNameSubjet = 'AK4PF' + pileupMethod
        jetCollection = jetAlgo + 'PFJets' + pileupMethod.upper()
        pfCand = "chs"

    ## for puppi jets
    elif pileupMethod == "Puppi":
        ### re-run optimal puppi weights
        if not hasattr(process, "puppi"):
            from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD
            makePuppiesFromMiniAOD(process, False)
            process.puppi.useExistingWeights = cms.bool(False)
            process.puppiNoLep.useExistingWeights = cms.bool(False)

        ## cluster puppi jets given rParameter and algorithm
        if not hasattr(process, jetAlgo + 'PFJets' + pileupMethod):
            setattr(
                process, jetAlgo + 'PFJets' + pileupMethod,
                ak4PFJetsPuppi.clone(src=cms.InputTag('puppi'),
                                     doAreaFastjet=True,
                                     rParam=coneSize,
                                     jetAlgorithm=ALGO))

        payloadName = jetAlgo + 'PF' + pileupMethod
        payloadNameSubjet = 'AK4PF' + pileupMethod
        jetCollection = jetAlgo + 'PFJets' + pileupMethod
        pfCand = "puppi"

    ## standard PF jets
    elif pileupMethod == "":
        ## no pileup mitigation
        if not hasattr(process, jetAlgo + 'PFJets'):
            setattr(
                process, jetAlgo + 'PFJets',
                ak4PFJetsPuppi.clone(src=cms.InputTag('packedPFCandidates'),
                                     doAreaFastjet=True,
                                     rParam=coneSize,
                                     jetAlgorithm=ALGO))
        payloadName = jetAlgo + 'PF'
        payloadNameSubjet = 'AK4PF'
        jetCollection = jetAlgo + 'PFJets'
        pfCand = "packedPFCandidates"

    ## apply selection and produce a restricted set of consituents only for jets passig the selection
    if not hasattr(process, jetCollection + "Reduced"):
        setattr(
            process, jetCollection + "Reduced",
            cms.EDFilter("MiniAODJetConstituentSelector",
                         src=cms.InputTag(jetCollection),
                         cut=cms.string("pt > 100 && abs(eta) < 2.5")))

    ## build pat-jets from this skimmed collection: example
    if not hasattr(process, "patJets" + jetCollection):

        addJetCollection(
            process,
            labelName=jetCollection,
            jetSource=cms.InputTag(jetCollection + "Reduced"),
            algo=algo,
            rParam=coneSize,
            pfCandidates=cms.InputTag(pfCand),
            jetCorrections=(payloadName, JECLevel, 'None'),
            svSource=cms.InputTag('slimmedSecondaryVertices'),
            genJetCollection=cms.InputTag("genJets" + jetAlgo),
            pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
            btagDiscriminators=bTagDiscriminators,
            getJetMCFlavour=isMC,
            genParticles=cms.InputTag("prunedGenParticles"),
        )

        ### special jec set for pruned/sof-drop mass correction --> to be taken from the EDAnalyzer
        if hasattr(process, "patJetCorrFactors" + jetCollection):
            if isMC:
                setattr(
                    process, "patJetCorrFactors" + jetCollection + "v2",
                    getattr(
                        process, "patJetCorrFactors" + jetCollection).clone(
                            levels=cms.vstring('L2Relative', 'L3Absolute')))
            else:
                setattr(
                    process, "patJetCorrFactors" + jetCollection + "v2",
                    getattr(process, "patJetCorrFactors" +
                            jetCollection).clone(levels=cms.vstring(
                                'L2Relative', 'L3Absolute', 'L2L3Residual')))

            getattr(process, "patJets" +
                    jetCollection).jetCorrFactorsSource = cms.VInputTag(
                        cms.InputTag("patJetCorrFactors" + jetCollection),
                        cms.InputTag("patJetCorrFactors" + jetCollection +
                                     "v2"))

        if hasattr(process, "selectedPatJets" + jetCollection):
            getattr(process, "selectedPatJets" +
                    jetCollection).cut = cms.string(selection)

    ## match reco-jets with hadronically decaying genBosons (W,Z,H)
    if isMC:
        if not hasattr(process, jetCollection + 'GenBosonMatched'):
            setattr(
                process,
                jetCollection + 'GenBosonMatched',
                cms.EDProducer(
                    "RecoJetCandDeltaRValueMapProducer",
                    ## basic reco::jet ungroomed
                    src=cms.InputTag(jetCollection + "Reduced"),
                    ## mathched groomed pat jet
                    matched=cms.InputTag('genBosons'),
                    distMax=cms.double(coneSize),
                    values=cms.vstring("pt", "eta", "phi", "mass"),
                    valueLabels=cms.vstring("pt", "eta", "phi", "mass")))

            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + 'GenBosonMatched:pt'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + 'GenBosonMatched:eta'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + 'GenBosonMatched:phi'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + 'GenBosonMatched:mass'
                    ]

    ## add QGLikelihood on fat jet
    if addQGLikelihood:
        if not hasattr(process, jetCollection + "QGL"):
            setattr(
                process, jetCollection + "QGL",
                QGTagger.clone(srcJets=cms.InputTag(jetCollection + "Reduced"),
                               jetsLabel=cms.string('QGL_AK4PFchs'),
                               srcVertexCollection=cms.InputTag(
                                   'offlineSlimmedPrimaryVertices')))
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + 'QGL:qgLikelihood'
                    ]

    ## addNsubjettiness
    if addNsubjettiness:
        if not hasattr(process, 'Njettiness' + jetCollection):
            setattr(
                process, 'Njettiness' + jetCollection,
                Njettiness.clone(src=cms.InputTag(jetCollection + "Reduced"),
                                 cone=cms.double(coneSize)))

            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        'Njettiness' + jetCollection + ':tau1',
                        'Njettiness' + jetCollection + ':tau2',
                        'Njettiness' + jetCollection + ':tau3',
                        'Njettiness' + jetCollection + ':tau4'
                    ]

        ## on gen jets
        if isMC:
            if not hasattr(process, "NjettinessGenJets" + jetAlgo):
                setattr(
                    process, "NjettinessGenJets" + jetAlgo,
                    Njettiness.clone(src=cms.InputTag("genJets" + jetAlgo),
                                     cone=cms.double(coneSize)))

                ## pattify gen jets --> temp
                if not hasattr(process, 'patGenJets' + jetAlgo):
                    setattr(
                        process, 'patGenJets' + jetAlgo,
                        patJets.clone(
                            jetSource=cms.InputTag("genJets" + jetAlgo),
                            addJetCorrFactors=cms.bool(False),
                            addBTagInfo=cms.bool(False),
                            addDiscriminators=cms.bool(False),
                            discriminatorSources=cms.VInputTag('None'),
                            addAssociatedTracks=cms.bool(False),
                            addJetCharge=cms.bool(False),
                            addGenPartonMatch=cms.bool(False),
                            embedGenPartonMatch=cms.bool(False),
                            addGenJetMatch=cms.bool(False),
                            embedGenJetMatch=cms.bool(False),
                            getJetMCFlavour=cms.bool(False),
                            addJetFlavourInfo=cms.bool(False)))

                    getattr(process, 'patGenJets' +
                            jetAlgo).userData.userFloats.src += [
                                "NjettinessGenJets" + jetAlgo + ':tau1'
                            ]
                    getattr(process, 'patGenJets' +
                            jetAlgo).userData.userFloats.src += [
                                "NjettinessGenJets" + jetAlgo + ':tau2'
                            ]
                    getattr(process, 'patGenJets' +
                            jetAlgo).userData.userFloats.src += [
                                "NjettinessGenJets" + jetAlgo + ':tau3'
                            ]
                    getattr(process, 'patGenJets' +
                            jetAlgo).userData.userFloats.src += [
                                "NjettinessGenJets" + jetAlgo + ':tau4'
                            ]

            if not hasattr(process, jetCollection + 'GenNjettinessMatched'):
                setattr(
                    process,
                    jetCollection + 'GenNjettinessMatched',
                    cms.EDProducer(
                        "RecoPATJetDeltaRValueMapProducer",
                        ## basic reco::jet ungroomed
                        src=cms.InputTag(jetCollection + "Reduced"),
                        ## mathched groomed pat jet
                        matched=cms.InputTag('patGenJets' + jetAlgo),
                        distMax=cms.double(coneSize),
                        values=cms.vstring(
                            "userFloat('NjettinessGenJets" + jetAlgo +
                            ":tau1')", "userFloat('NjettinessGenJets" +
                            jetAlgo + ":tau2')",
                            "userFloat('NjettinessGenJets" + jetAlgo +
                            ":tau3')", "userFloat('NjettinessGenJets" +
                            jetAlgo + ":tau4')"),
                        valueLabels=cms.vstring("tau1", "tau2", "tau3",
                                                "tau4")))

                getattr(process,
                        'patJets' + jetCollection).userData.userFloats.src += [
                            jetCollection + 'GenNjettinessMatched:tau1',
                            jetCollection + 'GenNjettinessMatched:tau2',
                            jetCollection + 'GenNjettinessMatched:tau3',
                            jetCollection + 'GenNjettinessMatched:tau4'
                        ]

    ## add ECF
    if addEnergyCorrelation:
        if not hasattr(process, 'ecf' + jetCollection):
            setattr(
                process, 'ecf' + jetCollection,
                ECF.clone(src=cms.InputTag(jetCollection + "Reduced"),
                          Njets=cms.vuint32(1, 2, 3)))

            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        'ecf' + jetCollection + ':ecf1'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        'ecf' + jetCollection + ':ecf2'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        'ecf' + jetCollection + ':ecf3'
                    ]

    ## add QJets
    if addQJets:
        if not hasattr(process, "qjets" + jetCollection):
            setattr(
                process, "qjets" + jetCollection,
                QJetsAdder.clone(src=cms.InputTag(jetCollection + "Reduced"),
                                 jeRad=cms.double(coneSize),
                                 jetAlgo=cms.string(algo)))

            setattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        "qjets" + jetCollection + ":QjetsVolatility"
                    ]

    ### start with substructure: Pruning (run it on both reco and gen jets):
    Tags = []
    Labels = []
    JECLevelTemp = copy.deepcopy(JECLevel)
    if 'L1FastJet' in JECLevelTemp:
        JECLevelTemp.remove(
            'L1FastJet')  ## in any case groomers are removing already pileup

    if addPruning:
        runGroomedMethod(process,
                         isMC=isMC,
                         jetCollection=jetCollection,
                         coneSize=coneSize,
                         algo=algo,
                         payloadName=payloadName,
                         payloadNameSubjet=payloadNameSubjet,
                         JECLevel=JECLevelTemp,
                         pfCand=pfCand,
                         btagDiscriminators=bTagDiscriminators,
                         addSubJets=addPrunedSubjets,
                         addQGLikelihood=addQGLikelihood,
                         isPruning=True,
                         isSoftDrop=False,
                         isTrimming=False,
                         isFiltering=False)

        if addPrunedSubjets:
            Tags += ['patJets' + jetCollection + 'PrunedPacked']
            Labels += ['Pruned']

    if addSoftDrop:
        runGroomedMethod(process,
                         isMC=isMC,
                         jetCollection=jetCollection,
                         coneSize=coneSize,
                         algo=algo,
                         payloadName=payloadName,
                         payloadNameSubjet=payloadNameSubjet,
                         JECLevel=JECLevelTemp,
                         pfCand=pfCand,
                         btagDiscriminators=bTagDiscriminators,
                         addSubJets=addSoftDropSubjets,
                         addQGLikelihood=addQGLikelihood,
                         isPruning=False,
                         isSoftDrop=True,
                         isTrimming=False,
                         isFiltering=False)

        if addSoftDropSubjets:
            Tags += ['patJets' + jetCollection + 'SoftDropPacked']
            Labels += ['SoftDrop']

    if addTrimming:
        runGroomedMethod(process,
                         isMC=isMC,
                         jetCollection=jetCollection,
                         coneSize=coneSize,
                         algo=algo,
                         payloadName=payloadName,
                         payloadNameSubjet=payloadNameSubjet,
                         JECLevel=JECLevelTemp,
                         pfCand=pfCand,
                         btagDiscriminators=bTagDiscriminators,
                         addSubJets=addTrimmedSubjets,
                         addQGLikelihood=addQGLikelihood,
                         isPruning=False,
                         isSoftDrop=False,
                         isTrimming=True,
                         isFiltering=False)

        if addTrimmedSubjets:
            Tags += ['patJets' + jetCollection + 'TrimmedPacked']
            Labels += ['Trimmed']

    if addFiltering:
        runGroomedMethod(process,
                         isMC=isMC,
                         jetCollection=jetCollection,
                         coneSize=coneSize,
                         algo=algo,
                         payloadName=payloadName,
                         payloadNameSubjet=payloadNameSubjet,
                         JECLevel=JECLevelTemp,
                         pfCand=pfCand,
                         btagDiscriminators=bTagDiscriminators,
                         addSubJets=addFilteredSubjets,
                         addQGLikelihood=addQGLikelihood,
                         isPruning=False,
                         isSoftDrop=False,
                         isTrimming=False,
                         isFiltering=True)

        if addFilteredSubjets:
            Tags += ['patJets' + jetCollection + 'FilteredPacked']
            Labels += ['Filtered']

    ## finally fix the pat fat jet collection
    if not hasattr(process, "packedPatJets" + jetCollection):
        setattr(
            process, "packedPatJets" + jetCollection,
            cms.EDProducer("JetSubstructurePacker",
                           jetSrc=cms.InputTag("selectedPatJets" +
                                               jetCollection),
                           distMax=cms.double(coneSize),
                           fixDaughters=cms.bool(False),
                           algoTags=cms.VInputTag(),
                           algoLabels=cms.vstring()))

        getattr(process, "packedPatJets" + jetCollection).algoTags = Tags
        getattr(process, "packedPatJets" + jetCollection).algoLabels = Labels

    return "packedPatJets" + jetCollection
Exemplo n.º 13
0
from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import *
from PhysicsTools.PatUtils.patPFMETCorrections_cff import patPFJetMETtype1p2Corr

process.patMETs.addGenMET = cms.bool(False)

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection

if options.cmsswVersion == "72X":
    addJetCollection(
        process,
        postfix="",
        labelName='AK4PFCHS',
        jetSource=cms.InputTag('ak4PFJetsCHS'),
        pvSource=cms.InputTag('unpackedTracksAndVertices'),
        trackSource=cms.InputTag('unpackedTracksAndVertices'),
        svSource=cms.InputTag('unpackedTracksAndVertices', 'secondary'),
        jetCorrections=('AK4PFchs',
                        cms.vstring(['L1FastJet', 'L2Relative',
                                     'L3Absolute']), 'Type-2'),
        btagDiscriminators=['combinedInclusiveSecondaryVertexV2BJetTags'],
        genJetCollection=cms.InputTag('ak4GenJets'),
        algo='AK',
        rParam=0.4)

    addJetCollection(
        process,
        postfix="",
        labelName='AK4PFCHSNoMu',
        jetSource=cms.InputTag('ak4PFJetsCHSNoMu'),
        pvSource=cms.InputTag('unpackedTracksAndVertices'),
        trackSource=cms.InputTag('unpackedTracksAndVertices'),
def applySubstructure( process ) :

    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection


    from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJetsDefault

    #add AK8
    addJetCollection(process, labelName = 'AK8',
                     jetSource = cms.InputTag('ak8PFJetsCHS'),
                     algo= 'AK', rParam = 0.8,
                     jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
                     btagDiscriminators = ([x.getModuleLabel() for x in patJetsDefault.discriminatorSources] + ['pfBoostedDoubleSecondaryVertexAK8BJetTags']),
                     genJetCollection = cms.InputTag('slimmedGenJetsAK8')
                     )
    process.patJetsAK8.userData.userFloats.src = [] # start with empty list of user floats
    process.selectedPatJetsAK8.cut = cms.string("pt > 170")


    process.load('RecoJets.JetProducers.ak8PFJetsPuppi_cfi')
    process.ak8PFJetsPuppi.doAreaFastjet = True # even for standard ak8PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff

    from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
    process.ak8PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
        j2tParametersVX,
        jets = cms.InputTag("ak8PFJetsPuppi")
    )
    process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
        src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"),
        var = cms.string('Pt'),
        exp = cms.double(1.0)
    )

    ## AK8 groomed masses
    from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop, ak8PFJetsPuppiSoftDrop 
    process.ak8PFJetsCHSPruned   = ak8PFJetsCHSPruned.clone()
    process.ak8PFJetsCHSSoftDrop = ak8PFJetsCHSSoftDrop.clone()
    process.ak8PFJetsPuppiSoftDrop = ak8PFJetsPuppiSoftDrop.clone()
    process.load("RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi")
    process.patJetsAK8.userData.userFloats.src += ['ak8PFJetsCHSPrunedMass','ak8PFJetsCHSSoftDropMass'] 
    process.patJetsAK8.addTagInfos = cms.bool(False)



    # add Njetiness
    process.load('RecoJets.JetProducers.nJettinessAdder_cfi')
    process.NjettinessAK8 = process.Njettiness.clone()
    process.NjettinessAK8.src = cms.InputTag("ak8PFJetsCHS")
    process.NjettinessAK8.cone = cms.double(0.8)
    process.patJetsAK8.userData.userFloats.src += ['NjettinessAK8:tau1','NjettinessAK8:tau2','NjettinessAK8:tau3']




    #add AK8 from PUPPI

    process.load('RecoJets.JetProducers.ak8PFJetsPuppi_cfi')
    process.ak8PFJetsPuppi.doAreaFastjet = True # even for standard ak8PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff

        
    addJetCollection(process, labelName = 'AK8Puppi',
                     jetSource = cms.InputTag('ak8PFJetsPuppi'),
                     algo= 'AK', rParam = 0.8,
                     jetCorrections = ('AK8PFPuppi', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
                     genJetCollection = cms.InputTag('slimmedGenJetsAK8')
                     )
    process.patJetsAK8Puppi.userData.userFloats.src = [] # start with empty list of user floats
    process.selectedPatJetsAK8Puppi.cut = cms.string("pt > 170")


    from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
    process.ak8PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
        j2tParametersVX,
        jets = cms.InputTag("ak8PFJetsPuppi")
    )
    process.patJetAK8PuppiCharge = cms.EDProducer("JetChargeProducer",
        src = cms.InputTag("ak8PFJetsPuppiTracksAssociatorAtVertex"),
        var = cms.string('Pt'),
        exp = cms.double(1.0)
    )

    ## AK8 groomed masses
    from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsPuppiSoftDrop
    process.ak8PFJetsPuppiSoftDrop = ak8PFJetsPuppiSoftDrop.clone()
    process.load("RecoJets.JetProducers.ak8PFJetsPuppi_groomingValueMaps_cfi")
    process.patJetsAK8Puppi.userData.userFloats.src += ['ak8PFJetsPuppiSoftDropMass']
    process.patJetsAK8Puppi.addTagInfos = cms.bool(False)



    # add Njetiness
    process.NjettinessAK8Puppi = process.Njettiness.clone()
    process.NjettinessAK8Puppi.src = cms.InputTag("ak8PFJetsPuppi")
    process.NjettinessAK8Puppi.cone = cms.double(0.8)
    process.patJetsAK8Puppi.userData.userFloats.src += ['NjettinessAK8Puppi:tau1','NjettinessAK8Puppi:tau2','NjettinessAK8Puppi:tau3']




    process.ak8PFJetsPuppiValueMap = cms.EDProducer("RecoJetToPatJetDeltaRValueMapProducer",
                                            src = cms.InputTag("ak8PFJetsCHS"),
                                            matched = cms.InputTag("patJetsAK8Puppi"),                                         
                                            distMax = cms.double(0.8),
                                            values = cms.vstring([
                                                'userFloat("NjettinessAK8Puppi:tau1")',
                                                'userFloat("NjettinessAK8Puppi:tau2")',
                                                'userFloat("NjettinessAK8Puppi:tau3")',
                                                'pt','eta','phi','mass'
                                            ]),
                                            valueLabels = cms.vstring( [
                                                'NjettinessAK8PuppiTau1',
                                                'NjettinessAK8PuppiTau2',
                                                'NjettinessAK8PuppiTau3',
                                                'pt','eta','phi','mass'
                                            ])
                        )
    #process.patJetsAK8.userData.userFloats.src += ['NjettinessAK8:tau1','NjettinessAK8:tau2','NjettinessAK8:tau3']

    process.patJetsAK8.userData.userFloats.src += [cms.InputTag('ak8PFJetsPuppiValueMap','NjettinessAK8PuppiTau1'),
                                                   cms.InputTag('ak8PFJetsPuppiValueMap','NjettinessAK8PuppiTau2'),
                                                   cms.InputTag('ak8PFJetsPuppiValueMap','NjettinessAK8PuppiTau3'),
                                                   cms.InputTag('ak8PFJetsPuppiValueMap','pt'),
                                                   cms.InputTag('ak8PFJetsPuppiValueMap','eta'),
                                                   cms.InputTag('ak8PFJetsPuppiValueMap','phi'),
                                                   cms.InputTag('ak8PFJetsPuppiValueMap','mass'),
                                                   ]

    
    ## PATify pruned fat jets
    addJetCollection(
        process,
        labelName = 'AK8PFCHSSoftDrop',
        jetSource = cms.InputTag('ak8PFJetsCHSSoftDrop'),
        btagDiscriminators = ['None'],
        jetCorrections = ('AK8PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
        getJetMCFlavour = False # jet flavor disabled
    )
    
    ## PATify soft drop subjets
    addJetCollection(
        process,
        labelName = 'AK8PFCHSSoftDropSubjets',
        jetSource = cms.InputTag('ak8PFJetsCHSSoftDrop','SubJets'),
        algo = 'ak',  # needed for subjet flavor clustering
        rParam = 0.8, # needed for subjet flavor clustering
        btagDiscriminators = ['pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags'],
        jetCorrections = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
        explicitJTA = True,  # needed for subjet b tagging
        svClustering = True, # needed for subjet b tagging
        genJetCollection = cms.InputTag('slimmedGenJets'), 
        fatJets=cms.InputTag('ak8PFJetsCHS'),             # needed for subjet flavor clustering
        groomedFatJets=cms.InputTag('ak8PFJetsCHSSoftDrop') # needed for subjet flavor clustering
    )
    process.selectedPatJetsAK8PFCHSSoftDrop.cut = cms.string("pt > 170")
    
    process.slimmedJetsAK8PFCHSSoftDropSubjets = cms.EDProducer("PATJetSlimmer",
        src = cms.InputTag("selectedPatJetsAK8PFCHSSoftDropSubjets"),
        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),
        modifierConfig = cms.PSet( modifications = cms.VPSet() )
    )

    
    ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
    process.slimmedJetsAK8PFCHSSoftDropPacked = cms.EDProducer("BoostedJetMerger",
        jetSrc=cms.InputTag("selectedPatJetsAK8PFCHSSoftDrop"),
        subjetSrc=cms.InputTag("slimmedJetsAK8PFCHSSoftDropSubjets")
    )

    
    

    ## PATify pruned fat jets
    addJetCollection(
        process,
        labelName = 'AK8PFPuppiSoftDrop',
        jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop'),
        btagDiscriminators = ['None'],
        jetCorrections = ('AK8PFPuppi', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
        getJetMCFlavour = False # jet flavor disabled
    )
    
    ## PATify soft drop subjets
    addJetCollection(
        process,
        labelName = 'AK8PFPuppiSoftDropSubjets',
        jetSource = cms.InputTag('ak8PFJetsPuppiSoftDrop','SubJets'),
        algo = 'ak',  # needed for subjet flavor clustering
        rParam = 0.8, # needed for subjet flavor clustering
        btagDiscriminators = ['pfCombinedSecondaryVertexV2BJetTags', 'pfCombinedInclusiveSecondaryVertexV2BJetTags'],
        jetCorrections = ('AK4PFPuppi', ['L1FastJet', '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
    )
    process.selectedPatJetsAK8PFPuppiSoftDrop.cut = cms.string("pt > 170")
    
    process.slimmedJetsAK8PFPuppiSoftDropSubjets = 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),
        modifierConfig = cms.PSet( modifications = cms.VPSet() )
    )

    
    ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
    process.slimmedJetsAK8PFPuppiSoftDropPacked = cms.EDProducer("BoostedJetMerger",
        jetSrc=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDrop"),
        subjetSrc=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropSubjets")
    )

    
    process.packedPatJetsAK8 = cms.EDProducer("JetSubstructurePacker",
            jetSrc = cms.InputTag("selectedPatJetsAK8"),
            distMax = cms.double(0.8),
            algoTags = cms.VInputTag(
                # NOTE: For an optimal storage of the AK8 jet daughters, the first subjet collection listed here should be
                #       derived from AK8 jets, i.e., subjets should contain either all or a subset of AK8 constituents.
                #       The PUPPI collection has its own pointers to its own PUPPI constituents. 
                cms.InputTag("slimmedJetsAK8PFCHSSoftDropPacked"),
                cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked")
            ),
            algoLabels = cms.vstring(
                'SoftDrop',
                'SoftDropPuppi'
                ),
            fixDaughters = cms.bool(True),
            packedPFCandidates = cms.InputTag("packedPFCandidates"),
    )

    # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards)
    process.slimmedJetsAK8.rekeyDaughters = "0"
Exemplo n.º 15
0
                                              rParam=0.8,
                                              jetAlgorithm='AntiKt')
jetSeq += process.ak8PFJetsPuppi

process.jetSequence = jetSeq

addJetCollection(
    process,
    #labelName = 'AK8PFCHS',
    labelName='AK8PFPuppi',
    #jetSource = cms.InputTag('ak8PFJetsCHS'),
    jetSource=cms.InputTag('ak8PFJetsPuppi'),
    #pvSource = cms.InputTag('offlinePrimaryVertices'),
    #svSource = cms.InputTag('inclusiveCandidateSecondaryVertices'),
    algo='AK',
    rParam=0.8,
    #jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
    jetCorrections=('AK8PFPuppi',
                    cms.vstring(['L1FastJet', 'L2Relative',
                                 'L3Absolute']), 'Type-2'),
    btagDiscriminators=[
        'pfBoostedDoubleSecondaryVertexAK8BJetTags',
        'pfDeepDoubleBJetTags:probQ',
        'pfDeepDoubleBJetTags:probH',
    ])

#process.patJetsAK8PFCHS.addTagInfos = True
process.patJetsAK8PFPuppi.addTagInfos = True

from pdb import set_trace
Exemplo n.º 16
0
process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff")
process.load("Configuration.EventContent.EventContent_cff")
process.load('Configuration.StandardSequences.Geometry_cff')
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
process.load(
    'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.GlobalTag.globaltag = 'START70_V6::All'

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
addJetCollection(process,
                 postfix="",
                 labelName='AK5PFCHS',
                 jetSource=cms.InputTag('ak5PFJetsCHS'),
                 trackSource=cms.InputTag('unpackedTracksAndVertices'),
                 pvSource=cms.InputTag('unpackedTracksAndVertices'),
                 jetCorrections=('AK5PFchs',
                                 cms.vstring(
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute']), 'Type-2'),
                 btagDiscriminators=['combinedSecondaryVertexBJetTags'])
process.patJetPartonMatchAK5PFCHS.matched = "prunedGenParticles"
process.patJetPartons.particles = "prunedGenParticles"
process.patJetPartonsLegacy.src = "prunedGenParticles"  # if using legacy jet flavour (not used by default)
process.patJetPartonsLegacy.skipFirstN = cms.uint32(
    0)  # do not skip first 6 particles, we already pruned some!
process.patJetPartonsLegacy.acceptNoDaughters = cms.bool(
    True
)  # as we drop intermediate stuff, we need to accept quarks with no siblings
process.patJetCorrFactorsAK5PFCHS.primaryVertices = "offlineSlimmedPrimaryVertices"
Exemplo n.º 17
0
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.elPFIsoDepositCharged.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.elPFIsoDepositChargedAll.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.elPFIsoDepositNeutral.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.elPFIsoDepositGamma.src = cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.elPFIsoDepositPU.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.photonSource = cms.InputTag("reducedEgamma","reducedGedPhotons")
    process.patPhotons.photonIDSources = cms.PSet(
                PhotonCutBasedIDLoose = cms.InputTag('reducedEgamma',
                                                      'PhotonCutBasedIDLoose'),
                PhotonCutBasedIDTight = cms.InputTag('reducedEgamma',
                                                      'PhotonCutBasedIDTight')
              )

    process.phPFIsoDepositCharged.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
    process.phPFIsoDepositChargedAll.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
    process.phPFIsoDepositNeutral.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
    process.phPFIsoDepositGamma.src = cms.InputTag("reducedEgamma","reducedGedPhotons")
    process.phPFIsoDepositPU.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('decayModeFinding')> 0.5")
    process.selectedPatPhotons.cut = cms.string("")

    # add CMS top tagger
    from RecoJets.JetProducers.caTopTaggers_cff import caTopTagInfos as toptag
    process.cmsttRaw = toptag.clone()
    process.caTopTagInfos = cms.EDProducer("RecoJetDeltaRTagInfoValueMapProducer",
                                    src = cms.InputTag("ak8PFJetsCHS"),
                                    matched = cms.InputTag("cmsTopTagPFJetsCHS"),
                                    matchedTagInfos = cms.InputTag("cmsttRaw"),
                                    distMax = cms.double(0.8)
                        )
    
    #add AK8
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
    addJetCollection(process, labelName = 'AK8',                     
                     jetSource = cms.InputTag('ak8PFJetsCHS'),
                     algo= 'AK', rParam = 0.8,
                     jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
                     btagInfos = ['caTopTagInfos']
                     )
    process.patJetsAK8.userData.userFloats.src = [] # start with empty list of user floats
    process.selectedPatJetsAK8.cut = cms.string("pt > 100")
    process.patJetGenJetMatchAK8.matched =  'slimmedGenJets'
    ## AK8 groomed masses
    from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSFiltered, ak8PFJetsCHSTrimmed 
    process.ak8PFJetsCHSPruned   = ak8PFJetsCHSPruned.clone()
    process.ak8PFJetsCHSTrimmed  = ak8PFJetsCHSTrimmed.clone()
    process.ak8PFJetsCHSFiltered = ak8PFJetsCHSFiltered.clone()
    process.load("RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi")
    process.patJetsAK8.userData.userFloats.src += ['ak8PFJetsCHSPrunedLinks','ak8PFJetsCHSTrimmedLinks','ak8PFJetsCHSFilteredLinks']

    # Add AK8 top tagging variables
    process.patJetsAK8.tagInfoSources = cms.VInputTag(cms.InputTag("caTopTagInfos"))
    process.patJetsAK8.addTagInfos = cms.bool(True) 



    # add Njetiness
    process.load('RecoJets.JetProducers.nJettinessAdder_cfi')
    process.NjettinessAK8 = process.Njettiness.clone()
    process.NjettinessAK8.src = cms.InputTag("ak8PFJetsCHS")
    process.NjettinessAK8.cone = cms.double(0.8)
    process.patJetsAK8.userData.userFloats.src += ['NjettinessAK8:tau1','NjettinessAK8:tau2','NjettinessAK8:tau3']

            
    
    #
    from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
    switchOnTriggerStandAlone( process, outputModule = '' )
    process.patTrigger.packTriggerPathNames = cms.bool(True)
    #
    # apply type I/type I + II PFMEt corrections to pat::MET object
    # and estimate systematic uncertainties on MET
    # FIXME: this and the typeI MET should become AK4 once we have the proper JEC?
    from PhysicsTools.PatUtils.tools.runType1PFMEtUncertainties import runType1PFMEtUncertainties
    addJetCollection(process, postfix   = "ForMetUnc", labelName = 'AK4PF', jetSource = cms.InputTag('ak4PFJets'), jetCorrections = ('AK4PF', ['L1FastJet', 'L2Relative', 'L3Absolute'], ''))
    process.patJetsAK4PFForMetUnc.getJetMCFlavour = False
    runType1PFMEtUncertainties(process,
                               addToPatDefaultSequence=False,
                               jetCollection="selectedPatJetsAK4PFForMetUnc",
                               electronCollection="selectedPatElectrons",
                               muonCollection="selectedPatMuons",
                               tauCollection="selectedPatTaus",
                               makeType1p2corrPFMEt=True,
                               outputModule=None)
 

    #keep this after all addJetCollections otherwise it will attempt computing them also for stuf with no taginfos
    #Some useful BTAG vars
    process.patJets.userData.userFunctions = cms.vstring(
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.M):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).nTracks):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().flightDistance(0).value):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().flightDistance(0).significance):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.x):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.y):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.z):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).position.x):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).position.y):(0)',
    '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).position.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("secondaryVertexTagInfos"))
    process.patJets.addTagInfos = cms.bool(True)
    #
    ## PU JetID
    process.load("PhysicsTools.PatAlgos.slimming.pileupJetId_cfi")
    process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]

    #VID Electron IDs
    electron_ids = ['RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_50ns_V1_cff',
                    'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_PU20bx25_V0_cff',
                    'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_25ns_cff',
                    'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_startup_cff']
    switchOnVIDElectronIdProducer(process)
    process.egmGsfElectronIDs.physicsObjectSrc = \
        cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.electronIDValueMapProducer.src = \
        cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.electronIDValueMapProducer.ebReducedRecHitCollection = \
        cms.InputTag("reducedEgamma","reducedEBRecHits")
    process.electronIDValueMapProducer.eeReducedRecHitCollection = \
        cms.InputTag("reducedEgamma","reducedEERecHits") 
    process.electronIDValueMapProducer.esReducedRecHitCollection = \
        cms.InputTag("reducedEgamma","reducedESRecHits")
    for idmod in electron_ids:
        setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection)
Exemplo n.º 18
0
    'pfNegativeCombinedMVABJetTags',
    'pfCombinedMVAV2BJetTags'
    #CTagging
    ,
    'pfCombinedCvsLJetTags',
    'pfCombinedCvsBJetTags'
    #ChargeTagging
    ,
    'pfChargeBJetTags'
]

# uncomment the following lines to add ak4PFJets with new b-tags to your PAT output
addJetCollection(process,
                 labelName='AK4PF',
                 jetSource=cms.InputTag('ak4PFJets'),
                 jetCorrections=('AK4PF',
                                 cms.vstring(
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute']), 'Type-2'),
                 btagDiscriminators=btagDiscriminators)
process.patJetsAK4PF.addTagInfos = True

# uncomment the following lines to add ak8PFJetsCHS with new b-tags to your PAT output
addJetCollection(
    process,
    labelName='AK8PFCHS',
    jetSource=cms.InputTag('ak8PFJetsCHS'),
    jetCorrections=('AK8PFchs',
                    cms.vstring(['L1FastJet', 'L2Relative',
                                 'L3Absolute']), 'Type-2'),
    algo='AK',
    rParam=0.8,
Exemplo n.º 19
0
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.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.photonSource = cms.InputTag("reducedEgamma",
                                                   "reducedGedPhotons")
    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('decayModeFinding')> 0.5")
    process.selectedPatPhotons.cut = cms.string("")

    # add CMS top tagger
    from RecoJets.JetProducers.caTopTaggers_cff import caTopTagInfos
    process.caTopTagInfos = caTopTagInfos.clone()
    process.caTopTagInfosPAT = cms.EDProducer(
        "RecoJetDeltaRTagInfoValueMapProducer",
        src=cms.InputTag("ak8PFJetsCHS"),
        matched=cms.InputTag("cmsTopTagPFJetsCHS"),
        matchedTagInfos=cms.InputTag("caTopTagInfos"),
        distMax=cms.double(0.8))

    #add AK8
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
    addJetCollection(
        process,
        labelName='AK8',
        jetSource=cms.InputTag('ak8PFJetsCHS'),
        algo='AK',
        rParam=0.8,
        jetCorrections=('AK8PFchs',
                        cms.vstring(['L1FastJet', 'L2Relative',
                                     'L3Absolute']), 'None'),
        btagInfos=['caTopTagInfosPAT'])
    process.patJetsAK8.userData.userFloats.src = [
    ]  # start with empty list of user floats
    process.selectedPatJetsAK8.cut = cms.string("pt > 100")
    process.patJetGenJetMatchAK8.matched = 'slimmedGenJets'
    ## AK8 groomed masses
    from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop, ak8PFJetsCHSFiltered, ak8PFJetsCHSTrimmed
    process.ak8PFJetsCHSPruned = ak8PFJetsCHSPruned.clone()
    process.ak8PFJetsCHSSoftDrop = ak8PFJetsCHSSoftDrop.clone()
    process.ak8PFJetsCHSTrimmed = ak8PFJetsCHSTrimmed.clone()
    process.ak8PFJetsCHSFiltered = ak8PFJetsCHSFiltered.clone()
    process.load("RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi")
    process.patJetsAK8.userData.userFloats.src += [
        'ak8PFJetsCHSPrunedMass', 'ak8PFJetsCHSSoftDropMass',
        'ak8PFJetsCHSTrimmedMass', 'ak8PFJetsCHSFilteredMass'
    ]

    # Add AK8 top tagging variables
    process.patJetsAK8.tagInfoSources = cms.VInputTag(
        cms.InputTag("caTopTagInfosPAT"))
    process.patJetsAK8.addTagInfos = cms.bool(True)

    # add Njetiness
    process.load('RecoJets.JetProducers.nJettinessAdder_cfi')
    process.NjettinessAK8 = process.Njettiness.clone()
    process.NjettinessAK8.src = cms.InputTag("ak8PFJetsCHS")
    process.NjettinessAK8.cone = cms.double(0.8)
    process.patJetsAK8.userData.userFloats.src += [
        'NjettinessAK8:tau1', 'NjettinessAK8:tau2', 'NjettinessAK8:tau3'
    ]

    #
    from PhysicsTools.PatAlgos.tools.trigTools import switchOnTriggerStandAlone
    switchOnTriggerStandAlone(process, outputModule='')
    process.patTrigger.packTriggerPathNames = cms.bool(True)
    #
    # apply type I/type I + II PFMEt corrections to pat::MET object
    # and estimate systematic uncertainties on MET
    # FIXME: this and the typeI MET should become AK4 once we have the proper JEC?
    from PhysicsTools.PatUtils.tools.runType1PFMEtUncertainties import runType1PFMEtUncertainties
    addJetCollection(process,
                     postfix="ForMetUnc",
                     labelName='AK4PF',
                     jetSource=cms.InputTag('ak4PFJets'),
                     jetCorrections=('AK4PF',
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute'], ''))
    process.patJetsAK4PFForMetUnc.getJetMCFlavour = False
    runType1PFMEtUncertainties(process,
                               addToPatDefaultSequence=False,
                               jetCollection="selectedPatJetsAK4PFForMetUnc",
                               electronCollection="selectedPatElectrons",
                               muonCollection="selectedPatMuons",
                               tauCollection="selectedPatTaus",
                               makeType1p2corrPFMEt=True,
                               outputModule=None)

    #keep this after all addJetCollections otherwise it will attempt computing them also for stuf with no taginfos
    #Some useful BTAG vars
    process.patJets.userData.userFunctions = cms.vstring(
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.M):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).nTracks):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().flightDistance(0).value):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().flightDistance(0).significance):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.x):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.y):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).p4.z):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).position.x):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).position.y):(0)',
        '?(tagInfoSecondaryVertex().nVertices()>0)?(tagInfoSecondaryVertex().secondaryVertex(0).position.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("secondaryVertexTagInfos"))
    process.patJets.addTagInfos = cms.bool(True)
    #
    ## PU JetID
    process.load("PhysicsTools.PatAlgos.slimming.pileupJetId_cfi")
    process.patJets.userData.userFloats.src = [
        cms.InputTag("pileupJetId:fullDiscriminant"),
    ]

    #VID Electron IDs
    electron_ids = [
        'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_50ns_V1_cff',
        'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_CSA14_PU20bx25_V0_cff',
        'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_25ns_cff',
        'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV50_CSA14_startup_cff'
    ]
    switchOnVIDElectronIdProducer(process)
    process.egmGsfElectronIDs.physicsObjectSrc = \
        cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.electronIDValueMapProducer.src = \
        cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.electronIDValueMapProducer.ebReducedRecHitCollection = \
        cms.InputTag("reducedEgamma","reducedEBRecHits")
    process.electronIDValueMapProducer.eeReducedRecHitCollection = \
        cms.InputTag("reducedEgamma","reducedEERecHits")
    process.electronIDValueMapProducer.esReducedRecHitCollection = \
        cms.InputTag("reducedEgamma","reducedESRecHits")
    for idmod in electron_ids:
        setupAllVIDIdsInModule(process, idmod, setupVIDElectronSelection)
Exemplo n.º 20
0
#addMETCollection(process, labelName='patMETCalo', metSource='met')
addMETCollection(process, labelName='patMETPF', metSource='pfMetT1')
#addMETCollection(process, labelName='patMETTC', metSource='tcMet') # FIXME: removed from RECO/AOD; needs functionality to add to processing

## uncomment the following line to add different jet collections
## to the event content
from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

## uncomment the following lines to add ak4PFJetsCHS to your PAT output
labelAK4PFCHS = 'AK4PFCHS'
postfixAK4PFCHS = 'Copy'
addJetCollection(process,
                 postfix=postfixAK4PFCHS,
                 labelName=labelAK4PFCHS,
                 jetSource=cms.InputTag('ak4PFJetsCHS'),
                 jetCorrections=('AK4PFchs',
                                 cms.vstring(
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute']), 'Type-2'))
process.out.outputCommands.append('drop *_selectedPatJets%s%s_caloTowers_*' %
                                  (labelAK4PFCHS, postfixAK4PFCHS))

# uncomment the following lines to add ak4PFJets to your PAT output
switchJetCollection(
    process,
    jetSource=cms.InputTag('ak4PFJets'),
    jetCorrections=('AK4PF',
                    cms.vstring(['L1FastJet', 'L2Relative',
                                 'L3Absolute']), 'Type-1'),
    btagDiscriminators=[
        'jetBProbabilityBJetTags', 'jetProbabilityBJetTags',
Exemplo n.º 21
0
def configurePatTuple(process, isMC=True, **kwargs):
    '''
    Core function for PATTuple production
    '''
    #fix argparser output
    isMC = bool(isMC)

    ########################
    ##                    ##
    ##  PATTuple content  ##
    ##                    ##
    ########################
    # Stuff we always keep
    output_commands = [
        '*_addPileupInfo_*_*',
        'edmMergeableCounter_*_*_*',
        '*_lumiProducer_*_*',
        '*_particleFlow_*_*',
        '*_offlineBeamSpot_*_*',
        '*_generalTracks_*_*',
        '*_electronGsfTracks_*_*',
        '*_gsfElectrons_*_*',
        '*_gsfElectronCores_*_*',
        '*_offlinePrimaryVertices*_*_*',
        '*_ak5GenJets_*_*',
        '*_hltTriggerSummaryAOD_*_*',
        'edmTriggerResults_TriggerResults_*_%s' % process.name_(),
        '*_MEtoEDMConverter*_*_%s' % process.name_(),
        'LHEEventProduct_*_*_*',
        'GenEventInfoProduct_generator_*_*',
        '*_kt6PFJetsForRhoComputationVoronoi_rho_*',
        '*_kt6PFJetsForIso_rho_*',
        '*_kt6PFJets_rho_*',
        '*_kt6PFJetsHZGPho_rho_*',
        '*_kt6PFJetsCentralHZGEle_rho_*',
        '*_kt6PFJetsCentralHZGMu_rho_*',
        '*_kt6PFJetsCentralNeutralHZGMu_rho_*',
        '*_kt6PFJetsCentral_rho_*',
        '*_kt6PFJetsCentralNeutral_rho_*',  # for zz muons
        '*_photonCore_*_*',
        '*_boostedFsrPhotons_*_*',
        # for Zmumu -> embedded samples
        # https://twiki.cern.ch/twiki/bin/view/CMS/MuonTauReplacementRecHit
        '*_generalTracksORG_*_EmbeddedRECO',
        '*_electronGsfTracksORG_*_EmbeddedRECO',
        'double_TauSpinnerReco_TauSpinnerWT_EmbeddedSPIN',
        'double_ZmumuEvtSelEffCorrWeightProducer_weight_EmbeddedRECO',
        'double_muonRadiationCorrWeightProducer_weight_EmbeddedRECO',
        'GenFilterInfo_generator_minVisPtFilter_EmbeddedRECO',
    ]
    # Define our patTuple production sequence
    process.tuplize = cms.Sequence()
    # Only keep interesting genParticles
    process.load("FinalStateAnalysis.RecoTools.genParticleTrimmer_cfi")
    process.genParticles = process.prunedGenParticles.clone()
    if isMC:
        #process.tuplize += process.genParticles
        #output_commands.append('*_genParticles_*_%s' % process.name_())
        output_commands.append('*_genParticles_*_*')

    output_commands.append('*_tauGenJetsSelectorAllHadrons_*_*')
    output_commands.append('*_tauGenJets_*_*')
    output_commands.append('*_ak5GenJets_*_*')

    ########################
    ##                    ##
    ##        PAT         ##
    ##                    ##
    ########################

    # Run pat default sequence
    process.load("PhysicsTools.PatAlgos.patSequences_cff")

    # Embed PF Isolation in electrons & muons
    pfTools.usePFIso(process)
    # Setup H2Tau custom iso definitions
    setup_h2tau_iso(process)
    # Setup hZg custom iso definitions
    add_hZg_iso_needs(process)

    # Now run PAT
    process.tuplize += process.patDefaultSequence

    # Add FSR photons for ZZ analysis
    process.load("FinalStateAnalysis.PatTools.fsrPhotons_cff")
    process.tuplize += process.fsrPhotonSequence

    ########################
    ##        GEN         ##
    ########################

    # Disable gen match embedding - we keep it in the ntuple
    process.patMuons.embedGenMatch = False
    process.patElectrons.embedGenMatch = False
    process.patTaus.embedGenMatch = False
    process.patTaus.embedGenJetMatch = False
    process.patPhotons.embedGenMatch = False
    if not isMC:
        coreTools.runOnData(process)

    ########################
    ##       MUONS        ##
    ########################

    # Unembed junk
    process.patMuons.embedCaloMETMuonCorrs = False
    process.patMuons.embedTcMETMuonCorrs = False
    process.patMuons.embedTrack = True
    process.patMuons.pvSrc = cms.InputTag("selectedPrimaryVertex")

    process.load("FinalStateAnalysis.PatTools.patMuonProduction_cff")
    final_muon_collection = chain_sequence(process.customizeMuonSequence,
                                           "selectedPatMuons")
    process.customizeMuonSequence.insert(0, process.selectedPatMuons)
    process.patDefaultSequence.replace(process.selectedPatMuons,
                                       process.customizeMuonSequence)
    process.cleanPatMuons.src = final_muon_collection
    process.patMuonRochesterCorrectionEmbedder.isMC = cms.bool(bool(isMC))

    ########################
    ##        TAUS        ##
    ########################

    # Use HPS taus
    tautools.switchToPFTauHPS(
        process)  #this NEEDS a sequence called patDefaultSequence
    # Disable tau IsoDeposits
    process.patDefaultSequence.remove(process.patPFTauIsolation)
    process.patTaus.isoDeposits = cms.PSet()
    process.patTaus.userIsolation = cms.PSet()

    process.load("FinalStateAnalysis.PatTools.patTauProduction_cff")
    # Require all taus to pass decay mode finding and have high PT
    process.patTauGarbageRemoval.cut = cms.string(
        "pt > 17 && abs(eta) < 2.5 && tauID('decayModeFindingNewDMs')")
    final_tau_collection = chain_sequence(process.customizeTauSequence,
                                          "selectedPatTaus")
    # Inject into the pat sequence
    process.customizeTauSequence.insert(0, process.selectedPatTaus)
    process.patDefaultSequence.replace(process.selectedPatTaus,
                                       process.customizeTauSequence)
    process.cleanPatTaus.src = final_tau_collection
    # Remove muons and electrons
    process.cleanPatTaus.checkOverlaps.muons.requireNoOverlaps = False
    process.cleanPatTaus.checkOverlaps.electrons.requireNoOverlaps = False
    # Cuts already applied by the garbage removal
    process.cleanPatTaus.preselection = ''
    process.cleanPatTaus.finalCut = ''

    ########################
    ##     ELECTRONS      ##
    ########################

    # Use POG recommendations for (these) electron Isos
    process.elPFIsoValueGamma04PFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.08)')
    process.elPFIsoValueGamma04NoPFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.08)')
    process.elPFIsoValueCharged04PFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)')
    process.elPFIsoValueCharged04NoPFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)')

    # Do extra electron ID
    process.load("FinalStateAnalysis.PatTools.electrons.electronID_cff")
    if cmssw_major_version() == 4:
        process.patDefaultSequence.replace(
            process.patElectrons,
            process.recoElectronID42X + process.patElectrons)
        process.patElectrons.electronIDSources = process.electronIDSources42X
    else:
        process.patDefaultSequence.replace(
            process.patElectrons,
            process.recoElectronID5YX + process.patElectrons)
        process.patElectrons.electronIDSources = process.electronIDSources5YX

    process.electronMatch.checkCharge = cms.bool(False)
    process.patElectrons.embedTrack = False
    process.patElectrons.embedPFCandidate = False
    process.patElectrons.embedGsfElectronCore = False
    process.patElectrons.embedSuperCluster = True

    # Produce the electron collections
    process.load("FinalStateAnalysis.PatTools.patElectronProduction_cff")

    # Electron Energy Regression and Calibrations
    process.load(
        "EgammaAnalysis.ElectronTools.electronRegressionEnergyProducer_cfi")
    process.load("EgammaAnalysis.ElectronTools.calibratedPatElectrons_cfi")

    #setup the energy regression for the specific dataset
    if kwargs['eleReg']:
        print "-- Applying Electron Regression and Calibration --"

        process.customizeElectronSequence += process.eleRegressionEnergy
        process.customizeElectronSequence += process.calibratedPatElectrons

        process.eleRegressionEnergy.energyRegressionType = cms.uint32(2)
        process.calibratedPatElectrons.correctionsType = cms.int32(2)

        if isMC:
            process.calibratedPatElectrons.inputDataset = cms.string(
                "Summer12_LegacyPaper")
        else:
            process.calibratedPatElectrons.inputDataset = cms.string(
                "22Jan2013ReReco")

        process.calibratedPatElectrons.combinationType = cms.int32(3)
        process.calibratedPatElectrons.lumiRatio = cms.double(1.0)
        process.calibratedPatElectrons.synchronization = cms.bool(True)
        process.calibratedPatElectrons.isMC = cms.bool(isMC == 1)
        process.calibratedPatElectrons.verbose = cms.bool(False)

    final_electron_collection = chain_sequence(
        process.customizeElectronSequence,
        "selectedPatElectrons",
        # Some of the EGamma modules have non-standard src InputTags,
        # specify them here.
        ("src", "inputPatElectronsTag", "inputElectronsTag"))

    #process.tuplize += process.customizeElectronSequence #why do we need this?
    process.customizeElectronSequence.insert(0, process.selectedPatElectrons)
    process.patDefaultSequence.replace(process.selectedPatElectrons,
                                       process.customizeElectronSequence)
    # We have to do the pat Jets before the pat electrons since we embed them
    process.customizeElectronSequence.insert(0, process.selectedPatJets)

    # Define cleanPatElectrons input collection
    process.cleanPatElectrons.src = final_electron_collection

    # Define the default lepton cleaning
    process.cleanPatElectrons.preselection = cms.string('pt > 5')
    process.cleanPatElectrons.checkOverlaps.muons.requireNoOverlaps = False
    # Make sure we don't kill any good taus by calling them electrons
    # Note that we don't actually remove these overlaps.
    process.cleanPatElectrons.checkOverlaps.taus = cms.PSet(
        src=final_tau_collection,
        algorithm=cms.string("byDeltaR"),
        preselection=cms.string(
            "tauID('decayModeFinding') > 0.5 &&"
            "tauID('byLooseCombinedIsolationDeltaBetaCorr') > 0.5 &&"
            "tauID('againstElectronLoose') > 0.5 && "
            "pt > 10"),
        deltaR=cms.double(0.1),
        checkRecoComponents=cms.bool(False),
        pairCut=cms.string(""),
        requireNoOverlaps=cms.bool(False),
    )

    ########################
    ##        JETS        ##
    ########################

    # Use PFJets and turn on JEC
    jec = ['L1FastJet', 'L2Relative', 'L3Absolute']
    # If we are running on data (not MC), or embedded sample,
    # apply the MC-DATA residual correction.
    if not isMC or kwargs['embedded']:
        jec.extend(['L2L3Residual'])

    # tmp
    # define the b-tag squences for offline reconstruction
    process.load("RecoBTag.SecondaryVertex.secondaryVertex_cff")
    process.load("RecoBTau.JetTagComputer.combinedMVA_cff")
    process.load('RecoVertex/AdaptiveVertexFinder/inclusiveVertexing_cff')
    process.load('RecoBTag/SecondaryVertex/bToCharmDecayVertexMerger_cfi')
    #process.load("PhysicsTools.PatAlgos.patSequences_cff")

    # Define options for BTagging - these are release dependent.
    btag_options = {'doBTagging': True}
    if cmssw_major_version() == 5:
        btag_options['btagInfo'] = [
            'impactParameterTagInfos', 'secondaryVertexTagInfos',
            'softMuonTagInfos', 'secondaryVertexNegativeTagInfos',
            'inclusiveSecondaryVertexFinderFilteredTagInfos'
        ]
        btag_options['btagdiscriminators'] = [
            'trackCountingHighEffBJetTags',
            'trackCountingHighPurBJetTags',
            'simpleSecondaryVertexHighEffBJetTags',
            'simpleSecondaryVertexHighPurBJetTags',
            'simpleInclusiveSecondaryVertexHighEffBJetTags',
            'simpleInclusiveSecondaryVertexHighPurBJetTags',
            'combinedSecondaryVertexMVABJetTags',
            'combinedSecondaryVertexBJetTags',
            'jetBProbabilityBJetTags',
            'jetProbabilityBJetTags',
        ]

    #Avoid embedding
    process.patJets.embedPFCandidates = True
    process.patJets.embedCaloTowers = False
    process.patJets.embedGenJetMatch = True
    process.patJets.addAssociatedTracks = True
    process.patJets.embedGenPartonMatch = True

    # Add AK5chs PFJets
    jettools.addJetCollection(process,
                              cms.InputTag('ak5PFchsJets'),
                              algoLabel="AK5",
                              typeLabel="PFchs",
                              doJTA=True,
                              jetCorrLabel=('AK5PFchs', jec),
                              doType1MET=False,
                              doL1Cleaning=False,
                              doL1Counters=False,
                              genJetCollection=cms.InputTag('ak5GenJets'),
                              doJetID=True,
                              **btag_options)

    # Use AK5 PFJets
    jettools.switchJetCollection(
        process,
        cms.InputTag('ak5PFJets'),
        doJTA=True,
        jetCorrLabel=('AK5PF', jec),
        #jetCorrLabel = None,
        doType1MET=False,
        doJetID=True,
        genJetCollection=cms.InputTag("ak5GenJets"),
        **btag_options)

    # Customize/embed all our sequences
    process.load("FinalStateAnalysis.PatTools.patJetProduction_cff")
    helpers.cloneProcessingSnippet(process, process.customizeJetSequence,
                                   'AK5PFchs')
    process.patJetGarbageRemoval.cut = 'pt > 12'
    final_jet_collection = chain_sequence(process.customizeJetSequence,
                                          "patJets")
    process.customizeJetSequence.insert(0, process.patJets)
    # Make it a "complete" sequence
    process.customizeJetSequence += process.selectedPatJets
    #    process.customizeJetSequence += process.btagging
    # We can't mess up the selected pat jets because the taus use them.
    process.selectedPatJets.src = final_jet_collection
    process.patDefaultSequence.replace(process.patJets,
                                       process.customizeJetSequence)

    process.customizeJetSequenceAK5PFchs.remove(process.patJetsPUIDAK5PFchs)
    process.customizeJetSequenceAK5PFchs.remove(
        process.pileupJetIdProducerAK5PFchs)
    process.patJetGarbageRemovalAK5PFchs.cut = 'pt > 20'
    process.patJetCorrFactorsAK5PFchs.payload = cms.string('AK5PFchs')
    final_jetchs_collection = chain_sequence(
        process.customizeJetSequenceAK5PFchs, "patJetsAK5PFchs")
    process.customizeJetSequenceAK5PFchs.insert(0, process.patJetsAK5PFchs)
    # Make it a "complete" sequence
    process.customizeJetSequenceAK5PFchs += process.selectedPatJetsAK5PFchs
    # We can't mess up the selected pat jets because the taus use them.
    process.selectedPatJetsAK5PFchs.src = final_jetchs_collection
    process.selectedPatJetsAK5chsPF = process.selectedPatJetsAK5PFchs.clone(
    )  #that's what we keep
    process.customizeJetSequenceAK5PFchs += process.selectedPatJetsAK5chsPF
    process.patDefaultSequence.replace(process.patJetsAK5PFchs,
                                       process.customizeJetSequenceAK5PFchs)

    output_commands.append('*_selectedPatJets_*_*')
    output_commands.append('*_selectedPatJetsAK5chsPF_*_*')
    output_commands.append('*SecondaryVertexTagInfo*_*_*_*')
    output_commands.append('*TrackIPTagInfo*_*_*_*')
    output_commands.append('*SoftLeptonTagInfo*_*_*_*')
    output_commands.append('*_ak5PFJets_*_*')
    output_commands.append('*_ak5PFchsJets_*_*')

    ########################
    ##        MET         ##
    ########################

    # Use PFMEt
    mettools.addPfMET(process)

    # We cut out a lot of the junky taus and jets - but we need these
    # to correctly apply the MET uncertainties.  So, let's make a
    # non-cleaned version of the jet and tau sequence.
    process.jetsForMetSyst = helpers.cloneProcessingSnippet(
        process, process.customizeJetSequence, 'ForMETSyst')
    process.tausForMetSyst = helpers.cloneProcessingSnippet(
        process, process.customizeTauSequence, 'ForMETSyst')
    # Don't apply any cut for these
    process.patTauGarbageRemovalForMETSyst.cut = ''
    process.patJetGarbageRemovalForMETSyst.cut = ''
    process.tuplize += process.jetsForMetSyst
    process.tuplize += process.tausForMetSyst
    # We have to make our clone of cleanPatTaus separately, since e/mu
    # cleaning is applied - therefore it isn't in the customizeTausSequence.
    process.cleanPatTausForMETSyst = process.cleanPatTaus.clone(
        src=cms.InputTag(process.cleanPatTaus.src.value() + "ForMETSyst"))
    process.cleanPatTausForMETSyst.preselection = ''
    process.cleanPatTausForMETSyst.finalCut = ''
    process.patTausEmbedJetInfoForMETSyst.jetSrc = \
        final_jet_collection.value() + "ForMETSyst"
    process.tuplize += process.cleanPatTausForMETSyst

    # Setup MET production
    process.load("FinalStateAnalysis.PatTools.patMETProduction_cff")
    # The MET systematics depend on all other systematics
    process.systematicsMET.tauSrc = cms.InputTag("cleanPatTausForMETSyst")
    process.systematicsMET.muonSrc = cms.InputTag("cleanPatMuons")
    process.systematicsMET.electronSrc = cms.InputTag("cleanPatElectrons")

    final_met_collection = chain_sequence(process.customizeMETSequence,
                                          "patMETsPF")
    process.tuplize += process.customizeMETSequence
    process.patMETsPF.addGenMET = bool(isMC)
    output_commands.append('*_%s_*_*' % final_met_collection.value())

    # Make a version with the MVA MET reconstruction method
    process.load("FinalStateAnalysis.PatTools.met.mvaMetOnPatTuple_cff")
    process.tuplize += process.pfMEtMVAsequence
    mva_met_sequence = helpers.cloneProcessingSnippet(
        process, process.customizeMETSequence, "MVA")
    final_mvamet_collection = chain_sequence(mva_met_sequence, "patMEtMVA")
    process.tuplize += mva_met_sequence
    output_commands.append('*_%s_*_*' % final_mvamet_collection.value())

    # Keep all the data formats needed for the systematics
    output_commands.append('recoLeafCandidates_*_*_%s' % process.name_())
    # We can drop to jet and tau MET specific products. They were only used for
    # computation of the MET numbers.
    output_commands.append('drop recoLeafCandidates_*ForMETSyst_*_%s' %
                           process.name_())

    ########################
    ##      PHOTONS       ##
    ########################

    #alter the photon matching to accept various fakes
    # and sort matches by d-pt-rel
    if isMC:
        process.photonMatch = cms.EDProducer(
            "MCMatcherByPt",
            src=cms.InputTag("photons"),
            maxDPtRel=cms.double(100.0),
            mcPdgId=cms.vint32(),
            mcStatus=cms.vint32(1),
            resolveByMatchQuality=cms.bool(False),
            maxDeltaR=cms.double(0.3),
            checkCharge=cms.bool(False),
            resolveAmbiguities=cms.bool(True),
            matched=cms.InputTag("genParticles"))

    # Setup pat::Photon Production
    process.load("FinalStateAnalysis.PatTools.patPhotonProduction_cff")
    final_photon_collection = chain_sequence(process.customizePhotonSequence,
                                             "selectedPatPhotons")
    #setup PHOSPHOR for a specific dataset
    if cmssw_major_version() == 4:  # for now 2011 = CMSSW42X
        process.patPhotonPHOSPHOREmbedder.year = cms.uint32(2011)
    else:  # 2012 is 5YX
        process.patPhotonPHOSPHOREmbedder.year = cms.uint32(2012)
    process.patPhotonPHOSPHOREmbedder.isMC = cms.bool(bool(isMC))
    #inject photons into pat sequence
    process.customizePhotonSequence.insert(0, process.selectedPatPhotons)
    process.patDefaultSequence.replace(process.selectedPatPhotons,
                                       process.customizePhotonSequence)
    process.cleanPatPhotons.src = final_photon_collection

    ########################
    ##      TRIGGER       ##
    ########################

    trigtools.switchOnTrigger(process)

    #configure the PAT trigger
    if kwargs['HLTprocess']:
        process.patTrigger.processName = cms.string(kwargs['HLTprocess'])
        process.patTriggerEvent.processName = cms.string(kwargs['HLTprocess'])

    ########################
    ##   --------------   ##
    ########################

    output_commands.append('*_cleanPatTaus_*_*')
    output_commands.append('*_cleanPatElectrons_*_*')
    output_commands.append('*_cleanPatMuons_*_*')
    output_commands.append('*_cleanPatPhotons_*_*')

    ########################
    ##                    ##
    ##        FSA         ##
    ##                    ##
    ########################

    # Now build the PATFinalStateLS object, which holds LumiSection info.
    process.load(
        "FinalStateAnalysis.PatTools.finalStates.patFinalStateLSProducer_cfi")
    process.tuplize += process.finalStateLS
    output_commands.append('*_finalStateLS_*_*')
    if isMC:
        process.finalStateLS.xSec = kwargs['xSec']

    # Tell the framework to shut up!
    process.load("FWCore.MessageLogger.MessageLogger_cfi")
    process.MessageLogger.cerr.FwkReport.reportEvery = 1000

    # Which collections are used to build the final states
    fs_daughter_inputs = {
        'electrons': 'cleanPatElectrons',
        'muons': 'cleanPatMuons',
        'taus': 'cleanPatTaus',
        'photons': 'cleanPatPhotons',
        'jets': 'selectedPatJets',
        'pfmet': final_met_collection,
        'mvamet': final_mvamet_collection,
    }

    # Setup all the PATFinalState objects
    produce_final_states(process,
                         fs_daughter_inputs,
                         output_commands,
                         process.tuplize,
                         kwargs['puTag'],
                         zzMode=kwargs.get('zzMode', False))

    return process.tuplize, output_commands
Exemplo n.º 22
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

    # Configure the RECO jets
    from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJetsPuppi
    from RecoJets.JetProducers.ak8PFJets_cfi import ak8PFJetsPuppi, ak8PFJetsPuppiSoftDrop, ak8PFJetsPuppiConstituents, ak8PFJetsCHSConstituents
    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)

    #add AK8 CHS
    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")

    ## 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'
    ]

    # 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'],
        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
    )

    # 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)
    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'
            ]

    # 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=(
            [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)

    ## 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'
    ]

    # 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")', 'pt', 'eta',
                'phi', 'mass'
            ]),
            valueLabels=cms.vstring([
                'ak8PFJetsCHSPrunedMass', 'ak8PFJetsCHSSoftDropMass',
                'NjettinessAK8CHSTau1', 'NjettinessAK8CHSTau2',
                'NjettinessAK8CHSTau3', 'pt', 'eta', 'phi', 'mass'
            ])), 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, 'pt'),
        cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'eta'),
        cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'phi'),
        cms.InputTag('ak8PFJetsCHSValueMap' + postfix, 'mass'),
    ]

    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"
Exemplo n.º 23
0
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)
    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)
    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",
                                        jetColl="selectedPatJets")
    
    #caloMET computation
    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
    addMETCollection(process,
                     labelName = "patCaloMet",
                     metSource = "caloMetM"
                     )

    #noHF pfMET =========
    process.noHFCands = cms.EDFilter("GenericPFCandidateSelector",
                                     src=cms.InputTag("particleFlow"),
                                     cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
                                     )
    runMetCorAndUncForMiniAODProduction(process,
                                        pfCandColl=cms.InputTag("noHFCands"),
                                        recomputeMET=True, #needed for HF removal
                                        postfix="NoHF"
                                        )
    process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
    process.slimmedMETsNoHF = process.slimmedMETs.clone()
    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
    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)
    #
    ## PU JetID
    process.load("RecoJets.JetProducers.PileupJetID_cfi")
    process.patJets.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]

    ## 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) )
    process.patJets.userData.userFloats.src += [ cms.InputTag("caloJetMap:pt"), cms.InputTag("caloJetMap:emEnergyFraction") ]

    #EGM object modifications
    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_V1_cff',
                    'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV60_cff',
                    'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_nonTrig_V1_cff']
    switchOnVIDElectronIdProducer(process,DataFormat.MiniAOD)
    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)

    #VID Photon IDs
    photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_PHYS14_PU20bx25_V2p1_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) 
    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)
    
    # Adding puppi jets
    process.load('CommonTools.PileupAlgos.Puppi_cff')
    process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
    process.ak4PFJetsPuppi.doAreaFastjet = True # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
    #process.puppi.candName = cms.InputTag('packedPFCandidates')
    #process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')
    # kind of ugly, is there a better way to do this?
    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 )
    )
    process.pfLeptonsPUPPET = cms.EDFilter("PdgIdCandViewSelector",
        src = cms.InputTag("particleFlow"),
        pdgId = cms.vint32(-11,11,-13,13),
    )
    process.puppiNoLep = process.puppi.clone()
    process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI') 

    from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
    process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer("JetTracksAssociatorAtVertex",
        j2tParametersVX,
        jets = cms.InputTag("ak4PFJetsPuppi")
    )
    process.patJetPuppiCharge = cms.EDProducer("JetChargeProducer",
        src = cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
        var = cms.string('Pt'),
        exp = cms.double(1.0)
    )

    addJetCollection(process, postfix   = "", labelName = 'Puppi', jetSource = cms.InputTag('ak4PFJetsPuppi'),
                    jetCorrections = ('AK4PFchs', ['L2Relative', 'L3Absolute'], ''),
                    algo= 'AK', rParam = 0.4, btagDiscriminators = map(lambda x: x.value() ,process.patJets.discriminatorSources)
                    )
    
    process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'
    
    process.patJetsPuppi.userData.userFloats.src = cms.VInputTag(cms.InputTag(""))
    process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")

    process.selectedPatJetsPuppi.cut = cms.string("pt > 20")

    process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi')
    process.slimmedJetsPuppi = process.slimmedJets.clone()
    process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi")    
    process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag("packedPFCandidates")

    ## puppi met
    process.load('RecoMET.METProducers.PFMET_cfi')
    process.puppiForMET = cms.EDProducer("CandViewMerger",
        src = cms.VInputTag( "pfLeptonsPUPPET", "puppiNoLep")
    ) 
    process.pfMetPuppi = process.pfMet.clone()
    process.pfMetPuppi.src = cms.InputTag("puppiForMET")
    process.pfMetPuppi.alias = cms.string('pfMetPuppi')
    # type1 correction, from puppi jets
    process.corrPfMetType1Puppi = process.corrPfMetType1.clone(
        src = 'ak4PFJetsPuppi',
        jetCorrLabel = 'ak4PFCHSL2L3Corrector',
    )
    del process.corrPfMetType1Puppi.offsetCorrLabel # no L1 for PUPPI jets
    process.pfMetT1Puppi = process.pfMetT1.clone(
        src = 'pfMetPuppi',
        srcCorrections = [ cms.InputTag("corrPfMetType1Puppi","type1") ]
    )

    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
    addMETCollection(process, labelName='patMETPuppi',   metSource='pfMetT1Puppi') # T1
    addMETCollection(process, labelName='patPFMetPuppi', metSource='pfMetPuppi')   # RAW

    process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
    process.slimmedMETsPuppi = process.slimmedMETs.clone()
    process.slimmedMETsPuppi.src = cms.InputTag("patMETPuppi")
    process.slimmedMETsPuppi.rawVariation   = cms.InputTag("patPFMetPuppi") # only central value
    # only central values for puppi met
    del process.slimmedMETsPuppi.t01Variation
    del process.slimmedMETsPuppi.t1SmearedVarsAndUncs
    del process.slimmedMETsPuppi.tXYUncForRaw
    del process.slimmedMETsPuppi.tXYUncForT1
    del process.slimmedMETsPuppi.tXYUncForT01
    del process.slimmedMETsPuppi.tXYUncForT1Smear
    del process.slimmedMETsPuppi.tXYUncForT01Smear
    del process.slimmedMETsPuppi.caloMET
Exemplo n.º 24
0
addJetCollection(
    process,
    labelName='AK5PF',
    jetSource=cms.InputTag('ak5PFJets'),
    jetCorrections=('AK5PF',
                    cms.vstring(['L1FastJet', 'L2Relative',
                                 'L3Absolute']), 'Type-2'),
    btagDiscriminators=[
        'jetBProbabilityBJetTags',
        'jetProbabilityBJetTags',
        'trackCountingHighPurBJetTags',
        'trackCountingHighEffBJetTags',
        'negativeOnlyJetBProbabilityJetTags',
        'negativeOnlyJetProbabilityJetTags',
        'negativeTrackCountingHighEffJetTags',
        'negativeTrackCountingHighPurJetTags',
        'positiveOnlyJetBProbabilityJetTags',
        'positiveOnlyJetProbabilityJetTags',
        'simpleSecondaryVertexHighEffBJetTags',
        'simpleSecondaryVertexHighPurBJetTags',
        'simpleSecondaryVertexNegativeHighEffBJetTags',
        'simpleSecondaryVertexNegativeHighPurBJetTags',
        'combinedSecondaryVertexBJetTags',
        'combinedSecondaryVertexPositiveBJetTags'
        #,'combinedSecondaryVertexV1BJetTags'
        #,'combinedSecondaryVertexV1PositiveBJetTags'
        ,
        'combinedSecondaryVertexMVABJetTags',
        'combinedSecondaryVertexNegativeBJetTags'
        #,'combinedSecondaryVertexV1NegativeBJetTags'
        ,
        'softPFMuonBJetTags',
        'softPFMuonByPtBJetTags',
        'softPFMuonByIP3dBJetTags',
        'softPFMuonByIP2dBJetTags',
        'positiveSoftPFMuonBJetTags',
        'positiveSoftPFMuonByPtBJetTags',
        'positiveSoftPFMuonByIP3dBJetTags',
        'positiveSoftPFMuonByIP2dBJetTags',
        'negativeSoftPFMuonBJetTags',
        'negativeSoftPFMuonByPtBJetTags',
        'negativeSoftPFMuonByIP3dBJetTags',
        'negativeSoftPFMuonByIP2dBJetTags',
        'softPFElectronBJetTags',
        'softPFElectronByPtBJetTags',
        'softPFElectronByIP3dBJetTags',
        'softPFElectronByIP2dBJetTags',
        'positiveSoftPFElectronBJetTags',
        'positiveSoftPFElectronByPtBJetTags',
        'positiveSoftPFElectronByIP3dBJetTags',
        'positiveSoftPFElectronByIP2dBJetTags',
        'negativeSoftPFElectronBJetTags',
        'negativeSoftPFElectronByPtBJetTags',
        'negativeSoftPFElectronByIP3dBJetTags',
        'negativeSoftPFElectronByIP2dBJetTags',
        'simpleInclusiveSecondaryVertexHighEffBJetTags',
        'simpleInclusiveSecondaryVertexHighPurBJetTags',
        'doubleSecondaryVertexHighEffBJetTags',
        'combinedInclusiveSecondaryVertexBJetTags',
        'combinedInclusiveSecondaryVertexPositiveBJetTags'
        #,'combinedMVABJetTags'
        ,
        'positiveCombinedMVABJetTags',
        'negativeCombinedMVABJetTags'
        #,'combinedSecondaryVertexSoftPFLeptonV1BJetTags'
        #,'positiveCombinedSecondaryVertexSoftPFLeptonV1BJetTags'
        #,'negativeCombinedSecondaryVertexSoftPFLeptonV1BJetTags'
    ],
)
      jecLevelsCalo.insert( 0, 'L1Offset' )
      jecLevelsCalo.remove( 'L1FastJet' )
      process.patJetCorrFactors.levels = jecLevelsCalo
      #process.patJetCorrFactors.useRho = False # FIXME: does not apply
  if usePFJets:
    if useL1FastJet:
      process.ak5PFJets = ak5PFJets.clone( doAreaFastjet = True )
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
    from PhysicsTools.PatAlgos.tools.metTools import addPfMET
    addJetCollection( process
                    , cms.InputTag( jetAlgo.lower() + pfSuffix + 'Jets' )
                    , jetAlgo
                    , pfSuffix
                    , doJTA            = True
                    , doBTagging       = True
                    , jetCorrLabel     = ( jecSetAddPF, jecLevels )
                    , doType1MET       = False
                    , doL1Cleaning     = False
                    , doL1Counters     = True
                    , genJetCollection = cms.InputTag( jetAlgo.lower() + 'GenJets' )
                    , doJetID          = True
                    )
    addPfMET( process
            , jetAlgo + pfSuffix
            )
  #removeSpecificPATObjects( process
  #                        , names = [ 'Photons', 'Taus' ]
  #                        ) # includes 'removeCleaning'
  
if runPF2PAT:
  if not runOnMC:
Exemplo n.º 26
0
    'combinedSecondaryVertexBJetTags',
    'combinedSecondaryVertexPositiveBJetTags',
    'combinedSecondaryVertexV1BJetTags',
    'combinedSecondaryVertexSoftPFLeptonV1BJetTags',
    'combinedSecondaryVertexMVABJetTags',
    'combinedInclusiveSecondaryVertexBJetTags',
    'combinedInclusiveSecondaryVertexPositiveBJetTags'
]

if doAK5:
    addJetCollection(
        process,
        labelName='AK5PF',
        postfix=postfix,
        jetSource=cms.InputTag('ak5PFJets'),
        algo='AK5',
        jetCorrections=('AK5PF', inputJetCorrLabel, ''),
        #btagDiscriminators = btagDiscriminators,
        #btagInfos = btagInfos,
        #jetTrackAssociation = True,
        outputModules=outputModules,
    )

if doAK4:
    #addJetCollection(process,
    #    labelName = 'AK4PF',
    #    postfix = postfix,
    #    jetSource = cms.InputTag('ak4PFJets'),
    #    algo = 'AK4',
    #    jetCorrections = ('AK5PF', inputJetCorrLabel, ''),
    #    btagDiscriminators = btagDiscriminators,
    #    btagInfos = btagInfos,
Exemplo n.º 27
0
def addFlashggPuppiJets(process,
                        vertexIndex = 0,
                        doQGTagging = True,
                        label       ='',
                        useLocalJEC = True,
                        dbfile      = 'flashgg/MetaData/data/PuppiJEC/PY8_RunIISpring15DR74_bx50_MC.db',
                        debug       = False):
    
  from CommonTools.PileupAlgos.flashggPuppi_cff          import flashggPuppi 
  from RecoJets.JetProducers.ak4PFJets_cfi               import ak4PFJets

  # fill the puppi parameters
  setattr(process, 'flashggPuppi' + label,
          flashggPuppi.clone( candName              = cms.InputTag('packedPFCandidates'),
                              vertexName            = cms.InputTag('offlineSlimmedPrimaryVertices'),
                              diPhotonTag           = cms.InputTag('flashggDiPhotons'),
                              VertexCandidateMapTag = cms.InputTag('flashggVertexMapForPUPPI'),
                              vertexIndex           = cms.uint32(vertexIndex),
                              debug                 = cms.untracked.bool(debug)
                            )
  )
  setattr ( process, 'ak4PFJetsPuppi' + label,
            ak4PFJets.clone ( src = cms.InputTag('flashggPuppi' + label), doAreaFastjet = True)
          )
  
  if useLocalJEC :
    print ':: using a local JEC dbfile for PUPPI :',
    print '\t -- ',  dbfile
    
    from flashgg.MicroAOD.flashggJetTools_cfi import loadLocalJECDBfile
    loadLocalJECDBfile(process,
                       dbfile = os.environ['CMSSW_BASE'] + '/src/' + dbfile,
                       tag    = 'JetCorrectorParametersCollection_PY8_RunIISpring15DR74_bx50_MC_AK4PUPPI',
                       label  = 'AK4PFPuppi')
    
  # do jet clustering
  addJetCollection(
    process,
    postfix            = label,
    labelName          = 'AK4PUPPI',
    jetSource          = cms.InputTag('ak4PFJetsPuppi' + label),
    pvSource           = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates       = cms.InputTag('packedPFCandidates'),
    svSource           = cms.InputTag('slimmedSecondaryVertices'),
    btagDiscriminators = [ flashggBTag ],
    jetCorrections     = ('AK4PFPuppi',['L1FastJet',  'L2Relative', 'L3Absolute'], 'None'),
    genJetCollection   = cms.InputTag('slimmedGenJets'),
    genParticles       = cms.InputTag('prunedGenParticles'),
    # jet param
    algo = 'AK', rParam = 0.4
  )

  getattr(process, 'patJetCorrFactorsAK4PUPPI' + label).primaryVertices = "offlineSlimmedPrimaryVertices"
  setattr( process,'flashggPUPPIJets'+ label,
           cms.EDProducer('FlashggJetProducer',
                          DiPhotonTag           = cms.InputTag('flashggDiPhotons'),
                          VertexTag             = cms.InputTag('offlineSlimmedPrimaryVertices'),
                          JetTag                = cms.InputTag('patJetsAK4PUPPI' + label),
                          VertexCandidateMapTag = cms.InputTag("flashggVertexMapForPUPPI"),
                          UsePuppi              = cms.untracked.bool(True),
                          ComputeSimpleRMS = cms.bool(True)
#                          PileupJetIdParameters = cms.PSet(pu_jetid)
                        ))

  # randomize Jets
  from flashgg.MicroAOD.flashggRandomizedJetProducer_cfi import flashggRandomizedJets
  flashggRandomizedPUPPIJets = flashggRandomizedJets.clone()
  flashggRandomizedPUPPIJets.src = "flashggPUPPIJets" + label
  setattr(process.RandomNumberGeneratorService, 'flashggRandomizedPUPPIJets' + label, cms.PSet(initialSeed = cms.untracked.uint32(36421523 + int(label))))
  setattr( process, 'flashggRandomizedPUPPIJets' + label, flashggRandomizedPUPPIJets )

  setattr( process, 'selectedFlashggPUPPIJets'+ label,
           cms.EDFilter("FLASHggJetSelector",
                        src = cms.InputTag( 'flashggRandomizedPUPPIJets'+ label ),
                        cut = cms.string("pt > 15.")
                      ))
Exemplo n.º 28
0
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)
    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)
    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/type I + II PFMEt corrections to pat::MET object
    # and estimate systematic uncertainties on MET
    # FIXME: are we 100% sure this should still be PF and not PFchs? -> MM: Yes for <=75X
    addJetCollection(process,
                     postfix="ForMetUnc",
                     labelName='AK4PF',
                     jetSource=cms.InputTag('ak4PFJets'),
                     jetCorrections=('AK4PF',
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute'], ''))
    process.patJetsAK4PFForMetUnc.getJetMCFlavour = False

    from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMETCorrectionsAndUncertainties

    #MET flavors
    runMETCorrectionsAndUncertainties(
        process,
        metType="PF",
        correctionLevel=["T0", "T1", "T2", "Smear", "Txy"],
        computeUncertainties=False,
        produceIntermediateCorrections=True,
        addToPatDefaultSequence=False,
        jetCollectionUnskimmed="patJetsAK4PFForMetUnc",
        jetCollection="selectedPatJetsAK4PFForMetUnc",
        postfix="",
    )

    #MET T1 uncertainties
    runMETCorrectionsAndUncertainties(
        process,
        metType="PF",
        correctionLevel=["T1"],
        computeUncertainties=True,
        produceIntermediateCorrections=False,
        addToPatDefaultSequence=False,
        jetCollectionUnskimmed="patJetsAK4PFForMetUnc",
        jetCollection="selectedPatJetsAK4PFForMetUnc",
        postfix="",
    )

    #MET T1 Smeared JER uncertainties
    runMETCorrectionsAndUncertainties(
        process,
        metType="PF",
        correctionLevel=["T1", "Smear"],
        computeUncertainties=True,
        produceIntermediateCorrections=False,
        addToPatDefaultSequence=False,
        jetCollectionUnskimmed="patJetsAK4PFForMetUnc",
        jetCollection="selectedPatJetsAK4PFForMetUnc",
        postfix="",
    )

    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
    addMETCollection(process, labelName="patCaloMet", metSource="caloMetM")

    #keep this after all addJetCollections otherwise it will attempt computing them also for stuf with no taginfos
    #Some useful BTAG vars
    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)
    #
    ## PU JetID
    process.load("PhysicsTools.PatAlgos.slimming.pileupJetId_cfi")
    process.patJets.userData.userFloats.src = [
        cms.InputTag("pileupJetId:fullDiscriminant"),
    ]

    ## 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))
    process.patJets.userData.userFloats.src += [
        cms.InputTag("caloJetMap:pt"),
        cms.InputTag("caloJetMap:emEnergyFraction")
    ]

    #EGM object modifications
    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_50ns_V1_cff',
        'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV60_cff',
        'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Spring15_25ns_nonTrig_V1_cff'
    ]
    switchOnVIDElectronIdProducer(process, DataFormat.MiniAOD)
    process.egmGsfElectronIDs.physicsObjectSrc = \
        cms.InputTag("reducedEgamma","reducedGedGsfElectrons")
    process.electronMVAValueMapProducer.src = \
        cms.InputTag('reducedEgamma','reducedGedGsfElectrons')
    for idmod in electron_ids:
        setupAllVIDIdsInModule(process, idmod, setupVIDElectronSelection, None,
                               False)

    #VID Photon IDs
    photon_ids = [
        'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_PHYS14_PU20bx25_V2_cff',
        'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_50ns_V1_cff',
        'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_25ns_nonTrig_V0_cff',
        'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_50ns_nonTrig_V2_cff'
    ]
    switchOnVIDPhotonIdProducer(process, DataFormat.MiniAOD)
    process.egmPhotonIDs.physicsObjectSrc = \
        cms.InputTag("reducedEgamma","reducedGedPhotons")
    process.photonIDValueMapProducer.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)

    # Adding puppi jets
    process.load('CommonTools.PileupAlgos.Puppi_cff')
    process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
    process.ak4PFJetsPuppi.doAreaFastjet = True  # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
    #process.puppi.candName = cms.InputTag('packedPFCandidates')
    #process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')

    from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
    process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer(
        "JetTracksAssociatorAtVertex",
        j2tParametersVX,
        jets=cms.InputTag("ak4PFJetsPuppi"))
    process.patJetPuppiCharge = cms.EDProducer(
        "JetChargeProducer",
        src=cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
        var=cms.string('Pt'),
        exp=cms.double(1.0))

    addJetCollection(process,
                     postfix="",
                     labelName='Puppi',
                     jetSource=cms.InputTag('ak4PFJetsPuppi'),
                     jetCorrections=('AK4PFchs', ['L2Relative',
                                                  'L3Absolute'], ''),
                     algo='AK',
                     rParam=0.4,
                     btagDiscriminators=map(
                         lambda x: x.value(),
                         process.patJets.discriminatorSources))

    process.patJetGenJetMatchPuppi.matched = 'slimmedGenJets'

    process.patJetsPuppi.userData.userFloats.src = cms.VInputTag(
        cms.InputTag(""))
    process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")

    process.selectedPatJetsPuppi.cut = cms.string("pt > 20")

    process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi')
    process.slimmedJetsPuppi = process.slimmedJets.clone()
    process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi")
    process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag(
        "packedPFCandidates")

    ## puppi met
    process.load('RecoMET.METProducers.PFMET_cfi')
    process.pfMetPuppi = process.pfMet.clone()
    process.pfMetPuppi.src = cms.InputTag("puppi")
    process.pfMetPuppi.alias = cms.string('pfMetPuppi')
    # type1 correction, from puppi jets
    process.corrPfMetType1Puppi = process.corrPfMetType1.clone(
        src='ak4PFJetsPuppi',
        jetCorrLabel='ak4PFCHSL2L3Corrector',
    )
    del process.corrPfMetType1Puppi.offsetCorrLabel  # no L1 for PUPPI jets
    process.pfMetT1Puppi = process.pfMetT1.clone(
        src='pfMetPuppi',
        srcCorrections=[cms.InputTag("corrPfMetType1Puppi", "type1")])

    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
    addMETCollection(process,
                     labelName='patMETPuppi',
                     metSource='pfMetT1Puppi')  # T1
    addMETCollection(process,
                     labelName='patPFMetPuppi',
                     metSource='pfMetPuppi')  # RAW

    process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
    process.slimmedMETsPuppi = process.slimmedMETs.clone()
    process.slimmedMETsPuppi.src = cms.InputTag("patMETPuppi")
    process.slimmedMETsPuppi.rawVariation = cms.InputTag(
        "patPFMetPuppi")  # only central value
    # only central values for puppi met
    del process.slimmedMETsPuppi.t01Variation
    del process.slimmedMETsPuppi.t1SmearedVarsAndUncs
    del process.slimmedMETsPuppi.tXYUncForRaw
    del process.slimmedMETsPuppi.tXYUncForT1
    del process.slimmedMETsPuppi.tXYUncForT01
    del process.slimmedMETsPuppi.tXYUncForT1Smear
    del process.slimmedMETsPuppi.tXYUncForT01Smear
    del process.slimmedMETsPuppi.caloMET
Exemplo n.º 29
0
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")
Exemplo n.º 30
0
#addMETCollection(process, labelName='patMETCalo', metSource='met')
addMETCollection(process, labelName='patMETPF', metSource='pfMetT1')
#addMETCollection(process, labelName='patMETTC', metSource='tcMet') # FIXME: removed from RECO/AOD; needs functionality to add to processing

## uncomment the following line to add different jet collections
## to the event content
from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

## uncomment the following lines to add ak4PFJetsCHS to your PAT output
labelAK4PFCHS = 'AK4PFCHS'
postfixAK4PFCHS = 'Copy'
addJetCollection(
   process,
   postfix   = postfixAK4PFCHS,
   labelName = labelAK4PFCHS,
   jetSource = cms.InputTag('ak4PFJetsCHS'),
   jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2')
   )
process.out.outputCommands.append( 'drop *_selectedPatJets%s%s_caloTowers_*'%( labelAK4PFCHS, postfixAK4PFCHS ) )

# uncomment the following lines to add ak4PFJets to your PAT output
switchJetCollection(
   process,
   jetSource = cms.InputTag('ak4PFJets'),
   jetCorrections = ('AK4PF', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-1'),
   btagDiscriminators = [
       'pfJetBProbabilityBJetTags'
     , 'pfJetProbabilityBJetTags'
     , 'pfTrackCountingHighPurBJetTags'
     , 'pfTrackCountingHighEffBJetTags'
Exemplo n.º 31
0
process.patJetsAK8Softdrop.jetCorrFactorsSource = cms.VInputTag(
    cms.InputTag("patJetCorrFactorsAK8Softdrop"))
process.selectedPatJetsAK8Softdrop = selectedPatJetsAK8.clone(
    cut='pt > 100', src="patJetsAK8Softdrop")

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
## PATify soft drop subjets
addJetCollection(
    process,
    labelName='AK8SoftDropSubjets',
    jetSource=cms.InputTag('ak8PFJetsCHSSoftDrop', 'SubJets'),
    algo='ak',  # needed for subjet flavor clustering
    rParam=0.8,  # needed for subjet flavor clustering
    getJetMCFlavour=False,
    pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
    genJetCollection=cms.InputTag('slimmedGenJets'),
    genParticles=cms.InputTag('prunedGenParticles'),
    btagDiscriminators=['None'],
    jetCorrections=('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
    #    explicitJTA = True,  # needed for subjet b tagging
    #    svClustering = True, # needed for subjet b tagging
    #    fatJets=cms.InputTag('ak8PFJetsCHS'),             # needed for subjet flavor clustering
    #    groomedFatJets=cms.InputTag('ak8PFJetsCHSSoftDrop') # needed for subjet flavor clustering
)
#'''
#from RecoBTag.DeepFlavour.DeepFlavourJetTagsProducer_cfi import *
# this loads all available b-taggers
#process.load("RecoBTag.Configuration.RecoBTag_cff")
#process.load("RecoBTag.DeepFlavour.DeepFlavourJetTagsProducer_cfi")
#process.load("RecoBTag.DeepFlavour.deepFlavour_cff")
#'''
Exemplo n.º 32
0
    preSeq += process.trackJetSequence

    # Make pat track-jets
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection

    addJetCollection(
        process,
        labelName = 'AK4PFTrack',
        jetSource = cms.InputTag('ak4TrackJets'),
        algo = 'AK',
        rParam = 0.4,
        jetCorrections = None,
        pfCandidates = cms.InputTag( 'packedPFCandidates' ),
        svSource = cms.InputTag( 'slimmedSecondaryVertices' ),
        genJetCollection = cms.InputTag( 'slimmedGenJets'),
        pvSource = cms.InputTag( 'offlineSlimmedPrimaryVertices' ),
        btagDiscriminators = [
                #'pfTrackCountingHighEffBJetTags',
                #'pfTrackCountingHighPurBJetTags',
                'pfJetProbabilityBJetTags'
                #'pfJetBProbabilityBJetTags'
        ],
        getJetMCFlavour = isMC,
        genParticles = cms.InputTag('prunedGenParticles'),
        outputModules = ['outputFile']
    )

    getattr(process,'selectedPatJetsAK4PFTrack').cut = cms.string('pt > 1.0')
    preSeq += getattr(process,'selectedPatJetsAK4PFTrack')
    process.skimEventProducer.trackJetTag = cms.InputTag("selectedPatJetsAK4PFTrack")
Exemplo n.º 33
0
def runGroomedMethod(process,
                     isMC,
                     jetCollection,
                     coneSize,
                     algo,
                     payloadName,
                     payloadNameSubjet,
                     JECLevel,
                     pfCand,
                     btagDiscriminators,
                     addSubJets=True,
                     addQGLikelihood=True,
                     isPruning=True,
                     isSoftDrop=True,
                     isTrimming=True,
                     isFiltering=True):

    ### name for cone size and algo
    coneSizeStr = str(coneSize).replace("0", "").replace(".", "")
    jetAlgo = algo + coneSizeStr

    if algo == "AK":
        ALGO = "AntiKt"
    elif algo == "CA":
        ALGO = "CambridgeAachen"

    btagSubjets = ['pfCombinedInclusiveSecondaryVertexV2BJetTags']

    ### form the right postfix
    if not isPruning and not isSoftDrop and not isTrimming and not isFiltering:
        sys.exit("runGroomedMethod: all bools are false --> please check")

    if isPruning and not isSoftDrop and not isTrimming and not isFiltering:
        postfix = "Pruned"
    elif not isPruning and isSoftDrop and not isTrimming and not isFiltering:
        postfix = "SoftDrop"
    elif not isPruning and not isSoftDrop and isTrimming and not isFiltering:
        postfix = "Trimmed"
    elif not isPruning and not isSoftDrop and not isTrimming and isFiltering:
        postfix = "Filtered"
    else:
        sys.exit(
            "wrong setup, only one groomer is allowed each time --> please check"
        )

    ## build default reco groomed jets
    if not hasattr(process, jetCollection + postfix):
        if isPruning:
            setattr(process, jetCollection + postfix,
                    ak8PFJetsCHSPruned.clone())
        elif isSoftDrop:
            setattr(process, jetCollection + postfix,
                    ak8PFJetsCHSSoftDrop.clone())
        elif isTrimming:
            setattr(process, jetCollection + postfix,
                    ak8PFJetsCHSTrimmed.clone())
        elif isFiltering:
            setattr(process, jetCollection + postfix,
                    ak8PFJetsCHSFiltered.clone())

        getattr(process, jetCollection + postfix).src = cms.InputTag(
            jetCollection + "Reduced", 'constituents')
        getattr(process, jetCollection + postfix).rParam = coneSize
        getattr(process, jetCollection + postfix).jetAlgorithm = ALGO
        ## write compounds means that subjets are stored as reco::Jet while the groomed jet is stored as base::Jet
        getattr(process,
                jetCollection + postfix).writeCompound = cms.bool(True)
        getattr(process,
                jetCollection + postfix).doAreaFastjet = cms.bool(True)

    ## gen groomed jets
    if isMC:
        if not hasattr(process, "genJets" + jetAlgo + postfix):
            ## store AK8 gen::Jet
            setattr(
                process, "genJets" + jetAlgo + postfix,
                getattr(process, jetCollection + postfix).clone(
                    src=cms.InputTag('genParticlesForJetsNoNu'),
                    writeCompound=cms.bool(False),
                    useExplicitGhosts=cms.bool(True),
                    jetPtMin=cms.double(50.),
                    jetType=cms.string('GenJet'),
                    jetCollInstanceName=cms.string("")))

    ## pruned pat jets with embeded gen-jet info
    if not hasattr(process, "patJets" + jetCollection + postfix):
        addJetCollection(
            process,
            labelName=jetCollection + postfix,
            jetSource=cms.InputTag(jetCollection + postfix),
            algo=algo,
            pfCandidates=cms.InputTag(pfCand),
            rParam=coneSize,
            jetCorrections=(payloadName, JECLevel, 'None'),
            svSource=cms.InputTag('slimmedSecondaryVertices'),
            genJetCollection=cms.InputTag("genJets" + jetAlgo + postfix),
            pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
            btagDiscriminators=
            btagDiscriminators,  ## no b-tag info for pruned jets                                                                                     
            getJetMCFlavour=
            isMC,  ## no flavor info                                                                                                                       
            genParticles=cms.InputTag("prunedGenParticles"))

    ## matched fat jet with groomed one adding info as user float
    if not hasattr(process, jetCollection + postfix + 'Matched'):
        setattr(
            process,
            jetCollection + postfix + 'Matched',
            cms.EDProducer(
                "RecoPATJetDeltaRValueMapProducer",
                ## basic reco::jet ungroomed
                src=cms.InputTag(jetCollection + "Reduced"),
                ## mathched groomed pat jet
                matched=cms.InputTag('patJets' + jetCollection + postfix),
                distMax=cms.double(coneSize),
                values=cms.vstring(
                    "mass", "pt", "eta", "phi",
                    "bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",
                    "bDiscriminator('pfBoostedDoubleSecondaryVertexAK8BJetTags')",
                    "correctedP4(0).mass()", "correctedP4(0).pt()",
                    "correctedP4(0).eta()", "correctedP4(0).phi()"),
                valueLabels=cms.vstring(
                    "mass", "pt", "eta", "phi",
                    "pfCombinedInclusiveSecondaryVertexV2BJetTags",
                    "pfBoostedDoubleSecondaryVertexAK8BJetTags", "rawmass",
                    "rawpt", "raweta", "rawphi")))

        if isMC:
            getattr(process,
                    jetCollection + postfix + 'Matched').valueLabels += [
                        "hadronFlavour", "partonFlavour", "genMass", "genPt",
                        "genEta", "genPhi"
                    ]
            getattr(process, jetCollection + postfix + 'Matched').values += [
                "hadronFlavour", "partonFlavour", "genJet().mass",
                "genJet().pt", "genJet().eta", "genJet().phi"
            ]

        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:mass'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:pt'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix +
                    'Matched:pfCombinedInclusiveSecondaryVertexV2BJetTags'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix +
                    'Matched:pfBoostedDoubleSecondaryVertexAK8BJetTags'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:eta'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:phi'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:rawmass'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:rawpt'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:raweta'
                ]
        getattr(process,
                'patJets' + jetCollection).userData.userFloats.src += [
                    jetCollection + postfix + 'Matched:rawphi'
                ]

        if isMC:
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + postfix + 'Matched:hadronFlavour'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + postfix + 'Matched:partonFlavour'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + postfix + 'Matched:genMass'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + postfix + 'Matched:genPt'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + postfix + 'Matched:genEta'
                    ]
            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + postfix + 'Matched:genPhi'
                    ]

    ## add QGL --> some tricks are needed
    if addQGLikelihood:
        ## redo groomed jet with a special postfix (ForQGL)
        if not hasattr(process, jetCollection + postfix + "ForQGL"):
            setattr(
                process, jetCollection + postfix + "ForQGL",
                getattr(process, jetCollection + postfix).clone(
                    writeCompound=cms.bool(False),
                    jetCollInstanceName=cms.string("")))

        ## run QGL evaluator
        if not hasattr(process, jetCollection + postfix + "QGL"):
            setattr(
                process, jetCollection + postfix + "QGL",
                QGTagger.clone(srcJets=cms.InputTag(jetCollection + postfix +
                                                    "ForQGL"),
                               jetsLabel=cms.string('QGL_AK4PFchs'),
                               srcVertexCollection=cms.InputTag(
                                   'offlineSlimmedPrimaryVertices')))

        ## pattify jets on the fly
        if not hasattr(process, 'patJets' + jetCollection + postfix + "QGL"):
            setattr(
                process, 'patJets' + jetCollection + postfix + "QGL",
                patJets.clone(jetSource=cms.InputTag(jetCollection + postfix +
                                                     "ForQGL"),
                              addJetCorrFactors=cms.bool(False),
                              addBTagInfo=cms.bool(False),
                              addDiscriminators=cms.bool(False),
                              discriminatorSources=cms.VInputTag('None'),
                              addAssociatedTracks=cms.bool(False),
                              addJetCharge=cms.bool(False),
                              addGenPartonMatch=cms.bool(False),
                              embedGenPartonMatch=cms.bool(False),
                              addGenJetMatch=cms.bool(False),
                              embedGenJetMatch=cms.bool(False),
                              getJetMCFlavour=cms.bool(False),
                              addJetFlavourInfo=cms.bool(False)))

            getattr(process, 'patJets' + jetCollection + postfix +
                    "QGL").userData.userFloats.src += [
                        jetCollection + postfix + "QGL:qgLikelihood"
                    ]

        ## match QGL value with the original jet
        if not hasattr(process, jetCollection + postfix + "QGLMatched"):
            setattr(
                process, jetCollection + postfix + 'QGLMatched',
                cms.EDProducer(
                    "RecoPATJetDeltaRValueMapProducer",
                    src=cms.InputTag(jetCollection + "Reduced"),
                    matched=cms.InputTag('patJets' + jetCollection + postfix +
                                         "QGL"),
                    distMax=cms.double(coneSize),
                    values=cms.vstring("userFloat('" + jetCollection +
                                       postfix + "QGL:qgLikelihood')"),
                    valueLabels=cms.vstring("qgLikelihood")))

            getattr(process,
                    'patJets' + jetCollection).userData.userFloats.src += [
                        jetCollection + postfix + 'QGLMatched:qgLikelihood'
                    ]

    ## add subjet information
    if addSubJets:

        ## gen groomed sub-jets --> star with default clustering
        if isMC and not hasattr(process,
                                "genJets" + jetAlgo + postfix + "SubJets"):
            setattr(
                process, "genJets" + jetAlgo + postfix + "SubJets",
                getattr(process, "genJets" + jetAlgo + postfix).clone(
                    writeCompound=cms.bool(True),
                    jetCollInstanceName=cms.string('SubJets')))

        if not hasattr(process,
                       "patJets" + jetCollection + postfix + "SubJets"):

            addJetCollection(
                process,
                labelName=jetCollection + postfix + 'SubJets',
                jetSource=cms.InputTag(jetCollection + postfix, 'SubJets'),
                algo=algo,  # needed for subjet b tagging
                rParam=coneSize,  # needed for subjet b tagging
                pfCandidates=cms.InputTag(pfCand),
                jetCorrections=(payloadNameSubjet, JECLevel, 'None'),
                pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
                svSource=cms.InputTag('slimmedSecondaryVertices'),
                getJetMCFlavour=isMC,
                genParticles=cms.InputTag("prunedGenParticles"),
                btagDiscriminators=btagSubjets,
                genJetCollection=cms.InputTag(
                    "genJets" + jetAlgo + postfix + "SubJets", "SubJets"),
                explicitJTA=True,  # needed for subjet b tagging
                svClustering=True,  # needed for subjet b tagging
                fatJets=cms.InputTag(
                    jetCollection +
                    "Reduced"),  # needed for subjet flavor clustering
                groomedFatJets=cms.InputTag(
                    jetCollection +
                    postfix),  # needed for subjet flavor clustering
            )

        ## adding sub-jet QGL
        if addQGLikelihood:
            if not hasattr(process, jetCollection + postfix + "SubJetsQGL"):
                setattr(
                    process, jetCollection + postfix + "SubJetsQGL",
                    QGTagger.clone(srcJets=cms.InputTag(
                        jetCollection + postfix, "SubJets"),
                                   jetsLabel=cms.string('QGL_AK4PFchs'),
                                   srcVertexCollection=cms.InputTag(
                                       'offlineSlimmedPrimaryVertices')))

                getattr(process, 'patJets' + jetCollection + postfix +
                        "SubJets").userData.userFloats.src += [
                            jetCollection + postfix + 'SubJetsQGL:qgLikelihood'
                        ]

        ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
        if not hasattr(process,
                       'patJets' + jetCollection + postfix + 'Packed'):
            setattr(
                process, 'patJets' + jetCollection + postfix + 'Packed',
                cms.EDProducer(
                    "BoostedJetMerger",
                    jetSrc=cms.InputTag('selectedPatJets' + jetCollection +
                                        postfix),
                    subjetSrc=cms.InputTag("selectedPatJets" + jetCollection +
                                           postfix + "SubJets")))
Exemplo n.º 34
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


    # 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")
Exemplo n.º 35
0
    preSeq += process.trackJetSequence

    # Make pat track-jets
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection

    addJetCollection(   
			process,
			labelName = 'AK4PFTrack',
			jetSource = cms.InputTag('ak4TrackJets'),
			algo = 'AK',
			rParam = 0.4,
			jetCorrections = None, 
			pfCandidates = cms.InputTag( 'packedPFCandidates' ),  
			svSource = cms.InputTag( 'slimmedSecondaryVertices' ),  
			genJetCollection = cms.InputTag( 'slimmedGenJets'),
			pvSource = cms.InputTag( 'offlineSlimmedPrimaryVertices' ), 
			btagDiscriminators = [
				#'pfTrackCountingHighEffBJetTags',
				#'pfTrackCountingHighPurBJetTags',
				'pfJetProbabilityBJetTags'
				#'pfJetBProbabilityBJetTags'
			],
			getJetMCFlavour = isMC,
			genParticles = cms.InputTag('prunedGenParticles'),
			outputModules = ['outputFile']
		    )
 
    getattr(process,'selectedPatJetsAK4PFTrack').cut = cms.string('pt > 1.0')
    preSeq += getattr(process,'selectedPatJetsAK4PFTrack')
    process.skimEventProducer.trackJetTag = cms.InputTag("selectedPatJetsAK4PFTrack")
    
Exemplo n.º 36
0
def applySubstructure(process):

    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection

    # add CMS top tagger
    from RecoJets.JetProducers.caTopTaggers_cff import caTopTagInfos
    process.caTopTagInfos = caTopTagInfos.clone()
    process.caTopTagInfosPAT = cms.EDProducer(
        "RecoJetDeltaRTagInfoValueMapProducer",
        src=cms.InputTag("ak8PFJetsCHS"),
        matched=cms.InputTag("cmsTopTagPFJetsCHS"),
        matchedTagInfos=cms.InputTag("caTopTagInfos"),
        distMax=cms.double(0.8))

    from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets as patJetsDefault

    #add AK8
    addJetCollection(
        process,
        labelName='AK8',
        jetSource=cms.InputTag('ak8PFJetsCHS'),
        algo='AK',
        rParam=0.8,
        jetCorrections=('AK8PFchs',
                        cms.vstring(['L1FastJet', 'L2Relative',
                                     'L3Absolute']), 'None'),
        btagDiscriminators=(
            [x.getModuleLabel() for x in patJetsDefault.discriminatorSources] +
            ['pfBoostedDoubleSecondaryVertexAK8BJetTags']),
        genJetCollection=cms.InputTag('slimmedGenJetsAK8'))
    process.patJetsAK8.userData.userFloats.src = [
    ]  # start with empty list of user floats
    process.selectedPatJetsAK8.cut = cms.string("pt > 170")

    ## AK8 groomed masses
    from RecoJets.Configuration.RecoPFJets_cff import ak8PFJetsCHSPruned, ak8PFJetsCHSSoftDrop, ak8PFJetsCHSFiltered, ak8PFJetsCHSTrimmed
    process.ak8PFJetsCHSPruned = ak8PFJetsCHSPruned.clone()
    process.ak8PFJetsCHSSoftDrop = ak8PFJetsCHSSoftDrop.clone()
    process.ak8PFJetsCHSTrimmed = ak8PFJetsCHSTrimmed.clone()
    process.ak8PFJetsCHSFiltered = ak8PFJetsCHSFiltered.clone()
    process.load("RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi")
    process.patJetsAK8.userData.userFloats.src += [
        'ak8PFJetsCHSPrunedMass', 'ak8PFJetsCHSSoftDropMass',
        'ak8PFJetsCHSTrimmedMass', 'ak8PFJetsCHSFilteredMass'
    ]

    # Add AK8 top tagging variables
    process.patJetsAK8.tagInfoSources = cms.VInputTag(
        cms.InputTag("caTopTagInfosPAT"))
    process.patJetsAK8.addTagInfos = cms.bool(True)

    # add Njetiness
    process.load('RecoJets.JetProducers.nJettinessAdder_cfi')
    process.NjettinessAK8 = process.Njettiness.clone()
    process.NjettinessAK8.src = cms.InputTag("ak8PFJetsCHS")
    process.NjettinessAK8.cone = cms.double(0.8)
    process.patJetsAK8.userData.userFloats.src += [
        'NjettinessAK8:tau1', 'NjettinessAK8:tau2', 'NjettinessAK8:tau3'
    ]

    ## PATify pruned fat jets
    addJetCollection(
        process,
        labelName='AK8PFCHSSoftDrop',
        jetSource=cms.InputTag('ak8PFJetsCHSSoftDrop'),
        btagDiscriminators=['None'],
        jetCorrections=('AK8PFchs', ['L1FastJet', 'L2Relative',
                                     'L3Absolute'], 'None'),
        getJetMCFlavour=False  # jet flavor disabled
    )

    ## PATify soft drop subjets
    addJetCollection(
        process,
        labelName='AK8PFCHSSoftDropSubjets',
        jetSource=cms.InputTag('ak8PFJetsCHSSoftDrop', 'SubJets'),
        algo='ak',  # needed for subjet flavor clustering
        rParam=0.8,  # needed for subjet flavor clustering
        btagDiscriminators=[
            'pfCombinedSecondaryVertexV2BJetTags',
            'pfCombinedInclusiveSecondaryVertexV2BJetTags'
        ],
        jetCorrections=('AK4PFchs', ['L1FastJet', 'L2Relative',
                                     'L3Absolute'], 'None'),
        explicitJTA=True,  # needed for subjet b tagging
        svClustering=True,  # needed for subjet b tagging
        genJetCollection=cms.InputTag('slimmedGenJets'),
        fatJets=cms.InputTag(
            'ak8PFJetsCHS'),  # needed for subjet flavor clustering
        groomedFatJets=cms.InputTag(
            'ak8PFJetsCHSSoftDrop')  # needed for subjet flavor clustering
    )
    process.selectedPatJetsAK8PFCHSSoftDrop.cut = cms.string("pt > 170")

    process.slimmedJetsAK8PFCHSSoftDropSubjets = cms.EDProducer(
        "PATJetSlimmer",
        src=cms.InputTag("selectedPatJetsAK8PFCHSSoftDropSubjets"),
        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),
        modifierConfig=cms.PSet(modifications=cms.VPSet()))

    ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
    process.slimmedJetsAK8PFCHSSoftDropPacked = cms.EDProducer(
        "BoostedJetMerger",
        jetSrc=cms.InputTag("selectedPatJetsAK8PFCHSSoftDrop"),
        subjetSrc=cms.InputTag("slimmedJetsAK8PFCHSSoftDropSubjets"))

    addJetCollection(
        process,
        labelName='CMSTopTagCHS',
        jetSource=cms.InputTag('cmsTopTagPFJetsCHS'),
        jetCorrections=('AK8PFchs',
                        cms.vstring(['L1FastJet', 'L2Relative',
                                     'L3Absolute']), 'None'),
        btagDiscriminators=['None'],
        genJetCollection=cms.InputTag('slimmedGenJetsAK8'),
        getJetMCFlavour=False  #
    )
    process.selectedPatJetsCMSTopTagCHS.cut = cms.string("pt > 200")

    addJetCollection(
        process,
        labelName='CMSTopTagCHSSubjets',
        jetSource=cms.InputTag('cmsTopTagPFJetsCHS', 'caTopSubJets'),
        algo='AK',  # needed for subjet flavor clustering
        rParam=0.8,  # needed for subjet flavor clustering        
        btagDiscriminators=[
            'pfCombinedSecondaryVertexV2BJetTags',
            'pfCombinedInclusiveSecondaryVertexV2BJetTags'
        ],
        jetCorrections=('AK4PFchs', ['L1FastJet', 'L2Relative',
                                     'L3Absolute'], 'None'),
        genJetCollection=cms.InputTag(
            'slimmedGenJets'
        ),  # Using ak4GenJets for matching which is not entirely appropriate
        explicitJTA=True,  # needed for subjet b tagging
        svClustering=True,  # needed for subjet b tagging
        fatJets=cms.InputTag(
            'ak8PFJetsCHS'),  # needed for subjet flavor clustering
        groomedFatJets=cms.InputTag(
            'cmsTopTagPFJetsCHS')  # needed for subjet flavor clustering
    )

    process.slimmedJetsCMSTopTagCHSSubjets = cms.EDProducer(
        "PATJetSlimmer",
        src=cms.InputTag("selectedPatJetsCMSTopTagCHSSubjets"),
        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),
        modifierConfig=cms.PSet(modifications=cms.VPSet()))

    ## Establish references between PATified fat jets and subjets using the BoostedJetMerger
    process.slimmedJetsCMSTopTagCHSPacked = cms.EDProducer(
        "BoostedJetMerger",
        jetSrc=cms.InputTag("selectedPatJetsCMSTopTagCHS"),
        subjetSrc=cms.InputTag("slimmedJetsCMSTopTagCHSSubjets"))

    process.packedPatJetsAK8 = cms.EDProducer(
        "JetSubstructurePacker",
        jetSrc=cms.InputTag("selectedPatJetsAK8"),
        distMax=cms.double(0.8),
        algoTags=cms.VInputTag(
            # NOTE: For an optimal storage of the AK8 jet daughters, the first subjet collection listed here should be
            #       derived from AK8 jets, i.e., subjets should contain either all or a subset of AK8 constituents.
            #       The CMSTopTag subjets are derived from CA8 jets later matched to AK8 jets and could in principle
            #       contain extra constituents not clustered inside AK8 jets.
            cms.InputTag("slimmedJetsAK8PFCHSSoftDropPacked"),
            cms.InputTag("slimmedJetsCMSTopTagCHSPacked")),
        algoLabels=cms.vstring('SoftDrop', 'CMSTopTag'),
        fixDaughters=cms.bool(True),
        packedPFCandidates=cms.InputTag("packedPFCandidates"),
    )

    # switch off daughter re-keying since it's done in the JetSubstructurePacker (and can't be done afterwards)
    process.slimmedJetsAK8.rekeyDaughters = "0"
Exemplo n.º 37
0
process.ak4GenJets = ak4GenJets.clone(src = 'packedGenParticles')

# The following is make patJets, but EI is done with the above
process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff")
process.load("Configuration.EventContent.EventContent_cff")
process.load('Configuration.StandardSequences.Geometry_cff')
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.GlobalTag.globaltag = 'PLS170_V7AN1::All'

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
addJetCollection(
    process,
    postfix        = "",
    labelName      = 'AK4PF',
    jetSource      = cms.InputTag('ak4PFJets'),
    trackSource    = cms.InputTag('unpackedTracksAndVertices'), 
    pvSource       = cms.InputTag('unpackedTracksAndVertices'), 
    jetCorrections = ('AK4PF', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
    btagDiscriminators = ['combinedSecondaryVertexBJetTags']
    ,algo= 'AK', rParam = 0.4)

# adjust MC matching
process.patJetGenJetMatchAK4PF.matched = "ak4GenJets"
process.patJetPartonMatchAK4PF.matched = "prunedGenParticles"
process.patJetPartons.particles        = "prunedGenParticles"

# adjust PV used for Jet Corrections
process.patJetCorrFactorsAK4PF.primaryVertices = "offlineSlimmedPrimaryVertices"

# the following part is needed if you want to run b-tagging on the freshly made jets
# CAVEAT: it is not 100% the same b-tagging as in RECO, but performance plots are almost identical
Exemplo n.º 38
0
process.ak5PFJetsCHS = ak5PFJets.clone(src = 'chs', doAreaFastjet = True) # no idea while doArea is false by default, but it's True in RECO so we have to set it
process.ak5GenJets = ak5GenJets.clone(src = 'packedGenParticles')

process.load("PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff")
process.load("Configuration.EventContent.EventContent_cff")
process.load('Configuration.StandardSequences.Geometry_cff')
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.GlobalTag.globaltag = 'START70_V6::All'

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
addJetCollection(
   process,
   postfix   = "",
   labelName = 'AK5PFCHS',
   jetSource = cms.InputTag('ak5PFJetsCHS'),
   trackSource = cms.InputTag('unpackedTracksAndVertices'), 	
   pvSource = cms.InputTag('unpackedTracksAndVertices'), 
   jetCorrections = ('AK5PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
   btagDiscriminators = [      'combinedSecondaryVertexBJetTags'     ]
   )
process.patJetPartonMatchPatJetsAK5PFCHS.matched = "prunedGenParticles"
process.patJetPartons.src = "prunedGenParticles"
process.patJetPartons.skipFirstN = cms.uint32(0) # do not skip first 6 particles, we already pruned some!
process.patJetPartons.acceptNoDaughters = cms.bool(True) # as we drop intermediate stuff, we need to accept quarks with no siblings
process.patJetCorrFactorsPatJetsAK5PFCHS.primaryVertices = "offlineSlimmedPrimaryVertices"

#recreate tracks and pv for btagging
process.load('PhysicsTools.PatAlgos.slimming.unpackedTracksAndVertices_cfi')
process.combinedSecondaryVertex.trackMultiplicityMin = 1 #silly sv, uses un filtered tracks.. i.e. any pt

process.load("FWCore.MessageLogger.MessageLogger_cfi")
Exemplo n.º 39
0
    'pfCombinedInclusiveSecondaryVertexBJetTags',
    'pfPositiveCombinedInclusiveSecondaryVertexBJetTags',
    'pfNegativeCombinedInclusiveSecondaryVertexBJetTags',
    'pfCombinedInclusiveSecondaryVertexV2BJetTags',
    'pfPositiveCombinedInclusiveSecondaryVertexV2BJetTags',
    'pfNegativeCombinedInclusiveSecondaryVertexV2BJetTags',
    'pfCombinedMVABJetTags',
    'pfPositiveCombinedMVABJetTags',
    'pfNegativeCombinedMVABJetTags'
]

# uncomment the following lines to add ak4PFJets with new b-tags to your PAT output
addJetCollection(
    process,
    labelName='AK4PF',
    jetSource=cms.InputTag('ak4PFJets'),
    jetCorrections=('AK4PF',
                    cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']),
                    'Type-2'),  # FIXME: Use proper JECs, as soon as available
    btagDiscriminators=btagDiscriminators)
process.patJetsAK4PF.addTagInfos = True

# uncomment the following lines to add subjets of pruned ca8PFJetsCHS with new b-tags to your PAT output
addJetCollection(
    process,
    labelName='CA8PFCHSPrunedSubjets',
    jetSource=cms.InputTag('ca8PFJetsCHSPruned', 'SubJets'),
    jetCorrections=('AK4PFchs',
                    cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']),
                    'Type-2'),  # FIXME: Use proper JECs, as soon as available
    algo='CA',
    rParam=0.8,
Exemplo n.º 40
0

process.load("PhysicsTools.PatAlgos.patSequences_cff")

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

addJetCollection(
    process,
    labelName = 'AK4PFCHS',
    jetSource = cms.InputTag('ak4PFJetsCHS'),
    algo = 'ak',
    rParam = 0.4,
    jetCorrections = ('AK5PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
    btagDiscriminators = [
        'jetBProbabilityBJetTags'
      , 'jetProbabilityBJetTags'
      , 'trackCountingHighPurBJetTags'
      , 'trackCountingHighEffBJetTags'
      , 'simpleSecondaryVertexHighEffBJetTags'
      , 'simpleSecondaryVertexHighPurBJetTags'
      , 'combinedSecondaryVertexBJetTags'
      ],
)
addJetCollection(
    process,
    labelName = 'CA8PFCHS',
    jetSource = cms.InputTag('ca8PFJetsCHS'),
    algo = 'ca',
    rParam = 0.8,
    jetCorrections = ('AK7PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None')
Exemplo n.º 41
0
def addFlashggPFCHS0(process):
  print "JET PRODUCER :: Flashgg PFCHS producer ::"
  
  # leptons to remove as per default CHS workflow
  # select the isolated leptons : electrons + muons
  process.selectedMuons     = cms.EDFilter("CandPtrSelector", 
                                           src = cms.InputTag("slimmedMuons"), 
                                           cut = cms.string('''abs(eta)<2.5 && pt>10. &&
                                           (pfIsolationR04().sumChargedHadronPt+
                                           max(0.,pfIsolationR04().sumNeutralHadronEt+
                                           pfIsolationR04().sumPhotonEt-
                                           0.50*pfIsolationR04().sumPUPt))/pt < 0.20 && 
                                           (isPFMuon && (isGlobalMuon || isTrackerMuon) )'''))
  
  process.selectedElectrons = cms.EDFilter("CandPtrSelector", 
                                           src = cms.InputTag("slimmedElectrons"), 
                                           cut = cms.string('''abs(eta)<2.5 && pt>20. &&
                                           gsfTrack.isAvailable() &&
                                           gsfTrack.hitPattern().numberOfLostHits(\'MISSING_INNER_HITS\') < 2 &&
                                           (pfIsolationVariables().sumChargedHadronPt+
                                           max(0.,pfIsolationVariables().sumNeutralHadronEt+
                                           pfIsolationVariables().sumPhotonEt-
                                           0.5*pfIsolationVariables().sumPUPt))/pt < 0.15'''))
  
  # Simple producer which just removes the Candidates which
  # don't come from the legacy vertex according to the Flashgg Vertex Map
  process.flashggCHSLegacyVertexCandidates = cms.EDProducer('FlashggCHSLegacyVertexCandidateProducer',
                                                            PFCandidatesTag       = cms.InputTag('packedPFCandidates'),
                                                            DiPhotonTag           = cms.InputTag('flashggDiPhotons'),
                                                            VertexCandidateMapTag = cms.InputTag("flashggVertexMapForCHS"),
                                                            VertexTag = cms.InputTag('offlineSlimmedPrimaryVertices')
                                                          )
  
  process.pfCHS0 = cms.EDFilter("CandPtrSelector", 
                                src = cms.InputTag("flashggCHSLegacyVertexCandidates"), 
                                cut = cms.string(""))
  
  # then remove the previously selected muons
  process.pfNoMuonCHS0      = cms.EDProducer("CandPtrProjector", 
                                             src  = cms.InputTag("pfCHS0"), 
                                             veto = cms.InputTag("selectedMuons"))
  # then remove the previously selected electrons
  process.pfNoElectronsCHS0 = cms.EDProducer("CandPtrProjector", 
                                             src  = cms.InputTag("pfNoMuonCHS0"), 
                                             veto = cms.InputTag("selectedElectrons"))
  
  #Import RECO jet producer for ak4 PF and GEN jet
  from RecoJets.JetProducers.ak4PFJets_cfi  import ak4PFJets
  process.ak4PFJetsCHS0 = ak4PFJets.clone ( src = 'pfNoElectronsCHS0', doAreaFastjet = True)
  
  # NOTE : these line are from the new Jet recipe 
  # The following is make patJets, but EI is done with the above
  process.load("Configuration.StandardSequences.MagneticField_cff")
  process.load("Configuration.Geometry.GeometryRecoDB_cff")
  process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
  
  
  
  # cluster the jets
  # NOTE: this is the 74X recipe for the jet clustering 
  addJetCollection(
    process,
    labelName      = 'AK4PFCHS0',
    jetSource      = cms.InputTag('ak4PFJetsCHS0'),
    pvSource       = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates   = cms.InputTag('packedPFCandidates'),
    svSource       = cms.InputTag('slimmedSecondaryVertices'),
    btagDiscriminators =  [ flashggBTag ],
    jetCorrections = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'),
    
    genParticles     = cms.InputTag('prunedGenParticles'),
    genJetCollection = cms.InputTag('slimmedGenJets'),
    # jet param
    algo = 'AK', rParam = 0.4
    )
  
  #adjust PV used for Jet Corrections
  process.patJetCorrFactorsAK4PFCHS0.primaryVertices = "offlineSlimmedPrimaryVertices"
Exemplo n.º 42
0
#addMETCollection(process, labelName='patMETCalo', metSource='met')
addMETCollection(process, labelName='patMETPF', metSource='pfMetT1')
#addMETCollection(process, labelName='patMETTC', metSource='tcMet') # FIXME: removed from RECO/AOD; needs functionality to add to processing

## uncomment the following line to add different jet collections
## to the event content
from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

## uncomment the following lines to add ak4PFJetsCHS to your PAT output
labelAK4PFCHS = 'AK4PFCHS'
postfixAK4PFCHS = 'Copy'
addJetCollection(process,
                 postfix=postfixAK4PFCHS,
                 labelName=labelAK4PFCHS,
                 jetSource=cms.InputTag('ak4PFJetsCHS'),
                 jetCorrections=('AK4PFchs',
                                 cms.vstring(
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute']), 'Type-2'))
process.out.outputCommands.append('drop *_selectedPatJets%s%s_caloTowers_*' %
                                  (labelAK4PFCHS, postfixAK4PFCHS))

# uncomment the following lines to add ak4PFJets to your PAT output
switchJetCollection(
    process,
    jetSource=cms.InputTag('ak4PFJets'),
    jetCorrections=('AK4PF',
                    cms.vstring(['L1FastJet', 'L2Relative',
                                 'L3Absolute']), 'Type-1'),
    btagDiscriminators=[
        'pfJetBProbabilityBJetTags', 'pfJetProbabilityBJetTags',
Exemplo n.º 43
0
    ,'pfDeepCSVJetTags:probc'
    ,'pfDeepCSVJetTags:probudsg'
    ,'pfDeepCSVJetTags:probbb'
     # DeepCMVA
    ,'pfDeepCMVAJetTags:probb'
    ,'pfDeepCMVAJetTags:probc'
    ,'pfDeepCMVAJetTags:probudsg'
    ,'pfDeepCMVAJetTags:probbb'
    ,'pfDeepCMVAJetTags:probcc'
]

# uncomment the following lines to add ak4PFJets with new b-tags to your PAT output
addJetCollection(
   process,
   labelName = 'AK4PF',
   jetSource = cms.InputTag('ak4PFJets'),
   jetCorrections = ('AK4PF', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
   btagDiscriminators = btagDiscriminators
)
process.patJetsAK4PF.addTagInfos = True

# uncomment the following lines to add ak8PFJetsCHS with new b-tags to your PAT output
addJetCollection(
   process,
   labelName = 'AK8PFCHS',
   jetSource = cms.InputTag('ak8PFJetsCHS'),
   jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
   algo = 'AK',
   rParam = 0.8,
   btagDiscriminators = ['pfBoostedDoubleSecondaryVertexAK8BJetTags']
)
Exemplo n.º 44
0
process.load('PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff')
process.load('PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff')
process.load("RecoJets.Configuration.RecoGenJets_cff")
process.load("RecoJets.Configuration.GenJetParticles_cff")

#process.ca8GenJetsNoNu = process.ca6GenJetsNoNu.clone( rParam = 0.8 )

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

addJetCollection(process,
                 labelName='AK4PFCHS',
                 jetSource=cms.InputTag('ak4PFJetsCHS'),
                 algo='ak4',
                 rParam=0.4,
                 jetCorrections=('AK5PFchs',
                                 cms.vstring(
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute']), 'None'))

addJetCollection(process,
                 labelName='CA8PFCHS',
                 jetSource=cms.InputTag('ca8PFJetsCHS'),
                 algo='ca8',
                 rParam=0.8,
                 jetCorrections=('AK7PFchs',
                                 cms.vstring(
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute']), 'None'))
Exemplo n.º 45
0
#process.Tracer = cms.Service('Tracer')

process.load('PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff')
process.load('PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff')
process.load("RecoJets.Configuration.RecoGenJets_cff")
process.load("RecoJets.Configuration.GenJetParticles_cff")

#process.ca8GenJetsNoNu = process.ca6GenJetsNoNu.clone( rParam = 0.8 )

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

addJetCollection(
    process,
    labelName = 'AK4PFCHS',
    jetSource = cms.InputTag('ak4PFJetsCHS'),
    algo = 'ak4',
    rParam = 0.4,
    jetCorrections = ('AK5PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None')
    )

addJetCollection(
    process,
    labelName = 'CA8PFCHS',
    jetSource = cms.InputTag('ca8PFJetsCHS'),
    algo = 'ca8',
    rParam = 0.8,
    jetCorrections = ('AK7PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None')
    )

addJetCollection(
    process,
Exemplo n.º 46
0
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)
    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)
    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

    process.selectedPatJetsForMETUnc = process.selectedPatJets.clone()
    process.selectedPatJetsForMETUnc.cut = cms.string("pt > 15")

    from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
    runMetCorAndUncForMiniAODProduction(process,
                                        metType="PF",
                                        jetCollUnskimmed="patJets",
                                        jetColl="selectedPatJetsForMETUnc")

    #caloMET computation
    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
    addMETCollection(process, labelName="patCaloMet", metSource="caloMetM")

    #noHF pfMET =========
    process.noHFCands = cms.EDFilter(
        "GenericPFCandidateSelector",
        src=cms.InputTag("particleFlow"),
        cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0"))
    runMetCorAndUncForMiniAODProduction(
        process,
        pfCandColl=cms.InputTag("noHFCands"),
        recoMetFromPFCs=True,  #needed for HF removal
        postfix="NoHF")
    process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
    process.slimmedMETsNoHF = process.slimmedMETs.clone()
    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')
    if not hasattr(process, 'pfSecondaryVertexTagInfos'):
        process.load('RecoBTag.SecondaryVertex.pfSecondaryVertexTagInfos_cfi')
    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)
    #
    ## PU JetID
    process.load("RecoJets.JetProducers.PileupJetID_cfi")
    process.patJets.userData.userFloats.src = [
        cms.InputTag("pileupJetId:fullDiscriminant"),
    ]

    ## 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))
    process.patJets.userData.userFloats.src += [
        cms.InputTag("caloJetMap:pt"),
        cms.InputTag("caloJetMap:emEnergyFraction")
    ]

    #EGM object modifications
    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)
    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)

    #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)
    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)

    #---------------------------------------------------------------------------
    #Adding  Boosted Subjets taus
    from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
    addBoostedTaus(process)
    #---------------------------------------------------------------------------

    # Adding puppi jets
    process.load('CommonTools.PileupAlgos.Puppi_cff')
    process.load('RecoJets.JetProducers.ak4PFJetsPuppi_cfi')
    process.ak4PFJetsPuppi.doAreaFastjet = True  # even for standard ak4PFJets this is overwritten in RecoJets/Configuration/python/RecoPFJets_cff
    #process.puppi.candName = cms.InputTag('packedPFCandidates')
    #process.puppi.vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')
    # kind of ugly, is there a better way to do this?
    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))
    process.pfLeptonsPUPPET = cms.EDFilter(
        "PdgIdCandViewSelector",
        src=cms.InputTag("particleFlow"),
        pdgId=cms.vint32(-11, 11, -13, 13),
    )
    process.puppiNoLep = process.puppi.clone()
    process.puppiNoLep.candName = cms.InputTag('pfNoLepPUPPI')

    from RecoJets.JetAssociationProducers.j2tParametersVX_cfi import j2tParametersVX
    process.ak4PFJetsPuppiTracksAssociatorAtVertex = cms.EDProducer(
        "JetTracksAssociatorAtVertex",
        j2tParametersVX,
        jets=cms.InputTag("ak4PFJetsPuppi"))
    process.patJetPuppiCharge = cms.EDProducer(
        "JetChargeProducer",
        src=cms.InputTag("ak4PFJetsPuppiTracksAssociatorAtVertex"),
        var=cms.string('Pt'),
        exp=cms.double(1.0))

    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.userData.userFloats.src = cms.VInputTag(
        cms.InputTag(""))
    process.patJetsPuppi.jetChargeSource = cms.InputTag("patJetPuppiCharge")

    process.selectedPatJetsPuppi.cut = cms.string("pt > 20")

    process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi')
    process.slimmedJetsPuppi = process.slimmedJets.clone()
    process.slimmedJetsPuppi.src = cms.InputTag("selectedPatJetsPuppi")
    process.slimmedJetsPuppi.packedPFCandidates = cms.InputTag(
        "packedPFCandidates")

    ## puppi met
    process.load('RecoMET.METProducers.PFMET_cfi')
    process.puppiForMET = cms.EDProducer("CandViewMerger",
                                         src=cms.VInputTag(
                                             "pfLeptonsPUPPET", "puppiNoLep"))
    process.pfMetPuppi = process.pfMet.clone()
    process.pfMetPuppi.src = cms.InputTag("puppiForMET")
    process.pfMetPuppi.alias = cms.string('pfMetPuppi')
    # type1 correction, from puppi jets
    process.corrPfMetType1Puppi = process.corrPfMetType1.clone(
        src='ak4PFJetsPuppi',
        jetCorrLabel='ak4PFPuppiL2L3Corrector',
    )
    del process.corrPfMetType1Puppi.offsetCorrLabel  # no L1 for PUPPI jets
    process.pfMetT1Puppi = process.pfMetT1.clone(
        src='pfMetPuppi',
        srcCorrections=[cms.InputTag("corrPfMetType1Puppi", "type1")])

    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
    addMETCollection(process,
                     labelName='patMETPuppi',
                     metSource='pfMetT1Puppi')  # T1
    addMETCollection(process,
                     labelName='patPFMetPuppi',
                     metSource='pfMetPuppi')  # RAW

    process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
    process.slimmedMETsPuppi = process.slimmedMETs.clone()
    process.slimmedMETsPuppi.src = cms.InputTag("patMETPuppi")
    process.slimmedMETsPuppi.rawVariation = cms.InputTag(
        "patPFMetPuppi")  # only central value
    # only central values for puppi met
    del process.slimmedMETsPuppi.t01Variation
    del process.slimmedMETsPuppi.t1SmearedVarsAndUncs
    del process.slimmedMETsPuppi.tXYUncForRaw
    del process.slimmedMETsPuppi.tXYUncForT1
    del process.slimmedMETsPuppi.tXYUncForT01
    del process.slimmedMETsPuppi.tXYUncForT1Smear
    del process.slimmedMETsPuppi.tXYUncForT01Smear
    del process.slimmedMETsPuppi.caloMET
#addMETCollection(process, labelName='patMETCalo', metSource='met')
addMETCollection(process, labelName='patMETPF', metSource='pfMetT1')
#addMETCollection(process, labelName='patMETTC', metSource='tcMet') # FIXME: removed from RECO/AOD; needs functionality to add to processing

## uncomment the following line to add different jet collections
## to the event content
from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

## uncomment the following lines to add ak4PFJetsCHS to your PAT output
labelAK4PFCHS = 'AK4PFCHS'
postfixAK4PFCHS = 'Copy'
addJetCollection(
   process,
   postfix   = postfixAK4PFCHS,
   labelName = labelAK4PFCHS,
   jetSource = cms.InputTag('ak4PFJetsCHS'),
   jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2') # FIXME: Use proper JECs, as soon as available
   )
process.out.outputCommands.append( 'drop *_selectedPatJets%s%s_caloTowers_*'%( labelAK4PFCHS, postfixAK4PFCHS ) )

# uncomment the following lines to add ak4PFJets to your PAT output
labelAK4PF = 'AK4PF'
addJetCollection(
   process,
   labelName = labelAK4PF,
   jetSource = cms.InputTag('ak4PFJets'),
   jetCorrections = ('AK4PF', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-1'), # FIXME: Use proper JECs, as soon as available
   btagDiscriminators = [
       'jetBProbabilityBJetTags'
     , 'jetProbabilityBJetTags'
Exemplo n.º 48
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

    # 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
    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).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)

    ## 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, 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, 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 addStandardPuppiJets(process,
                         label       ='',
                         useLocalJEC = True,
                         dbfile      = 'flashgg/MetaData/data/PuppiJEC/PY8_RunIISpring15DR74_bx50_MC.db',
                         debug       = False):

  print  ':: Running a standard PUPPI : --'
  
  from CommonTools.PileupAlgos.Puppi_cff           import puppi 
  from RecoJets.JetProducers.ak4PFJets_cfi         import ak4PFJets
  from PhysicsTools.PatAlgos.tools.jetTools        import addJetCollection
#  from RecoJets.JetProducers.PileupJetIDParams_cfi import cutbased_new as pu_jetid
  from flashgg.MicroAOD.flashggJets_cfi            import flashggBTag
  
  setattr(process, 'flashggStdPuppi' + label,
          puppi.clone( candName    = cms.InputTag('packedPFCandidates'),
                       vertexName  = cms.InputTag('offlineSlimmedPrimaryVertices'),
                     ))
  
  setattr(process, 'ak4PFJetsStdPuppi' + label,
          ak4PFJets.clone ( src = cms.InputTag('flashggStdPuppi'),
                            doAreaFastjet = True
                          ))

  if useLocalJEC :
    print ':: using a local JEC dbfile for PUPPI :',
    print ' -- ',  dbfile
    
    from flashgg.MicroAOD.flashggJetTools_cfi import loadLocalJECDBfile
    loadLocalJECDBfile(process,
                       dbfile = os.environ['CMSSW_BASE'] + '/src/' + dbfile,
                       tag    = 'JetCorrectorParametersCollection_PY8_RunIISpring15DR74_bx50_MC_AK4PUPPI',
                       label  = 'AK4PFPuppi')
    
    
  addJetCollection(
    process,
    postfix            = 'std' + label,
    labelName          = 'AK4PUPPI',
    jetSource          = cms.InputTag('ak4PFJetsStdPuppi'),
    pvSource           = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates       = cms.InputTag('packedPFCandidates'),
    svSource           = cms.InputTag('slimmedSecondaryVertices'),
    btagDiscriminators = [ flashggBTag ],
    jetCorrections     = ('AK4PFchs',['L1FastJet',  'L2Relative', 'L3Absolute'], 'None'),
    genJetCollection   = cms.InputTag('slimmedGenJets'),
    genParticles       = cms.InputTag('prunedGenParticles'),
    # jet param
    algo = 'AK', rParam = 0.4
  )
  
  getattr(process, 'patJetCorrFactorsAK4PUPPIstd' + label).primaryVertices = "offlineSlimmedPrimaryVertices"
  setattr(process, 'flashggStdPUPPIJets',
          cms.EDProducer('FlashggJetProducer',
                         DiPhotonTag           = cms.InputTag('flashggDiPhotons'),
                         VertexTag             = cms.InputTag('offlineSlimmedPrimaryVertices'),
                         JetTag                = cms.InputTag('patJetsAK4PUPPIstd' + label),
                         VertexCandidateMapTag = cms.InputTag("flashggVertexMapForPUPPI"),
                         UsePuppi              = cms.untracked.bool(True),
#                         PileupJetIdParameters = cms.PSet(pu_jetid))
                         )
          )
  setattr(process, 'selectedFlashggStdPUPPIJets' + label,
          cms.EDFilter("FLASHggJetSelector",
                       src = cms.InputTag( 'flashggStdPUPPIJets'),
                       cut = cms.string("pt > 15."))
          )
Exemplo n.º 50
0
process.CA12JetsCA3FilterjetsPF = CA12JetsCA3FilterjetsPF.clone(
    src='pfNoElectronsCHS')
process.CA12JetsCA3FilterjetsPF.jetPtMin = cms.double(180.)
process.CA12JetsCA3FilterjetsPF.doAreaFastjet = cms.bool(False)
process.HEPTopJetsPF = HEPTopJetsPF.clone(src='pfNoElectronsCHS')
process.HEPTopJetsPF.jetPtMin = cms.double(180.)
process.HEPTopJetsPF.doAreaFastjet = cms.bool(True)

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
# add fat CA1.2 pat jet
addJetCollection(process,
                 postfix="",
                 jetSource=cms.InputTag('CA12JetsCA3FilterjetsPF', 'fatjet'),
                 pfCandidates=cms.InputTag('packedPFCandidates'),
                 labelName='CA12PF',
                 trackSource=cms.InputTag('unpackedTracksAndVertices'),
                 pvSource=cms.InputTag('unpackedTracksAndVertices'),
                 btagDiscriminators=None,
                 jetCorrections=None,
                 getJetMCFlavour=False,
                 genJetCollection=None)
# the two subjets that created the mass drop
addJetCollection(process,
                 postfix="",
                 jetSource=cms.InputTag('CA12JetsCA3FilterjetsPF', 'subjets'),
                 pfCandidates=cms.InputTag('packedPFCandidates'),
                 labelName='CA3SubPF',
                 trackSource=cms.InputTag('unpackedTracksAndVertices'),
                 pvSource=cms.InputTag('unpackedTracksAndVertices'),
                 btagDiscriminators=None,
                 jetCorrections=None,
Exemplo n.º 51
0
                                               doAreaFastjet = True, 
                                               rParam = 0.8, 
                                               jetAlgorithm = 'AntiKt' )
jetSeq += process.ak8PFJetsPuppi

process.jetSequence = jetSeq

addJetCollection(
   process,
   #labelName = 'AK8PFCHS',
   labelName = 'AK8PFPuppi',
   #jetSource = cms.InputTag('ak8PFJetsCHS'),
   jetSource = cms.InputTag('ak8PFJetsPuppi'),
   #pvSource = cms.InputTag('offlinePrimaryVertices'),
   #svSource = cms.InputTag('inclusiveCandidateSecondaryVertices'),
   algo = 'AK',
   rParam = 0.8,
   #jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
   jetCorrections = ('AK8PFPuppi', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
   btagDiscriminators = [
      'pfBoostedDoubleSecondaryVertexAK8BJetTags',
      'pfDeepDoubleBvLJetTags:probQCD', 
      'pfDeepDoubleBvLJetTags:probHbb', 
      ]
   )

#process.patJetsAK8PFCHS.addTagInfos = True
process.patJetsAK8PFPuppi.addTagInfos = True

from pdb import set_trace

from PhysicsTools.PatAlgos.patInputFiles_cff import filesRelValTTbarPileUpMINIAODSIM
Exemplo n.º 52
0
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.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))
    process.pfChargedCHS = cms.EDFilter(
        "CandPtrSelector", src=cms.InputTag("packedPFCandidates"), cut=cms.string("fromPV && charge!=0")
    )
    from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets

    process.ak4PFChargedJetsCHS = ak4PFJets.clone(src="pfChargedCHS", doAreaFastjet=True)
    from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection

    addJetCollection(
        process,
        postfix="",
        labelName="AK4ChargedPFCHS",
        jetSource=cms.InputTag("ak4PFChargedJetsCHS"),
        pvSource=cms.InputTag("offlineSlimmedPrimaryVertices"),
        pfCandidates=cms.InputTag("packedPFCandidates"),
        svSource=cms.InputTag("slimmedSecondaryVertices"),
        btagDiscriminators=["None"],
        jetCorrections=("AK4PFchs", [], "None"),
        genJetCollection=cms.InputTag("slimmedGenJets"),
        genParticles=cms.InputTag("prunedGenParticles"),
        algo="AK",
        rParam=0.4,
    )
    process.MessageLogger.cerr.FwkReport.reportEvery = 1000
    process.MINIAODSIMoutput.outputCommands.append("keep patJets_patJetsAK4ChargedPFCHS__RERUN")
    process.p = cms.Path(process.pfChargedCHS * process.ak4PFChargedJetsCHS * process.patJetsAK4ChargedPFCHS)


process.endpath = cms.EndPath(process.MINIAODSIMoutput)

ofile = os.path.expandvars(options.outputFile)
Exemplo n.º 54
0
def addLSJets(process, pfCandLabel="customAK8ConstituentsTable:pfCandsNoLep", runOnMC=False):
    jetCollection = 'FatJetLSCollection'
    tagName = "FatJetLS"
    postfix = "Recluster"
    task = getPatAlgosToolsTask(process)
    addToProcessAndTask(jetCollection, ak8PFJetsPuppi.clone(src = cms.InputTag(pfCandLabel)),
                        process, task)
    getattr(process, jetCollection).jetAlgorithm = 'AntiKt'
    getattr(process, jetCollection).rParam = 0.8

    addJetCollection(process,
                     labelName          = "FatJetLS",
                     postfix            = postfix,
                     jetSource          = cms.InputTag(jetCollection),
                     pvSource           = cms.InputTag("offlineSlimmedPrimaryVertices"),
                     svSource           = cms.InputTag("slimmedSecondaryVertices"),
                     muSource           = cms.InputTag("slimmedMuons"),
                     elSource           = cms.InputTag("slimmedElectrons"),
                     algo               = "AK",
                     rParam             = 0.8,
                     jetCorrections     = ('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
                     pfCandidates       = cms.InputTag(pfCandLabel),
                     genJetCollection   = cms.InputTag("slimmedGenJetsAK8"),
                     genParticles       = cms.InputTag('prunedGenParticles'),
                     getJetMCFlavour    = False,
                     btagDiscriminators = ['pfDeepCSVJetTags:probb','pfDeepCSVJetTags:probbb','pfCombinedInclusiveSecondaryVertexV2BJetTags']
    )

    task = getPatAlgosToolsTask(process)
    addToProcessAndTask(jetCollection+'SoftDrop',
                        ak8PFJetsPuppiSoftDrop.clone( src =cms.InputTag(pfCandLabel),
                                                      rParam=0.8,
                                                      jetAlgorithm='AntiKt',
                                                      useExplicitGhosts=True,
                                                      R0= cms.double(0.8),
                                                      zcut=0.1,
                                                      beta=0,
                                                      doAreaFastjet = cms.bool(True),
                                                      writeCompound = cms.bool(True),
                                                      jetCollInstanceName=cms.string('SubJets') ),
                        process, task)

    task = getPatAlgosToolsTask(process)
    addToProcessAndTask(jetCollection+'SoftDropMass',
                        ak8PFJetsPuppiSoftDropMass.clone( src = cms.InputTag(jetCollection),
                                                          matched = cms.InputTag( jetCollection+'SoftDrop'),
                                                          distMax = cms.double(0.8)),
                        process, task)

    getattr(process,"patJetsFatJetLSRecluster").userData.userFloats.src = [jetCollection+'SoftDropMass']

    addJetCollection(process,
                     labelName          = "FatJetLSSubJets",
                     postfix            = postfix,
                     jetSource          = cms.InputTag(jetCollection+'SoftDrop','SubJets'),
                     pvSource           = cms.InputTag("offlineSlimmedPrimaryVertices"),
                     svSource           = cms.InputTag("slimmedSecondaryVertices"),
                     algo               = 'AK',
                     rParam             = 0.8,
                     btagDiscriminators = ['pfDeepCSVJetTags:probb', 'pfDeepCSVJetTags:probbb','pfCombinedInclusiveSecondaryVertexV2BJetTags'],
                     jetCorrections     = ('AK4PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
                     explicitJTA        = True,  # needed for subjet b tagging                                                                                                                             
                     svClustering       = True, # needed for subjet b tagging                                                                                                                              
                     genJetCollection   = cms.InputTag('slimmedGenJetsAK8SoftDropSubJets'),
                     genParticles       = cms.InputTag('prunedGenParticles'),
                     getJetMCFlavour    = False,
                     fatJets            = cms.InputTag(jetCollection), 
                     groomedFatJets     = cms.InputTag(jetCollection+'SoftDrop')
    )

    selectedPatJetCollection = "selectedPatJets{}{}".format(tagName,postfix)
    task = getPatAlgosToolsTask(process)
    addToProcessAndTask(selectedPatJetCollection+"Packed",
                        cms.EDProducer("BoostedJetMerger",
                                       jetSrc=cms.InputTag(selectedPatJetCollection),
                                       subjetSrc=cms.InputTag("patJetsFatJetLSSubJetsRecluster")),
                        process, task)

    task = getPatAlgosToolsTask(process)
    addToProcessAndTask('packedPatJets'+'FatJetLS',
                        cms.EDProducer("JetSubstructurePacker",
                                       jetSrc=cms.InputTag(selectedPatJetCollection),
                                       distMax = cms.double(0.8),
                                       fixDaughters = cms.bool(False),
                                       algoTags = cms.VInputTag(
                                           cms.InputTag(selectedPatJetCollection+"Packed")
                                       ),
                                       algoLabels =cms.vstring('SoftDrop')),
                        process, task)
    
    updateJetCollection(
        process,
        labelName          = "FatJetLS",
        postfix            = "Final",
        jetSource          = cms.InputTag('packedPatJets'+'FatJetLS'),
        rParam             = 0.8,
        jetCorrections     = ('AK8PFPuppi', ['L2Relative', 'L3Absolute'], 'None'),
        btagDiscriminators = ['pfDeepCSVJetTags:probb','pfDeepCSVJetTags:probbb','pfBoostedDoubleSecondaryVertexAK8BJetTags',
                              'pfCombinedInclusiveSecondaryVertexV2BJetTags',
                          ]
    )

    patJetFinalCollection="selectedUpdatedPatJets{}{}".format(tagName,"Final")

    process.customAK8LSTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
                                              src= cms.InputTag("selectedUpdatedPatJetsFatJetLSFinal"),
                                              cut = cms.string(""),
                                              name = cms.string("FatJetLS"),
                                              doc = cms.string("Lepton subtracted fat jets"),
                                              singleton = cms.bool(False),
                                              extension = cms.bool(False),
                                              variables = cms.PSet(P4Vars,
                                                                   msoftdropraw = Var("userFloat('FatJetLSCollectionSoftDropMass')", float, doc="raw soft drop mass",precision=10),
                                                               )
                                          )

    process.customAK8LSsubjetTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
                                                    src = cms.InputTag(jetCollection+'SoftDrop',"SubJets"),
                                                    cut = cms.string(""),
                                                    name = cms.string("FatJetLSSubJet"),
                                                    doc = cms.string("Lepton subtracted fat jets sub jets"),
                                                    singleton = cms.bool(False),
                                                    extension = cms.bool(False),
                                                    variables = cms.PSet(P4Vars,
                                                                     )
                                                )
Exemplo n.º 55
0
def addFlashggPFCHSJets(process, 
                        isData,
                        vertexIndex = 0, 
                        #doQGTagging = True, 
                        label ='', 
                        debug = False):
  setattr(process, 'selectedMuons' + label, cms.EDFilter("CandPtrSelector", 
                                                         src = cms.InputTag("slimmedMuons"), 
                                                         cut = cms.string('''abs(eta)<2.5 && pt>10. &&
                                                         (pfIsolationR04().sumChargedHadronPt+
                                                         max(0.,pfIsolationR04().sumNeutralHadronEt+
                                                         pfIsolationR04().sumPhotonEt-
                                                         0.50*pfIsolationR04().sumPUPt))/pt < 0.20 && 
                                                         (isPFMuon && (isGlobalMuon || isTrackerMuon) )''')))
  
  setattr(process, 'selectedElectrons' + label, cms.EDFilter("CandPtrSelector", 
                                                             src = cms.InputTag("slimmedElectrons"), 
                                                             cut = cms.string('''abs(eta)<2.5 && pt>20. &&
                                                             gsfTrack.isAvailable() &&
                                                             gsfTrack.hitPattern().numberOfLostHits(\'MISSING_INNER_HITS\') < 2 &&
                                                             (pfIsolationVariables().sumChargedHadronPt+
                                                             max(0.,pfIsolationVariables().sumNeutralHadronEt+
                                                             pfIsolationVariables().sumPhotonEt-
                                                             0.5*pfIsolationVariables().sumPUPt))/pt < 0.15''')))
  
  # Simple producer which just removes the Candidates which
  # don't come from the legacy vertex according to the Flashgg Vertex Map
  setattr(process,'flashggCHSLegacyVertexCandidates' + label,
          cms.EDProducer('FlashggMultiCHSLegacyVertexCandProducer',
                         PFCandidatesTag       = cms.InputTag('packedPFCandidates'),
                         DiPhotonTag           = cms.InputTag('flashggDiPhotons'),
                         VertexCandidateMapTag = cms.InputTag("flashggVertexMapForCHS"),
                         VertexTag             = cms.InputTag('offlineSlimmedPrimaryVertices'),
                         vertexIndex           = cms.uint32(vertexIndex),
                         debug                 = cms.untracked.bool(debug)
                       )
  )
  
  setattr(process, 'pfCHSLeg' + label, cms.EDFilter("CandPtrSelector", 
                                                    src = cms.InputTag('flashggCHSLegacyVertexCandidates' + label), 
                                                    cut = cms.string('')))
  
  # then remove the previously selected muons
  setattr(process, 'pfNoMuonCHSLeg' + label,  cms.EDProducer("CandPtrProjector", 
                                                             src  = cms.InputTag("pfCHSLeg" + label), 
                                                             veto = cms.InputTag("selectedMuons" + label)))
  # then remove the previously selected electrons
  setattr(process, 'pfNoElectronsCHSLeg' + label,  cms.EDProducer("CandPtrProjector", 
                                                                  src  = cms.InputTag("pfNoMuonCHSLeg" + label), 
                                                                  veto = cms.InputTag("selectedElectrons" + label)))
  
  #Import RECO jet producer for ak4 PF and GEN jet
  from RecoJets.JetProducers.ak4PFJets_cfi  import ak4PFJets
  setattr(process, 'ak4PFJetsCHSLeg' + label, ak4PFJets.clone ( src = 'pfNoElectronsCHSLeg' + label, doAreaFastjet = True))

  if isData:
    JECs = ['L1FastJet', 'L2Relative', 'L3Absolute','L2L3Residual']
  else:
    JECs = ['L1FastJet', 'L2Relative', 'L3Absolute']
    
  # NOTE: this is the 74X recipe for the jet clustering
  addJetCollection(
    process,
    postfix        = label,
    labelName      = 'AK4PFCHSLeg',
    jetSource      = cms.InputTag('ak4PFJetsCHSLeg' + label),
    pvSource       = cms.InputTag('offlineSlimmedPrimaryVertices'),
    pfCandidates   = cms.InputTag('packedPFCandidates'),
    svSource       = cms.InputTag('slimmedSecondaryVertices'),
    btagDiscriminators = [ flashggBTag ],
    jetCorrections = ('AK4PFchs', JECs, 'None'),
    genJetCollection = cms.InputTag('slimmedGenJets'),
    genParticles     = cms.InputTag('prunedGenParticles'),
    # jet param
    algo = 'AK', rParam = 0.4
  )
  
  #adjust PV used for Jet Corrections
  #process.patJetCorrFactorsAK4PFCHSLeg.primaryVertices = "offlineSlimmedPrimaryVertices"
  getattr(process, 'patJetCorrFactorsAK4PFCHSLeg' + label).primaryVertices = "offlineSlimmedPrimaryVertices"
  
  if not hasattr(process,"QGPoolDBESSource"):
    process.QGPoolDBESSource = cms.ESSource("PoolDBESSource",
                                            CondDBSetup,
                                            toGet = cms.VPSet(),
                                            connect = cms.string('sqlite:QGL_'+qgDatabaseVersion+'.db') 
                                            )
    process.es_prefer_qg = cms.ESPrefer('PoolDBESSource','QGPoolDBESSource')
  
  for type in ['AK4PFchs']:#,'AK4PFchs_antib']:
    process.QGPoolDBESSource.toGet.extend(cms.VPSet(cms.PSet(
          record = cms.string('QGLikelihoodRcd'),
          tag    = cms.string('QGLikelihoodObject_'+qgDatabaseVersion+'_'+type),
          label  = cms.untracked.string('QGL_'+type)
          )))
  
  from RecoJets.JetProducers.QGTagger_cfi import QGTagger
  setattr( process, 'QGTaggerPFCHS' + label,  
           QGTagger.clone( srcJets   = 'patJetsAK4PFCHSLeg' + label ,jetsLabel = 'QGL_AK4PFchs', vertexIndex = cms.uint32(vertexIndex),
                           srcVertexCollection = 'offlineSlimmedPrimaryVertices'))

  from RecoJets.JetProducers.PileupJetIDParams_cfi import full_80x_chs
  
  flashggJets = cms.EDProducer('FlashggJetProducer',
                               DiPhotonTag = cms.InputTag('flashggDiPhotons'),
                               VertexTag   = cms.InputTag('offlineSlimmedPrimaryVertices'),
                               JetTag      = cms.InputTag('patJetsAK4PFCHSLeg' + label),
                               VertexCandidateMapTag = cms.InputTag("flashggVertexMapForCHS"),
                               qgVariablesInputTag   = cms.InputTag('QGTaggerPFCHS'+label, 'qgLikelihood'),
                               ComputeSimpleRMS = cms.bool(True),
                               PileupJetIdParameters = full_80x_chs,
                               rho     = cms.InputTag("fixedGridRhoFastjetAll"),
                               JetCollectionIndex = cms.uint32(vertexIndex),
                               Debug = cms.untracked.bool(False)
                               )
  setattr( process, 'flashggPFCHSJets'+ label, flashggJets)

  # randomize Jets
  from flashgg.MicroAOD.flashggRandomizedJetProducer_cfi import flashggRandomizedJets
  flashggRandomizedPFCHSJets = flashggRandomizedJets.clone()
  flashggRandomizedPFCHSJets.src = "flashggPFCHSJets" + label
  setattr(process.RandomNumberGeneratorService, 'flashggRandomizedPFCHSJets' + label, cms.PSet(initialSeed = cms.untracked.uint32(36423784 + int(label))))
  setattr( process, 'flashggRandomizedPFCHSJets' + label, flashggRandomizedPFCHSJets )

  flashggSelectedJets = cms.EDFilter("FLASHggJetSelector",
                                     src = cms.InputTag( 'flashggRandomizedPFCHSJets' + label ),
                                     cut = cms.string("pt > 15.")
  )
  setattr( process, 'flashggSelectedPFCHSJets'+label, flashggSelectedJets )
Exemplo n.º 56
0
## uncomment the following line to add different jet collections
## to the event content
from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

## uncomment the following lines to add ak4PFJetsCHS to your PAT output
addJetCollection(
    process,
    labelName='AK4PFCHS',
    jetSource=cms.InputTag('ak4PFJetsCHS'),
    algo='ak',
    rParam=0.4,
    jetCorrections=('AK5PFchs',
                    cms.vstring(['L1FastJet', 'L2Relative',
                                 'L3Absolute']), 'Type-1'),
    btagDiscriminators=[
        'jetBProbabilityBJetTags', 'jetProbabilityBJetTags',
        'trackCountingHighPurBJetTags', 'trackCountingHighEffBJetTags',
        'simpleSecondaryVertexHighEffBJetTags',
        'simpleSecondaryVertexHighPurBJetTags',
        'combinedSecondaryVertexBJetTags'
    ],
    btagInfos=['secondaryVertexTagInfos'])

addJetCollection(process,
                 labelName='CA8PFCHS',
                 jetSource=cms.InputTag('ca8PFJetsCHS'),
                 algo='ca',
                 rParam=0.8,
                 jetCorrections=('AK7PFchs',
Exemplo n.º 57
0
process.ak12PFJetsCHSTrimmed = process.ak8PFJetsCHSTrimmed.clone(rParam = 1.2)
process.ak12PFJetsCHSFiltered = process.ak8PFJetsCHSFiltered.clone(rParam = 1.2)

process.ak15PFJetsCHSPruned = process.ak8PFJetsCHSPruned.clone(rParam = 1.5)
process.ak15PFJetsCHSTrimmed = process.ak8PFJetsCHSTrimmed.clone(rParam = 1.5)
process.ak15PFJetsCHSFiltered = process.ak8PFJetsCHSFiltered.clone(rParam = 1.5)

from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

addJetCollection(
    process,
    labelName = 'AK4PFCHS',
    jetSource = cms.InputTag('ak4PFJetsCHS'),
    algo = 'ak4',
    rParam = 0.4,
    jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
    trackSource = cms.InputTag('unpackedTracksAndVertices'),
    pvSource = cms.InputTag('unpackedTracksAndVertices'),
    btagDiscriminators = ['combinedSecondaryVertexBJetTags'],
    )

addJetCollection(
    process,
    labelName = 'AK8PFCHS',
    jetSource = cms.InputTag('ak8PFJetsCHS'),
    algo = 'ak8',
    rParam = 0.8,
    jetCorrections = ('AK8PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
    trackSource = cms.InputTag('unpackedTracksAndVertices'),
    pvSource = cms.InputTag('unpackedTracksAndVertices'),
Exemplo n.º 58
0
    def addRecoJetCollection(
        self,
        proc,
        jet,
        inputCollection="",
        genJetsCollection="",
        minPt=5.,
        bTagDiscriminators=None,
        JETCorrLevels=None,
    ):
        print(
            "jetCollectionTools::RecoJetAdder::addRecoJetCollection: Adding Reco Jet Collection: {}"
            .format(jet))

        currentTasks = []

        if inputCollection and inputCollection not in [
                "slimmedJets",
                "slimmedJetsAK8",
                "slimmedJetsPuppi",
                "slimmedCaloJets",
        ]:
            raise RuntimeError("Invalid input collection: %s" %
                               inputCollection)

        if bTagDiscriminators is None:
            bTagDiscriminators = self.bTagDiscriminators

        if JETCorrLevels is None:
            JETCorrLevels = self.JETCorrLevels

        #
        # Decide which jet collection we're dealing with
        #
        recoJetInfo = RecoJetInfo(jet, inputCollection)
        jetLower = recoJetInfo.jetLower
        jetUpper = recoJetInfo.jetUpper
        tagName = recoJetInfo.jetTagName

        if inputCollection == "slimmedJets":
            assert (jetLower == "ak4pfchs")
        elif inputCollection == "slimmedJetsAK8":
            assert (jetLower == "ak8pfpuppi")
        elif inputCollection == "slimmedJetsPuppi":
            assert (jetLower == "ak4pfpuppi")
        elif inputCollection == "slimmedCaloJets":
            assert (jetLower == "ak4calo")

        #=======================================================
        #
        # If jet collection in MiniAOD is not
        # specified, build the jet collection.
        #
        #========================================================
        if not inputCollection or recoJetInfo.doCalo:
            print(
                "jetCollectionTools::RecoJetAdder::addRecoJetCollection: inputCollection not specified. Building recojet collection now"
            )

            #=======================================================
            #
            # Prepare the inputs to jet clustering
            #
            #========================================================
            #
            # Set up PF candidates
            #
            pfCand = self.pfLabel
            #
            # Setup PU method for PF candidates
            #
            if recoJetInfo.jetPUMethod not in ["", "cs"]:
                pfCand += recoJetInfo.jetPUMethod
            #
            #
            #
            if pfCand not in self.prerequisites:
                #
                # Skip if no PU Method or CS specified
                #
                if recoJetInfo.jetPUMethod in ["", "cs"]:
                    pass
                #
                # CHS
                #
                elif recoJetInfo.jetPUMethod == "chs":
                    setattr(
                        proc, pfCand,
                        cms.EDFilter(
                            "CandPtrSelector",
                            src=cms.InputTag(self.pfLabel),
                            cut=cms.string("fromPV"),
                        ))
                    self.prerequisites.append(pfCand)
                #
                # PUPPI
                #
                elif recoJetInfo.jetPUMethod == "puppi":
                    setattr(
                        proc, pfCand,
                        puppi.clone(
                            candName=self.pfLabel,
                            vertexName=self.pvLabel,
                        ))
                    self.prerequisites.append(pfCand)
                #
                # Softkiller
                #
                elif recoJetInfo.jetPUMethod == "sk":
                    setattr(
                        proc, pfCand,
                        softKiller.clone(
                            PFCandidates=self.pfLabel,
                            rParam=recoJetInfo.jetSizeNr,
                        ))
                    self.prerequisites.append(pfCand)
                else:
                    raise RuntimeError(
                        "Currently unsupported PU method: '%s'" %
                        recoJetInfo.jetPUMethod)

            #============================================
            #
            # Create the recojet collection
            #
            #============================================
            if not recoJetInfo.doCalo:
                jetCollection = '{}Collection'.format(tagName)

                if jetCollection in self.main:
                    raise ValueError("Step '%s' already implemented" %
                                     jetCollection)

                setattr(
                    proc, jetCollection,
                    ak4PFJetsCS.clone(
                        src=pfCand,
                        doAreaFastjet=True,
                        jetPtMin=minPt,
                        jetAlgorithm=supportedJetAlgos[recoJetInfo.jetAlgo],
                        rParam=recoJetInfo.jetSizeNr,
                        useConstituentSubtraction=recoJetInfo.doCS,
                        csRParam=0.4 if recoJetInfo.doCS else -1.,
                        csRho_EtaMax=PFJetParameters.Rho_EtaMax
                        if recoJetInfo.doCS else -1.,
                        useExplicitGhosts=recoJetInfo.doCS
                        or recoJetInfo.jetPUMethod == "sk",
                    ))
                currentTasks.append(jetCollection)
            else:
                jetCollection = inputCollection

            #
            # PATify
            #
            if recoJetInfo.jetPUMethod == "puppi":
                jetCorrLabel = "Puppi"
            elif recoJetInfo.jetPUMethod in ["cs", "sk"]:
                jetCorrLabel = "chs"
            else:
                jetCorrLabel = recoJetInfo.jetPUMethod

            #
            # Jet correction
            #
            jetCorrections = (
                "{}{}{}{}".format(
                    recoJetInfo.jetAlgo.upper(), recoJetInfo.jetSize, "Calo"
                    if recoJetInfo.doCalo else recoJetInfo.jetReco.upper(),
                    jetCorrLabel),
                JETCorrLevels,
                "None",
            )

            addJetCollection(
                proc,
                labelName=tagName,
                jetSource=cms.InputTag(jetCollection),
                algo=recoJetInfo.jetAlgo,
                rParam=recoJetInfo.jetSizeNr,
                pvSource=cms.InputTag(self.pvLabel),
                pfCandidates=cms.InputTag(self.pfLabel),
                svSource=cms.InputTag(self.svLabel),
                muSource=cms.InputTag(self.muLabel),
                elSource=cms.InputTag(self.elLabel),
                btagDiscriminators=bTagDiscriminators
                if not recoJetInfo.doCalo else ["None"],
                jetCorrections=jetCorrections,
                genJetCollection=cms.InputTag(genJetsCollection),
                genParticles=cms.InputTag(self.gpLabel),
            )

            getJetMCFlavour = not recoJetInfo.doCalo and recoJetInfo.jetPUMethod != "cs"

            if not self.runOnMC:  #Remove modules for Gen-level object matching
                delattr(proc, 'patJetGenJetMatch{}'.format(tagName))
                delattr(proc, 'patJetPartonMatch{}'.format(tagName))
                getJetMCFlavour = False

            setattr(getattr(proc, "patJets{}".format(tagName)),
                    "getJetMCFlavour", cms.bool(getJetMCFlavour))
            setattr(getattr(proc, "patJetCorrFactors{}".format(tagName)),
                    "payload", cms.string(recoJetInfo.jetCorrPayload))
            selJet = "selectedPatJets{}".format(tagName)
        else:
            selJet = inputCollection

        if not recoJetInfo.skipUserData:
            #
            #
            #
            jercVar = "jercVars{}".format(tagName)
            if jercVar in self.main:
                raise ValueError("Step '%s' already implemented" % jercVar)
            setattr(proc, jercVar, proc.jercVars.clone(srcJet=selJet))
            currentTasks.append(jercVar)
            #
            # JetID Loose
            #
            looseJetId = "looseJetId{}".format(tagName)
            if looseJetId in self.main:
                raise ValueError("Step '%s' already implemented" % looseJetId)
            setattr(
                proc, looseJetId,
                proc.looseJetId.clone(
                    src=selJet,
                    filterParams=proc.looseJetId.filterParams.clone(
                        version="WINTER16"),
                ))
            currentTasks.append(looseJetId)
            #
            # JetID Tight
            #
            tightJetId = "tightJetId{}".format(tagName)
            if tightJetId in self.main:
                raise ValueError("Step '%s' already implemented" % tightJetId)
            setattr(
                proc, tightJetId,
                proc.tightJetId.clone(
                    src=selJet,
                    filterParams=proc.tightJetId.filterParams.clone(
                        version="SUMMER18{}".format(
                            "PUPPI" if recoJetInfo.jetPUMethod ==
                            "puppi" else "")),
                ))
            tightJetIdObj = getattr(proc, tightJetId)
            run2_jme_2016.toModify(tightJetIdObj.filterParams,
                                   version="WINTER16")
            run2_jme_2017.toModify(
                tightJetIdObj.filterParams,
                version='WINTER17{}'.format(
                    "PUPPI" if recoJetInfo.jetPUMethod == "puppi" else ""))
            currentTasks.append(tightJetId)
            #
            # JetID TightLepVeto
            #
            tightJetIdLepVeto = "tightJetIdLepVeto{}".format(tagName)
            if tightJetIdLepVeto in self.main:
                raise ValueError("Step '%s' already implemented" %
                                 tightJetIdLepVeto)
            setattr(
                proc, tightJetIdLepVeto,
                proc.tightJetIdLepVeto.clone(
                    src=selJet,
                    filterParams=proc.tightJetIdLepVeto.filterParams.clone(
                        version="SUMMER18{}".format(
                            "PUPPI" if recoJetInfo.jetPUMethod ==
                            "puppi" else "")),
                ))
            tightJetIdLepVetoObj = getattr(proc, tightJetIdLepVeto)
            run2_jme_2016.toModify(tightJetIdLepVetoObj.filterParams,
                                   version="WINTER16")
            run2_jme_2017.toModify(
                tightJetIdLepVetoObj.filterParams,
                version='WINTER17{}'.format(
                    "PUPPI" if recoJetInfo.jetPUMethod == "puppi" else ""),
            )
            currentTasks.append(tightJetIdLepVeto)
            #
            #
            #
            selectedPatJetsWithUserData = "{}WithUserData".format(selJet)
            if selectedPatJetsWithUserData in self.main:
                raise ValueError("Step '%s' already implemented" %
                                 selectedPatJetsWithUserData)
            setattr(
                proc, selectedPatJetsWithUserData,
                cms.EDProducer(
                    "PATJetUserDataEmbedder",
                    src=cms.InputTag(selJet),
                    userFloats=cms.PSet(
                        jercCHPUF=cms.InputTag(
                            "{}:chargedHadronPUEnergyFraction".format(
                                jercVar)),
                        jercCHF=cms.InputTag(
                            "{}:chargedHadronCHSEnergyFraction".format(
                                jercVar)),
                    ),
                    userInts=cms.PSet(
                        tightId=cms.InputTag(tightJetId),
                        tightIdLepVeto=cms.InputTag(tightJetIdLepVeto),
                    ),
                ))
            selectedPatJetsWithUserDataObj = getattr(
                proc, selectedPatJetsWithUserData)
            run2_jme_2016.toModify(
                selectedPatJetsWithUserDataObj.userInts,
                looseId=cms.InputTag(looseJetId),
            )
            currentTasks.append(selectedPatJetsWithUserData)
        else:
            selectedPatJetsWithUserData = "selectedPatJets{}".format(tagName)

        #
        # Not sure why we can't re-use patJetCorrFactors* created by addJetCollection()
        # (even cloning doesn't work) Let's just create our own
        #
        jetCorrFactors = "jetCorrFactors{}".format(tagName)
        if jetCorrFactors in self.main:
            raise ValueError("Step '%s' already implemented" % jetCorrFactors)

        setattr(
            proc, jetCorrFactors,
            patJetCorrFactors.clone(
                src=selectedPatJetsWithUserData,
                levels=JETCorrLevels,
                primaryVertices=self.pvLabel,
                payload=recoJetInfo.jetCorrPayload,
                rho="fixedGridRhoFastjetAll{}".format(
                    "Calo" if recoJetInfo.doCalo else ""),
            ))
        currentTasks.append(jetCorrFactors)

        updatedJets = "updatedJets{}".format(tagName)
        if updatedJets in self.main:
            raise ValueError("Step '%s' already implemented" % updatedJets)

        setattr(
            proc, updatedJets,
            updatedPatJets.clone(
                addBTagInfo=False,
                jetSource=selectedPatJetsWithUserData,
                jetCorrFactorsSource=[jetCorrFactors],
            ))
        currentTasks.append(updatedJets)

        self.main.extend(currentTasks)

        return recoJetInfo
Exemplo n.º 59
0
addJetCollection(
   process,
   labelName = 'AK5PF',
   jetSource = cms.InputTag('ak5PFJets'),
   jetCorrections = ('AK5PF', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
   btagDiscriminators = [
       'jetBProbabilityBJetTags'
      ,'jetProbabilityBJetTags'
      ,'trackCountingHighPurBJetTags'
      ,'trackCountingHighEffBJetTags'
      ,'negativeOnlyJetBProbabilityJetTags'
      ,'negativeOnlyJetProbabilityJetTags'
      ,'negativeTrackCountingHighEffJetTags'
      ,'negativeTrackCountingHighPurJetTags'
      ,'positiveOnlyJetBProbabilityJetTags'
      ,'positiveOnlyJetProbabilityJetTags'
      ,'simpleSecondaryVertexHighEffBJetTags'
      ,'simpleSecondaryVertexHighPurBJetTags'
      ,'simpleSecondaryVertexNegativeHighEffBJetTags'
      ,'simpleSecondaryVertexNegativeHighPurBJetTags'
      ,'combinedSecondaryVertexBJetTags'
      ,'combinedSecondaryVertexPositiveBJetTags'
      #,'combinedSecondaryVertexV1BJetTags'
      #,'combinedSecondaryVertexV1PositiveBJetTags'
      ,'combinedSecondaryVertexMVABJetTags'
      ,'combinedSecondaryVertexNegativeBJetTags'
      #,'combinedSecondaryVertexV1NegativeBJetTags'
      ,'softPFMuonBJetTags'
      ,'softPFMuonByPtBJetTags'
      ,'softPFMuonByIP3dBJetTags'
      ,'softPFMuonByIP2dBJetTags'
      ,'positiveSoftPFMuonBJetTags'
      ,'positiveSoftPFMuonByPtBJetTags'
      ,'positiveSoftPFMuonByIP3dBJetTags'
      ,'positiveSoftPFMuonByIP2dBJetTags'
      ,'negativeSoftPFMuonBJetTags'
      ,'negativeSoftPFMuonByPtBJetTags'
      ,'negativeSoftPFMuonByIP3dBJetTags'
      ,'negativeSoftPFMuonByIP2dBJetTags'
      ,'softPFElectronBJetTags'
      ,'softPFElectronByPtBJetTags'
      ,'softPFElectronByIP3dBJetTags'
      ,'softPFElectronByIP2dBJetTags'
      ,'positiveSoftPFElectronBJetTags'
      ,'positiveSoftPFElectronByPtBJetTags'
      ,'positiveSoftPFElectronByIP3dBJetTags'
      ,'positiveSoftPFElectronByIP2dBJetTags'
      ,'negativeSoftPFElectronBJetTags'
      ,'negativeSoftPFElectronByPtBJetTags'
      ,'negativeSoftPFElectronByIP3dBJetTags'
      ,'negativeSoftPFElectronByIP2dBJetTags'
      ,'simpleInclusiveSecondaryVertexHighEffBJetTags'
      ,'simpleInclusiveSecondaryVertexHighPurBJetTags'
      ,'doubleSecondaryVertexHighEffBJetTags'
      ,'combinedInclusiveSecondaryVertexBJetTags'
      ,'combinedInclusiveSecondaryVertexPositiveBJetTags'
      #,'combinedMVABJetTags'
      ,'positiveCombinedMVABJetTags'
      ,'negativeCombinedMVABJetTags'
      #,'combinedSecondaryVertexSoftPFLeptonV1BJetTags'
      #,'positiveCombinedSecondaryVertexSoftPFLeptonV1BJetTags'
      #,'negativeCombinedSecondaryVertexSoftPFLeptonV1BJetTags'
    ],
  )
## uncomment the following line to add different jet collections
## to the event content
from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
from PhysicsTools.PatAlgos.tools.jetTools import switchJetCollection

#runOn62 = True
runOn62 = False

## uncomment the following lines to add ak5PFJetsCHS to your PAT output
labelAK5PFCHS = 'AK5PFCHS'
postfixAK5PFCHS = 'Copy'
addJetCollection(process,
                 postfix=postfixAK5PFCHS,
                 labelName=labelAK5PFCHS,
                 jetSource=cms.InputTag('ak5PFJetsCHS'),
                 jetCorrections=('AK5PFchsOwca',
                                 cms.vstring(
                                     ['L1FastJet', 'L2Relative',
                                      'L3Absolute']), 'Type-2'))
process.out.outputCommands.append('drop *_selectedPatJets%s%s_caloTowers_*' %
                                  (labelAK5PFCHS, postfixAK5PFCHS))

if not runOn62:
    # ak4PFJetsCHS
    labelAK4PFCHS = 'AK4PFCHS'
    postfixAK4PFCHS = 'Copy'
    addJetCollection(
        process,
        postfix=postfixAK4PFCHS,
        labelName=labelAK4PFCHS,
        jetSource=cms.InputTag('ak4PFJetsCHS'),