Example #1
0
def addMuVars(s3):
    vars = {}
    flags = {}

    muVars = dict(
        normalizedChi2="? {0}.isGlobalMuon ? {0}.globalTrack.normalizedChi2 : -9999",
        numberOfValidMuonHits="? {0}.isGlobalMuon ? {0}.globalTrack.hitPattern.numberOfValidMuonHits : -9999",
        numberOfMatches="? {0}.isGlobalMuon ? {0}.numberOfMatches : -9999",
        TMLastStationTight="? {0}.isTrackerMuon ? {0}.muonID('TMLastStationTight') : -9999",
        trkKink="{0}.combinedQuality.trkKink",
        trackerLayersWithMeasurement="{0}.innerTrack.hitPattern.trackerLayersWithMeasurement",
        numberOfValidPixelHits="{0}.innerTrack.hitPattern.numberOfValidPixelHits",
        trackRelErr="abs({0}.track.ptError / {0}.pt)",
        #         trackRelErr2                 = "abs({0}.track.ptError / {0}.track.pt)",
    )
    muFlags = dict(isGlobalMuon="{0}.isGlobalMuon()", isTrakerMuon="{0}.isTrackerMuon()", isPFMuon="{0}.isPFMuon")

    for i in [0, 1]:
        for (name, raw) in muVars.iteritems():
            formula = ("? abs({0}.pdgId) == 13 ? " + raw + " : -9999").format("candByPt(" + str(i) + ")")
            vars[name + str(i + 1)] = cms.string(formula)
        for (name, raw) in muFlags.iteritems():
            formula = ("? abs({0}.pdgId) == 13 ? " + raw + " : -9999").format("candByPt(" + str(i) + ")")
            flags[name + str(i + 1)] = cms.string(formula)

    addVarFlags(s3, vars=vars, flags=flags)
def createJERESource(process):
    datadir = "%s/src/flashgg/Systematics/data/JER" % environ["CMSSW_BASE"]
    print "WARNING: we are reading JER from %s so GRID jobs might not work" % datadir
    process.load("Configuration.StandardSequences.Services_cff")
    process.load("JetMETCorrections.Modules.JetResolutionESProducer_cfi")
    from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup

    process.jer = cms.ESSource(
        "PoolDBESSource",
        CondDBSetup,
        toGet=cms.VPSet(
            # Resolution
            cms.PSet(
                record=cms.string("JetResolutionRcd"),
                tag=cms.string("JR_Summer15_25nsV6_MC_PtResolution_AK4PFchs"),
                label=cms.untracked.string("AK4PFchs_pt"),
            ),
            # Scale factors
            cms.PSet(
                record=cms.string("JetResolutionScaleFactorRcd"),
                tag=cms.string("JR_Summer15_25nsV6_MC_SF_AK4PFchs"),
                label=cms.untracked.string("AK4PFchs"),
            ),
        ),
        # [2016-02-21 14:50:14,703] INFO: Connecting to Systematics/data/JER/Summer15_25nsV6_MC.db [sqlite:///Systematics/data/JER/Summer15_25nsV6_MC.db]
        # JR_Summer15_25nsV6_MC_SF_AK4PFchs             Run       JME::JetResolutionObject  any              -1             2016-02-05 20:59:34.061327  New Tag
        # JR_Summer15_25nsV6_MC_PtResolution_AK4PFchs   Run       JME::JetResolutionObject  any              -1             2016-02-05 20:59:34.064554  New Tag
        connect=cms.string("sqlite_file:%s/Summer15_25nsV6_MC.db" % datadir),
    )
    process.es_prefer_jer = cms.ESPrefer("PoolDBESSource", "jer")
Example #3
0
def customise_Digi(process):
    # deal with csc
    process = digitizer_timing_pre3_median(process)
    process = digiEventContent(process)
    process.CSCIndexerESProducer.AlgoName = cms.string("CSCIndexerPostls1")
    process.CSCChannelMapperESProducer.AlgoName = cms.string("CSCChannelMapperPostls1")
    return process
