Exemplo n.º 1
0
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
process.load(
    'Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff'
)
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load("CondCore.DBCommon.CondDBCommon_cfi")

from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
#process.GlobalTag = GlobalTag(process.GlobalTag, '80X_mcRun2_asymptotic_2016_miniAODv2_v1', '')
process.GlobalTag = GlobalTag(process.GlobalTag, '80X_mcRun2_asymptotic_v20',
                              '')
process.HiForest.GlobalTagLabel = process.GlobalTag.globaltag

# Customization
from HeavyIonsAnalysis.Configuration.CommonFunctions_cff import overrideJEC_pPb8TeV
process = overrideJEC_pPb8TeV(process)

process.GlobalTag.toGet.extend([
    cms.PSet(
        record=cms.string("HeavyIonRcd"),
        #tag = cms.string("CentralityTable_HFtowersPlusTrunc200_EPOS8TeV_v80x01_mc"),
        tag=cms.string(
            "CentralityTable_HFtowersPlusTrunc200_EPOS5TeV_v80x01_mc"),
        connect=cms.string("frontier://FrontierProd/CMS_CONDITIONS"),
        label=cms.untracked.string("HFtowersPlusTruncEpos")),
    cms.PSet(record=cms.string("L1TGlobalPrescalesVetosRcd"),
             tag=cms.string("L1TGlobalPrescalesVetos_Stage2v0_hlt"),
             connect=cms.string("frontier://FrontierProd/CMS_CONDITIONS"))
])

#####################################################################################
process.load('Configuration.StandardSequences.Services_cff')
process.load('Configuration.Geometry.GeometryDB_cff')
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load("CondCore.DBCommon.CondDBCommon_cfi")
 
from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, '80X_mcRun2_asymptotic_2016_miniAODv2_v1', '')
process.HiForest.GlobalTagLabel = process.GlobalTag.globaltag


# Customization
from HeavyIonsAnalysis.Configuration.CommonFunctions_cff import overrideJEC_pPb8TeV
process = overrideJEC_pPb8TeV(process)

process.GlobalTag.toGet.extend([
	cms.PSet(record = cms.string("HeavyIonRcd"),
		 #tag = cms.string("CentralityTable_HFtowersPlusTrunc200_EPOS8TeV_v80x01_mc"),
                 tag = cms.string("CentralityTable_HFtowersPlusTrunc200_EPOS5TeV_v80x01_mc"),
                 connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS"),
                 label = cms.untracked.string("HFtowersPlusTruncEpos")
             ),
	cms.PSet(record = cms.string("L1TGlobalPrescalesVetosRcd"),
                tag = cms.string("L1TGlobalPrescalesVetos_Stage2v0_hlt"),
                connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS")
                )
])

