예제 #1
0
    def fillGenLeptons(self, event, particle, isTau=False, recovered=False, sourceId=25):
        """Get the gen level light leptons (prompt and/or from tau decays)"""

        for i in xrange( particle.numberOfDaughters() ):
            dau = GenParticle(particle.daughter(i))
            dau.sourceId = sourceId
            dau.isTau = isTau
            id = abs(dau.pdgId())
            moid = abs(dau.mother().pdgId()) if dau.mother() else 2212 #if no mom, let say it is a proton (consistent with CMSSW < 74X)
            if id in [11,13]:
                if not recovered:
                    if isTau: event.gentauleps.append(dau)
                    else:     event.genleps.append(dau)
                else:
                    if isTau: event.gentaulepsRecovered.append(dau)
                    else:     event.genlepsRecovered.append(dau)
            elif id == 15:
                if not recovered:
                    if moid in [22,23,24]:
                        event.gentaus.append(dau)
                    self.fillGenLeptons(event, dau, True, sourceId)
                else:
                    if moid in [22,23,24]:
                        event.gentausRecovered.append(dau)
                    self.fillGenLeptons(event, dau, True, True, sourceId) 
            elif id in [22,23,24]:
                if not recovered: self.fillGenLeptons(event, dau, False,       sourceId)
                else:             self.fillGenLeptons(event, dau, False, True, sourceId)
예제 #2
0
    def fillWZQuarks(self, event, particle, isWZ=False, sourceId=25):
        """Descend daughters of 'particle', and add quarks from W,Z to event.genwzquarks
           isWZ is set to True if already processing daughters of W,Z's, to False before it"""

        for i in xrange(particle.numberOfDaughters()):
            dau = GenParticle(particle.daughter(i))
            dau.sourceId = sourceId
            id = abs(dau.pdgId())
            if id <= 5 and isWZ:
                event.genwzquarks.append(dau)
            elif id in [22, 23, 24]:
                self.fillWZQuarks(event, dau, True, sourceId)
예제 #3
0
    def fillWZQuarks(self, event, particle, isWZ=False, sourceId=25):
        """Descend daughters of 'particle', and add quarks from W,Z to event.genwzquarks
           isWZ is set to True if already processing daughters of W,Z's, to False before it"""

        for i in xrange( particle.numberOfDaughters() ):
            dau = GenParticle(particle.daughter(i))
            dau.sourceId = sourceId
            id = abs(dau.pdgId())
            if id <= 5 and isWZ:
                event.genwzquarks.append(dau)
            elif id in [22,23,24]:
                self.fillWZQuarks(event, dau, True, sourceId)
예제 #4
0
    def fillTopQuarks(self, event):
        """Get the b quarks from top decays into event.genbquarksFromTop"""

        event.gentopquarks = [ p for p in event.genParticles if abs(p.pdgId()) == 6 and p.numberOfDaughters() > 0 and abs(p.daughter(0).pdgId()) != 6 ]
        #if len(event.gentopquarks) != 2:
        #    print "Not two top quarks? \n%s\n" % event.gentopquarks

        for tq in event.gentopquarks:
            for i in xrange( tq.numberOfDaughters() ):
                dau = GenParticle(tq.daughter(i))
                if abs(dau.pdgId()) == 5:
                    dau.sourceId = 6
                    event.genbquarksFromTop.append( dau )
                elif abs(dau.pdgId()) == 24:
                    self.fillGenLeptons( event, dau, sourceId=6 )
                    self.fillWZQuarks(   event, dau, True, sourceId=6 )
예제 #5
0
    def fillGenLeptons(self, event, particle, isTau=False, sourceId=25):
        """Get the gen level light leptons (prompt and/or from tau decays)"""

        for i in xrange(particle.numberOfDaughters()):
            dau = GenParticle(particle.daughter(i))
            dau.sourceId = sourceId
            dau.isTau = isTau
            id = abs(dau.pdgId())
            moid = abs(dau.mother().pdgId())
            if id in [11, 13]:
                if isTau: event.gentauleps.append(dau)
                else: event.genleps.append(dau)
            elif id == 15:
                if moid in [22, 23, 24]:
                    event.gentaus.append(dau)
                self.fillGenLeptons(event, dau, True, sourceId)
            elif id in [22, 23, 24]:
                self.fillGenLeptons(event, dau, False, sourceId)