Example #4
0
def calculateMetPhiCorrectedMET(process, prefix, conf, src):
    process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")

    if conf.isMC:
        process.pfMEtSysShiftCorr.parameter = process.pfMEtSysShiftCorrParameters_2012runABCDvsNvtx_mc
    else:
        process.pfMEtSysShiftCorr.parameter = process.pfMEtSysShiftCorrParameters_2012runABCDvsNvtx_data

    selectedVerticesForMETCorr = process.selectedVerticesForMEtCorr.clone(
        src=cms.InputTag("goodOfflinePrimaryVertices")
    )
    systShiftMETCorr = process.pfMEtSysShiftCorr.clone(
        src=cms.InputTag(src), srcVertices=cms.InputTag(prep(prefix, "selectedVerticesForMETCorr"))
    )

    prod = cms.EDProducer(
        "CorrectedPATMETProducer",
        src=cms.InputTag(src),
        applyType1Corrections=cms.bool(True),
        srcType1Corrections=cms.VInputTag(cms.InputTag(prep(prefix, "systShiftMETCorr"))),
        type0Rsoft=cms.double(0.6),
        applyType2Corrections=cms.bool(False),
        srcCHSSums=cms.VInputTag(cms.InputTag("pfchsMETcorr", "type0")),
        applyType0Corrections=cms.bool(False),
    )
    seq = cms.Sequence(selectedVerticesForMETCorr * systShiftMETCorr * prod)
    sa(process, prefix, "systShiftMETCorr", systShiftMETCorr)
    sa(process, prefix, "selectedVerticesForMETCorr", selectedVerticesForMETCorr)
    sa(process, prefix, "phiCorrMETs", prod)
    sa(process, prefix, "metPhiCorrSequence", seq)
    return seq
Example #5
0
    def configure(self):
        # return configuration object
        # for set of drawJobs

        for iPlot in range(len(self.plots)):

            drawJob = copy.deepcopy(self.template)

            dqmSubDirectory = self.dqmSubDirectories[iPlot]

            dqmDirectory = self.dqmDirectory
            if dqmSubDirectory != "":
                dqmDirectory += dqmSubDirectory
            if not dqmDirectory.endswith("/"):
                dqmDirectory += "/"

            plot = self.plots[iPlot]

            dqmMonitorElement = dqmDirectory + getattr(plot, "meName")

            setattr(drawJob.plots, "dqmMonitorElements", cms.vstring([dqmMonitorElement]))
            if hasattr(plot, "PAR"):
                setattr(drawJob, "parameter", cms.vstring(getattr(plot, "PAR")))
            setattr(drawJob, "title", cms.string(getattr(plot, "title")))
            setattr(drawJob, "xAxis", cms.string(getattr(plot, "xAxis")))

            # add drawJob configuration to set of drawJobs
            setattr(self.drawJobs, getattr(plot, "name"), drawJob)

        return self.drawJobs
def customise(process):
    process.load("GeneratorInterface.RivetInterface.rivetAnalyzer_cfi")
    process.rivetAnalyzer.AnalysisNames = cms.vstring("ATLAS_2010_S8894728")  # CMS_2010_S8547297')
    process.rivetAnalyzer.OutputFile = cms.string("EPOS.aida")
    process.generation_step += process.rivetAnalyzer
    process.schedule.remove(process.GENoutput_step)
    return process
    def addMuMuSVFit(self, moduleName):
        dicand = cms.EDProducer("PATMuMuSVFitter")
        dicand.src = cms.InputTag(self.input)
        dicand.srcPrimaryVertex = cms.InputTag("offlinePrimaryVerticesWithBS")
        dicand.srcBeamSpot = cms.InputTag("offlineBeamSpot")
        dicand.svFit = cms.PSet(
            psKine=cms.PSet(
                likelihoodFunctions=cms.VPSet(svFitLikelihoodMuMuKinematicsPhaseSpace),
                estUncertainties=cms.PSet(numSamplings=cms.int32(-1)),
            ),
            psKine_MEt=cms.PSet(
                likelihoodFunctions=cms.VPSet(svFitLikelihoodMuMuKinematicsPhaseSpace, svFitLikelihoodMuMuMEt),
                estUncertainties=cms.PSet(numSamplings=cms.int32(-1)),
            ),
            psKine_MEt_ptBalance=cms.PSet(
                likelihoodFunctions=cms.VPSet(
                    svFitLikelihoodMuMuKinematicsPhaseSpace, svFitLikelihoodMuMuMEt, svFitLikelihoodMuMuPtBalance
                ),
                estUncertainties=cms.PSet(numSamplings=cms.int32(-1)),
            ),
        )

        pyModule = sys.modules[self.pyModuleName[0]]
        if pyModule is None:
            raise ValueError("'pyModuleName' Parameter invalid")
        setattr(pyModule, moduleName, dicand)
        self.sequence *= dicand
        self.input = moduleName
