Example #1
0
def TagAndProbeBase(sample, rname):
    """
    Base for Z->ll tag and probe stuff.
    """

    selector = ROOT.EventSelector(rname)

    operators = [
        'MetFilters', 'LeptonSelection', 'TauVeto', 'TagAndProbePairZ',
        'JetCleaning', 'BjetVeto', 'CopyMet', 'CopySuperClusters',
        'JetMetDPhi', 'Met'
    ]

    for op in operators:
        selector.addOperator(getattr(ROOT, op)())

    if not sample.data:
        selector.addOperator(
            ROOT.ConstantWeight(sample.crosssection / sample.sumw))

        sg.addPUWeight(sample, selector)

    selector.findOperator('LeptonSelection').setN(0, 0)

    selector.findOperator('LeptonSelection').setIgnoreDecision(True)
    selector.findOperator('TauVeto').setIgnoreDecision(True)
    selector.findOperator('BjetVeto').setIgnoreDecision(True)
    selector.findOperator('JetCleaning').setCleanAgainst(ROOT.cTaus, False)
    # selector.findOperator('JetCleaning').setCleanAgainst(ROOT.cElectrons, False)
    selector.findOperator('Met').setThreshold(50.)
    selector.findOperator('Met').setIgnoreDecision(True)

    return selector
Example #2
0
def tightloose(sample, rname):
    """
    One tight lepton, one loose lepton
    """
    selector = ROOT.EventSelector(rname)

    selector.addOperator(ROOT.MetFilters())

    leptons = ROOT.LeptonSelection()
    leptons.setN(1, 1)
    leptons.setStrictEl(False)
    leptons.setStrictMu(False)
    leptons.setRequireTight(False)
    leptons.setRequireMedium(False)
    leptons.setRequireHWWTight(True)
    leptons.setOutMuonType(ROOT.LeptonSelection.kMuTrigger17Safe)
    leptons.setOutElectronType(ROOT.LeptonSelection.kElTrigger17Safe)
    selector.addOperator(leptons)

    jets = ROOT.JetCleaning()
    jets.setCleanAgainst(ROOT.cElectrons, True)
    jets.setCleanAgainst(ROOT.cTaus, True)
    selector.addOperator(jets)

    selector.addOperator(ROOT.CopyMet())

    if not sample.data:
        selector.addOperator(ROOT.ConstantWeight(sample.crosssection / sample.sumw, 'crosssection'))

        sg.addPUWeight(sample, selector)
        sg.addPDFVariation(sample, selector)

    return selector
Example #3
0
def tagprobeBase(sample, rname):
    """
    Base for selectors skimming tag & probe input trees.
    """

    selector = ROOT.TagAndProbeSelector(rname)

    setSampleId(sample, selector)

    if not sample.data:
        selector.addOperator(
            ROOT.ConstantWeight(sample.crosssection / sample.sumw))
        sg.addPUWeight(sample, selector)

    return selector
Example #4
0
def vbflBase(sample, rname):
    """
    VBF + lepton(s).
    """

    selconf['puweightSource'] = ('puweight_vbf75', datadir + '/pileup_vbf75.root')

    selector = ROOT.EventSelector(rname)

    selector.setPreskim('Sum$(chsAK4Jets.pt_ > 50.) > 1')

    trig = ROOT.HLTFilter(selconf['vbfTrigger'])
    trig.setIgnoreDecision(True)
    selector.addOperator(trig)

    operators = [
        'MetFilters',
        'LeptonSelection',
        'JetCleaning',
        'DijetSelection',
        'BjetVeto',
        'CopyMet',
        'JetMetDPhi',
        'Met'
    ]

    for op in operators:
        selector.addOperator(getattr(ROOT, op)())

    leptonSel = selector.findOperator('LeptonSelection')
    leptonSel.setRequireMedium(False)

    dijetSel = selector.findOperator('DijetSelection')
    dijetSel.setMinDEta(0.)
    dijetSel.setMinMjj(0.)

    if not sample.data:
        selector.addOperator(ROOT.ConstantWeight(sample.crosssection / sample.sumw, 'crosssection'))

        sg.addPUWeight(sample, selector)
        sg.addPDFVariation(sample, selector)

    selector.findOperator('BjetVeto').setIgnoreDecision(True)
    selector.findOperator('JetCleaning').setCleanAgainst(ROOT.cTaus, False)
    selector.findOperator('JetMetDPhi').setIgnoreDecision(True)
    selector.findOperator('Met').setIgnoreDecision(True)

    return selector
