Beispiel #1
0
            for metcut in binningMET:
                observedlimit[bjb][htcut][metcut] = -1
                expectedlimit[bjb][htcut][metcut] = -1
                execfile(
                    "/afs/hephy.at/user/s/schoefbeck/www/systematicResults/systematics_htSig-"
                    + str(htcut) + "_metSig-" + str(metcut) + ".py")
                for mode in ["Mu", "Ele"]:
                    totalSysUncert2 = 0.
                    for sys in largestAbsDoubleRatioDeviation.keys():
                        uncert = min(
                            largestAbsDoubleRatioDeviation[sys][mode][bjb],
                            largestAbsSingleRatioDeviation[sys][mode][bjb])
                        print mode, "DR.-Sys:", "htSig-" + str(
                            htcut) + "_metSig-" + str(
                                metcut), "sys", sys, "bjb", bjb, niceNum(
                                    largestAbsDoubleRatioDeviation[sys][mode]
                                    [bjb]), "SR.-Sys:", niceNum(
                                        largestAbsSingleRatioDeviation[sys]
                                        [mode][bjb]), "picked:", niceNum(
                                            uncert)
                        totalSysUncert2 += uncert**2

                    totalSysUncert[mode][bjb][htcut][metcut] = {
                        "MC":
                        sqrt(totalSysUncert2 + relStatErrMC[mode][bjb]**2),
                        "Data":
                        sqrt(totalSysUncert2 + relStatErrData[mode][bjb]**2)
                    }
                    print mode, "Total sys. uncert. for ", "htSig-" + str(
                        htcut) + "_metSig-" + str(
                            metcut), "bjb", bjb, ": MC", niceNum(
Beispiel #2
0
#  res[15]+=weight*n 
#  niceName["15"] ="...&&650<HT && 5.5<METsig         " 
print 
nstring = " & "
for sample in allSamples:
  nstring+=" \multicolumn{2}{c}{"+sample["name"]+"} &"

nstring = nstring[:-1]+"\\hline\\\\"
print nstring

for nr in range(0,100):
  sstring = ""
  if niceName.has_key(str(nr)):
    sstring += niceName[str(nr)]+" & "
    for sample in allSamples:
      sstring+=niceNum(res[sample["name"]][nr])+"&"+niceNum(100*res[sample["name"]][nr]/res[sample["name"]][0])+"\\% &"
    sstring = sstring[:-1]+"\\\\"
    print sstring

#for thisbin in sample["bins"]: 
#  c = ROOT.TChain("pfRA4Analyzer/Events") 
##  for thisbin in sample["bins"]: 
#  print "Adding thisbin",thisbin 
#  c.Add(sample["dirname"]+thisbin+"/*.root") 
#  c.Draw(">>eList",commoncf+"&&"+"jet3pt>40&&ngoodMuons==1&&ngoodElectrons==0&&nvetoMuons==1&&nvetoElectrons==0&&ht>300&&met>150") 
#  elist = ROOT.gDirectory.Get("eList") 
#  number_events = elist.GetN() 
#  for i in range(0, number_events): 
#    c.GetEntry(elist.GetEntry(i)) 
#    print "event, run, lumiblock: ", int(c.GetLeaf("event").GetValue()), int(c.GetLeaf("run").GetValue()), int(c.GetLeaf("lumiblock").GetValue()) 
#    print "met, lepton-pt, ht            :", niceNum(c.GetLeaf("met").GetValue()   ) , niceNum(c.GetLeaf("lepton_pt").GetValue()) , niceNum(c.GetLeaf("ht").GetValue()    ) 
Beispiel #3
0
#  res[15]+=weight*n
#  niceName["15"] ="...&&650<HT && 5.5<METsig         "
print
nstring = " & "
for sample in allSamples:
    nstring += " \multicolumn{2}{c}{" + sample["name"] + "} &"

nstring = nstring[:-1] + "\\hline\\\\"
print nstring

for nr in range(0, 100):
    sstring = ""
    if niceName.has_key(str(nr)):
        sstring += niceName[str(nr)] + " & "
        for sample in allSamples:
            sstring += niceNum(res[sample["name"]][nr]) + "&" + niceNum(
                100 * res[sample["name"]][nr] /
                res[sample["name"]][0]) + "\\% &"
        sstring = sstring[:-1] + "\\\\"
        print sstring

#for thisbin in sample["bins"]:
#  c = ROOT.TChain("pfRA4Analyzer/Events")
##  for thisbin in sample["bins"]:
#  print "Adding thisbin",thisbin
#  c.Add(sample["dirname"]+thisbin+"/*.root")
#  c.Draw(">>eList",commoncf+"&&"+"jet3pt>40&&ngoodMuons==1&&ngoodElectrons==0&&nvetoMuons==1&&nvetoElectrons==0&&ht>300&&met>150")
#  elist = ROOT.gDirectory.Get("eList")
#  number_events = elist.GetN()
#  for i in range(0, number_events):
#    c.GetEntry(elist.GetEntry(i))
Beispiel #4
0
#  print "...&&300<HT<650 && 5.5<METsig", n, "(",weight*n,")",round(100*weight*n/(basis),2),"%"
#  res[14]+=weight*n 
#  niceName["14"] ="...&&300<HT<650 && 5.5<METsig" 
#
#
#  n = c.GetEntries(commoncf+"&&"+"ngoodMuons==1&&ngoodElectrons==0&&jet3pt>30.&& 650<ht          && 5.5<kinMetSig")
#  print "...&&650<HT && 5.5<METsig ", n, "(",weight*n,")",round(100*weight*n/(basis),2),"%"
#  res[15]+=weight*n 
#  niceName["15"] ="...&&650<HT && 5.5<METsig" 
basis = res[0]
print 
for nr in range(len(res)):
  sstring = ""
  if niceName.has_key(str(nr)):
    sstring += niceName[str(nr)]
    print sstring+"  "+niceNum(res[nr])+" "+niceNum(100*res[nr]/basis)+"%"

#for thisbin in sample["bins"]: 
#  c = ROOT.TChain("pfRA4Analyzer/Events") 
##  for thisbin in sample["bins"]: 
#  print "Adding thisbin",thisbin 
#  c.Add(sample["dirname"]+thisbin+"/*.root") 
#  c.Draw(">>eList",commoncf+"&&"+"jet3pt>40&&ngoodMuons==1&&ngoodElectrons==0&&nvetoMuons==1&&nvetoElectrons==0&&ht>300&&met>150") 
#  elist = ROOT.gDirectory.Get("eList") 
#  number_events = elist.GetN() 
#  for i in range(0, number_events): 
#    c.GetEntry(elist.GetEntry(i)) 
#    print "event, run, lumiblock: ", int(c.GetLeaf("event").GetValue()), int(c.GetLeaf("run").GetValue()), int(c.GetLeaf("lumiblock").GetValue()) 
#    print "met, lepton-pt, ht            :", niceNum(c.GetLeaf("met").GetValue()   ) , niceNum(c.GetLeaf("lepton_pt").GetValue()) , niceNum(c.GetLeaf("ht").GetValue()    ) 
#    print "jet0pt, jet1pt, jet2pt, jet3pt:", niceNum(c.GetLeaf("jet0pt").GetValue()) , niceNum(c.GetLeaf("jet1pt").GetValue()   ) , niceNum(c.GetLeaf("jet2pt").GetValue()), niceNum( c.GetLeaf("jet3pt").GetValue()) 
#    print  
Beispiel #5
0
                xbin = h.GetXaxis().FindBin(mbin)
                ybin = h.GetYaxis().FindBin(hbin)
                rescale = h.GetXaxis().GetBinWidth(xbin) * h.GetYaxis().GetBinWidth(ybin)
                h.SetBinContent(h.FindBin(mbin, hbin), h.GetBinContent(h.FindBin(mbin, hbin)) / rescale)
                h = htVSkinMetSig["data"][bjb].data_histo
                h.SetBinContent(h.FindBin(mbin, hbin), h.GetBinContent(h.FindBin(mbin, hbin)) / rescale)

                metpos = var.data_histo.GetXaxis().GetBinCenter(var.data_histo.GetXaxis().FindBin(mbin))
                hpos = var.data_histo.GetYaxis().GetBinCenter(var.data_histo.GetYaxis().FindBin(hbin))
                if hbin > binningHT[0] and mbin > binningkinMetSig[0]:
                    htVSkinMetSig["mc"][bjb].lines.append(
                        [
                            metpos,
                            hpos,
                            "#splitline{"
                            + str(niceNum(res["mc"][bjb][hbin][mbin])).replace(" ", "")
                            + "}{("
                            + str(niceNum(res["pred"][bjb][hbin][mbin])).replace(" ", "")
                            + ")}",
                            0.02,
                            22,
                            False,
                        ]
                    )
                    #          print "Appending MC",hbin,mbin,"#splitline{"+str(niceNum(res["mc"][bjb][hbin][mbin])).replace(" ","")+"}{("+str(niceNum(res["pred"][bjb][hbin][mbin])).replace(" ","")+")}"
                    htVSkinMetSig["data"][bjb].lines.append(
                        [
                            metpos,
                            hpos,
                            "#splitline{"
                            + str(niceNum(res["data"][bjb][hbin][mbin])).replace(" ", "")
    totalSysUncert["Mu"][bjb] = {}
    totalSysUncert["Ele"][bjb] = {}
    for htcut in binningHT:
      observedlimit[bjb][htcut]={}
      expectedlimit[bjb][htcut]={}
      totalSysUncert["Mu" ][bjb][htcut] = {}
      totalSysUncert["Ele"][bjb][htcut] = {}
      for metcut in binningMET:
        observedlimit[bjb][htcut][metcut]=-1
        expectedlimit[bjb][htcut][metcut]=-1
        execfile("/afs/hephy.at/user/s/schoefbeck/www/systematicResults/systematics_htSig-"+str(htcut)+"_metSig-"+str(metcut)+".py")
        for mode in ["Mu", "Ele"]:
          totalSysUncert2 = 0. 
          for sys in largestAbsDoubleRatioDeviation.keys():
            uncert = min(largestAbsDoubleRatioDeviation[sys][mode][bjb], largestAbsSingleRatioDeviation[sys][mode][bjb])
            print mode, "DR.-Sys:", "htSig-"+str(htcut)+"_metSig-"+str(metcut),"sys",sys,"bjb",bjb,niceNum(largestAbsDoubleRatioDeviation[sys][mode][bjb]), "SR.-Sys:", niceNum(largestAbsSingleRatioDeviation[sys][mode][bjb]), "picked:",niceNum(uncert)
            totalSysUncert2+=uncert**2

          totalSysUncert[mode][bjb][htcut][metcut] = {"MC":sqrt(totalSysUncert2 + relStatErrMC[mode][bjb]**2), "Data":sqrt(totalSysUncert2 + relStatErrData[mode][bjb]**2)}
          print mode, "Total sys. uncert. for ","htSig-"+str(htcut)+"_metSig-"+str(metcut), "bjb",bjb,": MC", niceNum(totalSysUncert[mode][bjb][htcut][metcut]["MC"]),"Data:",niceNum(totalSysUncert[mode][bjb][htcut][metcut]["Data"]),"stat.uncert: MC:",niceNum(relStatErrMC[mode][bjb]),"Data:",niceNum(relStatErrData[mode][bjb])

        nSig = bkgYield["Mu"][bjb][htcut][metcut] + bkgYield["Ele"][bjb][htcut][metcut]
        epsilon = 0.2
        nSig_Err = sqrt((totalSysUncert["Mu"][bjb][htcut][metcut]["MC"]*bkgYield["Mu"][bjb][htcut][metcut])**2 + (totalSysUncert["Ele"][bjb][htcut][metcut]["MC"]*bkgYield["Ele"][bjb][htcut][metcut])**2)
#        precision = 0.008
        precision = 0.025
        cl = 0.95
        expectedlimit[bjb][htcut][metcut] = BayesianUpperLimit(int(nSig),epsilon,nSig,nSig_Err,cl,precision)

        nSigObserved = dataCount["Mu"][bjb] + dataCount["Ele"][bjb]
        nSigPredicted = dataPrediction["Mu"][bjb] + dataPrediction["Ele"][bjb]
Beispiel #7
0
#  print "...&&300<HT<650 && 5.5<METsig", n, "(",weight*n,")",round(100*weight*n/(basis),2),"%"
#  res[14]+=weight*n
#  niceName["14"] ="...&&300<HT<650 && 5.5<METsig"
#
#
#  n = c.GetEntries(commoncf+"&&"+"ngoodMuons==1&&ngoodElectrons==0&&jet3pt>30.&& 650<ht          && 5.5<kinMetSig")
#  print "...&&650<HT && 5.5<METsig ", n, "(",weight*n,")",round(100*weight*n/(basis),2),"%"
#  res[15]+=weight*n
#  niceName["15"] ="...&&650<HT && 5.5<METsig"
basis = res[0]
print
for nr in range(len(res)):
    sstring = ""
    if niceName.has_key(str(nr)):
        sstring += niceName[str(nr)]
        print sstring + "  " + niceNum(res[nr]) + " " + niceNum(100 * res[nr] / basis) + "%"

# for thisbin in sample["bins"]:
#  c = ROOT.TChain("pfRA4Analyzer/Events")
##  for thisbin in sample["bins"]:
#  print "Adding thisbin",thisbin
#  c.Add(sample["dirname"]+thisbin+"/*.root")
#  c.Draw(">>eList",commoncf+"&&"+"jet3pt>40&&ngoodMuons==1&&ngoodElectrons==0&&nvetoMuons==1&&nvetoElectrons==0&&ht>300&&met>150")
#  elist = ROOT.gDirectory.Get("eList")
#  number_events = elist.GetN()
#  for i in range(0, number_events):
#    c.GetEntry(elist.GetEntry(i))
#    print "event, run, lumiblock: ", int(c.GetLeaf("event").GetValue()), int(c.GetLeaf("run").GetValue()), int(c.GetLeaf("lumiblock").GetValue())
#    print "met, lepton-pt, ht            :", niceNum(c.GetLeaf("met").GetValue()   ) , niceNum(c.GetLeaf("lepton_pt").GetValue()) , niceNum(c.GetLeaf("ht").GetValue()    )
#    print "jet0pt, jet1pt, jet2pt, jet3pt:", niceNum(c.GetLeaf("jet0pt").GetValue()) , niceNum(c.GetLeaf("jet1pt").GetValue()   ) , niceNum(c.GetLeaf("jet2pt").GetValue()), niceNum( c.GetLeaf("jet3pt").GetValue())
#    print
Beispiel #8
0
 if btb == "4p":
     print "\\hline\\multicolumn{15}{c}{$\\HT>" + str(
         htb) + "$, \\fourTag}\\\\\\hline"
 for metb in [150, 250, 350, 450]:
     #      md = "MC_predictedYield_fromb2_METshapeSpFUncorr"
     suffix = "Uncorr"
     md = "MC_predictedYield_fromb2_METshapeSpF" + suffix
     res = yields[btb]["SF"][htb][metb][md]
     sysErr_b_Up = yields[btb]["SF_b_Up"][htb][metb][md] - res
     sysErr_b_Down = yields[btb]["SF_b_Down"][htb][metb][md] - res
     sysErr_light_Up = yields[btb]["SF_light_Up"][htb][metb][md] - res
     sysErr_light_Down = yields[btb]["SF_light_Down"][htb][metb][
         md] - res
     sigmaStat = sqrt(yields[btb]["SF"][htb][metb]
                      ["Var_MC_predictedYield_fromb2_METshapeSpFCorr"])
     sstring = "$" + niceNum(res).rstrip() + "$&${}^{" + niceNum(
         sysErr_b_Up, 2, True) + "}_{" + niceNum(
             sysErr_b_Down, 2, True) + "}$"
     sstring += "&${}^{" + niceNum(
         sysErr_light_Up, 2, True) + "}_{" + niceNum(
             sysErr_light_Down, 2, True) + "}$&$\pm$&$" + niceNum(
                 sigmaStat, 2) + "$"
     #predicted from higher btb bin
     md = "MC_predictedYield_frombtb_METshapeSpF" + suffix
     res = yields[btb]["SF"][htb][metb][md]
     relStatErr = 1. / sqrt(controlYield[btb][mode][htb]["MC"])
     sstring += "&$" + niceNum(res) + "$&$\pm$&$" + niceNum(
         res * relStatErr, 2) + "$"
     #MC truth yield
     sstring += "&$" + niceNum(
         yields[btb]["SF"][htb][metb]["MC"]) + "$&$\pm$&$" + niceNum(
  for htb in htbins_table:
    if btb=="3":
      print "\\hline\\multicolumn{15}{c}{$\\HT>"+str(htb)+"$, \\threeTag}\\\\\\hline"
    if btb=="4p":
      print "\\hline\\multicolumn{15}{c}{$\\HT>"+str(htb)+"$, \\fourTag}\\\\\\hline"
    for metb in [150, 250, 350, 450]:
#      md = "MC_predictedYield_fromb2_METshapeSpFUncorr"
      suffix = "Uncorr"
      md = "MC_predictedYield_fromb2_METshapeSpF"+suffix
      res               = yields[btb]["SF"][htb][metb][md]
      sysErr_b_Up       = yields[btb]["SF_b_Up"][htb][metb][md] - res
      sysErr_b_Down     = yields[btb]["SF_b_Down"][htb][metb][md] - res
      sysErr_light_Up   = yields[btb]["SF_light_Up"][htb][metb][md] - res
      sysErr_light_Down = yields[btb]["SF_light_Down"][htb][metb][md] - res
      sigmaStat    = sqrt(yields[btb]["SF"][htb][metb]["Var_MC_predictedYield_fromb2_METshapeSpFCorr"])
      sstring =  "$"+niceNum(res).rstrip()+"$&${}^{"+niceNum(sysErr_b_Up,2,True)+"}_{"+niceNum(sysErr_b_Down,2,True)+"}$"
      sstring += "&${}^{"+niceNum(sysErr_light_Up,2,True)+"}_{"+niceNum(sysErr_light_Down,2,True)+"}$&$\pm$&$"+niceNum(sigmaStat, 2)+"$"
      #predicted from higher btb bin
      md = "MC_predictedYield_frombtb_METshapeSpF"+suffix
      res = yields[btb]["SF"][htb][metb][md]
      relStatErr = 1./sqrt(controlYield[btb][mode][htb]["MC"]) 
      sstring+="&$"+niceNum(res)+"$&$\pm$&$"+niceNum(res*relStatErr, 2)+"$"
      #MC truth yield
      sstring+="&$"+niceNum(yields[btb]["SF"][htb][metb]["MC"])+"$&$\pm$&$"+niceNum(sqrt(yields[btb]["SF"][htb][metb]["Var_MC"]), 2)+"$"
      #signal yield
      sstring+="&$"+niceNum(yields[btb]["SF"][htb][metb]["signal"])+"$&$\pm$&$"+niceNum(sqrt(yields[btb]["SF"][htb][metb]["Var_signal"]), 2)+"$\\\\"
      print "$\\ETmiss>"+str(metb)+"$&"+sstring

#      res = yields[btb]["SF"][htb][metb]["corr"]
#      print "\nHT/MET >= ", htb, metb,"nControl(data, btb=2)", controlYield[htb]['SF']["2"]["data"],  "nControl(data, btb="+btb+")", controlYield[htb]['SF'][btb]["data"], "nSig(data)", yields[htb][mode][btb][metb]["data"]
#      print "high sys.  low stat:",niceNum(res)+"+/-"+niceNum(max(deltap), 3)+"+/-"+niceNum(res* 1./sqrt(max(1, controlYield[htb]['SF']["2"]["data"])),3)