Example #8
0
def customise_Validation(process, pileup):
    process.validation_step.remove(process.PixelTrackingRecHitsValid)
    # We don't run the HLT
    process.validation_step.remove(process.HLTSusyExoVal)
    process.validation_step.remove(process.hltHiggsValidator)
    process.validation_step.remove(process.relvalMuonBits)
    if pileup > 30:
        process.trackValidator.label = cms.VInputTag(cms.InputTag("cutsRecoTracksHp"))
        process.tracksValidationSelectors = cms.Sequence(process.cutsRecoTracksHp)
        process.globalValidation.remove(process.recoMuonValidation)
        process.validation.remove(process.recoMuonValidation)
        process.validation_preprod.remove(process.recoMuonValidation)
        process.validation_step.remove(process.recoMuonValidation)
        process.validation.remove(process.globalrechitsanalyze)
        process.validation_prod.remove(process.globalrechitsanalyze)
        process.validation_step.remove(process.globalrechitsanalyze)
        process.validation.remove(process.stripRecHitsValid)
        process.validation_step.remove(process.stripRecHitsValid)
        process.validation_step.remove(process.StripTrackingRecHitsValid)
        process.globalValidation.remove(process.vertexValidation)
        process.validation.remove(process.vertexValidation)
        process.validation_step.remove(process.vertexValidation)
        process.mix.input.nbPileupEvents.averageNumber = cms.double(0.0)
        process.mix.minBunch = cms.int32(0)
        process.mix.maxBunch = cms.int32(0)

    return process
def initPayloadWriter(process, outputDBConnect="sqlite_file:l1config.db", outputDBAuth=".", tagBaseVec=[]):
    import FWCore.ParameterSet.Config as cms
    from CondTools.L1Trigger.L1CondEnum_cfi import L1CondEnum

    if len(tagBaseVec) == 0:
        from CondTools.L1Trigger.L1UniformTags_cfi import initL1UniformTags

        initL1UniformTags()
        tagBaseVec = initL1UniformTags.tagBaseVec

    process.load("CondTools.L1Trigger.L1CondDBPayloadWriter_cfi")

    from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup

    initPayloadWriter.outputDB = cms.Service(
        "PoolDBOutputService",
        CondDBSetup,
        connect=cms.string(outputDBConnect),
        toPut=cms.VPSet(
            cms.PSet(
                record=cms.string("L1TriggerKeyListRcd"),
                tag=cms.string("L1TriggerKeyList_" + tagBaseVec[L1CondEnum.L1TriggerKeyList]),
            )
        ),
    )
    initPayloadWriter.outputDB.DBParameters.authenticationPath = outputDBAuth
    process.add_(initPayloadWriter.outputDB)
Example #10
0
def customisePercentile(process):

    process.siStripZeroSuppression.Algorithms.CommonModeNoiseSubtractionMode = cms.string("Percentile")
    process.siStripZeroSuppression.Algorithms.Percentile = cms.double(25.0)
    process.siStripZeroSuppression.storeCM = cms.bool(True)

    return process
def customise_csc_cond_ungangedME11A_mc(process):
    """ Pick up upgrade condions data directly from DB tags using ESPrefer's.
    Might be useful when dealing with a global tag that doesn't include 
    'unganged' CSC conditions.
    """
    myconds = [
        ("CSCDBGainsRcd", "CSCDBGains_ungangedME11A_mc"),
        ("CSCDBNoiseMatrixRcd", "CSCDBNoiseMatrix_ungangedME11A_mc"),
        ("CSCDBCrosstalkRcd", "CSCDBCrosstalk_ungangedME11A_mc"),
        ("CSCDBPedestalsRcd", "CSCDBPedestals_ungangedME11A_mc"),
        ("CSCDBGasGainCorrectionRcd", "CSCDBGasGainCorrection_ungangedME11A_mc"),
        ("CSCDBChipSpeedCorrectionRcd", "CSCDBChipSpeedCorrection_ungangedME11A_mc"),
    ]

    from CalibMuon.Configuration.getCSCConditions_frontier_cff import cscConditions

    for (classname, tag) in myconds:
        print classname, tag
        sourcename = "unganged_" + classname
        process.__setattr__(sourcename, cscConditions.clone())
        process.__getattribute__(sourcename).toGet = cms.VPSet(
            cms.PSet(record=cms.string(classname), tag=cms.string(tag))
        )
        process.__getattribute__(sourcename).connect = cms.string("frontier://FrontierProd/CMS_COND_CSC_000")
        process.__setattr__("esp_" + classname, cms.ESPrefer("PoolDBESSource", sourcename))

    del cscConditions

    return process