Example #5
0
def zmumu(sample, rname):
    """
    Just dimuon. 
    """
    selector = ROOT.EventSelector(rname)

    selector.setPreskim('muons.size > 1')

    selector.addOperator(ROOT.MetFilters())

    leptons = ROOT.LeptonSelection()
    leptons.setN(0, 2)
    leptons.setStrictMu(False)
    leptons.setRequireTight(False)
    selector.addOperator(leptons)

    # LeptonVertex loads pfCandidates - turning it off for speedup
    #    vtx = ROOT.LeptonVertex()
    #    vtx.setSpecies(ROOT.lMuon)
    #    selector.addOperator(vtx)

    mass = ROOT.Mass()
    mass.setPrefix('dimu')
    mass.setMin(60.)
    mass.setMax(120.)
    mass.setCollection1(ROOT.cMuons)
    mass.setCollection2(ROOT.cMuons)
    selector.addOperator(mass)

    jets = ROOT.JetCleaning()
    jets.setCleanAgainst(ROOT.cPhotons, False)
    jets.setCleanAgainst(ROOT.cElectrons, False)
    jets.setCleanAgainst(ROOT.cTaus, False)
    selector.addOperator(jets)

    selector.addOperator(ROOT.CopyMet())

    if not sample.data:
        selector.addOperator(
            ROOT.ConstantWeight(sample.crosssection / sample.sumw,
                                'crosssection'))

        sg.addPUWeight(sample, selector)
        sg.addPDFVaraition(sample, selector)

    return selector
Example #6
0
def gghgBase(sample, rname, selcls=None):
    """
    For low MT case.
    Monophoton candidate-like selection (high-pT photon, lepton veto, dphi(photon, MET) and dphi(jet, MET)). 
    Base for other selectors.
    """

    if selcls is None:
        selector = ROOT.EventSelector(rname)
    else:
        selector = selcls(rname)

    selector.setPreskim(
        'superClusters.rawPt > 210. && TMath::Abs(superClusters.eta) < 1.4442')

    if sample.data:
        selector.addOperator(ROOT.HLTFilter(selconf['sphTrigger']))

    operators = [
        'MetFilters', 'PhotonSelection', 'LeptonSelection', 'TauVeto',
        'JetCleaning', 'DijetSelection', 'BjetVeto', 'CopyMet',
        'CopySuperClusters'
    ]

    if not sample.data:
        operators.append('MetVariations')

    operators += [
        'Met', 'PhotonMetDPhi', 'JetMetDPhi', 'PhotonJetDPhi',
        'PhotonPtOverMet', 'PhotonMt'
    ]

    for op in operators:
        selector.addOperator(getattr(ROOT, op)())

    photonSel = selector.findOperator('PhotonSelection')
    photonSel.setMinPt(220.)
    photonSel.setIDTune(selconf['photonIDTune'])
    photonSel.setWP(selconf['photonWP'])

    leptonSel = selector.findOperator('LeptonSelection')
    leptonSel.setN(0, 0)
    leptonSel.setRequireMedium(False)
    leptonSel.setRequireTight(False)

    dijetSel = selector.findOperator('DijetSelection')
    dijetSel.setMinDEta(3.)
    dijetSel.setMinMjj(500.)
    dijetSel.setIgnoreDecision(True)

    if not sample.data:
        metVar = selector.findOperator('MetVariations')
        metVar.setPhotonSelection(photonSel)

        photonDPhi = selector.findOperator('PhotonMetDPhi')
        photonDPhi.setMetVariations(metVar)

        jetDPhi = selector.findOperator('JetMetDPhi')
        jetDPhi.setMetVariations(metVar)

        selector.findOperator('PhotonJetDPhi').setMetVariations(metVar)

        selector.addOperator(
            ROOT.ConstantWeight(sample.crosssection / sample.sumw,
                                'crosssection'))

        sg.addPUWeight(sample, selector)
        sg.addPDFVariation(sample, selector)

    selector.findOperator('TauVeto').setIgnoreDecision(True)
    selector.findOperator('BjetVeto').setIgnoreDecision(True)
    selector.findOperator('JetCleaning').setCleanAgainst(ROOT.cTaus, False)
    selector.findOperator('PhotonMetDPhi').setIgnoreDecision(True)
    selector.findOperator('JetMetDPhi').setIgnoreDecision(True)
    selector.findOperator('Met').setIgnoreDecision(True)
    selector.findOperator('Met').setThreshold(100.)
    selector.findOperator('PhotonPtOverMet').setIgnoreDecision(True)

    return selector
