示例#1
0
process.kappaTuple.Electrons.minPt = 8.0
process.load("Kappa.Skimming.KElectrons_miniAOD_cff")
process.kappaTuple.Electrons.electrons.src = cms.InputTag("slimmedElectrons")
process.kappaTuple.Electrons.electrons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
process.kappaTuple.Electrons.electrons.rhoIsoInputTag = cms.InputTag("slimmedJets", "rho")
from Kappa.Skimming.KElectrons_miniAOD_cff import setupElectrons
process.kappaTuple.Electrons.srcIds = cms.string("standalone");

process.kappaTuple.Electrons.ids = cms.vstring("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
				"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
				"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
				"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
				"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring15NonTrig25nsV1Values")


setupElectrons(process, "slimmedElectrons")
process.path *= ( process.makeKappaElectrons )

#  Jets  ###########################################################
# Kappa jet processing
process.kappaTuple.Jets.minPt = 5.0
process.kappaTuple.Jets.taggers = cms.vstring()

# containers for objects to process
kappa_jets = {}  # algoname: kappa jet config

# GenJets
if not data:
	process.kappaTuple.active += cms.vstring('LV')

#Run JetToolbox to get jet collections: https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetToolbox
示例#2
0
def getBaseConfig(
        nickname,
        testfile=False,  # false if not given, string otherwise
        maxevents=-1,
        outputfilename='kappaTuple.root'):

    from Kappa.Skimming.KSkimming_template_cfg import process
    ## ------------------------------------------------------------------------

    # count number of events before doing anything else
    process.p *= process.nEventsTotal
    process.p *= process.nNegEventsTotal

    muons = "slimmedMuons"
    electrons = "slimmedElectrons"

    # new tau id only available for 8_0_20 (I believe) and above
    if tools.is_above_cmssw_version([8, 0, 20]):
        taus = "NewTauIDsEmbedded"
    else:
        taus = "slimmedTaus"
    isSignal = datasetsHelper.isSignal(nickname)

    # produce selected collections and filter events with not even one Lepton
    if options.preselect and not isSignal:
        from Kappa.Skimming.KSkimming_preselection import do_preselection

        do_preselection(process)
        process.p *= process.goodEventFilter

        process.selectedKappaTaus.cut = cms.string('pt > 15 && abs(eta) < 2.5')
        process.selectedKappaMuons.cut = cms.string('pt > 8 && abs(eta) < 2.6')
        process.selectedKappaElectrons.cut = cms.string(
            'pt > 8 && abs(eta) < 2.7')
        muons = "selectedKappaMuons"
        electrons = "selectedKappaElectrons"
        taus = "selectedKappaTaus"
        process.goodEventFilter.minNumber = cms.uint32(2)

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

    # possibility to write out edmDump. Be careful when using unsceduled mode
    process.load("Kappa.Skimming.edmOut")
    process.ep = cms.EndPath()
    #process.ep *= process.edmOut

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

    # Configure Kappa
    if testfile:
        process.source.fileNames = cms.untracked.vstring("%s" % testfile)
    else:
        process.source = cms.Source('PoolSource',
                                    fileNames=cms.untracked.vstring())
    process.maxEvents.input = maxevents
    process.kappaTuple.verbose = cms.int32(0)
    # uncomment the following option to select only running on certain luminosity blocks. Use only for debugging
    # process.source.lumisToProcess  = cms.untracked.VLuminosityBlockRange("1:500-1:1000")
    # process.source.eventsToProcess  = cms.untracked.VEventRange("299368:56418140-299368:56418140")
    process.kappaTuple.profile = cms.bool(True)

    globaltag = datasetsHelper.getGlobalTag(nickname)
    print "Global Tag:", globaltag
    process.GlobalTag.globaltag = globaltag

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

    # Configure Metadata describing the file
    # Important to be evaluated correctly for the following steps
    # data, isEmbedded, miniaod, process.kappaTuple.TreeInfo.parameters = datasetsHelper.getTreeInfo(nickname, globaltag, kappaTag)
    process.kappaTuple.active = cms.vstring('TreeInfo')

    data = datasetsHelper.isData(nickname)
    isEmbedded = datasetsHelper.isEmbedded(nickname)
    print "nickname:", nickname

    #####miniaod = datasetsHelper.isMiniaod(nickname) not used anymore, since everything is MiniAOD now
    process.kappaTuple.TreeInfo.parameters = datasetsHelper.getTreeInfo(
        nickname)

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

    # General configuration
    if tools.is_above_cmssw_version([7, 4]) and not data and not isEmbedded:
        process.kappaTuple.Info.pileUpInfoSource = cms.InputTag(
            "slimmedAddPileupInfo", "", "PAT")
    if not tools.is_above_cmssw_version([9]):
        if isSignal:
            process.kappaTuple.Info.lheSource = cms.InputTag("source")

    # save primary vertex
    process.kappaTuple.active += cms.vstring(
        'VertexSummary')  # save VertexSummary

    process.kappaTuple.VertexSummary.whitelist = cms.vstring(
        'offlineSlimmedPrimaryVertices')  # save VertexSummary
    process.kappaTuple.VertexSummary.rename = cms.vstring(
        'offlineSlimmedPrimaryVertices => goodOfflinePrimaryVerticesSummary')

    if tools.is_above_cmssw_version([7, 6]):
        process.kappaTuple.VertexSummary.goodOfflinePrimaryVerticesSummary = cms.PSet(
            src=cms.InputTag("offlineSlimmedPrimaryVertices"))

    process.kappaTuple.active += cms.vstring('TriggerObjectStandalone')

    # setup BadPFMuonFilter and BadChargedCandidateFilter
    if tools.is_above_cmssw_version(
        [8]) and not tools.is_above_cmssw_version([9]):
        process.load('RecoMET.METFilters.BadPFMuonFilter_cfi')
        process.BadPFMuonFilter.muons = cms.InputTag("slimmedMuons")
        process.BadPFMuonFilter.PFCandidates = cms.InputTag(
            "packedPFCandidates")
        process.BadPFMuonFilter.taggingMode = cms.bool(True)

        process.load('RecoMET.METFilters.BadChargedCandidateFilter_cfi')
        process.BadChargedCandidateFilter.muons = cms.InputTag("slimmedMuons")
        process.BadChargedCandidateFilter.PFCandidates = cms.InputTag(
            "packedPFCandidates")
        process.BadChargedCandidateFilter.taggingMode = cms.bool(True)

        # in reMiniAOD data these filters are already present; only need to run the dedicated module for MC and older data
        if not "03Feb2017" in str(
                process.kappaTuple.TreeInfo.parameters.scenario):
            process.load('RecoMET.METFilters.badGlobalMuonTaggersMiniAOD_cff')
            #switch on tagging mode:
            process.badGlobalMuonTaggerMAOD.taggingMode = cms.bool(True)
            process.cloneGlobalMuonTaggerMAOD.taggingMode = cms.bool(True)
            process.kappaTuple.TriggerObjectStandalone.metfilterbitslist = cms.vstring(
                "BadChargedCandidateFilter", "BadPFMuonFilter",
                "badGlobalMuonTaggerMAOD", "cloneGlobalMuonTaggerMAOD")
        else:
            process.kappaTuple.TriggerObjectStandalone.metfilterbitslist = cms.vstring(
                "BadChargedCandidateFilter", "BadPFMuonFilter")

    process.kappaTuple.Info.hltSource = cms.InputTag("TriggerResults", "",
                                                     "HLT")
    if isEmbedded:
        process.kappaTuple.TriggerObjectStandalone.bits = cms.InputTag(
            "TriggerResults", "", "SIMembedding")
        process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag(
            "TriggerResults", "", "MERGE")
        process.kappaTuple.Info.hltSource = cms.InputTag(
            "TriggerResults", "", "SIMembedding")
    elif data:
        if tools.is_above_cmssw_version([9]):
            process.kappaTuple.Info.hltSource = cms.InputTag(
                "TriggerResults", "", "HLT")
            process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag(
                "TriggerResults", "",
                "RECO")  # take last process used in production for data
        elif "03Feb2017" in str(
                process.kappaTuple.TreeInfo.parameters.scenario):
            process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag(
                "TriggerResults", "", "PAT")
        else:
            process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag(
                "TriggerResults", "", "RECO")
            process.kappaTuple.Info.hltSource = cms.InputTag(
                "TriggerResults", "", "RECO")
    else:
        process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag(
            "TriggerResults", "",
            "PAT")  # take last process used in production for mc

    if not isEmbedded and "Spring16" in str(
            process.kappaTuple.TreeInfo.parameters.campaign):
        # adds for each HLT Trigger wich contains "Tau" or "tau" in the name a Filter object named "l1extratauccolltection"
        process.kappaTuple.TriggerObjectStandalone.l1extratauJetSource = cms.untracked.InputTag(
            "l1extraParticles", "IsoTau", "RECO")

    if not tools.is_above_cmssw_version([9]):
        process.kappaTuple.TriggerObjectStandalone.triggerObjects = cms.PSet(
            src=cms.InputTag("selectedPatTrigger"))
        process.kappaTuple.TriggerObjectStandalone.bits = cms.InputTag(
            "TriggerResults", "", "HLT")

    process.kappaTuple.active += cms.vstring('BeamSpot')
    if tools.is_above_cmssw_version([7, 6]):
        process.kappaTuple.BeamSpot.offlineBeamSpot = cms.PSet(
            src=cms.InputTag("offlineBeamSpot"))

    if not isEmbedded and data:
        process.kappaTuple.active += cms.vstring(
            'DataInfo')  # produce Metadata for data,

    if not isEmbedded and not data:
        process.kappaTuple.active += cms.vstring(
            'GenInfo')  # produce Metadata for MC,
        process.kappaTuple.active += cms.vstring(
            'GenParticles')  # save GenParticles,
        process.kappaTuple.active += cms.vstring(
            'GenTaus')  # save GenParticles,
        process.kappaTuple.GenParticles.genParticles.src = cms.InputTag(
            "prunedGenParticles")
        process.kappaTuple.GenTaus.genTaus.src = cms.InputTag(
            "prunedGenParticles")

    # write out for all processes where available
    process.kappaTuple.Info.lheWeightNames = cms.vstring(".*")

    # save Flag
    process.kappaTuple.Info.isEmbedded = cms.bool(isEmbedded)

    if isEmbedded:
        #process.load('RecoBTag/Configuration/RecoBTag_cff')
        #process.load('RecoJets/JetAssociationProducers/ak5JTA_cff')
        #process.ak5PFJetNewTracksAssociatorAtVertex.tracks = "tmfTracks"
        #process.ak5PFCHSNewJetTracksAssociatorAtVertex.tracks = "tmfTracks"
        #process.p *= process.btagging
        # disable overrideHLTCheck for embedded samples, since it triggers an Kappa error
        process.kappaTuple.Info.overrideHLTCheck = cms.untracked.bool(True)
        process.kappaTuple.active += cms.vstring('GenInfo')
        process.kappaTuple.active += cms.vstring(
            'GenParticles')  # save GenParticles,
        process.kappaTuple.GenParticles.genParticles.src = cms.InputTag(
            "prunedGenParticles")
        process.kappaTuple.active += cms.vstring('GenTaus')
        process.kappaTuple.GenTaus.genTaus.src = cms.InputTag(
            "prunedGenParticles")

        #process.kappaTuple.active += cms.vstring('GenTaus') # save GenParticles,
        #process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("genParticles","","EmbeddedRECO")

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

    # Trigger
    from Kappa.Skimming.hlt_run2 import hltBlacklist, hltWhitelist
    process.kappaTuple.Info.hltWhitelist = hltWhitelist
    process.kappaTuple.Info.hltBlacklist = hltBlacklist

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

    # should not be the default, it blows up the skim a lot
    #process.kappaTuple.active += cms.vstring('packedPFCandidates')
    #process.kappaTuple.packedPFCandidates.packedPFCandidates = cms.PSet(src = cms.InputTag("packedPFCandidates"))

    jetCollectionPuppi = "slimmedJetsPuppi"
    if tools.is_above_cmssw_version([9]):
        jetCollection = "slimmedJets"
    elif tools.is_above_cmssw_version([8]):
        from RecoMET.METPUSubtraction.jet_recorrections import recorrectJets
        #from RecoMET.METPUSubtraction.jet_recorrections import loadLocalSqlite
        #loadLocalSqlite(process, sqliteFilename = "Spring16_25nsV6_DATA.db" if data else "Spring16_25nsV6_MC.db",
        #                         tag = 'JetCorrectorParametersCollection_Spring16_25nsV6_DATA_AK4PF' if data else 'JetCorrectorParametersCollection_Spring16_25nsV6_MC_AK4PF')
        recorrectJets(process, isData=data)
        jetCollection = "patJetsReapplyJEC"
    else:
        from RecoMET.METPUSubtraction.localSqlite import recorrectJets
        recorrectJets(process, isData=data)
        jetCollection = "patJetsReapplyJEC"

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

    # Configure Muons
    process.load("Kappa.Skimming.KMuons_miniAOD_cff")
    process.kappaTuple.Muons.muons.src = cms.InputTag(muons)
    process.kappaTuple.Muons.muons.vertexcollection = cms.InputTag(
        "offlineSlimmedPrimaryVertices")
    process.kappaTuple.Muons.use03ConeForPfIso = cms.bool(True)
    process.kappaTuple.Muons.doPfIsolation = cms.bool(False)
    for src in [
            "muPFIsoDepositCharged", "muPFIsoDepositChargedAll",
            "muPFIsoDepositNeutral", "muPFIsoDepositGamma", "muPFIsoDepositPU"
    ]:
        setattr(getattr(process, src), "src", cms.InputTag(muons))

    process.kappaTuple.active += cms.vstring('Muons')
    process.kappaTuple.Muons.noPropagation = cms.bool(True)
    process.p *= (process.makeKappaMuons)

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

    # Configure Electrons
    process.kappaTuple.active += cms.vstring('Electrons')
    process.load("Kappa.Skimming.KElectrons_miniAOD_cff")
    process.kappaTuple.Electrons.electrons.src = cms.InputTag(
        "slimmedElectrons")
    process.kappaTuple.Electrons.electrons.vertexcollection = cms.InputTag(
        "offlineSlimmedPrimaryVertices")
    process.kappaTuple.Electrons.electrons.rhoIsoInputTag = cms.InputTag(
        "slimmedJets", "rho")
    process.kappaTuple.Electrons.electrons.allConversions = cms.InputTag(
        "reducedEgamma", "reducedConversions")
    from Kappa.Skimming.KElectrons_miniAOD_cff import setupElectrons
    process.kappaTuple.Electrons.srcIds = cms.string("standalone")

    if tools.is_above_cmssw_version([9, 4]):
        process.kappaTuple.Electrons.ids = cms.VInputTag(
            "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-veto",
            "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-loose",
            "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-medium",
            "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-tight",
            "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp90",
            "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp80",
            "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wpLoose",
            "egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp90",
            "egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp80",
            "egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wpLoose",
            "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Values",
            "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV1Values",
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
            "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"
        )
    elif tools.is_above_cmssw_version([8]):
        process.kappaTuple.Electrons.ids = cms.VInputTag(
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
            "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
            "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"
        )
    else:
        process.kappaTuple.Electrons.ids = cms.VInputTag(
            "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
            "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
            "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
            "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
            "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring15NonTrig25nsV1Values"
        )

    setupElectrons(process, electrons)
    process.p *= (process.makeKappaElectrons)

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

    # new tau id only available for 8_0_20 (I believe) and above
    if tools.is_above_cmssw_version([8, 0, 20]):
        process.load(
            'RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
        process.load("Kappa.Skimming.KPatTaus_run2_cff")
        process.p *= (process.makeKappaTaus)

        # embed new id's into new tau collection
        embedID = cms.EDProducer(
            "PATTauIDEmbedder",
            src=cms.InputTag('slimmedTaus'),
            tauIDSources=cms.PSet(
                rerunDiscriminationByIsolationMVAOldDMrun2v1raw=cms.InputTag(
                    'rerunDiscriminationByIsolationMVAOldDMrun2v1raw'),
                rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose=cms.
                InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose'),
                rerunDiscriminationByIsolationMVAOldDMrun2v1Loose=cms.InputTag(
                    'rerunDiscriminationByIsolationMVAOldDMrun2v1Loose'),
                rerunDiscriminationByIsolationMVAOldDMrun2v1Medium=cms.
                InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1Medium'),
                rerunDiscriminationByIsolationMVAOldDMrun2v1Tight=cms.InputTag(
                    'rerunDiscriminationByIsolationMVAOldDMrun2v1Tight'),
                rerunDiscriminationByIsolationMVAOldDMrun2v1VTight=cms.
                InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1VTight'),
                rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight=cms.
                InputTag(
                    'rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight'),
                rerunDiscriminationByIsolationMVANewDMrun2v1raw=cms.InputTag(
                    'rerunDiscriminationByIsolationMVANewDMrun2v1raw'),
                rerunDiscriminationByIsolationMVANewDMrun2v1VLoose=cms.
                InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1VLoose'),
                rerunDiscriminationByIsolationMVANewDMrun2v1Loose=cms.InputTag(
                    'rerunDiscriminationByIsolationMVANewDMrun2v1Loose'),
                rerunDiscriminationByIsolationMVANewDMrun2v1Medium=cms.
                InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1Medium'),
                rerunDiscriminationByIsolationMVANewDMrun2v1Tight=cms.InputTag(
                    'rerunDiscriminationByIsolationMVANewDMrun2v1Tight'),
                rerunDiscriminationByIsolationMVANewDMrun2v1VTight=cms.
                InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1VTight'),
                rerunDiscriminationByIsolationMVANewDMrun2v1VVTight=cms.
                InputTag(
                    'rerunDiscriminationByIsolationMVANewDMrun2v1VVTight')),
        )
        setattr(process, taus, embedID)
        process.p *= getattr(process, taus)

    process.kappaTuple.active += cms.vstring('PatTaus')
    process.kappaTuple.PatTaus.taus.binaryDiscrBlacklist = cms.vstring()
    process.kappaTuple.PatTaus.taus.src = cms.InputTag(taus)
    process.kappaTuple.PatTaus.taus.floatDiscrBlacklist = cms.vstring()
    # just took everything from https://twiki.cern.ch/twiki/bin/viewauth/CMS/TauIDRecommendation13TeV
    process.kappaTuple.PatTaus.taus.preselectOnDiscriminators = cms.vstring()
    process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist = cms.vstring(
        "decayModeFinding",
        "decayModeFindingNewDMs",
        "byLooseCombinedIsolationDeltaBetaCorr3Hits",
        "byMediumCombinedIsolationDeltaBetaCorr3Hits",
        "byTightCombinedIsolationDeltaBetaCorr3Hits",
        "byCombinedIsolationDeltaBetaCorrRaw3Hits",
        "chargedIsoPtSum",
        "neutralIsoPtSum",
        "neutralIsoPtSumWeight",
        "puCorrPtSum",
        "footprintCorrection",
        "photonPtSumOutsideSignalCone",
        "byIsolationMVArun2v1DBoldDMwLTraw",
        "byVLooseIsolationMVArun2v1DBoldDMwLT",
        "byLooseIsolationMVArun2v1DBoldDMwLT",
        "byMediumIsolationMVArun2v1DBoldDMwLT",
        "byTightIsolationMVArun2v1DBoldDMwLT",
        "byVTightIsolationMVArun2v1DBoldDMwLT",
        "byVVTightIsolationMVArun2v1DBoldDMwLT",
        #"byIsolationMVArun2v1DBnewDMwLTraw",
        #"byVLooseIsolationMVArun2v1DBnewDMwLT",
        #"byLooseIsolationMVArun2v1DBnewDMwLT",
        #"byMediumIsolationMVArun2v1DBnewDMwLT",
        #"byTightIsolationMVArun2v1DBnewDMwLT",
        #"byVTightIsolationMVArun2v1DBnewDMwLT",
        #"byVVTightIsolationMVArun2v1DBnewDMwLT",
        "againstMuonLoose3",
        "againstMuonTight3",
        "againstElectronMVA6category",
        "againstElectronMVA6raw",
        "againstElectronVLooseMVA6",
        "againstElectronLooseMVA6",
        "againstElectronMediumMVA6",
        "againstElectronTightMVA6",
        "againstElectronVTightMVA6"  #,
        #"chargedIsoPtSumdR03",
        #"neutralIsoPtSumdR03",
        #"neutralIsoPtSumWeightdR03",
        #"footprintCorrectiondR03",
        #"photonPtSumOutsideSignalConedR03",
        #"byLooseCombinedIsolationDeltaBetaCorr3HitsdR03",
        #"byMediumCombinedIsolationDeltaBetaCorr3HitsdR03",
        #"byTightCombinedIsolationDeltaBetaCorr3HitsdR03",
        #"byIsolationMVArun2v1DBdR03oldDMwLTraw",
        #"byVLooseIsolationMVArun2v1DBdR03oldDMwLT",
        #"byLooseIsolationMVArun2v1DBdR03oldDMwLT",
        #"byMediumIsolationMVArun2v1DBdR03oldDMwLT",
        #"byTightIsolationMVArun2v1DBdR03oldDMwLT",
        #"byVTightIsolationMVArun2v1DBdR03oldDMwLT",
        #"byVVTightIsolationMVArun2v1DBdR03oldDMwLT",
    )
    if tools.is_above_cmssw_version([8, 0, 20]):
        process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist += cms.vstring(
            "rerunDiscriminationByIsolationMVAOldDMrun2v1raw",
            "rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose",
            "rerunDiscriminationByIsolationMVAOldDMrun2v1Loose",
            "rerunDiscriminationByIsolationMVAOldDMrun2v1Medium",
            "rerunDiscriminationByIsolationMVAOldDMrun2v1Tight",
            "rerunDiscriminationByIsolationMVAOldDMrun2v1VTight",
            "rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight",
            "rerunDiscriminationByIsolationMVANewDMrun2v1raw",
            "rerunDiscriminationByIsolationMVANewDMrun2v1VLoose",
            "rerunDiscriminationByIsolationMVANewDMrun2v1Loose",
            "rerunDiscriminationByIsolationMVANewDMrun2v1Medium",
            "rerunDiscriminationByIsolationMVANewDMrun2v1Tight",
            "rerunDiscriminationByIsolationMVANewDMrun2v1VTight",
            "rerunDiscriminationByIsolationMVANewDMrun2v1VVTight")
    ## now also possible to save all MVA isolation inputs for taus # turn of per default

    process.kappaTuple.PatTaus.taus.extrafloatDiscrlist = cms.untracked.vstring(
        "decayDistX", "decayDistY", "decayDistZ", "decayDistM", "nPhoton",
        "ptWeightedDetaStrip", "ptWeightedDphiStrip", "ptWeightedDrSignal",
        "ptWeightedDrIsolation", "leadingTrackChi2", "eRatio")

    process.kappaTuple.PatTaus.taus.floatDiscrWhitelist = process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist
    process.kappaTuple.PatTaus.verbose = cms.int32(1)

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

    ## Configure Jets
    process.kappaTuple.active += cms.vstring('PileupDensity')
    process.kappaTuple.PileupDensity.whitelist = cms.vstring(
        "fixedGridRhoFastjetAll")
    process.kappaTuple.PileupDensity.rename = cms.vstring(
        "fixedGridRhoFastjetAll => pileupDensity")
    if tools.is_above_cmssw_version([7, 6]):
        process.kappaTuple.PileupDensity.pileupDensity = cms.PSet(
            src=cms.InputTag("fixedGridRhoFastjetAll"))
    process.kappaTuple.active += cms.vstring('PatJets')
    if tools.is_above_cmssw_version([7, 6]):
        process.kappaTuple.PatJets.ak4PF = cms.PSet(
            src=cms.InputTag(jetCollection))
        process.kappaTuple.PatJets.puppiJets = cms.PSet(
            src=cms.InputTag(jetCollectionPuppi))

    ## Standard MET and GenMet from pat::MET
    process.kappaTuple.active += cms.vstring('PatMET')
    process.kappaTuple.PatMET.met = cms.PSet(src=cms.InputTag("slimmedMETs"))
    if tools.is_above_cmssw_version([9]):
        pass
    elif tools.is_above_cmssw_version([8, 0, 14]):
        from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
        runMetCorAndUncFromMiniAOD(process, isData=data)
        process.kappaTuple.PatMET.met = cms.PSet(
            src=cms.InputTag("slimmedMETs", "", "KAPPA"))

    #process.kappaTuple.PatMET.pfmetT1 = cms.PSet(src=cms.InputTag("patpfMETT1"))
    process.kappaTuple.PatMET.metPuppi = cms.PSet(
        src=cms.InputTag("slimmedMETsPuppi"))

    if not tools.is_above_cmssw_version([9]):
        ## Write MVA MET to KMETs
        process.kappaTuple.active += cms.vstring('PatMETs')
        # new MVA MET
        from RecoMET.METPUSubtraction.MVAMETConfiguration_cff import runMVAMET
        runMVAMET(process, jetCollectionPF=jetCollection)
        process.kappaTuple.PatMETs.MVAMET = cms.PSet(
            src=cms.InputTag("MVAMET", "MVAMET"))
        process.MVAMET.srcLeptons = cms.VInputTag(
            muons, electrons, taus)  # to produce all possible combinations
        process.MVAMET.requireOS = cms.bool(False)
        if tools.is_above_cmssw_version([8, 0]) and isEmbedded:
            process.MVAMET.srcMETs = cms.VInputTag(
                cms.InputTag("slimmedMETs", "", "MERGE"),
                cms.InputTag("patpfTrackMET"), cms.InputTag("patpfNoPUMET"),
                cms.InputTag("patpfPUCorrectedMET"),
                cms.InputTag("patpfPUMET"),
                cms.InputTag("slimmedMETsPuppi", "", "MERGE"))

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

    ## GenJets
    if not data or isEmbedded:
        process.load('PhysicsTools/JetMCAlgos/TauGenJets_cfi')
        process.load(
            'PhysicsTools/JetMCAlgos/TauGenJetsDecayModeSelectorAllHadrons_cfi'
        )
        process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles")
        process.p *= (process.tauGenJets +
                      process.tauGenJetsSelectorAllHadrons)
        if isSignal:
            process.kappaTuple.GenJets.whitelist = cms.vstring(
                "tauGenJets", "slimmedGenJets")
        else:
            process.kappaTuple.GenJets.whitelist = cms.vstring("tauGenJets")
        process.kappaTuple.active += cms.vstring('GenJets')
        if tools.is_above_cmssw_version([7, 6]):
            if isSignal:
                process.kappaTuple.GenJets.genJets = cms.PSet(
                    src=cms.InputTag("slimmedGenJets"))
            process.kappaTuple.GenJets.tauGenJets = cms.PSet(
                src=cms.InputTag("tauGenJets"))
            process.kappaTuple.GenJets.tauGenJetsSelectorAllHadrons = cms.PSet(
                src=cms.InputTag("tauGenJetsSelectorAllHadrons"))

    # add repository revisions to TreeInfo
    for repo, rev in tools.get_repository_revisions().iteritems():
        setattr(process.kappaTuple.TreeInfo.parameters, repo, cms.string(rev))

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

    ## Count Events after running all filters
    if not data:
        process.nEventsTotal.isMC = cms.bool(True)
        process.nNegEventsTotal.isMC = cms.bool(True)
        process.nEventsFiltered.isMC = cms.bool(True)
        process.nNegEventsFiltered.isMC = cms.bool(True)

    process.p *= process.nEventsFiltered
    process.p *= process.nNegEventsFiltered
    process.kappaTuple.active += cms.vstring('FilterSummary')

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

    ## if needed adapt output filename
    process.ep *= process.kappaOut
    if outputfilename != '':
        process.kappaTuple.outputFile = cms.string('%s' % outputfilename)

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

    ## Further information saved to Kappa output
    if options.dumpPython:
        f = open("dumpPython.py", "w")
        f.write(process.dumpPython())
        f.close()

    # add python config to TreeInfo
    process.kappaTuple.TreeInfo.parameters.config = cms.string(
        process.dumpPython())

    return process
示例#3
0
process.kappaTuple.active += cms.vstring('Electrons')
process.load("Kappa.Skimming.KElectrons_miniAOD_cff")
process.kappaTuple.Electrons.electrons.src = cms.InputTag("slimmedElectrons")
process.kappaTuple.Electrons.electrons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
process.kappaTuple.Electrons.electrons.rhoIsoInputTag = cms.InputTag("slimmedJets", "rho")
process.kappaTuple.Electrons.electrons.allConversions = cms.InputTag("reducedEgamma", "reducedConversions")
from Kappa.Skimming.KElectrons_miniAOD_cff import setupElectrons
process.kappaTuple.Electrons.srcIds = cms.string("standalone");
process.kappaTuple.Electrons.ids = cms.vstring(
	"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
	"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
	"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
	"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
	"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring15NonTrig25nsV1Values"
)
setupElectrons(process, "slimmedElectrons")
process.p *= (process.makeKappaElectrons)

## Taus

process.kappaTuple.active += cms.vstring('PatTaus')
process.kappaTuple.PatTaus.taus.preselectOnDiscriminators = cms.vstring()
process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist = cms.vstring(
	"decayModeFinding",
	"decayModeFindingNewDMs",
	"byLooseCombinedIsolationDeltaBetaCorr3Hits",
	"byMediumCombinedIsolationDeltaBetaCorr3Hits",
	"byTightCombinedIsolationDeltaBetaCorr3Hits",
	"byCombinedIsolationDeltaBetaCorrRaw3Hits",
	"chargedIsoPtSum",
	"neutralIsoPtSum",
示例#4
0
def getBaseConfig( globaltag= 'START70_V7::All',
                   testfile=cms.untracked.vstring(""),
                   maxevents=100, ## -1 = all in file
                   nickname = 'VBFHToTauTauM125_Phys14DR_PU20bx25_13TeV_MINIAODSIM',
                   kappaTag = 'Kappa_2_0_0' ):

	## ------------------------------------------------------------------------
	# Configure Kappa
	from Kappa.Skimming.KSkimming_template_cfg import process

	process.source.fileNames      = testfile
	process.maxEvents.input	      = maxevents
	process.kappaTuple.verbose    = cms.int32(0)
	process.kappaTuple.profile    = cms.bool(True)
	if not globaltag.lower() == 'auto' :
		process.GlobalTag.globaltag   = globaltag
		print "GT (overwritten):", process.GlobalTag.globaltag

	## ------------------------------------------------------------------------
	# Configure Metadata describing the file
	# Important to be evaluated correctly for the following steps
	process.kappaTuple.active = cms.vstring('TreeInfo')
	data, isEmbedded, miniaod, process.kappaTuple.TreeInfo.parameters = datasetsHelper.getTreeInfo(nickname, globaltag, kappaTag)

	## ------------------------------------------------------------------------
	# General configuration

	process.kappaTuple.active += cms.vstring('VertexSummary')            # save VertexSummary,
	if miniaod:
		process.load("Kappa.Skimming.KVertices_cff")
		process.goodOfflinePrimaryVertices.src = cms.InputTag('offlineSlimmedPrimaryVertices')
		process.p *= ( process.makeVertexes )
		if (cmssw_version_number.startswith("7_4")):
			process.kappaTuple.VertexSummary.whitelist = cms.vstring('offlineSlimmedPrimaryVertices')  # save VertexSummary,
			process.kappaTuple.VertexSummary.rename = cms.vstring('offlineSlimmedPrimaryVertices => goodOfflinePrimaryVerticesSummary')
		else:
			process.kappaTuple.VertexSummary.whitelist = cms.vstring('goodOfflinePrimaryVertices')  # save VertexSummary,

		process.kappaTuple.active += cms.vstring('TriggerObjectStandalone')

	process.kappaTuple.active += cms.vstring('BeamSpot')                 # save Beamspot,

	if not miniaod:
		process.kappaTuple.active += cms.vstring('TriggerObjects')

	if not isEmbedded and data:
			process.kappaTuple.active+= cms.vstring('DataInfo')          # produce Metadata for data,

	if not isEmbedded and not data:
			process.kappaTuple.active+= cms.vstring('GenInfo')           # produce Metadata for MC,
			process.kappaTuple.active+= cms.vstring('GenParticles')      # save GenParticles,
			process.kappaTuple.active+= cms.vstring('GenTaus')           # save GenParticles,

			if(miniaod):
				process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("prunedGenParticles")
				process.kappaTuple.GenTaus.genTaus.src = cms.InputTag("prunedGenParticles")
	# Prune genParticles
	if not isEmbedded and not data and not miniaod:
		process.load("Kappa.Skimming.PruneGenParticles_cff")
	
	# Special settings for embedded samples
	# https://twiki.cern.ch/twiki/bin/viewauth/CMS/MuonTauReplacementWithPFlow
	if isEmbedded:
		#process.load('RecoBTag/Configuration/RecoBTag_cff')
		#process.load('RecoJets/JetAssociationProducers/ak5JTA_cff')
		#process.ak5PFJetNewTracksAssociatorAtVertex.tracks = "tmfTracks"
		#process.ak5PFCHSNewJetTracksAssociatorAtVertex.tracks = "tmfTracks"
		#process.p *= process.btagging
		# disable overrideHLTCheck for embedded samples, since it triggers an Kappa error
		process.kappaTuple.Info.overrideHLTCheck = cms.untracked.bool(True)
		process.kappaTuple.active += cms.vstring('DataInfo')
		process.kappaTuple.active += cms.vstring('GenParticles') # save GenParticles,
		process.kappaTuple.active += cms.vstring('GenTaus') # save GenParticles,
		process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("genParticles","","EmbeddedRECO")

	## ------------------------------------------------------------------------
	# Trigger
	from Kappa.Skimming.hlt_run2 import hltBlacklist, hltWhitelist
	process.kappaTuple.Info.hltWhitelist = hltWhitelist
	process.kappaTuple.Info.hltBlacklist = hltBlacklist

	## ------------------------------------------------------------------------
	# Configure PFCandidates and offline PV
	if(not miniaod):
		process.load("Kappa.Skimming.KPFCandidates_run2_cff")
		process.kappaTuple.active += cms.vstring('PFCandidates') # save PFCandidates for deltaBeta corrected
		process.kappaTuple.PFCandidates.whitelist = cms.vstring( # isolation used for electrons and muons.
		##	"pfNoPileUpChargedHadrons",    ## switch to pfAllChargedParticles
			"pfAllChargedParticles",       ## same as pfNoPileUpChargedHadrons +pf_electrons + pf_muons
			"pfNoPileUpNeutralHadrons",
			"pfNoPileUpPhotons",
			"pfPileUpChargedHadrons",
			)
		##process.p *= ( process.makePFBRECO * process.makePFCandidatesForDeltaBeta )
		process.p *= ( process.makeKappaPFCandidates )

	if(miniaod):
		process.load("Kappa.Skimming.KPFCandidates_miniAOD_cff")
		process.kappaTuple.active += cms.vstring('packedPFCandidates') # save PFCandidates. Not sure for what, because might not be usefull for isolation
		process.p *= ( process.makeKappaPFCandidates )

	## ------------------------------------------------------------------------
	# Configure Muons
	if not miniaod:
		process.load("Kappa.Skimming.KMuons_run2_cff")
	if(miniaod):
		process.load("Kappa.Skimming.KMuons_miniAOD_cff")
		process.kappaTuple.Muons.muons.src = cms.InputTag("slimmedMuons")
		process.kappaTuple.Muons.muons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.kappaTuple.Muons.muons.srcMuonIsolationPF = cms.InputTag("")
		process.kappaTuple.Muons.use03ConeForPfIso = cms.bool(True)

	process.kappaTuple.active += cms.vstring('Muons')
	process.kappaTuple.Muons.minPt = cms.double(8.0)
	process.p *= ( process.makeKappaMuons )

	## ------------------------------------------------------------------------
	# Configure Electrons
	process.kappaTuple.active += cms.vstring('Electrons')
	if(miniaod):
		process.load("Kappa.Skimming.KElectrons_miniAOD_cff")
		process.kappaTuple.Electrons.electrons.src = cms.InputTag("slimmedElectrons")
		process.kappaTuple.Electrons.electrons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.kappaTuple.Electrons.electrons.rhoIsoInputTag = cms.InputTag("slimmedJets", "rho")
		process.kappaTuple.Electrons.electrons.allConversions = cms.InputTag("reducedEgamma", "reducedConversions")
		from Kappa.Skimming.KElectrons_miniAOD_cff import setupElectrons
		process.kappaTuple.Electrons.srcIds = cms.string("standalone");

		if (cmssw_version_number.startswith("7_4")):
			process.kappaTuple.Electrons.ids = cms.vstring("egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V2-standalone-veto",
						"egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V2-standalone-loose",
						"egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V2-standalone-medium",
						"egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V2-standalone-tight",
						"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Phys14NonTrigValues")
		else:
			process.kappaTuple.Electrons.ids = cms.vstring("egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V1-miniAOD-standalone-veto",
						"egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V1-miniAOD-standalone-loose",
						"egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V1-miniAOD-standalone-medium",
						"egmGsfElectronIDs:cutBasedElectronID-PHYS14-PU20bx25-V1-miniAOD-standalone-tight")

	if not miniaod:
		process.load("Kappa.Skimming.KElectrons_run2_cff")
		process.kappaTuple.Electrons.minPt = cms.double(8.0)
		from Kappa.Skimming.KElectrons_run2_cff import setupElectrons

		if (cmssw_version_number.startswith("7_4")):
			process.kappaTuple.Electrons.ids = cms.vstring("cutBasedEleIdPHYS14Loose",
							       	   "cutBasedEleIdPHYS14Medium",
							       	   "cutBasedEleIdPHYS14Tight",
							       	   "cutBasedEleIdPHYS14Veto",
								   "mvaNonTrig25nsPHYS14")
		else:
			process.kappaTuple.Electrons.ids = cms.vstring("cutBasedEleIdPHYS14Loose",
							       	   "cutBasedEleIdPHYS14Medium",
							       	   "cutBasedEleIdPHYS14Tight",
							       	   "cutBasedEleIdPHYS14Veto",
							       	   "mvaTrigV050nsCSA14",
							       	   "mvaTrigV025nsCSA14",
							       	   "mvaNonTrigV050nsCSA14",
							       	   "mvaNonTrigV025nsCSA14",
						       		   "mvaNonTrigV025nsPHYS14")

	setupElectrons(process)
	process.p *= ( process.makeKappaElectrons )
	## ------------------------------------------------------------------------
	if(miniaod):
		process.kappaTuple.active += cms.vstring('PatTaus')
		#process.kappaTuple.PATTaus.taus.binaryDiscrBlacklist = cms.vstring("^shrinkingCone.*", ".*PFlow$", ".*raw.*", ".*Raw.*", "^hpsPFTauDiscriminationByVLoose.*", "^hpsPFTauDiscriminationByVTight.*", "^hpsPFTauDiscriminationByMedium.*")
		process.kappaTuple.PatTaus.taus.preselectOnDiscriminators = cms.vstring()
	## ------------------------------------------------------------------------
	# Configure Taus
	if(not miniaod):
		process.load("Kappa.Skimming.KTaus_run2_cff")
		process.kappaTuple.active += cms.vstring('Taus')
		process.kappaTuple.Taus.minPt = cms.double(8.0)
		process.p *= ( process.makeKappaTaus )

	# Reduced number of Tau discriminators
	# The blacklist is to some degree arbitrary to get below 64 binaty tau discriminators
	# - they may need to be changed as soon as 'official' discriminators for TauID 2014 will be published
		process.kappaTuple.Taus.taus.binaryDiscrBlacklist = cms.vstring("^shrinkingCone.*", ".*PFlow$", ".*raw.*", ".*Raw.*", "^hpsPFTauDiscriminationByVLoose.*", "^hpsPFTauDiscriminationByVTight.*", "^hpsPFTauDiscriminationByMedium.*")
		process.kappaTuple.Taus.taus.preselectOnDiscriminators = cms.vstring("hpsPFTauDiscriminationByDecayModeFindingNewDMs")

	## ------------------------------------------------------------------------
	## Configure Jets

	process.kappaTuple.active += cms.vstring('PileupDensity')
	if not miniaod:
		process.load("Kappa.Skimming.KJets_run2_cff")
		process.kappaTuple.active += cms.vstring('Jets')
		process.kappaTuple.Jets = process.kappaTupleJets
		process.kappaTuple.Jets.minPt = cms.double(10.0)

		#Check if working
		process.p *= (
			process.makePFJets *
			process.makePFJetsCHS *
		#	process.makeQGTagging *
			process.makeBTagging *
			process.makePUJetID *
			process.kt6PFJets
		)

	if miniaod:
		process.kappaTuple.active += cms.vstring('PatJets')
		process.kappaTuple.PileupDensity.whitelist = cms.vstring("fixedGridRhoFastjetAll")
		process.kappaTuple.PileupDensity.rename = cms.vstring("fixedGridRhoFastjetAll => pileupDensity")


	## ------------------------------------------------------------------------
	## MET
	process.load("Kappa.Skimming.KMET_run2_cff")
	process.kappaTuple.active += cms.vstring('MET')                       ## produce/save KappaPFMET and MVA MET

	if (not miniaod):
		process.kappaTuple.active += cms.vstring('BasicMET')                  ## produce/save KappaMET

	if(miniaod):
		process.ak4PFJets.src = cms.InputTag("packedPFCandidates")
		process.pfMetMVA.srcVertices = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.puJetIdForPFMVAMEt.jec =  cms.string('AK4PF')
		process.puJetIdForPFMVAMEt.vertexes = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.puJetIdForPFMVAMEt.rho = cms.InputTag("fixedGridRhoFastjetAll")
		process.mvaMETMuons.src = cms.InputTag("slimmedMuons")
		# process.mvaMETElectrons.src = cms.InputTag("slimmedElectrons")
		# Todo for miniAOD: find a selector that works in pat Taus and slimmedElectrons
		process.pfMetMVAEM.srcLeptons = cms.VInputTag("slimmedElectrons", "mvaMETMuons" )
		process.pfMetMVAET.srcLeptons = cms.VInputTag("slimmedElectrons", "slimmedTaus")
		process.pfMetMVAMT.srcLeptons = cms.VInputTag("mvaMETMuons"    , "slimmedTaus")
		process.pfMetMVATT.srcLeptons = cms.VInputTag("slimmedTaus")
		process.pfMetMVAEM.srcVertices = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.pfMetMVAET.srcVertices = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.pfMetMVAMT.srcVertices = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.pfMetMVATT.srcVertices = cms.InputTag("offlineSlimmedPrimaryVertices")
		process.pfMetMVAEM.srcPFCandidates = cms.InputTag("packedPFCandidates")
		process.pfMetMVAET.srcPFCandidates = cms.InputTag("packedPFCandidates")
		process.pfMetMVAMT.srcPFCandidates = cms.InputTag("packedPFCandidates")
		process.pfMetMVATT.srcPFCandidates = cms.InputTag("packedPFCandidates")
		#process.makeKappaMET = cms.Sequence( process.ak4PFJets * process.calibratedAK4PFJetsForPFMVAMEt * process.mvaMETJets * process.puJetIdForPFMVAMEt * process.mvaMETMuons * process.pfMetMVAEM * process.pfMetMVAET * process.pfMetMVAMT * process.pfMetMVATT )
		process.makeKappaMET = cms.Sequence( process.ak4PFJets * process.calibratedAK4PFJetsForPFMVAMEt * process.mvaMETJets )

		## Standard MET and GenMet from pat::MET
		process.kappaTuple.active += cms.vstring('PatMET')


	process.p *= process.makeKappaMET
	## ------------------------------------------------------------------------
	## GenJets 
	if not data:
		process.load('PhysicsTools/JetMCAlgos/TauGenJets_cfi')
		process.load('PhysicsTools/JetMCAlgos/TauGenJetsDecayModeSelectorAllHadrons_cfi')
		if(miniaod):
			process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles")
		process.p *= ( 
			process.tauGenJets +
			process.tauGenJetsSelectorAllHadrons
			)
		process.kappaTuple.GenJets.whitelist = cms.vstring("tauGenJets")
		process.kappaTuple.active += cms.vstring('GenJets')

	## ------------------------------------------------------------------------
	## Further information saved to Kappa output 
	# add python config to TreeInfo
	process.kappaTuple.TreeInfo.parameters.config = cms.string(process.dumpPython())

	# add repository revisions to TreeInfo
	for repo, rev in tools.get_repository_revisions().iteritems():
			setattr(process.kappaTuple.TreeInfo.parameters, repo, cms.string(rev))

	## ------------------------------------------------------------------------
	## let Kappa run
	process.p *= ( process.kappaOut )

	## ------------------------------------------------------------------------
	## Write out edmFile for debugging perposes 
	#process.load("Kappa.Skimming.edmOut")

	return process
示例#5
0
def getBaseConfig( globaltag= 'START70_V7::All',
                   testfile=cms.untracked.vstring(""),
                   maxevents=100, ## -1 = all in file
                   nickname = 'SUSYGluGluToHToTauTauM160_RunIIFall15MiniAODv2_PU25nsData2015v1_13TeV_MINIAOD_pythia8',
                   kappaTag = 'Kappa_2_0_0',
				   outputfilename = ''):

	from Kappa.Skimming.KSkimming_template_cfg import process
	## ------------------------------------------------------------------------
	# count number of events before doing anything elese
	process.p *= process.nEventsTotal
	process.p *= process.nNegEventsTotal

	muons = "slimmedMuons"
	electrons = "slimmedElectrons"
	taus = "slimmedTaus"
	# produce selected collections and filter events with not even one Lepton
	if(options.preselect):
		from Kappa.Skimming.KSkimming_preselection import do_preselection
		do_preselection(process)
		process.p *= process.goodEventFilter

		process.selectedKappaTaus.cut = cms.string('pt > 15 && abs(eta) < 2.5') 
		process.selectedKappaMuons.cut = cms.string('pt > 8 && abs(eta) < 2.6')
		process.selectedKappaElectrons.cut = cms.string('pt > 8 && abs(eta) < 2.7')
		process.goodEventFilter.minNumber = cms.uint32(2)
		muons = "selectedKappaMuons"
		electrons = "selectedKappaElectrons"
		taus = "selectedKappaTaus"
	## ------------------------------------------------------------------------
		# possibility to write out edmDump. Be careful when using unsceduled mode
	process.load("Kappa.Skimming.edmOut")
	process.ep = cms.EndPath()
	#process.ep *= process.edmOut

	## ------------------------------------------------------------------------
	# Configure Kappa
	if testfile:
		process.source.fileNames      = testfile
	else:
		process.source 			  = cms.Source('PoolSource', fileNames=cms.untracked.vstring())
	process.maxEvents.input	      = maxevents
	process.kappaTuple.verbose    = cms.int32(0)
	process.kappaTuple.profile    = cms.bool(True)
	if not globaltag.lower() == 'auto' :
		process.GlobalTag.globaltag   = globaltag
		print "GT (overwritten):", process.GlobalTag.globaltag
	## ------------------------------------------------------------------------
	# Configure Metadata describing the file
	# Important to be evaluated correctly for the following steps
	process.kappaTuple.active = cms.vstring('TreeInfo')
	data, isEmbedded, miniaod, process.kappaTuple.TreeInfo.parameters = datasetsHelper.getTreeInfo(nickname, globaltag, kappaTag)

	## ------------------------------------------------------------------------
	# General configuration
	if ((cmssw_version_number.startswith("7_4") and split_cmssw_version[2] >= 14) or (cmssw_version_number.startswith("7_6"))):
		process.kappaTuple.Info.pileUpInfoSource = cms.InputTag("slimmedAddPileupInfo")

	process.kappaTuple.active += cms.vstring('VertexSummary')            # save VertexSummary,

	process.load("Kappa.Skimming.KVertices_cff")
	process.goodOfflinePrimaryVertices.src = cms.InputTag('offlineSlimmedPrimaryVertices')
	process.p *= ( process.makeVertexes )
	process.kappaTuple.VertexSummary.whitelist = cms.vstring('offlineSlimmedPrimaryVertices')  # save VertexSummary,
	process.kappaTuple.VertexSummary.rename = cms.vstring('offlineSlimmedPrimaryVertices => goodOfflinePrimaryVerticesSummary')
	if (cmssw_version_number.startswith("7_6")):
		process.kappaTuple.VertexSummary.goodOfflinePrimaryVerticesSummary = cms.PSet(src=cms.InputTag("offlineSlimmedPrimaryVertices"))

	process.kappaTuple.active += cms.vstring('TriggerObjectStandalone')
	if(data and ("Run2015" in nickname)):
		process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag("TriggerResults", "", "RECO")
	# Adds for each HLT Trigger wich contains "Tau" or "tau" in the name a Filter object named "l1extratauccolltection" 
	process.kappaTuple.TriggerObjectStandalone.l1extratauJetSource = cms.untracked.InputTag("l1extraParticles","IsoTau","RECO")
	
	process.kappaTuple.active += cms.vstring('BeamSpot')                 # save Beamspot,
	if (cmssw_version_number.startswith("7_6")):
		process.kappaTuple.BeamSpot.offlineBeamSpot = cms.PSet(src = cms.InputTag("offlineBeamSpot"))

	if not isEmbedded and data:
			process.kappaTuple.active+= cms.vstring('DataInfo')          # produce Metadata for data,

	if not isEmbedded and not data:
			process.kappaTuple.active+= cms.vstring('GenInfo')           # produce Metadata for MC,
			process.kappaTuple.active+= cms.vstring('GenParticles')      # save GenParticles,
			process.kappaTuple.active+= cms.vstring('GenTaus')           # save GenParticles,

			process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("prunedGenParticles")
			process.kappaTuple.GenTaus.genTaus.src = cms.InputTag("prunedGenParticles")

	if isEmbedded:
		#process.load('RecoBTag/Configuration/RecoBTag_cff')
		#process.load('RecoJets/JetAssociationProducers/ak5JTA_cff')
		#process.ak5PFJetNewTracksAssociatorAtVertex.tracks = "tmfTracks"
		#process.ak5PFCHSNewJetTracksAssociatorAtVertex.tracks = "tmfTracks"
		#process.p *= process.btagging
		# disable overrideHLTCheck for embedded samples, since it triggers an Kappa error
		process.kappaTuple.Info.overrideHLTCheck = cms.untracked.bool(True)
		process.kappaTuple.active += cms.vstring('DataInfo')
		process.kappaTuple.active += cms.vstring('GenParticles') # save GenParticles,
		process.kappaTuple.active += cms.vstring('GenTaus') # save GenParticles,
		process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("genParticles","","EmbeddedRECO")

	## ------------------------------------------------------------------------
	# Trigger
	from Kappa.Skimming.hlt_run2 import hltBlacklist, hltWhitelist
	process.kappaTuple.Info.hltWhitelist = hltWhitelist
	process.kappaTuple.Info.hltBlacklist = hltBlacklist

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

	#process.kappaTuple.active += cms.vstring('packedPFCandidates') # save PFCandidates. Not sure for what, because might not be usefull for isolation
	#process.kappaTuple.packedPFCandidates.packedPFCandidates = cms.PSet(src = cms.InputTag("packedPFCandidates"))


	from RecoMET.METPUSubtraction.localSqlite import recorrectJets
	recorrectJets(process, isData=data)
	jetCollection = "patJetsReapplyJEC"


	## ------------------------------------------------------------------------
	# Configure Muons
	process.load("Kappa.Skimming.KMuons_miniAOD_cff")
	process.kappaTuple.Muons.muons.src = cms.InputTag(muons)
	process.kappaTuple.Muons.muons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
	process.kappaTuple.Muons.muons.srcMuonIsolationPF = cms.InputTag("")
	process.kappaTuple.Muons.use03ConeForPfIso = cms.bool(True)
	for src in [ "muPFIsoDepositCharged", "muPFIsoDepositChargedAll", "muPFIsoDepositNeutral", "muPFIsoDepositGamma", "muPFIsoDepositPU"]:
		setattr(getattr(process, src), "src", cms.InputTag(muons))

	process.kappaTuple.active += cms.vstring('Muons')
	process.kappaTuple.Muons.noPropagation = cms.bool(True)
	process.p *= ( process.makeKappaMuons )

	## ------------------------------------------------------------------------
	# Configure Electrons
	process.kappaTuple.active += cms.vstring('Electrons')
	process.load("Kappa.Skimming.KElectrons_miniAOD_cff")
	process.kappaTuple.Electrons.electrons.src = cms.InputTag("slimmedElectrons")
	process.kappaTuple.Electrons.electrons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
	process.kappaTuple.Electrons.electrons.rhoIsoInputTag = cms.InputTag("slimmedJets", "rho")
	process.kappaTuple.Electrons.electrons.allConversions = cms.InputTag("reducedEgamma", "reducedConversions")
	from Kappa.Skimming.KElectrons_miniAOD_cff import setupElectrons
	process.kappaTuple.Electrons.srcIds = cms.string("standalone");

	process.kappaTuple.Electrons.ids = cms.vstring("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
					"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
					"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
					"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
					"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring15NonTrig25nsV1Values")


	setupElectrons(process, electrons)
	process.p *= ( process.makeKappaElectrons )
	## ------------------------------------------------------------------------
	process.kappaTuple.active += cms.vstring('PatTaus')
	process.kappaTuple.PatTaus.taus.binaryDiscrBlacklist = cms.vstring()
	process.kappaTuple.PatTaus.taus.floatDiscrBlacklist = cms.vstring()
	# just took everything from https://twiki.cern.ch/twiki/bin/viewauth/CMS/TauIDRecommendation13TeV
	process.kappaTuple.PatTaus.taus.preselectOnDiscriminators = cms.vstring ()
	process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist = cms.vstring(
	                                                                       "decayModeFinding",
	                                                                       "decayModeFindingNewDMs",
	                                                                       "byLooseCombinedIsolationDeltaBetaCorr3Hits",
	                                                                       "byMediumCombinedIsolationDeltaBetaCorr3Hits",
	                                                                       "byTightCombinedIsolationDeltaBetaCorr3Hits",
	                                                                       "byCombinedIsolationDeltaBetaCorrRaw3Hits",
	                                                                       "chargedIsoPtSum",
	                                                                       "neutralIsoPtSum",
	                                                                       "puCorrPtSum",
	                                                                       "footprintCorrection",
	                                                                       "photonPtSumOutsideSignalCone",
	                                                                       "byIsolationMVArun2v1DBoldDMwLTraw",
	                                                                       "byLooseIsolationMVArun2v1DBoldDMwLT",
	                                                                       "byMediumIsolationMVArun2v1DBoldDMwLT",
	                                                                       "byTightIsolationMVArun2v1DBoldDMwLT",
	                                                                       "byVTightIsolationMVArun2v1DBoldDMwLT",
	                                                                       "byIsolationMVArun2v1DBnewDMwLTraw",
	                                                                       "byLooseIsolationMVArun2v1DBnewDMwLT",
	                                                                       "byMediumIsolationMVArun2v1DBnewDMwLT",
	                                                                       "byTightIsolationMVArun2v1DBnewDMwLT",
	                                                                       "byVTightIsolationMVArun2v1DBnewDMwLT",
	                                                                       "againstMuonLoose3",
	                                                                       "againstMuonTight3",
	                                                                       "againstElectronMVA5category",
	                                                                       "againstElectronMVA5raw",
	                                                                       "againstElectronVLooseMVA5",
	                                                                       "againstElectronLooseMVA5",
	                                                                       "againstElectronMediumMVA5",
	                                                                       "againstElectronTightMVA5",
	                                                                       "againstElectronVTightMVA5",
	                                                                       "againstElectronMVA6category",
	                                                                       "againstElectronMVA6raw",
	                                                                       "againstElectronVLooseMVA6",
	                                                                       "againstElectronLooseMVA6",
	                                                                       "againstElectronMediumMVA6",
	                                                                       "againstElectronTightMVA6",
	                                                                       "againstElectronVTightMVA6",
	                                                                       "byLooseCombinedIsolationDeltaBetaCorr3HitsdR03",
	                                                                       "byMediumCombinedIsolationDeltaBetaCorr3HitsdR03",
	                                                                       "byTightCombinedIsolationDeltaBetaCorr3HitsdR03",
	                                                                       "byLooseIsolationMVArun2v1DBdR03oldDMwLT",
	                                                                       "byMediumIsolationMVArun2v1DBdR03oldDMwLT",
	                                                                       "byTightIsolationMVArun2v1DBdR03oldDMwLT",
	                                                                       "byVTightIsolationMVArun2v1DBdR03oldDMwLT"
	)
	process.kappaTuple.PatTaus.taus.floatDiscrWhitelist = process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist
	## ------------------------------------------------------------------------
	## Configure Jets
	process.kappaTuple.active += cms.vstring('PileupDensity')
	process.kappaTuple.PileupDensity.whitelist = cms.vstring("fixedGridRhoFastjetAll")
	process.kappaTuple.PileupDensity.rename = cms.vstring("fixedGridRhoFastjetAll => pileupDensity")
	if (cmssw_version_number.startswith("7_6")):
		process.kappaTuple.PileupDensity.pileupDensity = cms.PSet(src=cms.InputTag("fixedGridRhoFastjetAll"))
	process.kappaTuple.active += cms.vstring('PatJets')
	if (cmssw_version_number.startswith("7_6")):
		process.kappaTuple.PatJets.ak4PF = cms.PSet(src=cms.InputTag(jetCollection))
	#from Kappa.Skimming.KMET_run2_cff import configureMVAMetForMiniAOD
	#configureMVAMetForMiniAOD(process)

	## Standard MET and GenMet from pat::MET
	process.kappaTuple.active += cms.vstring('PatMET')
	process.kappaTuple.PatMET.met = cms.PSet(src=cms.InputTag("slimmedMETs"))
	process.kappaTuple.PatMET.pfmetT1 = cms.PSet(src=cms.InputTag("patpfMETT1"))
	process.kappaTuple.PatMET.metPuppi = cms.PSet(src=cms.InputTag("slimmedMETsPuppi"))

	## Write MVA MET to KMETs
	process.kappaTuple.active += cms.vstring('PatMETs')
	# new MVA MET
	from RecoMET.METPUSubtraction.MVAMETConfiguration_cff import runMVAMET
	runMVAMET( process, jetCollectionPF = jetCollection)
	process.kappaTuple.PatMETs.MVAMET = cms.PSet(src=cms.InputTag("MVAMET", "MVAMET"))
	process.MVAMET.srcLeptons  = cms.VInputTag(muons, electrons, taus) # to produce all possible combinations
	process.MVAMET.requireOS = cms.bool(False)


	## ------------------------------------------------------------------------
	## GenJets 
	if not data:
		process.load('PhysicsTools/JetMCAlgos/TauGenJets_cfi')
		process.load('PhysicsTools/JetMCAlgos/TauGenJetsDecayModeSelectorAllHadrons_cfi')
		process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles")
		process.p *= ( 
			process.tauGenJets +
			process.tauGenJetsSelectorAllHadrons
			)
		process.kappaTuple.GenJets.whitelist = cms.vstring("tauGenJets")
		process.kappaTuple.active += cms.vstring('GenJets')
		if (cmssw_version_number.startswith("7_6")):
			process.kappaTuple.GenJets.tauGenJets = cms.PSet(src=cms.InputTag("tauGenJets"))
			process.kappaTuple.GenJets.tauGenJetsSelectorAllHadrons = cms.PSet(src=cms.InputTag("tauGenJetsSelectorAllHadrons"))

	## ------------------------------------------------------------------------
	## Further information saved to Kappa output 
	# add python config to TreeInfo
	process.kappaTuple.TreeInfo.parameters.config = cms.string(process.dumpPython())

	# add repository revisions to TreeInfo
	for repo, rev in tools.get_repository_revisions().iteritems():
			setattr(process.kappaTuple.TreeInfo.parameters, repo, cms.string(rev))


	## ------------------------------------------------------------------------
	## Count Events after running all filters 
	if not data:
		process.nEventsTotal.isMC = cms.bool(True)
		process.nNegEventsTotal.isMC = cms.bool(True)
		process.nEventsFiltered.isMC = cms.bool(True)
		process.nNegEventsFiltered.isMC = cms.bool(True)

	process.p *= process.nEventsFiltered
	process.p *= process.nNegEventsFiltered
	process.kappaTuple.active += cms.vstring('FilterSummary')

	## ------------------------------------------------------------------------
	## if needed adapt output filename
	process.p *= process.kappaOut
	if outputfilename != '':
		process.kappaTuple.outputFile = cms.string('%s'%outputfilename)

	return process
示例#6
0
    "slimmedJets", "rho")

# -- electron IDs
process.kappaTuple.Electrons.srcIds = cms.string("standalone")
process.kappaTuple.Electrons.ids = cms.VInputTag(
    # cut-based VIDs
    "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-veto",
    "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-loose",
    "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-medium",
    "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V1-tight",
)

# -- call the default KAPPA electron setup routine
setupElectrons(
    process,
    "slimmedElectrons",
    id_modules=[
        'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff'
    ])

# -- add to process
process.path *= (process.makeKappaElectrons)

######################
# Configure JTB Jets #
######################

# jet collections obtained with 'JetToolbox' CMSSW module:
# https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetToolbox
from JMEAnalysis.JetToolbox.jetToolbox_cff import jetToolbox

# -- set basic skimming parameters
示例#7
0
        engineName=cms.untracked.string('TRandom3'),
    ))