Example #12
0
def addVariable(vpset, expr, name=None, nbins=None, vmin=None, vmax=None):
    if ":=" in expr:
        toks = [v.rstrip(" ").lstrip(" ") for v in expr.split(":=")]
        ## print toks
        name, expr = toks

    if not name:
        name = expr.replace(".", "_").replace("get", "")
    if name.endswith("]"):
        name, rng = name.replace("]", "").split("[")
        rng = rng.split(",")
        nbins = int(rng[0])
        vmin = float(rng[1])
        vmax = float(rng[2])

    if "map(" in expr:
        var, bins, vals = expr.lstrip("map(").rstrip(")").split("::")
        bins = [float(b) for b in bins.split(",")]
        vals = [float(v) for v in vals.split(",")]
        pset = cms.PSet(
            expr=cms.PSet(var=cms.string(var), bins=cms.vdouble(bins), vals=cms.vdouble(vals)),
            name=cms.untracked.string(name),
        )
    else:
        pset = cms.PSet(expr=cms.string(expr), name=cms.untracked.string(name))
    if nbins:
        pset.nbins = cms.untracked.int32(nbins)
        pset.vmin = cms.untracked.double(vmin)
        pset.vmax = cms.untracked.double(vmax)
    vpset.append(pset)
def psetMinPtCut():
    return cms.PSet(
        cutName=cms.string("MinPtCut"),
        minPt=cms.double(35.0),
        needsAdditionalProducts=cms.bool(False),
        isIgnored=cms.bool(False),
    )
Example #14
0
def electronTriggerMatchPT(process, triggerProcess):

    process.triggeredPatElectronsL = cms.EDProducer(
        "ElectronTriggerMatcher",
        src=cms.InputTag("cleanPatElectrons"),
        trigEvent=cms.InputTag("hltTriggerSummaryAOD"),
        filters=cms.VInputTag(cms.InputTag("hltEle17CaloIdLCaloIsoVLPixelMatchFilterDoubleEG125", "", triggerProcess)),
        pdgId=cms.int32(0),
    )
    process.triggeredPatElectrons = cms.EDProducer(
        "ElectronTriggerMatcher",
        src=cms.InputTag("triggeredPatElectronsL"),
        trigEvent=cms.InputTag("hltTriggerSummaryAOD"),
        filters=cms.VInputTag(
            cms.InputTag("hltOverlapFilterIsoEle15IsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle15TightIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle18MediumIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle18TightIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle18IsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle20MediumIsoPFTau20", "", triggerProcess),
        ),
        pdgId=cms.int32(11),
    )

    process.analysisSequence = cms.Sequence(
        process.analysisSequence * process.triggeredPatElectronsL * process.triggeredPatElectrons
    )
Example #15
0
    def alcaHarvesting(self, globalTag, datasetName, **args):
        """
        _alcaHarvesting_

        Proton collisions data taking AlCa Harvesting

        """
        if not "skims" in args:
            return None
        options = defaultOptions
        options.scenario = self.cbSc if hasattr(self, "cbSc") else self.__class__.__name__
        options.step = "ALCAHARVEST:" + ("+".join(args["skims"]))
        options.name = "ALCAHARVEST"
        options.conditions = globalTag

        process = cms.Process("ALCAHARVEST")
        process.source = cms.Source("PoolSource")
        configBuilder = ConfigBuilder(options, process=process)
        configBuilder.prepare()

        #
        # customise process for particular job
        #
        process.source.processingMode = cms.untracked.string("RunsAndLumis")
        process.source.fileNames = cms.untracked(cms.vstring())
        process.maxEvents.input = -1
        process.dqmSaver.workflow = datasetName

        return process
