Exemplo n.º 1
0
    def getTPScaleFactor(self, lep, efficiency, info,
                         scale=''):
        '''
        Get a scale factor for a specific lepton.
        lep (str): which lepton
        efficiency (str): type of scale factor ('TightID' etc.)
        info (TreeBuffer or iterable): If a TreeBuffer (ntuple row), lepton
        pt and eta are taken from it. If an iterable, info[0] is pt,
        info[1] is eta.
        scale (str; 'up', 'down', or '' [default]): scale up or down for 
        systematics, or '' for central value.
        '''
        lepType = lep[0]
        effName = self.effNames[efficiency.lower()]
        f = self.functions[lepType][effName]

        if isinstance(info, TreeBuffer):
            pt = objVar(row, 'Pt', lep)
            absEta = abs(objVar(row, 'Eta', lep))
        else:
            try:
                pt = info[0]
                absEta = abs(info[1])
            except IndexError:
                print ("getTPScaleFactor info must be an ntuple row or an "
                       "iterable [pt, eta].")
                raise

        return f(pt, absEta, self.scales[scale])
Exemplo n.º 2
0
 def storeVars(self, row, objects, cuts):
     '''
     Need Z1 distance from nominal mass and scalar sum of pt of Z2 
     leptons.
     '''
     self.dZ = zCompatibility(row, objects[0], objects[1], cuts.fsrVar)
     self.ptSum = objVar(row, 'Pt', objects[2]) + objVar(row, 'Pt', objects[3])
Exemplo n.º 3
0
def getCandInfo3l(row, *objects):
    numbers = {}
    numbers["run"] = row.run
    numbers["lumi"] = row.lumi
    numbers["event"] = row.evt
    numbers["m3l"] = evVar(row, "Mass")
    numbers["mZ"] = nObjVar(row, "Mass", objects[0], objects[1])
    numbers["ptL3"] = objVar(row, "Pt", objects[2])
    numbers["l3Tight"] = 1 if objVar(row, "ZZTightID", objects[2]) and objVar(row, "ZZIsoPass", objects[2]) else 0

    return numbers
Exemplo n.º 4
0
 def addLepton(self, name, row):
     pt = objVar(row, 'Pt', name)
     if pt in self.leptons:
         # Do nothing if we've already seen this one
         return
     if name[0] == 'e':
         self.leptons[pt] = LeptonCollection.Electron(name, row, pt)
     else:
         self.leptons[pt] = LeptonCollection.Muon(name, row, pt)
Exemplo n.º 5
0
def getCandInfo(zMassVar, row, *objects):
    numbers = {}
    numbers['run'] = row.run
    numbers['lumi'] = row.lumi
    numbers['event'] = row.evt
    numbers['mass4l'] = evVar(row, 'MassFSR')
    numbers['mZ1'] = nObjVar(row, zMassVar, objects[0], objects[1])
    numbers['mZ2'] = nObjVar(row, zMassVar, objects[2], objects[3])

    # eemm channel may have masses swapped
    if zMassDist(numbers['mZ1']) > zMassDist(numbers['mZ2']):
        temp = numbers['mZ2']
        numbers['mZ2'] = numbers['mZ1']
        numbers['mZ1'] = temp

    numbers['D_bkg^kin'] = evVar(row, 'D_bkg_kin')
    numbers['D_bkg'] = evVar(row, 'D_bkg')
    numbers['D_gg'] = evVar(row, 'D_gg')
    numbers['Dkin_HJJ^VBF'] = evVar(row, 'D_VBF2j')
    numbers['D_0-'] = evVar(row, 'D_g4')
    numbers['Dkin_HJ^VBF-1'] = evVar(row, 'D_VBF1j')
    numbers['Dkin_HJJ^WH-h'] = evVar(row, 'D_WHh')
    numbers['Dkin_HJJ^ZH-h'] = evVar(row, 'D_ZHh')
    numbers['njets30'] = evVar(row, 'nJets')
    numbers['jet1pt'] = max(-1.,evVar(row, 'jet1Pt'))
    numbers['jet2pt'] = max(-1.,evVar(row, 'jet2Pt'))
    numbers['jet1qgl'] = evVar(row, 'jet1QGLikelihood')
    numbers['jet2qgl'] = evVar(row, 'jet2QGLikelihood')
    numbers['Dfull_HJJ^VBF'] = evVar(row, 'D_VBF2j_QG')
    numbers['Dfull_HJ^VBF-1'] = evVar(row, 'D_VBF1j_QG')
    numbers['Dfull_HJJ^WH-h'] = evVar(row, 'D_WHh_QG')
    numbers['Dfull_HJJ^ZH-h'] = evVar(row, 'D_ZHh_QG')
    numbers['category'] = evVar(row, "ZZCategory")
    # numbers['m4lRefit'] = evVar(row, 'MassRefit')
    # numbers['m4lRefitError'] = evVar(row, 'MassRefitError')

    if not args.data:
        numbers['weight'] = evVar(row, 'genWeight')
        numbers['weight'] /= abs(numbers['weight'])

        for ob in objects:
            numbers['weight'] *= objVar(row, 'EffScaleFactor', ob)

    outTemp = ('{run}:{lumi}:{event}:{mass4l:.2f}:{mZ1:.2f}:{mZ2:.2f}:{D_bkg^kin:'
               '.3f}:{D_bkg:.3f}:{D_gg:.3f}:{Dkin_HJJ^VBF:.3f}:{D_0-:.3f}:'
               '{Dkin_HJ^VBF-1:.3f}:{Dkin_HJJ^WH-h:.3f}:{Dkin_HJJ^ZH-h:.3f}:'
               '{njets30:d}:{jet1pt:.2f}:{jet2pt:.2f}:{jet1qgl:.3f}:{jet2qgl:.3f}:'
               '{Dfull_HJJ^VBF:.3f}:{Dfull_HJ^VBF-1:.3f}:{Dfull_HJJ^WH-h:.3f}:'
               '{Dfull_HJJ^ZH-h:.3f}:{category}') #:{m4lRefit:.2f}:{m4lRefitError:.2f}:'
    if not args.data:
        outTemp += ':{weight:.3f}'

    return outTemp.format(**numbers)