예제 #6
0
    def fillTopQuarks(self, event):
        """Get the b quarks from top decays into event.genbquarksFromTop"""

        event.gentopquarks = [
            p for p in event.genParticles if abs(p.pdgId()) == 6
            and p.numberOfDaughters() > 0 and abs(p.daughter(0).pdgId()) != 6
        ]

        #Find the top decay mode (0 - leptonic, 1 - hadronic)
        for top in event.gentopquarks:
            ndaus = top.numberOfDaughters()
            top.decayMode = -1

            #go over top daughters
            for idau in range(ndaus):
                dau = top.daughter(idau)
                #found the W
                if abs(dau.pdgId()) == 24:
                    #find the true daughters of the W (in case of decay chain)
                    W_daus = realGenDaughters(dau)
                    decayMode = -1
                    #go over the daughters of the W
                    for idauw in range(len(W_daus)):
                        w_dau_id = abs(W_daus[idauw].pdgId())
                        #leptonic
                        if w_dau_id in [11, 12, 13, 14, 15, 16]:
                            decayMode = 0
                            break
                        #hadronic
                        elif w_dau_id < 6:
                            decayMode = 1
                            break
                    top.decayMode = decayMode
                    break
        for tq in event.gentopquarks:
            for i in xrange(tq.numberOfDaughters()):
                dau = GenParticle(tq.daughter(i))
                if abs(dau.pdgId()) == 5:
                    dau.sourceId = 6
                    event.genbquarksFromTop.append(dau)
                elif abs(dau.pdgId()) == 24:
                    self.fillGenLeptons(event, dau, sourceId=6)
                    self.fillWZQuarks(event, dau, True, sourceId=6)
예제 #7
0
    def fillTopQuarks(self, event):
        """Get the b quarks from top decays into event.genbquarksFromTop"""

        event.gentopquarks = [ p for p in event.genParticles if abs(p.pdgId()) == 6 and p.numberOfDaughters() > 0 and abs(p.daughter(0).pdgId()) != 6 ]
       
        #Find the top decay mode (0 - leptonic, 1 - hadronic)
        for top in event.gentopquarks:
            ndaus = top.numberOfDaughters()
            top.decayMode = -1
            
            #go over top daughters
            for idau in range(ndaus):
                dau = top.daughter(idau)
                #found the W
                if abs(dau.pdgId()) == 24:
                    #find the true daughters of the W (in case of decay chain)
                    W_daus = realGenDaughters(dau)
                    decayMode = -1
                    #go over the daughters of the W
                    for idauw in range(len(W_daus)):
                        w_dau_id = abs(W_daus[idauw].pdgId())
                        #leptonic
                        if w_dau_id in [11,12,13,14,15,16]:
                            decayMode = 0
                            break
                        #hadronic
                        elif w_dau_id < 6:
                            decayMode = 1
                            break
                    top.decayMode = decayMode
                    break
        for tq in event.gentopquarks:
            for i in xrange( tq.numberOfDaughters() ):
                dau = GenParticle(tq.daughter(i))
                if abs(dau.pdgId()) == 5:
                    dau.sourceId = 6
                    event.genbquarksFromTop.append( dau )
                elif abs(dau.pdgId()) == 24:
                    self.fillGenLeptons( event, dau, sourceId=6 )
                    self.fillWZQuarks(   event, dau, True, sourceId=6 )
예제 #8
0
    def fillGenLeptons(self,
                       event,
                       particle,
                       isTau=False,
                       recovered=False,
                       sourceId=25):
        """Get the gen level light leptons (prompt and/or from tau decays)"""

        for i in xrange(particle.numberOfDaughters()):
            dau = GenParticle(particle.daughter(i))
            dau.sourceId = sourceId
            dau.isTau = isTau
            id = abs(dau.pdgId())
            moid = abs(dau.mother().pdgId()) if dau.mother(
            ) else 2212  #if no mom, let say it is a proton (consistent with CMSSW < 74X)
            if id in [11, 13]:
                if not recovered:
                    if isTau: event.gentauleps.append(dau)
                    else: event.genleps.append(dau)
                else:
                    if isTau: event.gentaulepsRecovered.append(dau)
                    else: event.genlepsRecovered.append(dau)
            elif id == 15:
                if not recovered:
                    if moid in [22, 23, 24]:
                        event.gentaus.append(dau)
                    self.fillGenLeptons(event, dau, True, sourceId)
                else:
                    if moid in [22, 23, 24]:
                        event.gentausRecovered.append(dau)
                    self.fillGenLeptons(event, dau, True, True, sourceId)
            elif id in [22, 23, 24]:
                if not recovered:
                    self.fillGenLeptons(event, dau, False, sourceId)
                else:
                    self.fillGenLeptons(event, dau, False, True, sourceId)