def miniAOD_customizeMETFiltersFastSim(process):
    """Replace some MET filters that don't work in FastSim with trivial bools"""
    for X in "CSCTightHaloFilter", "HBHENoiseFilter", "HBHENoiseFilterResultProducer":
        process.globalReplace(X, cms.EDFilter("HLTBool", result=cms.bool(True)))
    for X in "manystripclus53X", "toomanystripclus53X", "logErrorTooManyClusters":
        process.globalReplace(X, cms.EDFilter("HLTBool", result=cms.bool(False)))
    return process
Example #17
0
def dqmIOSource(args):
    import FWCore.ParameterSet.Config as cms

    if args.get("newDQMIO", False):
        return cms.Source("DQMRootSource", fileNames=cms.untracked(cms.vstring()))
    else:
        return cms.Source("PoolSource", fileNames=cms.untracked(cms.vstring()))
Example #18
0
def replace(cfg_object, **replacements):
    if isinstance(cfg_object, cms._Parameterizable):
        output = cfg_object.clone()
        # If this is a PSet like type (PSet, EDFilter, etc), recurse down
        for par in cfg_object.parameters_().keys():
            # Do this so we get objects, not copies
            value = getattr(cfg_object, par)
            # Recurse down
            new_value = replace(value, **replacements)
            new_name = replace_str(par, **replacements)

            setattr(output, new_name, new_value)
            # Check if the name changed - delete the old one.
            if new_name != par:
                delattr(output, par)

        return output
    # Otherwise check if we need to update this
    if isinstance(cfg_object, cms.string):
        new_str = replace_str(cfg_object.value(), **replacements)
        return cms.string(new_str)
    elif isinstance(cfg_object, cms.vstring):
        formatted = []
        for x in cfg_object:
            formatted.append(replace_str(x, **replacements))
        return cms.vstring(formatted)
    elif isinstance(cfg_object, cms.InputTag):
        formatted = replace_str(cfg_object.value(), **replacements)
        return cms.InputTag(formatted)
    elif isinstance(cfg_object, cms.VPSet):
        output = cms.VPSet()
        for subpset in cfg_object:
            output += replace(subpset, **replacements)
        return output
def addDileptonFilters(process):

    # leptons
    process.llPreselectionCounter = cms.EDProducer("EventCountProducer")
    process.lCandidates = cms.EDProducer("CandViewMerger", src=cms.VInputTag("gsfElectrons", "muons"))
    process.lCandCounter = cms.EDFilter("CandViewCountFilter", src=cms.InputTag("lCandidates"), minNumber=cms.uint32(2))
    process.llCandidates = cms.EDProducer(
        "CandViewShallowCloneCombiner",
        decay=cms.string("lCandidates lCandidates"),
        cut=cms.string(
            "mass>12 && daughter(0).pt()>20 && daughter(1).pt()>20 && abs(daughter(0).eta)<2.5 && abs(daughter(1).eta())<2.5"
        ),
        checkCharge=cms.bool(False),
    )
    process.llCandidateCounter = cms.EDFilter(
        "CandViewCountFilter", src=cms.InputTag("llCandidates"), minNumber=cms.uint32(1)
    )
    process.llSelectionCounter = process.llPreselectionCounter.clone()
    process.llCandidateSequence = cms.Sequence(
        process.llPreselectionCounter
        * process.lCandidates
        * process.lCandCounter
        * process.llCandidates
        * process.llCandidateCounter
        * process.llSelectionCounter
    )
    print " *** ll CandidateSequences is defined"