Example #7
0
def gghlBase(sample, rname, flavor, selcls=None):
    """
    Base for n-lepton + photon selection.
    For MC, we could use PartonSelector, but for interest of clarity and comparing cut flow
    with the other groups, we let events with all flavors pass.
    """

    if selcls is None:
        selector = ROOT.EventSelector(rname)
    else:
        selector = selcls(rname)

    selector.setPreskim(
        'superClusters.rawPt > 210. && TMath::Abs(superClusters.eta) < 1.4442')

    if sample.data:
        selector.addOperator(ROOT.HLTFilter(selconf['sphTrigger']))
    else:
        partons = ROOT.PartonFlavor()
        if flavor == ROOT.lElectron:
            partons.setRequiredPdgId(11)
        elif flavor == ROOT.lMuon:
            partons.setRequiredPdgId(13)

        partons.setIgnoreDecision(True)
        selector.addOperator(partons)

    operators = [
        'MetFilters',
        'PhotonSelection',
        'LeptonSelection',
        'TauVeto',
        'JetCleaning',
        'DijetSelection',
        'BjetVeto',
        'CopyMet',
        'CopySuperClusters',
        'LeptonRecoil',
    ]

    if not sample.data:
        operators.append('MetVariations')

    operators += [
        'PhotonMetDPhi', 'JetMetDPhi', 'Met', 'PhotonPtOverMet', 'PhotonMt'
    ]

    for op in operators:
        selector.addOperator(getattr(ROOT, op)())

    jetDPhi = selector.findOperator('JetMetDPhi')
    jetDPhi.setMetSource(ROOT.kInMet)

    photonSel = selector.findOperator('PhotonSelection')
    photonSel.setMinPt(220.)
    photonSel.setIDTune(selconf['photonIDTune'])
    photonSel.setWP(selconf['photonWP'])

    leptonSel = selector.findOperator('LeptonSelection')
    leptonSel.setRequireMedium(False)

    dijetSel = selector.findOperator('DijetSelection')
    dijetSel.setMinDEta(3.)
    dijetSel.setMinMjj(500.)
    dijetSel.setIgnoreDecision(True)

    sp.setupPhotonSelection(photonSel)

    selector.findOperator('LeptonRecoil').setFlavor(flavor)

    if not sample.data:
        metVar = selector.findOperator('MetVariations')
        metVar.setPhotonSelection(photonSel)

        realMetVar = ROOT.MetVariations('RealMetVar')
        realMetVar.setMetSource(ROOT.kInMet)
        realMetVar.setPhotonSelection(photonSel)

        selector.findOperator('PhotonMetDPhi').setMetVariations(metVar)

        jetDPhi.setMetVariations(realMetVar)

        selector.addOperator(
            ROOT.ConstantWeight(sample.crosssection / sample.sumw,
                                'crosssection'))

        sg.addPUWeight(sample, selector)
        sp.addIDSFWeight(sample, selector)
        sg.addPDFVariation(sample, selector)

        if flavor == ROOT.lElectron:
            sp.addElectronIDSFWeight(sample, selector)
        else:
            sp.addMuonIDSFWeight(sample, selector)

    selector.findOperator('TauVeto').setIgnoreDecision(True)
    selector.findOperator('BjetVeto').setIgnoreDecision(True)
    selector.findOperator('JetCleaning').setCleanAgainst(ROOT.cTaus, False)
    selector.findOperator('PhotonMetDPhi').setIgnoreDecision(True)
    selector.findOperator('JetMetDPhi').setIgnoreDecision(True)
    selector.findOperator('Met').setIgnoreDecision(True)
    selector.findOperator('Met').setThreshold(100.)
    selector.findOperator('PhotonPtOverMet').setIgnoreDecision(True)

    return selector
