def printDecay(particle_, genParts, prefix=""):
    daughters = getDaughters(particle_, genParts)
    if True: print prefix+"%s (index %i, status: %i, n-daughters: %i) pt: %6.2f eta: %6.2f phi: %6.2f"\
            %( pdgToName(particle_['pdgId']),particle_['index'], particle_['status'], len(daughters), particle_['pt'], particle_['eta'], particle_['phi'])
    if len(daughters)==0 or (len(daughters)==1 and daughters[0]==particle_):
        return
    else:
        for p in daughters:
            printDecay(p, genParts, prefix=prefix.replace('|->','|  ')+'|->')
Example #2
0
    prompt_gen_e  = filter( lambda l:abs(l['pdgId']) == 11, prompt_gen_leptons )

    logger.info( "GenDecay: %s providing prompt gen mu: %i ele: %i" , bold("/".join(W_decay) ), len(prompt_gen_mu), len(prompt_gen_e) )
    for l in prompt_gen_leptons:
        reco_match = bestDRMatchInCollection( l, filter(lambda p:p['pdgId']==l['pdgId'], all_reco_leps ), deltaRelPt = -1 )
        delta_pt = reco_match['pt'] - l['pt'] if reco_match else float('nan')
        if reco_match is None:
            selected_lepton_match_string = ""
        elif reco_match['pt']==reader.data.l1_pt:
            selected_lepton_match_string = bold("leading")
        elif reco_match['pt']==reader.data.l2_pt:
            selected_lepton_match_string = bold("trailing")
        else:
            selected_lepton_match_string = "Not matched to l1,l2"
        logger.info( "gen prompt %s %s pt %3.2f eta %3.2f all-reco-match %s delta_pt %3.2f matched to: %s", \
            pdgToName(l['pdgId']),l['source'], l['pt'], l['eta'],
            bool(reco_match), delta_pt, selected_lepton_match_string
            )

    # Status 1 gen leptons in acceptance
    gen_leps = filter( lambda p:abs(p['pdgId']) in [11, 13] and p['status']==1, gPart )
    for gl in gen_leps:
        ancestry = [ gPart[x]['pdgId'] for x in genSearch.ancestry( gl ) ]
        gl["n_D"]   =  sum([ancestry.count(p) for p in D_mesons])
        gl["n_B"]   =  sum([ancestry.count(p) for p in B_mesons])
        gl["n_W"]   =  sum([ancestry.count(p) for p in [24, -24]])
        gl["n_t"]   =  sum([ancestry.count(p) for p in [6, -6]])
        gl["n_tau"] =  sum([ancestry.count(p) for p in [15, -15]])
        gl["ancestry"] = ancestry

    for gl in gen_leps:
Example #3
0
                if len(looseMu)>=3:  counterRecoGen_looseMu[mode][gMode]+=1
                if len(looseEle)>=3:   counterRecoGen_looseEle[mode][gMode]+=1
                leptonsFailRelIso03  = any([l['relIso03']>0.1 for l in leptons])
                leptonsFailRelIso03_012  = any([l['relIso03']>0.12 for l in leptons])
                leptonsFailRelIso04  = any([l['relIso04']>0.1 for l in leptons])
                leptonsFailRelIso04_012  = any([l['relIso04']>0.12 for l in leptons])
                if leptonsFailRelIso03: counterRecoGen_failRelIso03[mode][gMode]+=1
                if len(genLepNotAccepted)>0: counterRecoGen_genLepOutOfAcceptance[mode][gMode]+=1
                if deltaMet>50:  counterRecofake_fakeMet50[mode][gMode]+=1
                neutrinoFromWPt = vecPtSum(genNeutrinosFromW)
                neutrinoFromWAndTauPt = vecPtSum(genNeutrinosFromW+genNeutrinosFromTau)
                neutrinoFromTauPt = vecPtSum(genNeutrinosFromTau)

                otherNeutrinoPt = vecPtSum(otherNeutrinos)
                if otherNeutrinoPt>40:
                    neutrinoMotherString = ",".join([pdgToName(p['motherId']) for p in otherNeutrinos if p['pt']>20])
                    if len(neutrinoMotherString)>0:neutrinoMotherString=bold(" high-pt nu")+" from "+neutrinoMotherString
                else:
                      neutrinoMotherString=""
                allNeutrinoPt = vecPtSum(otherNeutrinos+genNeutrinosFromW+genNeutrinosFromTau)
                jets = getJets(s.chain, jetVars+['mcPt'], jetColl="JetGood")
                dx, dy = 0., 0.
                for j in jets:
                    if j['mcPt']>0:
                        dx+=(j['pt']-j['mcPt'])*cos(j['phi'])
                        dy+=(j['pt']-j['mcPt'])*cos(j['phi'])
                jetMismeas = sqrt(dx**2+dy**2)
                if jetMismeas>40:
                    jetMismeasString=bold("jet-mism:")+" %6.2f"%jetMismeas
                else:
                    jetMismeasString=     "jet-mism:"+" %6.2f"%jetMismeas