Example #20
0
def electronTriggerMatchPT(process, triggerProcess, HLT):

    process.triggeredPatElectronsL = cms.EDProducer(
        "ElectronTriggerMatcher",
        src=cms.InputTag("cleanPatElectrons"),
        trigEvent=cms.InputTag(HLT),
        filters=cms.VInputTag(cms.InputTag("hltEle17CaloIdLCaloIsoVLPixelMatchFilterDoubleEG125", "", triggerProcess)),
        pdgId=cms.int32(0),
    )
    process.triggeredPatElectrons = cms.EDProducer(
        "ElectronTriggerMatcher",
        src=cms.InputTag("cleanPatElectrons"),
        trigEvent=cms.InputTag(HLT),
        filters=cms.VInputTag(
            cms.InputTag("hltOverlapFilterIsoEle15IsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle15TightIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle18MediumIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle18TightIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle18IsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle20MediumIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle20LooseIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltOverlapFilterIsoEle20WP90LooseIsoPFTau20", "", triggerProcess),
            cms.InputTag("hltEle20CaloIdVTCaloIsoTTrkIdTTrkIsoTTrackIsoFilterL1IsoEG18OrEG20", "", triggerProcess),
            cms.InputTag("hltEle22WP90RhoTrackIsoFilter", "", triggerProcess),
            cms.InputTag("hltEle27WP80TrackIsoFilter", "", triggerProcess),
            cms.InputTag("hltEle27WP80TrackIsoFilter", "", triggerProcess),
            cms.InputTag("hltEle17TightIdLooseIsoEle8TightIdLooseIsoTrackIsoDoubleFilter", "", triggerProcess),
            cms.InputTag("hltEle17TightIdLooseIsoEle8TightIdLooseIsoTrackIsoFilter", "", triggerProcess),
        ),
        pdgId=cms.int32(11),
    )

    process.analysisSequence = cms.Sequence(
        process.analysisSequence * process.triggeredPatElectronsL * process.triggeredPatElectrons
    )
    def addHLT(self, path, triggerProcess, summaryText=""):
        hltSkimmer = cms.EDFilter(
            "HLTHighLevel",
            TriggerResultsTag=cms.InputTag("TriggerResults", "", triggerProcess),
            HLTPaths=cms.vstring(path),  # provide list of HLT paths (or patterns) you want
            eventSetupPathsKey=cms.string(""),  # not empty => use read paths from AlCaRecoTriggerBitsRcd via this key
            andOr=cms.bool(
                True
            ),  # how to deal with multiple triggers: True (OR) accept if ANY is true, False (AND) accept if ALL are true
            throw=cms.bool(True),  # throw exception on unknown path names
        )

        pyModule = sys.modules[self.pyModuleName[0]]
        if pyModule is None:
            raise ValueError("'pyModuleName' Parameter invalid")
        setattr(pyModule, "hltSkimmer", hltSkimmer)
        self.sequence *= hltSkimmer

        # now the counter
        if summaryText is not "":
            counter = cms.EDProducer("EventCounter")
            counter.name = cms.string(summaryText)
            counter.setLabel("hltSkimmerCounter")
            pyModule = sys.modules[self.pyModuleName[0]]
            if pyModule is None:
                raise ValueError("'pyModuleName' Parameter invalid")
            setattr(pyModule, "hltSkimmerCounter", counter)
            self.sequence *= counter
Example #22
0
def turn_on_Pixel_aging_1000(process):
    # just incase we want aging afterall
    if hasattr(process, "mix") and hasattr(process.mix, "digitizers") and hasattr(process.mix.digitizers, "hcal"):
        process.mix.digitizers.pixel.PseudoRadDamage = cms.double(1.5)
        process.mix.digitizers.pixel.PseudoRadDamageRadius = cms.double(4.0)

    return process
def loadLocalJECDBfile(
    process,
    dbfile="",
    tag="JetCorrectorParametersCollection_PY8_RunIISpring15DR74_bx50_MC_AK4PUPPI",
    label="AK4PFPuppi",
):
    # ===================================================
    # local BD reader
    # load and replace the data base by the local one
    # ===================================================
    # print ':: dbfile == ', dbfile

    process.load("CondCore.DBCommon.CondDBCommon_cfi")
    process.load("CondCore.DBCommon.CondDBSetup_cfi")
    setattr(
        process,
        "jec" + label,
        cms.ESSource(
            "PoolDBESSource",
            DBParameters=cms.PSet(messageLevel=cms.untracked.int32(0)),
            timetype=cms.string("runnumber"),
            toGet=cms.VPSet(
                cms.PSet(
                    record=cms.string("JetCorrectionsRecord"), tag=cms.string(tag), label=cms.untracked.string(label)
                )
            ),
            connect=cms.string("sqlite_file:%s" % dbfile),
        ),
    )

    setattr(process, "es_prefer_jec" + label, cms.ESPrefer("PoolDBESSource", "jec" + label))