process.path += process.calibratedPatElectrons

# selection criteria for ensuring well-defined VIDs
process.selectedElectrons = cms.EDFilter(
    "PATElectronSelector",
    src=cms.InputTag("calibratedPatElectrons"),
    cut=cms.string("pt>5 && abs(eta)"))

process.path += process.selectedElectrons

# -- call the KAPPA electron setup routine with calibrated collection
_electron_tag = "selectedElectrons"
setupElectrons(process, _electron_tag)

process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag(_electron_tag)
process.electronIDValueMapProducer.srcMiniAOD = cms.InputTag(_electron_tag)
process.electronRegressionValueMapProducer.srcMiniAOD = cms.InputTag(
    _electron_tag)
process.electronMVAValueMapProducer.srcMiniAOD = cms.InputTag(_electron_tag)
process.kappaTuple.Electrons.electrons.src = _electron_tag

###setupElectrons(process, "slimmedElectrons")

# -- add to process
process.path *= (process.makeKappaElectrons)

# process.path += process.egmGsfElectronIDSequence
示例#8
0
def getBaseConfig( globaltag= 'START70_V7::All',
	testfile=cms.untracked.vstring(""),
	maxevents=50,
	nickname = 'SUSYGluGluToHToTauTauM160_RunIIFall15MiniAODv2_PU25nsData2015v1_13TeV_MINIAOD_pythia8',
	kappaTag = 'Kappa_2_0_0',
	outputfilename = ''):

	from Kappa.Skimming.KSkimming_template_cfg import process
	## ------------------------------------------------------------------------

	# count number of events before doing anything else
	process.p *= process.nEventsTotal
	process.p *= process.nNegEventsTotal

	muons = "slimmedMuons"
	electrons = "slimmedElectrons"

	# new tau id only available for 8_0_20 (I believe) and above
	if tools.is_above_cmssw_version([8,0,20]):
		taus = "NewTauIDsEmbedded"
	else:
		taus = "slimmedTaus"
	isSignal = datasetsHelper.isSignal(nickname)

	# produce selected collections and filter events with not even one Lepton
	if options.preselect and not isSignal:
		from Kappa.Skimming.KSkimming_preselection import do_preselection

		do_preselection(process)
		process.p *= process.goodEventFilter

		process.selectedKappaTaus.cut = cms.string('pt > 15 && abs(eta) < 2.5')
		process.selectedKappaMuons.cut = cms.string('pt > 8 && abs(eta) < 2.6')
		process.selectedKappaElectrons.cut = cms.string('pt > 8 && abs(eta) < 2.7')
		muons = "selectedKappaMuons"
		electrons = "selectedKappaElectrons"
		taus = "selectedKappaTaus"
		process.goodEventFilter.minNumber = cms.uint32(2)

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

	# possibility to write out edmDump. Be careful when using unsceduled mode
	process.load("Kappa.Skimming.edmOut")
	process.ep = cms.EndPath()
	#process.ep *= process.edmOut

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

	# Configure Kappa
	if testfile:
		process.source            = cms.Source('PoolSource', fileNames=cms.untracked.vstring(testfile))
		# uncomment the following option to select only running on certain luminosity blocks. Use only for debugging
		# in this example 1 - is run and after semicolon - the LumiSection
		# process.source.lumisToProcess  = cms.untracked.VLuminosityBlockRange("1:62090-1:63091")
		#process.source.eventsToProcess = cms.untracked.VEventRange('1:917:1719279', '1:1022:1915188')
		#process.source.skipEvents = cms.untracked.uint32(539)
	else:
		process.source 			  = cms.Source('PoolSource', fileNames=cms.untracked.vstring())
	process.maxEvents.input	      = maxevents
	process.kappaTuple.verbose    = cms.int32(0)

	process.kappaTuple.profile    = cms.bool(True)
	if not globaltag.lower() == 'auto' :
		process.GlobalTag.globaltag   = globaltag

		# Auto alternative
		#from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
		#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '')

		print "GT (overwritten):", process.GlobalTag.globaltag
	## ------------------------------------------------------------------------

	# Configure Metadata describing the file
	# Important to be evaluated correctly for the following steps
	# data, isEmbedded, miniaod, process.kappaTuple.TreeInfo.parameters = datasetsHelper.getTreeInfo(nickname, globaltag, kappaTag)
	process.kappaTuple.active = cms.vstring('TreeInfo')

	data = datasetsHelper.isData(nickname)
	isEmbedded = datasetsHelper.isEmbedded(nickname)
	print "nicknane:", nickname

	#####miniaod = datasetsHelper.isMiniaod(nickname) not used anymore, since everything is MiniAOD now
	process.kappaTuple.TreeInfo.parameters= datasetsHelper.getTreeInfo(nickname, globaltag, kappaTag)

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

	# General configuration
	if tools.is_above_cmssw_version([7,4]) and not data and not isEmbedded:
		process.kappaTuple.Info.pileUpInfoSource = cms.InputTag("slimmedAddPileupInfo", "", "PAT")

	# save primary vertex
	process.kappaTuple.active += cms.vstring('VertexSummary') # save VertexSummary

	process.load("Kappa.Skimming.KVertices_cff")
	process.goodOfflinePrimaryVertices.src = cms.InputTag('offlineSlimmedPrimaryVertices')
	process.p *= ( process.makeVertexes )

	process.kappaTuple.VertexSummary.whitelist = cms.vstring('offlineSlimmedPrimaryVertices')  # save VertexSummary
	process.kappaTuple.VertexSummary.rename = cms.vstring('offlineSlimmedPrimaryVertices => goodOfflinePrimaryVerticesSummary')

	if tools.is_above_cmssw_version([7,6]):
		process.kappaTuple.VertexSummary.goodOfflinePrimaryVerticesSummary = cms.PSet(src=cms.InputTag("offlineSlimmedPrimaryVertices"))

	process.kappaTuple.active += cms.vstring('TriggerObjectStandalone')

	# setup BadPFMuonFilter and BadChargedCandidateFilter
	if tools.is_above_cmssw_version([8]) and not tools.is_above_cmssw_version([9]):
		process.load('RecoMET.METFilters.BadPFMuonFilter_cfi')
		process.BadPFMuonFilter.muons = cms.InputTag("slimmedMuons")
		process.BadPFMuonFilter.PFCandidates = cms.InputTag("packedPFCandidates")
		process.BadPFMuonFilter.taggingMode = cms.bool(True)

		process.load('RecoMET.METFilters.BadChargedCandidateFilter_cfi')
		process.BadChargedCandidateFilter.muons = cms.InputTag("slimmedMuons")
		process.BadChargedCandidateFilter.PFCandidates = cms.InputTag("packedPFCandidates")
		process.BadChargedCandidateFilter.taggingMode = cms.bool(True)

		# in reMiniAOD data these filters are already present; only need to run the dedicated module for MC and older data
		if not "03Feb2017" in str(process.kappaTuple.TreeInfo.parameters.scenario):
			process.load('RecoMET.METFilters.badGlobalMuonTaggersMiniAOD_cff')
			#switch on tagging mode:
			process.badGlobalMuonTaggerMAOD.taggingMode = cms.bool(True)
			process.cloneGlobalMuonTaggerMAOD.taggingMode = cms.bool(True)

			process.kappaTuple.TriggerObjectStandalone.metfilterbitslist = cms.vstring("BadChargedCandidateFilter", "BadPFMuonFilter", "badGlobalMuonTaggerMAOD", "cloneGlobalMuonTaggerMAOD")
		else:
			process.kappaTuple.TriggerObjectStandalone.metfilterbitslist = cms.vstring("BadChargedCandidateFilter","BadPFMuonFilter")

	process.kappaTuple.Info.hltSource = cms.InputTag("TriggerResults", "", "HLT")
	if isEmbedded:
		process.kappaTuple.TriggerObjectStandalone.bits = cms.InputTag("TriggerResults", "", "SIMembedding")
		process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag("TriggerResults", "", "MERGE")
		process.kappaTuple.Info.hltSource = cms.InputTag("TriggerResults", "", "SIMembedding")
	elif data:
		if tools.is_above_cmssw_version([9]):
			process.kappaTuple.Info.hltSource = cms.InputTag("TriggerResults", "", "HLT")
			#process.kappaTuple.TriggerObjectStandalone.bits = cms.InputTag("TriggerResults", "", "RECO")
		elif "03Feb2017" in str(process.kappaTuple.TreeInfo.parameters.scenario):
			process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag("TriggerResults", "", "PAT")
		else:
			process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag("TriggerResults", "", "RECO")
			process.kappaTuple.Info.hltSource = cms.InputTag("TriggerResults", "", "RECO")
	if not isEmbedded:
		if "reHLT" in str(process.kappaTuple.TreeInfo.parameters.campaign):
			process.kappaTuple.Info.hltSource = cms.InputTag("TriggerResults", "", "HLT2")
			process.kappaTuple.TriggerObjectStandalone.bits = cms.InputTag("TriggerResults", "", "HLT2")
			process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag("TriggerResults", "", "HLT2")
		elif "Spring16" in str(process.kappaTuple.TreeInfo.parameters.campaign):
			# adds for each HLT Trigger wich contains "Tau" or "tau" in the name a Filter object named "l1extratauccolltection"
			process.kappaTuple.TriggerObjectStandalone.l1extratauJetSource = cms.untracked.InputTag("l1extraParticles","IsoTau","RECO")

	process.kappaTuple.active += cms.vstring('BeamSpot')
	if tools.is_above_cmssw_version([7,6]):
		process.kappaTuple.BeamSpot.offlineBeamSpot = cms.PSet(src = cms.InputTag("offlineBeamSpot"))

	if not isEmbedded and data:
		process.kappaTuple.active+= cms.vstring('DataInfo')          # produce Metadata for data,

	if not isEmbedded and not data:
		process.kappaTuple.active+= cms.vstring('GenInfo')           # produce Metadata for MC,
		process.kappaTuple.active+= cms.vstring('GenParticles')      # save GenParticles,
		process.kappaTuple.active+= cms.vstring('GenTaus')           # save GenParticles,
		process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("prunedGenParticles")
		process.kappaTuple.GenTaus.genTaus.src = cms.InputTag("prunedGenParticles")

		process.kappaTuple.Info.lheSource = cms.InputTag("externalLHEProducer")
		process.kappaTuple.Info.lheWeightNames = cms.vstring(".*")

		if any([pattern in nickname for pattern in ["HToTauTau", "H2JetsToTauTau", "Higgs", "DY", "LFV"]]):
			process.kappaTuple.active += cms.vstring("LHE")
			process.kappaTuple.LHE.whitelist = cms.vstring("source")
			process.kappaTuple.LHE.rename = cms.vstring("source => LHEafter")
			if tools.is_above_cmssw_version([7, 6]):
				if "jhugen" in nickname.lower():
					process.kappaTuple.LHE.LHEafter = cms.PSet(src=cms.InputTag("source"))
				else:
					process.kappaTuple.LHE.LHEafter = cms.PSet(src=cms.InputTag("externalLHEProducer"))

	# save Flag
	process.kappaTuple.Info.isEmbedded = cms.bool(isEmbedded)

	if isEmbedded:
		#process.load('RecoBTag/Configuration/RecoBTag_cff')
		#process.load('RecoJets/JetAssociationProducers/ak5JTA_cff')
		#process.ak5PFJetNewTracksAssociatorAtVertex.tracks = "tmfTracks"
		#process.ak5PFCHSNewJetTracksAssociatorAtVertex.tracks = "tmfTracks"
		#process.p *= process.btagging
		# disable overrideHLTCheck for embedded samples, since it triggers an Kappa error
		process.kappaTuple.Info.overrideHLTCheck = cms.untracked.bool(True)
		process.kappaTuple.active += cms.vstring('GenInfo')
		process.kappaTuple.active += cms.vstring('GenParticles') # save GenParticles,
		process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("prunedGenParticles")
		process.kappaTuple.active += cms.vstring('GenTaus')
		process.kappaTuple.GenTaus.genTaus.src = cms.InputTag("prunedGenParticles")

		#process.kappaTuple.active += cms.vstring('GenTaus') # save GenParticles,
		#process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("genParticles","","EmbeddedRECO")

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

	# Trigger
	from Kappa.Skimming.hlt_run2 import hltBlacklist, hltWhitelist
	process.kappaTuple.Info.hltWhitelist = hltWhitelist
	process.kappaTuple.Info.hltBlacklist = hltBlacklist

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

	# should not be the default, it blows up the skim a lot
	#process.kappaTuple.active += cms.vstring('packedPFCandidates')
	#process.kappaTuple.packedPFCandidates.packedPFCandidates = cms.PSet(src = cms.InputTag("packedPFCandidates"))

	jetCollectionPuppi = "slimmedJetsPuppi"
	if tools.is_above_cmssw_version([9]):
		jetCollection = "slimmedJets"
	elif tools.is_above_cmssw_version([8]):
		from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
		updateJetCollection(
			process,
			jetSource = cms.InputTag('slimmedJets'),
			labelName = 'UpdatedJEC',
			jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual']), 'None'),
		)
		jetCollection = "updatedPatJetsUpdatedJEC"
		"""
		from RecoMET.METPUSubtraction.jet_recorrections import recorrectJets
		#from RecoMET.METPUSubtraction.jet_recorrections import loadLocalSqlite
		#loadLocalSqlite(process, sqliteFilename = "Spring16_25nsV6_DATA.db" if data else "Spring16_25nsV6_MC.db",
		#                         tag = 'JetCorrectorParametersCollection_Spring16_25nsV6_DATA_AK4PF' if data else 'JetCorrectorParametersCollection_Spring16_25nsV6_MC_AK4PF')
		recorrectJets(process, isData=data)
		jetCollection = "patJetsReapplyJEC"
		"""
	else:
		from RecoMET.METPUSubtraction.localSqlite import recorrectJets
		recorrectJets(process, isData=data)
		jetCollection = "patJetsReapplyJEC"

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

	# Configure Muons
	process.load("Kappa.Skimming.KMuons_miniAOD_cff")
	process.kappaTuple.Muons.muons.src = cms.InputTag(muons)
	process.kappaTuple.Muons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
	process.kappaTuple.Muons.srcMuonIsolationPF = cms.InputTag("")
	process.kappaTuple.Muons.use03ConeForPfIso = cms.bool(True)
	process.kappaTuple.Muons.doPfIsolation = cms.bool(False)
	for src in [ "muPFIsoDepositCharged", "muPFIsoDepositChargedAll", "muPFIsoDepositNeutral", "muPFIsoDepositGamma", "muPFIsoDepositPU"]:
		setattr(getattr(process, src), "src", cms.InputTag(muons))

	process.kappaTuple.active += cms.vstring('Muons')
	process.kappaTuple.Muons.noPropagation = cms.bool(True)
	process.p *= ( process.makeKappaMuons )

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

	# Configure Electrons
	process.kappaTuple.active += cms.vstring('Electrons')
	process.load("Kappa.Skimming.KElectrons_miniAOD_cff")
	process.kappaTuple.Electrons.electrons.src = cms.InputTag("slimmedElectrons")
	process.kappaTuple.Electrons.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
	process.kappaTuple.Electrons.rhoIsoInputTag = cms.InputTag("slimmedJets", "rho")
	process.kappaTuple.Electrons.allConversions = cms.InputTag("reducedEgamma", "reducedConversions")
	from Kappa.Skimming.KElectrons_miniAOD_cff import setupElectrons
	process.kappaTuple.Electrons.srcIds = cms.string("standalone")

	if tools.is_above_cmssw_version([8]):
		process.kappaTuple.Electrons.ids = cms.vstring(
			"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
			"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
			"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
			"egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
			"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values"
			)
	else:
		process.kappaTuple.Electrons.ids = cms.vstring(
			"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
			"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
			"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
			"egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
			"electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring15NonTrig25nsV1Values"
			)

	setupElectrons(process, electrons)
	process.p *= (process.makeKappaElectrons)

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

	# new tau id only available for 8_0_20 (I believe) and above
	if tools.is_above_cmssw_version([8,0,20]):
		process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
		process.load("Kappa.Skimming.KPatTaus_run2_cff")
		process.p *= ( process.makeKappaTaus )

		# embed new id's into new tau collection
		embedID = cms.EDProducer("PATTauIDEmbedder",
			src = cms.InputTag('slimmedTaus'),
			tauIDSources = cms.PSet(
				rerunDiscriminationByIsolationMVAOldDMrun2v1raw = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1raw'),
				rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose'),
				rerunDiscriminationByIsolationMVAOldDMrun2v1Loose = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1Loose'),
				rerunDiscriminationByIsolationMVAOldDMrun2v1Medium = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1Medium'),
				rerunDiscriminationByIsolationMVAOldDMrun2v1Tight = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1Tight'),
				rerunDiscriminationByIsolationMVAOldDMrun2v1VTight = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1VTight'),
				rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight'),
				rerunDiscriminationByIsolationMVANewDMrun2v1raw = cms.InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1raw'),
				rerunDiscriminationByIsolationMVANewDMrun2v1VLoose = cms.InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1VLoose'),
				rerunDiscriminationByIsolationMVANewDMrun2v1Loose = cms.InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1Loose'),
				rerunDiscriminationByIsolationMVANewDMrun2v1Medium = cms.InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1Medium'),
				rerunDiscriminationByIsolationMVANewDMrun2v1Tight = cms.InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1Tight'),
				rerunDiscriminationByIsolationMVANewDMrun2v1VTight = cms.InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1VTight'),
				rerunDiscriminationByIsolationMVANewDMrun2v1VVTight = cms.InputTag('rerunDiscriminationByIsolationMVANewDMrun2v1VVTight')
			),
		)
		setattr(process, taus, embedID)
		process.p *= getattr(process, taus)

	process.kappaTuple.active += cms.vstring('PatTaus')
	process.kappaTuple.PatTaus.vertexcollection = cms.InputTag("offlineSlimmedPrimaryVertices")
	process.kappaTuple.PatTaus.offlineBeamSpot = cms.InputTag("offlineBeamSpot")
	process.kappaTuple.PatTaus.taus.binaryDiscrBlacklist = cms.vstring()
	process.kappaTuple.PatTaus.taus.src = cms.InputTag(taus)
	process.kappaTuple.PatTaus.taus.floatDiscrBlacklist = cms.vstring()
	# just took everything from https://twiki.cern.ch/twiki/bin/viewauth/CMS/TauIDRecommendation13TeV
	process.kappaTuple.PatTaus.taus.preselectOnDiscriminators = cms.vstring ()
	process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist = cms.vstring(
		"decayModeFinding",
		"decayModeFindingNewDMs",
		"byLooseCombinedIsolationDeltaBetaCorr3Hits",
		"byMediumCombinedIsolationDeltaBetaCorr3Hits",
		"byTightCombinedIsolationDeltaBetaCorr3Hits",
		"byCombinedIsolationDeltaBetaCorrRaw3Hits",
		"chargedIsoPtSum",
		"neutralIsoPtSum",
		"neutralIsoPtSumWeight",
		"puCorrPtSum",
		"footprintCorrection",
		"photonPtSumOutsideSignalCone",
		"byIsolationMVArun2v1DBoldDMwLTraw",
		"byVLooseIsolationMVArun2v1DBoldDMwLT",
		"byLooseIsolationMVArun2v1DBoldDMwLT",
		"byMediumIsolationMVArun2v1DBoldDMwLT",
		"byTightIsolationMVArun2v1DBoldDMwLT",
		"byVTightIsolationMVArun2v1DBoldDMwLT",
		"byVVTightIsolationMVArun2v1DBoldDMwLT",
		#"byIsolationMVArun2v1DBnewDMwLTraw",
		#"byVLooseIsolationMVArun2v1DBnewDMwLT",
		#"byLooseIsolationMVArun2v1DBnewDMwLT",
		#"byMediumIsolationMVArun2v1DBnewDMwLT",
		#"byTightIsolationMVArun2v1DBnewDMwLT",
		#"byVTightIsolationMVArun2v1DBnewDMwLT",
		#"byVVTightIsolationMVArun2v1DBnewDMwLT",
		"againstMuonLoose3",
		"againstMuonTight3",
		"againstElectronMVA6category",
		"againstElectronMVA6raw",
		"againstElectronVLooseMVA6",
		"againstElectronLooseMVA6",
		"againstElectronMediumMVA6",
		"againstElectronTightMVA6",
		"againstElectronVTightMVA6"#,
		#"chargedIsoPtSumdR03",
		#"neutralIsoPtSumdR03",
		#"neutralIsoPtSumWeightdR03",
		#"footprintCorrectiondR03",
		#"photonPtSumOutsideSignalConedR03",
		#"byLooseCombinedIsolationDeltaBetaCorr3HitsdR03",
		#"byMediumCombinedIsolationDeltaBetaCorr3HitsdR03",
		#"byTightCombinedIsolationDeltaBetaCorr3HitsdR03",
		#"byIsolationMVArun2v1DBdR03oldDMwLTraw",
		#"byVLooseIsolationMVArun2v1DBdR03oldDMwLT",
		#"byLooseIsolationMVArun2v1DBdR03oldDMwLT",
		#"byMediumIsolationMVArun2v1DBdR03oldDMwLT",
		#"byTightIsolationMVArun2v1DBdR03oldDMwLT",
		#"byVTightIsolationMVArun2v1DBdR03oldDMwLT",
		#"byVVTightIsolationMVArun2v1DBdR03oldDMwLT",
		)
	if tools.is_above_cmssw_version([8,0,20]):
		process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist += cms.vstring(
			"rerunDiscriminationByIsolationMVAOldDMrun2v1raw",
			"rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose",
			"rerunDiscriminationByIsolationMVAOldDMrun2v1Loose",
			"rerunDiscriminationByIsolationMVAOldDMrun2v1Medium",
			"rerunDiscriminationByIsolationMVAOldDMrun2v1Tight",
			"rerunDiscriminationByIsolationMVAOldDMrun2v1VTight",
			"rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight",
			"rerunDiscriminationByIsolationMVANewDMrun2v1raw",
			"rerunDiscriminationByIsolationMVANewDMrun2v1VLoose",
			"rerunDiscriminationByIsolationMVANewDMrun2v1Loose",
			"rerunDiscriminationByIsolationMVANewDMrun2v1Medium",
			"rerunDiscriminationByIsolationMVANewDMrun2v1Tight",
			"rerunDiscriminationByIsolationMVANewDMrun2v1VTight",
			"rerunDiscriminationByIsolationMVANewDMrun2v1VVTight"
			)
	## now also possible to save all MVA isolation inputs for taus # turn of per default

	process.kappaTuple.PatTaus.taus.extrafloatDiscrlist = cms.untracked.vstring(
		"decayDistX",
		"decayDistY",
		"decayDistZ",
		"decayDistM",
		"nPhoton",
		"ptWeightedDetaStrip",
		"ptWeightedDphiStrip",
		"ptWeightedDrSignal",
		"ptWeightedDrIsolation",
		"leadingTrackChi2",
		"eRatio"
		)

	process.kappaTuple.PatTaus.taus.floatDiscrWhitelist = process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist
	process.kappaTuple.PatTaus.verbose = cms.int32(1)

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

	## Configure Jets
	process.kappaTuple.active += cms.vstring('PileupDensity')
	process.kappaTuple.PileupDensity.whitelist = cms.vstring("fixedGridRhoFastjetAll")
	process.kappaTuple.PileupDensity.rename = cms.vstring("fixedGridRhoFastjetAll => pileupDensity")
	if tools.is_above_cmssw_version([7,6]):
		process.kappaTuple.PileupDensity.pileupDensity = cms.PSet(src=cms.InputTag("fixedGridRhoFastjetAll"))
	process.kappaTuple.active += cms.vstring('PatJets')
	if tools.is_above_cmssw_version([7,6]):
		process.kappaTuple.PatJets.ak4PF = cms.PSet(src=cms.InputTag(jetCollection))
		process.kappaTuple.PatJets.puppiJets = cms.PSet(src=cms.InputTag(jetCollectionPuppi))
	elif tools.is_above_cmssw_version([8,0]):
		process.jecSequence = cms.Sequence(process.patJetCorrFactorsUpdatedJEC * process.updatedPatJetsUpdatedJEC)
		process.p *= process.jecSequence

	# process.load("Configuration.StandardSequences.Reconstruction_cff") or process.load("Configuration.Geometry.GeometryRecoDB_cff")
	process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")

	## Refitted Vertices collection
	if not tools.is_above_cmssw_version([9]):
		process.kappaTuple.active += cms.vstring('RefitVertex')
		process.load("VertexRefit.TauRefit.AdvancedRefitVertexProducer_cfi")

		if tools.is_above_cmssw_version([7,6]) and not tools.is_above_cmssw_version([9]):
			process.AdvancedRefitVertexBSProducer.srcElectrons = cms.InputTag(electrons)
			process.AdvancedRefitVertexBSProducer.srcMuons = cms.InputTag(muons)
			process.AdvancedRefitVertexBSProducer.srcTaus = cms.InputTag(taus)
			process.AdvancedRefitVertexBSProducer.srcLeptons = cms.VInputTag(electrons, muons, taus)
			process.p *= (process.AdvancedRefitVertexBS)

		process.AdvancedRefitVertexNoBSProducer.srcElectrons = cms.InputTag(electrons)
		process.AdvancedRefitVertexNoBSProducer.srcMuons = cms.InputTag(muons)
		process.AdvancedRefitVertexNoBSProducer.srcTaus = cms.InputTag(taus)
		process.AdvancedRefitVertexNoBSProducer.srcLeptons = cms.VInputTag(electrons, muons, taus)
		process.p *= (process.AdvancedRefitVertexNoBS)

		process.kappaTuple.RefitVertex.whitelist = cms.vstring('AdvancedRefitVertexBS', 'AdvancedRefitVertexNoBS')

		if tools.is_above_cmssw_version([7,6]) and not tools.is_above_cmssw_version([9]):
			process.kappaTuple.RefitVertex.AdvancedRefittedVerticesBS = cms.PSet(src=cms.InputTag("AdvancedRefitVertexBSProducer"))
			process.AdvancedRefitVertexBSProducer.srcElectrons = cms.InputTag(electrons)
			process.AdvancedRefitVertexBSProducer.srcMuons = cms.InputTag(muons)
			process.AdvancedRefitVertexBSProducer.srcTaus = cms.InputTag(taus)
			process.AdvancedRefitVertexBSProducer.srcLeptons = cms.VInputTag(electrons, muons, taus)

		if tools.is_above_cmssw_version([7,6]):
			process.kappaTuple.RefitVertex.AdvancedRefittedVerticesNoBS = cms.PSet(src=cms.InputTag("AdvancedRefitVertexNoBSProducer"))
			process.AdvancedRefitVertexNoBSProducer.srcElectrons = cms.InputTag(electrons)
			process.AdvancedRefitVertexNoBSProducer.srcMuons = cms.InputTag(muons)
			process.AdvancedRefitVertexNoBSProducer.srcTaus = cms.InputTag(taus)
			process.AdvancedRefitVertexNoBSProducer.srcLeptons = cms.VInputTag(electrons, muons, taus)

	## calculate IP info wrt refitted PV
	process.kappaTuple.Electrons.refitvertexcollection = cms.InputTag("AdvancedRefitVertexNoBSProducer")
	process.kappaTuple.Muons.refitvertexcollection = cms.InputTag("AdvancedRefitVertexNoBSProducer")
	process.kappaTuple.PatTaus.refitvertexcollection = cms.InputTag("AdvancedRefitVertexNoBSProducer")

	## Standard MET and GenMet from pat::MET
	process.kappaTuple.active += cms.vstring('PatMET')
	process.kappaTuple.PatMET.met = cms.PSet(src=cms.InputTag("slimmedMETs"))
	if tools.is_above_cmssw_version([9]):
		pass
	elif tools.is_above_cmssw_version([8,0,14]):
		from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
		runMetCorAndUncFromMiniAOD(process, isData=data  )
		process.kappaTuple.PatMET.met = cms.PSet(src=cms.InputTag("slimmedMETs", "", "KAPPA"))

	#process.kappaTuple.PatMET.pfmetT1 = cms.PSet(src=cms.InputTag("patpfMETT1"))
	process.kappaTuple.PatMET.metPuppi = cms.PSet(src=cms.InputTag("slimmedMETsPuppi"))

	if not tools.is_above_cmssw_version([8]):
		## Write MVA MET to KMETs
		process.kappaTuple.active += cms.vstring('PatMETs')
		# new MVA MET
		from RecoMET.METPUSubtraction.MVAMETConfiguration_cff import runMVAMET
		runMVAMET( process, jetCollectionPF = jetCollection)
		process.kappaTuple.PatMETs.MVAMET = cms.PSet(src=cms.InputTag("MVAMET", "MVAMET"))
		process.MVAMET.srcLeptons  = cms.VInputTag(muons, electrons, taus) # to produce all possible combinations
		process.MVAMET.requireOS = cms.bool(False)
		if tools.is_above_cmssw_version([8,0]) and isEmbedded:
			process.MVAMET.srcMETs = cms.VInputTag(
				cms.InputTag("slimmedMETs", "", "MERGE"),
				cms.InputTag("patpfTrackMET"),
				cms.InputTag("patpfNoPUMET"),
				cms.InputTag("patpfPUCorrectedMET"),
				cms.InputTag("patpfPUMET"),
				cms.InputTag("slimmedMETsPuppi", "", "MERGE")
				)

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

	## GenJets
	if not data or isEmbedded:
		process.load('PhysicsTools/JetMCAlgos/TauGenJets_cfi')
		process.load('PhysicsTools/JetMCAlgos/TauGenJetsDecayModeSelectorAllHadrons_cfi')
		process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles")
		process.p *= (
			process.tauGenJets +
			process.tauGenJetsSelectorAllHadrons
			)
		if isSignal:
			process.kappaTuple.GenJets.whitelist = cms.vstring("tauGenJets", "slimmedGenJets")
		else:
			process.kappaTuple.GenJets.whitelist = cms.vstring("tauGenJets")
		process.kappaTuple.active += cms.vstring('GenJets')
		if tools.is_above_cmssw_version([7,6]):
			if isSignal:
				process.kappaTuple.GenJets.genJets = cms.PSet(src=cms.InputTag("slimmedGenJets"))
			process.kappaTuple.GenJets.tauGenJets = cms.PSet(src=cms.InputTag("tauGenJets"))
			process.kappaTuple.GenJets.tauGenJetsSelectorAllHadrons = cms.PSet(src=cms.InputTag("tauGenJetsSelectorAllHadrons"))

	# add repository revisions to TreeInfo
	for repo, rev in tools.get_repository_revisions().iteritems():
		setattr(process.kappaTuple.TreeInfo.parameters, repo, cms.string(rev))

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

	## Count Events after running all filters
	if not data:
		process.nEventsTotal.isMC = cms.bool(True)
		process.nNegEventsTotal.isMC = cms.bool(True)
		process.nEventsFiltered.isMC = cms.bool(True)
		process.nNegEventsFiltered.isMC = cms.bool(True)

	process.p *= process.nEventsFiltered
	process.p *= process.nNegEventsFiltered
	process.kappaTuple.active += cms.vstring('FilterSummary')

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

	## if needed adapt output filename
	process.ep *= process.kappaOut
	if outputfilename != '':
		process.kappaTuple.outputFile = cms.string('%s'%outputfilename)

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

	## Further information saved to Kappa output
	if options.dumpPython:
		f = open("dumpPython.py", "w")
		f.write(process.dumpPython())
		f.close()

	# add python config to TreeInfo
	process.kappaTuple.TreeInfo.parameters.config = cms.string(process.dumpPython())

	print "process.p:", process.p
	return process
    "slimmedJets", "rho")