#####################################################################################
Exemplo n.º 3
0
def miniAOD_ForHiEWQ_customizeCommon(process, isData):
    # Add JEC for pPb 8 TeV
    overrideJEC_pPb8TeV(process)
    # Add MET Filters
    includeMETFilters(process)
    # Apply trigger matching
    applyTriggerMatching(process)

    process.patMuons.isoDeposits = cms.PSet()
    process.patElectrons.isoDeposits = cms.PSet()
    process.patTaus.isoDeposits = cms.PSet()
    process.patPhotons.isoDeposits = cms.PSet()
    #
    process.patMETs.srcJetResPhi = cms.string('AK4PF_phi')
    process.patMETs.srcJetResPt = cms.string('AK4PF_pt')
    process.patMETs.srcJetSF = cms.string('AK4PF')
    #
    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")
    #

    if isData:
        process.load("HeavyIonsAnalysis.JetAnalysis.FullJetSequence_DataPPb")
    else:
        process.load("HeavyIonsAnalysis.JetAnalysis.FullJetSequence_JECPPb")

    # make ak4PF jets the baseline jets
    process.patJets = process.ak4PFpatJetsWithBtagging.clone()

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

    #
    # apply type I + other PFMEt corrections to pat::MET object
    # and estimate systematic uncertainties on MET

    # pfMET from ak4PF jets
    from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
    runMetCorAndUncForMiniAODProduction(
        process,
        metType="PF",
        jetCollUnskimmed="ak4PFpatJetsWithBtagging",
        jetFlavor="AK4PF_offline",
        postfix="")

    #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
        jetCollUnskimmed="ak4PFpatJetsWithBtagging",
        jetFlavor="AK4PF_offline",
        jetSelection="pt>15 && abs(eta)<3.",
        postfix="NoHF")
    process.corrPfMetType1NoHF.src = cms.InputTag("ak4PFJets")

    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)

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

    # REMOVE PUPPI FROM HELL !!!!!!!!!!!!
    process.packedPFCandidates.PuppiSrc = ''
    process.packedPFCandidates.PuppiNoLepSrc = ''
    # REMOVE AK8 JETS !!!!!!!!!!!!
    del process.slimmedJetsAK8
    #---------------------------------------------------------------------------
    #Ignore  Boosted Subjets taus
    #from RecoTauTag.Configuration.boostedHPSPFTaus_cfi import addBoostedTaus
    #addBoostedTaus(process)
    #---------------------------------------------------------------------------
    #Ignore noHF pfMET =========
    ## Ignore Legacy tight b-tag track selection

    from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag, massSearchReplaceParam
    listSeq = [
        cms.Sequence(process.patCaloMet + process.ak4PFL1OffsetCorrector),
        process.pfBTagging, process.patCandidates,
        process.ak4PFL1FastL2L3ResidualCorrectorChain,
        process.patMETCorrections, process.patMETCorrectionsNoHF,
        process.fullPatMetSequence, process.fullPatMetSequenceNoHF
    ]
    for seq in listSeq:
        massSearchReplaceAnyInputTag(seq,
                                     cms.InputTag("ak4PFJetsCHS"),
                                     cms.InputTag("ak4PFJets"),
                                     skipLabelTest=True)
        massSearchReplaceAnyInputTag(seq,
                                     cms.InputTag("AK4PFchs"),
                                     cms.InputTag("AK4PF_offline"),
                                     skipLabelTest=True)
        massSearchReplaceAnyInputTag(seq,
                                     cms.InputTag("AK4PF"),
                                     cms.InputTag("AK4PF_offline"),
                                     skipLabelTest=True)
        massSearchReplaceParam(seq, "algorithm", cms.string('AK4PF'),
                               cms.string('AK4PF_offline'))
        massSearchReplaceParam(seq, "algorithm", cms.string('AK4PFchs'),
                               cms.string('AK4PF_offline'))
        massSearchReplaceParam(seq, "payload", cms.string('AK4PFchs'),
                               cms.string('AK4PF_offline'))
        massSearchReplaceParam(seq, "payload", cms.string('AK4PF'),
                               cms.string('AK4PF_offline'))
        massSearchReplaceAnyInputTag(seq,
                                     cms.InputTag("L2L3Residual"),
                                     cms.InputTag("L3Absolute"),
                                     skipLabelTest=True)
        massSearchReplaceAnyInputTag(seq,
                                     cms.InputTag("L1FastJet"),
                                     cms.InputTag(''),
                                     skipLabelTest=True)
        massSearchReplaceAnyInputTag(
            seq,
            cms.InputTag("ak4PFL1FastL2L3ResidualCorrector"),
            cms.InputTag('ak4PFL1FastL2L3Corrector'),
            skipLabelTest=True)
        massSearchReplaceParam(seq, "addResidualJES", cms.bool(True),
                               cms.bool(False))
        massSearchReplaceAnyInputTag(seq,
                                     cms.InputTag("AK4PFchs_pt"),
                                     cms.InputTag("AK4PF_pt"),
                                     skipLabelTest=True)
        massSearchReplaceAnyInputTag(seq,
                                     cms.InputTag("AK4PFchs_phi"),
                                     cms.InputTag("AK4PF_phi"),
                                     skipLabelTest=True)
        massSearchReplaceParam(seq, "srcJetResPt", cms.string('AK4PFchs_pt'),
                               cms.string('AK4PF_pt'))
        massSearchReplaceParam(seq, "algopt", cms.string('AK4PFchs_pt'),
                               cms.string('AK4PF_pt'))
        massSearchReplaceParam(seq, "srcJetResPhi", cms.string('AK4PFchs_phi'),
                               cms.string('AK4PF_phi'))
        massSearchReplaceParam(seq, "jetCorrPayloadName",
                               cms.string('AK4PF_offline'),
                               cms.string("AK4PF"))
        massSearchReplaceParam(seq, "srcJetSF", cms.string('AK4PFchs'),
                               cms.string('AK4PF'))
        massSearchReplaceParam(seq, "algo", cms.string('AK4PF'),
                               cms.string('AK4PF_offline'))
        if isData:
            massSearchReplaceParam(seq, "algo", cms.string('AK4PFchs'),
                                   cms.string('AK4PF_offline'))
        else:
            massSearchReplaceParam(seq, "algo", cms.string('AK4PFchs'),
                                   cms.string('AK4PF'))

    del process.towerMaker