Example #24
0
def addPFCandidates(process, src, patLabel="PFParticles", cut="", postfix=""):
    from PhysicsTools.PatAlgos.producersLayer1.pfParticleProducer_cfi import patPFParticles

    # make modules
    producer = patPFParticles.clone(pfCandidateSource=src)
    filter = cms.EDFilter("PATPFParticleSelector", src=cms.InputTag("pat" + patLabel), cut=cms.string(cut))
    counter = cms.EDFilter(
        "PATCandViewCountFilter",
        minNumber=cms.uint32(0),
        maxNumber=cms.uint32(999999),
        src=cms.InputTag("pat" + patLabel),
    )
    # add modules to process
    setattr(process, "pat" + patLabel, producer)
    setattr(process, "selectedPat" + patLabel, filter)
    setattr(process, "countPat" + patLabel, counter)
    # insert into sequence
    getattr(process, "patDefaultSequence" + postfix).replace(
        applyPostfix(process, "patCandidateSummary", postfix),
        producer + applyPostfix(process, "patCandidateSummary", postfix),
    )
    getattr(process, "patDefaultSequence" + postfix).replace(
        applyPostfix(process, "selectedPatCandidateSummary", postfix),
        filter + applyPostfix(process, "selectedPatCandidateSummary", postfix),
    )
    index = len(applyPostfix(process, "patDefaultSequence", postfix).moduleNames())
    applyPostfix(process, "patDefaultSequence", postfix).insert(index, counter)
    # summary tables
    applyPostfix(process, "patCandidateSummary", postfix).candidates.append(cms.InputTag("pat" + patLabel))
    applyPostfix(process, "selectedPatCandidateSummary", postfix).candidates.append(
        cms.InputTag("selectedPat" + patLabel)
    )
Example #25
0
    def alcaHarvesting(self, globalTag, **args):
        """
        _alcaHarvesting_

        Heavy-ion collisions data taking AlCa Harvesting

        """
        options = defaultOptions
        options.scenario = "HeavyIons"
        options.step = "ALCAHARVEST:BeamSpotByRun+BeamSpotByLumi"
        options.isMC = False
        options.isData = True
        options.beamspot = None
        options.eventcontent = None
        options.name = "ALCAHARVEST"
        options.conditions = globalTag
        options.arguments = ""
        options.evt_type = ""
        options.filein = []

        process = cms.Process("ALCAHARVEST")
        process.source = cms.Source("PoolSource")
        configBuilder = ConfigBuilder(options, process=process)
        configBuilder.prepare()

        #
        # customise process for particular job
        #
        process.source.processingMode = cms.untracked.string("RunsAndLumis")
        process.source.fileNames = cms.untracked(cms.vstring())
        process.maxEvents.input = -1

        return process
Example #26
0
def SpawnPSet(lArgument, subPset):
    """SpawnPSet(lArgument, subPset) --> cms.PSet\n
    lArgument is a list containing a list of three strings/values:\n
           1-name to give to the spawned pset\n
           2-variable(s) to be changed\n
           3-value(s) of the variable(s): SAME LENGTH OF 2-!\n
           Supported types: int string float(converted to double)"""
    ret = cms.PSet()
    for spawn in lArgument:
        if len(spawn) != 3:
            print "ERROR! SpawnPSet uses argument of three data\n"
            print self.__doc__
            return None
        if len(spawn[1]) != len(spawn[2]):
            print "ERROR! Lists of arguments to replace must have the same length"
            print self.__doc__
            return None
        spawnArg = copy.deepcopy(subPset)
        for par, val in zip(spawn[1], spawn[2]):
            if type(val) is str:
                setattr(spawnArg, par, cms.string(val))
            elif type(val) is int:
                setattr(spawnArg, par, cms.int32(val))
            elif type(val) is float:
                setattr(spawnArg, par, cms.double(val))
        setattr(ret, spawn[0], spawnArg)
    return ret
Example #27
0
def customise_Reco(process):
    # lowering HO threshold with SiPM
    if hasattr(process, "particleFlowRecHitHO"):
        for prod in process.particleFlowRecHitHO.producers:
            prod.qualityTests = cms.VPSet(
                cms.PSet(
                    name=cms.string("PFRecHitQTestThreshold"), threshold=cms.double(0.05)  # new threshold for SiPM HO
                ),
                cms.PSet(
                    name=cms.string("PFRecHitQTestHCALChannel"),
                    maxSeverities=cms.vint32(11),
                    cleaningThresholds=cms.vdouble(0.0),
                    flags=cms.vstring("Standard"),
                ),
            )

        # Lower Thresholds also for Clusters!!!

        for p in process.particleFlowClusterHO.seedFinder.thresholdsByDetector:
            p.seedingThreshold = cms.double(0.08)

        for p in process.particleFlowClusterHO.initialClusteringStep.thresholdsByDetector:
            p.gatheringThreshold = cms.double(0.05)

        for p in process.particleFlowClusterHO.pfClusterBuilder.recHitEnergyNorms:
            p.recHitEnergyNorm = cms.double(0.05)

        process.particleFlowClusterHO.pfClusterBuilder.positionCalc.logWeightDenominator = cms.double(0.05)
        process.particleFlowClusterHO.pfClusterBuilder.allCellsPositionCalc.logWeightDenominator = cms.double(0.05)

    # Muon reconstruction do not exclude bad chambers
    if hasattr(process, "muonDetIdAssociator"):
        process.muonDetIdAssociator.includeBadChambers = cms.bool(True)

    return process