# -- electron IDs
process.kappaTuple.Electrons.srcIds = cms.string("standalone")
process.kappaTuple.Electrons.ids = cms.VInputTag(
    # cut-based VIDs (80X)
    "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-veto",
    "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-loose",
    "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-medium",
    "egmGsfElectronIDs:cutBasedElectronID-Summer16-80X-V1-tight",
    # MVA VIDs
    "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring16GeneralPurposeV1Values",
)

# -- call the default KAPPA electron setup routine
setupElectrons(process, "calibratedPatElectrons")

# -- EGM post-reco sequence
from RecoEgamma.EgammaTools.EgammaPostRecoTools import setupEgammaPostRecoSeq

setupEgammaPostRecoSeq(process,
                       applyEnergyCorrections=True,
                       applyVIDOnCorrectedEgamma=True,
                       isMiniAOD=True,
                       era='2016-Legacy')

# -- add to process
process.path *= (process.makeKappaElectrons * process.egammaPostRecoSeq)

######################
# Configure JTB Jets #
示例#10
0
def getBaseConfig(
        globaltag='START70_V7::All',
        testfile=cms.untracked.vstring(""),
        maxevents=100,  ## -1 = all in file
        nickname='SUSYGluGluToHToTauTauM160_RunIIFall15MiniAODv2_PU25nsData2015v1_13TeV_MINIAOD_pythia8',
        kappaTag='Kappa_2_0_0',
        outputfilename=''):

    from Kappa.Skimming.KSkimming_template_cfg import process
    ## ------------------------------------------------------------------------
    # count number of events before doing anything elese
    process.p *= process.nEventsTotal
    process.p *= process.nNegEventsTotal

    muons = "slimmedMuons"
    electrons = "slimmedElectrons"
    taus = "slimmedTaus"
    # produce selected collections and filter events with not even one Lepton
    if (options.preselect):
        from Kappa.Skimming.KSkimming_preselection import do_preselection
        do_preselection(process)
        process.p *= process.goodEventFilter

        process.selectedKappaTaus.cut = cms.string('pt > 15 && abs(eta) < 2.5')
        process.selectedKappaMuons.cut = cms.string('pt > 8 && abs(eta) < 2.6')
        process.selectedKappaElectrons.cut = cms.string(
            'pt > 8 && abs(eta) < 2.7')
        process.goodEventFilter.minNumber = cms.uint32(2)
        muons = "selectedKappaMuons"
        electrons = "selectedKappaElectrons"
        taus = "selectedKappaTaus"
    ## ------------------------------------------------------------------------
    # possibility to write out edmDump. Be careful when using unsceduled mode
    process.load("Kappa.Skimming.edmOut")
    process.ep = cms.EndPath()
    #process.ep *= process.edmOut

    ## ------------------------------------------------------------------------
    # Configure Kappa
    if testfile:
        process.source.fileNames = testfile
    else:
        process.source = cms.Source('PoolSource',
                                    fileNames=cms.untracked.vstring())
    process.maxEvents.input = maxevents
    process.kappaTuple.verbose = cms.int32(0)
    process.kappaTuple.profile = cms.bool(True)
    if not globaltag.lower() == 'auto':
        process.GlobalTag.globaltag = globaltag
        print "GT (overwritten):", process.GlobalTag.globaltag
    ## ------------------------------------------------------------------------
    # Configure Metadata describing the file
    # Important to be evaluated correctly for the following steps
    process.kappaTuple.active = cms.vstring('TreeInfo')
    data, isEmbedded, miniaod, process.kappaTuple.TreeInfo.parameters = datasetsHelper.getTreeInfo(
        nickname, globaltag, kappaTag)

    ## ------------------------------------------------------------------------
    # General configuration
    if ((cmssw_version_number.startswith("7_4")
         and split_cmssw_version[2] >= 14)
            or (cmssw_version_number.startswith("7_6"))):
        process.kappaTuple.Info.pileUpInfoSource = cms.InputTag(
            "slimmedAddPileupInfo")

    process.kappaTuple.active += cms.vstring(
        'VertexSummary')  # save VertexSummary,

    process.load("Kappa.Skimming.KVertices_cff")
    process.goodOfflinePrimaryVertices.src = cms.InputTag(
        'offlineSlimmedPrimaryVertices')
    process.p *= (process.makeVertexes)
    process.kappaTuple.VertexSummary.whitelist = cms.vstring(
        'offlineSlimmedPrimaryVertices')  # save VertexSummary,
    process.kappaTuple.VertexSummary.rename = cms.vstring(
        'offlineSlimmedPrimaryVertices => goodOfflinePrimaryVerticesSummary')
    if (cmssw_version_number.startswith("7_6")):
        process.kappaTuple.VertexSummary.goodOfflinePrimaryVerticesSummary = cms.PSet(
            src=cms.InputTag("offlineSlimmedPrimaryVertices"))

    process.kappaTuple.active += cms.vstring('TriggerObjectStandalone')
    if (data and ("Run2015" in nickname)):
        process.kappaTuple.TriggerObjectStandalone.metfilterbits = cms.InputTag(
            "TriggerResults", "", "RECO")
    # Adds for each HLT Trigger wich contains "Tau" or "tau" in the name a Filter object named "l1extratauccolltection"
    process.kappaTuple.TriggerObjectStandalone.l1extratauJetSource = cms.untracked.InputTag(
        "l1extraParticles", "IsoTau", "RECO")

    process.kappaTuple.active += cms.vstring('BeamSpot')  # save Beamspot,
    if (cmssw_version_number.startswith("7_6")):
        process.kappaTuple.BeamSpot.offlineBeamSpot = cms.PSet(
            src=cms.InputTag("offlineBeamSpot"))

    if not isEmbedded and data:
        process.kappaTuple.active += cms.vstring(
            'DataInfo')  # produce Metadata for data,

    if not isEmbedded and not data:
        process.kappaTuple.active += cms.vstring(
            'GenInfo')  # produce Metadata for MC,
        process.kappaTuple.active += cms.vstring(
            'GenParticles')  # save GenParticles,
        process.kappaTuple.active += cms.vstring(
            'GenTaus')  # save GenParticles,

        process.kappaTuple.GenParticles.genParticles.src = cms.InputTag(
            "prunedGenParticles")
        process.kappaTuple.GenTaus.genTaus.src = cms.InputTag(
            "prunedGenParticles")

    if isEmbedded:
        #process.load('RecoBTag/Configuration/RecoBTag_cff')
        #process.load('RecoJets/JetAssociationProducers/ak5JTA_cff')
        #process.ak5PFJetNewTracksAssociatorAtVertex.tracks = "tmfTracks"
        #process.ak5PFCHSNewJetTracksAssociatorAtVertex.tracks = "tmfTracks"
        #process.p *= process.btagging
        # disable overrideHLTCheck for embedded samples, since it triggers an Kappa error
        process.kappaTuple.Info.overrideHLTCheck = cms.untracked.bool(True)
        process.kappaTuple.active += cms.vstring('DataInfo')
        process.kappaTuple.active += cms.vstring(
            'GenParticles')  # save GenParticles,
        process.kappaTuple.active += cms.vstring(
            'GenTaus')  # save GenParticles,
        process.kappaTuple.GenParticles.genParticles.src = cms.InputTag(
            "genParticles", "", "EmbeddedRECO")

    ## ------------------------------------------------------------------------
    # Trigger
    from Kappa.Skimming.hlt_run2 import hltBlacklist, hltWhitelist
    process.kappaTuple.Info.hltWhitelist = hltWhitelist
    process.kappaTuple.Info.hltBlacklist = hltBlacklist

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

    #process.kappaTuple.active += cms.vstring('packedPFCandidates') # save PFCandidates. Not sure for what, because might not be usefull for isolation
    #process.kappaTuple.packedPFCandidates.packedPFCandidates = cms.PSet(src = cms.InputTag("packedPFCandidates"))

    from RecoMET.METPUSubtraction.localSqlite import recorrectJets
    recorrectJets(process, isData=data)
    jetCollection = "patJetsReapplyJEC"

    ## ------------------------------------------------------------------------
    # Configure Muons
    process.load("Kappa.Skimming.KMuons_miniAOD_cff")
    process.kappaTuple.Muons.muons.src = cms.InputTag(muons)
    process.kappaTuple.Muons.muons.vertexcollection = cms.InputTag(
        "offlineSlimmedPrimaryVertices")
    process.kappaTuple.Muons.muons.srcMuonIsolationPF = cms.InputTag("")
    process.kappaTuple.Muons.use03ConeForPfIso = cms.bool(True)
    for src in [
            "muPFIsoDepositCharged", "muPFIsoDepositChargedAll",
            "muPFIsoDepositNeutral", "muPFIsoDepositGamma", "muPFIsoDepositPU"
    ]:
        setattr(getattr(process, src), "src", cms.InputTag(muons))

    process.kappaTuple.active += cms.vstring('Muons')
    process.kappaTuple.Muons.noPropagation = cms.bool(True)
    process.p *= (process.makeKappaMuons)

    ## ------------------------------------------------------------------------
    # Configure Electrons
    process.kappaTuple.active += cms.vstring('Electrons')
    process.load("Kappa.Skimming.KElectrons_miniAOD_cff")
    process.kappaTuple.Electrons.electrons.src = cms.InputTag(
        "slimmedElectrons")
    process.kappaTuple.Electrons.electrons.vertexcollection = cms.InputTag(
        "offlineSlimmedPrimaryVertices")
    process.kappaTuple.Electrons.electrons.rhoIsoInputTag = cms.InputTag(
        "slimmedJets", "rho")
    process.kappaTuple.Electrons.electrons.allConversions = cms.InputTag(
        "reducedEgamma", "reducedConversions")
    from Kappa.Skimming.KElectrons_miniAOD_cff import setupElectrons
    process.kappaTuple.Electrons.srcIds = cms.string("standalone")

    process.kappaTuple.Electrons.ids = cms.vstring(
        "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto",
        "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose",
        "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium",
        "egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight",
        "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Spring15NonTrig25nsV1Values"
    )

    setupElectrons(process, electrons)
    process.p *= (process.makeKappaElectrons)
    ## ------------------------------------------------------------------------
    process.kappaTuple.active += cms.vstring('PatTaus')
    process.kappaTuple.PatTaus.taus.binaryDiscrBlacklist = cms.vstring()
    process.kappaTuple.PatTaus.taus.floatDiscrBlacklist = cms.vstring()
    # just took everything from https://twiki.cern.ch/twiki/bin/viewauth/CMS/TauIDRecommendation13TeV
    process.kappaTuple.PatTaus.taus.preselectOnDiscriminators = cms.vstring()
    process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist = cms.vstring(
        "decayModeFinding", "decayModeFindingNewDMs",
        "byLooseCombinedIsolationDeltaBetaCorr3Hits",
        "byMediumCombinedIsolationDeltaBetaCorr3Hits",
        "byTightCombinedIsolationDeltaBetaCorr3Hits",
        "byCombinedIsolationDeltaBetaCorrRaw3Hits", "chargedIsoPtSum",
        "neutralIsoPtSum", "puCorrPtSum", "footprintCorrection",
        "photonPtSumOutsideSignalCone", "byIsolationMVArun2v1DBoldDMwLTraw",
        "byLooseIsolationMVArun2v1DBoldDMwLT",
        "byMediumIsolationMVArun2v1DBoldDMwLT",
        "byTightIsolationMVArun2v1DBoldDMwLT",
        "byVTightIsolationMVArun2v1DBoldDMwLT",
        "byIsolationMVArun2v1DBnewDMwLTraw",
        "byLooseIsolationMVArun2v1DBnewDMwLT",
        "byMediumIsolationMVArun2v1DBnewDMwLT",
        "byTightIsolationMVArun2v1DBnewDMwLT",
        "byVTightIsolationMVArun2v1DBnewDMwLT", "againstMuonLoose3",
        "againstMuonTight3", "againstElectronMVA5category",
        "againstElectronMVA5raw", "againstElectronVLooseMVA5",
        "againstElectronLooseMVA5", "againstElectronMediumMVA5",
        "againstElectronTightMVA5", "againstElectronVTightMVA5",
        "againstElectronMVA6category", "againstElectronMVA6raw",
        "againstElectronVLooseMVA6", "againstElectronLooseMVA6",
        "againstElectronMediumMVA6", "againstElectronTightMVA6",
        "againstElectronVTightMVA6",
        "byLooseCombinedIsolationDeltaBetaCorr3HitsdR03",
        "byMediumCombinedIsolationDeltaBetaCorr3HitsdR03",
        "byTightCombinedIsolationDeltaBetaCorr3HitsdR03",
        "byLooseIsolationMVArun2v1DBdR03oldDMwLT",
        "byMediumIsolationMVArun2v1DBdR03oldDMwLT",
        "byTightIsolationMVArun2v1DBdR03oldDMwLT",
        "byVTightIsolationMVArun2v1DBdR03oldDMwLT")
    process.kappaTuple.PatTaus.taus.floatDiscrWhitelist = process.kappaTuple.PatTaus.taus.binaryDiscrWhitelist
    ## ------------------------------------------------------------------------
    ## Configure Jets
    process.kappaTuple.active += cms.vstring('PileupDensity')
    process.kappaTuple.PileupDensity.whitelist = cms.vstring(
        "fixedGridRhoFastjetAll")
    process.kappaTuple.PileupDensity.rename = cms.vstring(
        "fixedGridRhoFastjetAll => pileupDensity")
    if (cmssw_version_number.startswith("7_6")):
        process.kappaTuple.PileupDensity.pileupDensity = cms.PSet(
            src=cms.InputTag("fixedGridRhoFastjetAll"))
    process.kappaTuple.active += cms.vstring('PatJets')
    if (cmssw_version_number.startswith("7_6")):
        process.kappaTuple.PatJets.ak4PF = cms.PSet(
            src=cms.InputTag(jetCollection))
    #from Kappa.Skimming.KMET_run2_cff import configureMVAMetForMiniAOD
    #configureMVAMetForMiniAOD(process)

    ## Standard MET and GenMet from pat::MET
    process.kappaTuple.active += cms.vstring('PatMET')
    process.kappaTuple.PatMET.met = cms.PSet(src=cms.InputTag("slimmedMETs"))
    process.kappaTuple.PatMET.pfmetT1 = cms.PSet(
        src=cms.InputTag("patpfMETT1"))
    process.kappaTuple.PatMET.metPuppi = cms.PSet(
        src=cms.InputTag("slimmedMETsPuppi"))

    ## Write MVA MET to KMETs
    process.kappaTuple.active += cms.vstring('PatMETs')
    # new MVA MET
    from RecoMET.METPUSubtraction.MVAMETConfiguration_cff import runMVAMET
    runMVAMET(process, jetCollectionPF=jetCollection)
    process.kappaTuple.PatMETs.MVAMET = cms.PSet(
        src=cms.InputTag("MVAMET", "MVAMET"))
    process.MVAMET.srcLeptons = cms.VInputTag(
        muons, electrons, taus)  # to produce all possible combinations
    process.MVAMET.requireOS = cms.bool(False)

    ## ------------------------------------------------------------------------
    ## GenJets
    if not data:
        process.load('PhysicsTools/JetMCAlgos/TauGenJets_cfi')
        process.load(
            'PhysicsTools/JetMCAlgos/TauGenJetsDecayModeSelectorAllHadrons_cfi'
        )
        process.tauGenJets.GenParticles = cms.InputTag("prunedGenParticles")
        process.p *= (process.tauGenJets +
                      process.tauGenJetsSelectorAllHadrons)
        process.kappaTuple.GenJets.whitelist = cms.vstring("tauGenJets")
        process.kappaTuple.active += cms.vstring('GenJets')
        if (cmssw_version_number.startswith("7_6")):
            process.kappaTuple.GenJets.tauGenJets = cms.PSet(
                src=cms.InputTag("tauGenJets"))
            process.kappaTuple.GenJets.tauGenJetsSelectorAllHadrons = cms.PSet(
                src=cms.InputTag("tauGenJetsSelectorAllHadrons"))

    ## ------------------------------------------------------------------------
    ## Further information saved to Kappa output
    # add python config to TreeInfo
    process.kappaTuple.TreeInfo.parameters.config = cms.string(
        process.dumpPython())

    # add repository revisions to TreeInfo
    for repo, rev in tools.get_repository_revisions().iteritems():
        setattr(process.kappaTuple.TreeInfo.parameters, repo, cms.string(rev))

    ## ------------------------------------------------------------------------
    ## Count Events after running all filters
    if not data:
        process.nEventsTotal.isMC = cms.bool(True)
        process.nNegEventsTotal.isMC = cms.bool(True)
        process.nEventsFiltered.isMC = cms.bool(True)
        process.nNegEventsFiltered.isMC = cms.bool(True)

    process.p *= process.nEventsFiltered
    process.p *= process.nNegEventsFiltered
    process.kappaTuple.active += cms.vstring('FilterSummary')

    ## ------------------------------------------------------------------------
    ## if needed adapt output filename
    process.p *= process.kappaOut
    if outputfilename != '':
        process.kappaTuple.outputFile = cms.string('%s' % outputfilename)

    return process