Example #8
0
def vbfgBase(sample, rname):
    """
    Base for VBF + photon.
    """

    selector = ROOT.EventSelector(rname)

    selector.setPreskim('superClusters.rawPt > 80. && Sum$(chsAK4Jets.pt_ > 50.) > 2') # 1 for the photon

    if sample.data:
        trigger = ROOT.HLTFilter('VBFTrigger')
        paths = ROOT.vector('TString')()
        for pd, triggers in selconf['vbfTrigger'].iteritems():
            if pd in sample.name:
                for path in triggers:
                    paths.push_back(path)
        trigger.setPathNames(paths)
    
        selector.addOperator(trigger)

        veto = ROOT.HLTFilter('VBFVetoTrigger')
        paths = ROOT.vector('TString')()
        for pd, triggers in selconf['vbfTrigger'].iteritems():
            if pd not in sample.name:
                for path in triggers:
                    paths.push_back(path)
        veto.setPathNames(paths)
        veto.setVeto(True)

        selector.addOperator(veto)

    else:
        trigger = ROOT.HLTFilter('VBFTrigger')
        paths = ROOT.vector('TString')()
        for triggers in selconf['vbfTrigger'].itervalues():
            for path in triggers:
                paths.push_back(path)
        trigger.setPathNames(paths)
    
        selector.addOperator(trigger)

    operators = [
        'MetFilters',
        'PhotonSelection',
        'LeptonSelection',
        'JetCleaning',
        'DijetSelection',
        'BjetVeto',
        'CopyMet'
    ]

    if not sample.data:
        operators.append('MetVariations')

    operators += [
        'AddTrailingPhotons',
        'PhotonMt',
        'PhotonMetDPhi',
        'JetMetDPhi'
    ]

    for op in operators:
        selector.addOperator(getattr(ROOT, op)())

    photonSel = selector.findOperator('PhotonSelection')
    photonSel.setIDTune(selconf['photonIDTune'])
    photonSel.setMinPt(80.)

    leptonSel = selector.findOperator('LeptonSelection')
    leptonSel.setN(0, 0)
    leptonSel.setRequireTight(False)
    leptonSel.setRequireMedium(False)

    dijetSel = selector.findOperator('DijetSelection')
    dijetSel.setMinDEta(3.)
    dijetSel.setMinMjj(500.)

    jetCleaning = selector.findOperator('JetCleaning')
    jetCleaning.setCleanAgainst(ROOT.cTaus, False)

    if not sample.data:
        metVar = selector.findOperator('MetVariations')
        metVar.setPhotonSelection(photonSel)

        photonDPhi = selector.findOperator('PhotonMetDPhi')
        photonDPhi.setMetVariations(metVar)
        
        jetDPhi = selector.findOperator('JetMetDPhi')
        jetDPhi.setMetVariations(metVar)

        selector.addOperator(ROOT.ConstantWeight(sample.crosssection / sample.sumw, 'crosssection'))

        ## nominal 9.76182e-01 + 1.03735e-04 * x  -> has 43499 entries in efficiency.root ptwide_pass histogram
        ## alt 9.82825e-01 + 1.37474e-05 * x  -> 29315 entries
        ## taking the sqrt(N)-weighted average for nominal
        #triggersf_photon = ROOT.PhotonPtWeight(ROOT.TF1('trigsf_ph_nominal', '0.9792 + 6.317e-05 * x', 80., 1000.), 'trigeff_ph')
        ## single photon measurement
        #triggersf_photon.addVariation("trigsf_photonUp", ROOT.TF1('trigeff_ph_up', '9.76182e-01 + 1.03735e-04 * x', 80., 1000.))
        ## symmetric reflection of Down about nominal
        #triggersf_photon.addVariation("trigsf_photonDown", ROOT.TF1('trigeff_ph_down', '0.9822 + 2.260e-05 * x', 80., 1000.))
        #
        #selector.addOperator(triggersf_photon)
        #
        #triggersf_vbf = ROOT.DEtajjWeight(ROOT.TF1('trigsf_vbf_nominal', '1.00989e+00 - 1.04419e-02 * x', 3., 10.), 'trigeff_vbf')
        #triggersf_vbf.setDijetSelection(dijetSel)
        #selector.addOperator(triggersf_vbf)

        sg.addPUWeight(sample, selector)
        sg.addPDFVariation(sample, selector)

        sp.addElectronVetoSFWeight(sample, selector)
        sp.addMuonVetoSFWeight(sample, selector)        

        selector.addOperator(ROOT.AddGenJets())

    selector.findOperator('BjetVeto').setIgnoreDecision(True)
    selector.findOperator('PhotonMetDPhi').setIgnoreDecision(True)
    selector.findOperator('JetMetDPhi').setIgnoreDecision(True)

    return selector