Example #28
0
def CreatePlotEntry(analyzer, discriminatorLabel=None, step=True):
    """CreatePlotEntry(analyzer, discriminatorLabel)\n
    Creates a PSet with the informations used by TauDQMHistEffProducer\n
    where to find the numerator and denominator\n
    where to put the new plot and how to name it\n
    which variables control"""

    producer = analyzer.TauProducer.pythonValue()[1:-1]
    ext = analyzer.ExtensionName.pythonValue()[1:-1]
    if discriminatorLabel == None:
        num = "RecoTauV/%s%s_Matched/%sMatched_vs_#PAR#TauVisible" % (producer, ext, producer)
        # out = 'RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#'%(producer,ext)
        if producer.find("caloReco") != -1:
            out = "RecoTauV/%s%s_Matched/CaloJetMatchingEff#PAR#" % (producer, ext)
        else:
            out = "RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#" % (producer, ext)
    else:
        num = "RecoTauV/%s%s_%s/%s_vs_#PAR#TauVisible" % (producer, ext, discriminatorLabel, discriminatorLabel)
        if discriminatorLabel.find("DiscriminationBy") != -1:
            hname = discriminatorLabel[(discriminatorLabel.find("DiscriminationBy") + len("DiscriminationBy")) :]
        else:
            hname = discriminatorLabel[(discriminatorLabel.find("Discrimination") + len("Discrimination")) :]
        out = "RecoTauV/%s%s_%s/%sEff#PAR#" % (producer, ext, discriminatorLabel, hname)

    den = "RecoTauV/%s%s_ReferenceCollection/nRef_Taus_vs_#PAR#TauVisible" % (producer, ext)
    ret = cms.PSet(
        numerator=cms.string(num),
        denominator=cms.string(den),
        efficiency=cms.string(out),
        parameter=cms.vstring("pt", "eta", "phi", "pileup"),
        stepByStep=cms.bool(step),
    )
    return ret
def customise_pu_protons_ctpps(process):

    process = customise(process)

    process.mix.mixObjects.mixHepMC.makeCrossingFrame = cms.untracked.bool(True)

    process.ppssim.UseHepMCProducer = cms.untracked.bool(False)
    # PU gen particle
    process.genParticlesPU = cms.EDProducer(
        "GenParticleProducer",
        saveBarCodes=cms.untracked.bool(True),
        mix=cms.string("mix"),
        abortOnUnknownPDGCode=cms.untracked.bool(False),
        useCrossingFrame=cms.untracked.bool(True),
    )
    process.genProtonsPU = cms.EDFilter(
        "GenParticleSelector", filter=cms.bool(False), src=cms.InputTag("genParticlesPU"), cut=cms.string("")
    )

    process.genProtonsPU.cut = "status = 1 & pdgId == 2212 & abs(pz) >= %f" % (0.5 * 13000.0 / 2.0)
    outputCommandsPU = ["keep *_genParticlesPU_*_*", "keep *_genProtonsPU_*_*"]

    process.ppssim.genSource = cms.InputTag("genProtonsPU")  # for Pile-up events

    process.digitisation_step.replace(
        process.pdigi_valid, process.pdigi_valid * process.genParticlesPU * process.genProtonsPU
    )

    return process
Example #30
0
def customise_csc_Packer(process):
    """Use 2013 a.k.a. post-LS1 version
    """
    process.cscpacker.useFormatVersion = cms.uint32(2013)
    process.cscpacker.usePreTriggers = cms.bool(False)
    process.cscpacker.packEverything = cms.bool(True)
    return process