Exemplo n.º 6
0
 def __init__(self, name, row, pt=0):
     if pt != 0:
         self.pt = pt
     else:
         self.pt = objVar(row, 'Pt', name)
     self.eta = objVar(row, 'Eta', name)
     self.phi = objVar(row, 'Phi', name)
     self.sip = objVar(row, 'SIP3D', name)
     self.chHadIso = objVar(row, 'PFChargedIso', name)
     self.neutHadIso = objVar(row, 'PFNeutralIso', name)
     self.phoIso = objVar(row, 'PFPhotonIso', name)
     self.puCorr = 0 # daughter class must define
     self.combRelIso = -1 # Daughter class must define
     self.bdt = 0 # daughter class must define (if electron)
     self.pdgId = 0 # daughter class must define
Exemplo n.º 7
0
    def realZFirst(self, row, channel, objects):
        '''
        For use with 4l final states only. If the second Z is made out of
        tight + isolated leptons and the first isn't, swap them.
        '''
        if (objVar(row, 'ZZTightID', objects[2]) < 0.5 or
            objVar(row, 'ZZTightID', objects[3]) < 0.5 or
            objVar(row, 'ZZIsoPass', objects[2]) < 0.5 or
            objVar(row, 'ZZIsoPass', objects[3]) < 0.5 or
            nObjVar(row, 'SS', objects[2], objects[3])):
            return objects
        
        if (objVar(row, 'ZZTightID', objects[0]) < 0.5 or
            objVar(row, 'ZZTightID', objects[1]) < 0.5 or
            objVar(row, 'ZZIsoPass', objects[0]) < 0.5 or
            objVar(row, 'ZZIsoPass', objects[1]) < 0.5):
            return objects[2:]+objects[:2] # Z2 good, Z1 not (Z1 guaranteed OSSF if Z2 is)

        # if both are good, order however the base class would
        if super(ZPlusAnything, self).needReorder(channel):
            return super(ZPlusAnything, self).orderLeptons(row, channel, objects)
        return objects
Exemplo n.º 8
0
 def __init__(self, name, row, pt=0):
     super(LeptonCollection.Electron, self).__init__(name, row, pt)
     self.combRelIso = objVar(row, 'RelPFIsoRho', name)
     self.bdt = objVar(row, 'MVANonTrigID', name)
     self.pdgId = -11 * objVar(row, "Charge", name)
     self.puCorr = objVar(row, 'Rho', name)
Exemplo n.º 9
0
 def __init__(self, name, row, pt=0):
     super(LeptonCollection.Muon, self).__init__(name, row, pt)
     self.combRelIso = objVar(row, 'RelPFIsoDBDefault', name)
     self.pdgId = -13 * objVar(row, "Charge", name)
     self.puCorr = objVar(row, "PFPUChargedIso", name)