Example #9
0
def ph75(sample, rname):
    selector = ROOT.EventSelector(rname)
    vbfgSetting()

    selector.setPreskim('superClusters.rawPt > 50.')

    selector.addOperator(ROOT.HLTFilter('HLT_Photon50_OR_HLT_Photon75'))

    hltph50 = ROOT.HLTFilter('HLT_Photon50')
    hltph50.setIgnoreDecision(True)
    selector.addOperator(hltph50)
    hltph75 = ROOT.HLTFilter('HLT_Photon75')
    hltph75.setIgnoreDecision(True)
    selector.addOperator(hltph75)
    hltph75vbf = ROOT.HLTFilter(selconf['vbfTrigger'])
    hltph75vbf.setIgnoreDecision(True)
    selector.addOperator(hltph75vbf)

    operators = [
        'MetFilters',
        'PhotonSelection',
        'LeptonSelection',
        'TauVeto',
        'JetCleaning',
        'BjetVeto',
        'CopyMet',
        'CopySuperClusters'
    ]

    if not sample.data:
        operators.append('MetVariations')
        
    operators += [
        'PhotonMetDPhi',
        'JetMetDPhi',
        'PhotonJetDPhi',
        'PhotonMt',
        'DijetSelection'
    ]

    for op in operators:
        selector.addOperator(getattr(ROOT, op)())

    photonSel = selector.findOperator('PhotonSelection')
    photonSel.setMinPt(50.)
    photonSel.setIDTune(selconf['photonIDTune'])
    photonSel.setWP(selconf['photonWP'])
    sp.setupPhotonSelection(photonSel, changes = ['-Sieie', '-CHIso', '+Sieie15', '+CHIso11'])

    leptonSel = selector.findOperator('LeptonSelection')
    leptonSel.setN(0, 0)
    leptonSel.setRequireMedium(False)
    leptonSel.setRequireTight(False)

    dijetSel = selector.findOperator('DijetSelection')
    dijetSel.setMinDEta(3.)
    dijetSel.setMinMjj(500.)
    dijetSel.setIgnoreDecision(True)

    if not sample.data:
        metVar = selector.findOperator('MetVariations')
        metVar.setPhotonSelection(photonSel)

        photonDPhi = selector.findOperator('PhotonMetDPhi')
        photonDPhi.setMetVariations(metVar)
        
        jetDPhi = selector.findOperator('JetMetDPhi')
        jetDPhi.setMetVariations(metVar)

        selector.findOperator('PhotonJetDPhi').setMetVariations(metVar)

        selector.addOperator(ROOT.ConstantWeight(sample.crosssection / sample.sumw, 'crosssection'))

        sg.addPUWeight(sample, selector)
        sg.addPDFVariation(sample, selector)

        sp.addElectronVetoSFWeight(sample, selector)
        sp.addMuonVetoSFWeight(sample, selector)

    selector.findOperator('TauVeto').setIgnoreDecision(True)
    selector.findOperator('BjetVeto').setIgnoreDecision(True)
    selector.findOperator('JetCleaning').setCleanAgainst(ROOT.cTaus, False)
    selector.findOperator('PhotonMetDPhi').setIgnoreDecision(True)
    selector.findOperator('JetMetDPhi').setIgnoreDecision(True)

    return selector