Example #1
0
                  getVar = var
                  if prefixString!="":
                    getVar = prefixString+"_"+var
                  exec("s."+var+"="+str(getVarValue(c, getVar)).replace("nan","float('nan')"))
#                if bin.count("Run"):
#                  if not checkLumi(s.run, s.lumi):
#  #                  print s.run, s.lumi
#                    continue
                s.weight  = sample["weight"][bin]*nvtxWeight
                s.met = c.GetLeaf(c.GetAlias('barepfmet')).GetValue()
                s.event = long(c.GetLeaf(c.GetAlias('event')).GetValue())

                for var in extraVariables:
                  exec("s."+var+"=float('nan')")

                s.type1met = c.GetLeaf(c.GetAlias('met')).GetValue()
                nmuons = getVarValue(c, "nmuons")
                neles = getVarValue(c, "neles")
                if (chmode=="doubleMu" and nmuons>=2) or (chmode=="doubleEle" and neles>=2) or (chmode=="eleMu" and nmuons>=1 and neles>=1):
                  allGoodLeptons = getGoodLeptons(c, nmuons, neles, cmode)
                  goodJets , s.ht, s.nbtags = getGoodJets(c, allGoodLeptons["leptons"])
#                  print s.ht, c.GetLeaf(c.GetAlias('ht')).GetValue(), s.nbtags, c.GetLeaf(c.GetAlias('nbtags')).GetValue()
                  s.njets = len(goodJets)
#                  print s.njets, s.nbtags, s.ht
                  mhtpx, mhtpy = 0., 0.
                  for j,jet in enumerate(goodJets):
                    mhtpx -= jet["pt"]*cos(jet["phi"])
                    mhtpy -= jet["pt"]*sin(jet["phi"])
                    if j<4:
                      exec("s.jet"+str(j)+"pt="+str(jet["pt"]))
                  s.mht = sqrt(mhtpx**2 + mhtpy**2)