Beispiel #1
0
    def getDiTauWeight(self, Chain, lVec, lIndices):
        weight = 1.
        nTightTau = 0
        for i, l in enumerate(lIndices):
            if isTightTau(Chain, l):
                weight *= 1.
                nTightTau += 1
            else:
                weight *= self.getFakeFactor(lVec[i].Pt(), abs(lVec[i].Eta()))

        if nTightTau == 0:
            weight *= -1.
        elif nTightTau == 2:
            return -999.
        return weight
Beispiel #2
0
def isCorrectNumberOfFakes(Chain, lIndices, nLooseTau, nTightTau):
    #If only one tau, required to be fake
    if nLooseTau == 1:
        if not objectSelection.isFakeTau(Chain, lIndices[2]): return False

    #If two taus, split up according to how many tight
    elif nLooseTau == 2:
        if nTightTau == 0:
            if not objectSelection.isFakeTau(Chain, lIndices[1]): return False
            if not objectSelection.isFakeTau(Chain, lIndices[2]): return False
        elif nTightTau == 1:
            for l in lIndices[1:]:
                if not objectSelection.isTightTau(
                        Chain, l) and not objectSelection.isFakeTau(Chain, l):
                    return False
        elif nTightTau == 2:
            nFake = 0
            for l in lIndices[1:]:
                if objectSelection.isFakeTau(Chain, l): nFake += 1
            if nFake < 1: return False

    return True
Beispiel #3
0
def numberOfTightTaus(Chain, lIndices):
    nTaus = 0
    for l in lIndices:
        if Chain._lFlavor[l] == 2 and objectSelection.isTightTau(Chain, l):
            nTaus += 1
    return nTaus
Beispiel #4
0
 def getSingleTauWeight(self, Chain, lVec,
                        lIndex):  #if else selects loose but not tight
     if isTightTau(Chain, lIndex):
         return -999.
     else:
         return self.getFakeFactor(lVec[2].Pt(), abs(lVec[2].Eta()))
Beispiel #5
0
            Chain._weight * ((sample.xsec * lumi) / sample.hCount)
            for _ in range(2)
        ])  #numerator, denominator
    else:
        weightfactor = np.array([1., 1.])  #Numerator, denominator
    if forPromptSubtraction: weightfactor *= -1.

    if not isData:
        puWeight = puReweighting(Chain._nTrueInt)
        weightfactor *= puWeight

        #weightfactor[0] *= tauSF.getSF(args.year, 'Tight')[0]
        #weightfactor[1] *= tauSF.getSF(args.year, 'VLoose')[0]

    #Fill Fake Rate
    #If elif structure: if measured in data and MC sample for prompt subtraction, both numerator and denominator are always filled
    #else it looks if the tau is tight to fill the numerator
    FR.fill_denominator((tau_FV.Pt(), abs(tau_FV.Eta())), weightfactor[1])
    if forPromptSubtraction:
        FR.fill_numerator((tau_FV.Pt(), abs(tau_FV.Eta())), weightfactor[0])
    elif objectSelection.isTightTau(Chain, tau_index):
        FR.fill_numerator((tau_FV.Pt(), abs(tau_FV.Eta())), weightfactor[0])

print FR.get_numerator().GetSumOfWeights(), FR.get_denominator(
).GetSumOfWeights()
print FR.get_numerator().GetEntries(), FR.get_denominator().GetEntries()

if not args.isTest:
    #if True:
    FR.writeFR()