def WriteEvtCount(inputdic, outFile, samplename="region"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c|c}") tableList.append("%s & Sideband & Control & ZZ & Signal \\\\" % samplename) tableList.append("\\hline\\hline") tableList.append("& & & & \\\\") for i, cut in enumerate(dump_lst): #get the corresponding region outstr = "" outstr += cut.replace("_", " ") for j, region in enumerate(region_lst): #get the mass plot outstr += " & " outstr += str(helpers.round_sig(inputdic[cut][region], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[cut][region + "_err"], 2)) outstr+="\\\\" tableList.append(outstr) tableList.append("& & & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line+" \n")
def DataCutFlow(inputdic, outFile, samplename="region"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c|c|c|c}") tableList.append( "Cut & Data & $m_{G}=1$TeV & $m_{G}=2$TeV & $m_{G}=3$TeV & $t\\bar{t}$ & $Z+jets$ \\\\" ) tableList.append("\\hline\\hline") tableList.append("& & & & & & \\\\") ### do the cuts based on cutflow table for i, cut in enumerate(datasel_lst): outstr = "" outstr += datasel_dic[cut] for k, sample in enumerate(sample_lst): outstr += " & " outstr += str(helpers.round_sig(inputdic[sample][cut], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[sample][cut + "_err"], 2)) outstr += "\\\\" tableList.append(outstr) ### do the cuts based on the number of entries in each plot for i, cut in enumerate(cut_lst): #get the corresponding region for j, region in enumerate(region_lst): outstr = "" outstr += cut_dic[cut] + ", " + region_dic[region] #get the mass plot for k, sample in enumerate(sample_lst): outstr += " & " #print sample, cut, region if sample == "data" and region == "Signal" and (("TwoTag_split" in cut) \ or ("ThreeTag" in cut) or ("FourTag" in cut)) and blind: outstr += " blinded " else: outstr += str( helpers.round_sig(inputdic[sample][cut][region], 2)) outstr += " $\\pm$ " outstr += str( helpers.round_sig( inputdic[sample][cut][region + "_err"], 2)) outstr += "\\\\" tableList.append(outstr) tableList.append("& & & & & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line + " \n")
def add_entry(value, state=None, percent=False): temstr = "" temstr += " & " temstr += str(helpers.round_sig(value, 2)) temstr += " $\\%$ " if percent else "" if state is not None: temstr += " $\\pm$ " temstr += str(helpers.round_sig(state, 2)) temstr += " $\\%$ " if percent else "" return temstr
def Dump_BKGCompare(tag="FourTag", title="SR_Varations", region="Signal"): column_lst = ["Prediction", "QCD", "ttbar"] column_key_lst = ["data_est", "qcd_est", "ttbar_est"] #for looping through the objects texoutpath = inputpath + inputdir + "/" + "Plot/Tables/" if not os.path.exists(texoutpath): os.makedirs(texoutpath) outFile = open(texoutpath + tag + "_" + title + ".tex", "w") ### tableList = [] ### #start the table add_table_head(tableList, column_lst, title=" " + tag) ##save a temp value nominal = {} for i, syst in enumerate(syst_lst): #get the corresponding region outstr = "" outstr += syst.replace("_", " ") if syst is not "" else "Nominal" systpath = "_" + syst if syst is not "" else "" inputtex = inputpath + inputdir + (systpath + "/" + "sum_" + inputdir + systpath + ".txt") f1 = open(inputtex, 'r') masterdic = json.load(f1) #save the noiminal values if (syst is ""): for Types in column_key_lst: nominal[Types] = helpers.round_sig( masterdic[Types][tag][region], 2) nominal[Types + "_err"] = helpers.round_sig( masterdic[Types][tag][region + "_err"], 2) #print masterdic, tag for Types in column_key_lst: value = (masterdic[Types][tag][region] / nominal[Types] - 1) * 100 error = helpers.ratioerror(masterdic[Types][tag][region], nominal[Types], masterdic[Types][tag][region + "_err"], nominal[Types + "_err"]) * 100 outstr += add_entry(value, error, percent=True) #finish up del (masterdic) f1.close() #finish the current entry outstr += "\\\\" if (syst != syst_lst[0]): tableList.append(outstr) #finish the table add_table_tail(tableList, column_lst) #return the table for line in tableList: print line outFile.write(line + " \n")
def Dump_BKGCompare(tag="FourTag", title="SR_Varations", region="Signal"): column_lst = ["Prediction", "Diff", "QCD", "ttbar"] column_key_lst = ["data_est", "data_est", "qcd_est", "ttbar_est"] #for looping through the objects texoutpath = inputpath + inputdir + "/" + "Plot/Tables/" if not os.path.exists(texoutpath): os.makedirs(texoutpath) outFile = open( texoutpath + tag + "_" + title + ".tex", "w") ### tableList = [] ### #start the table add_table_head(tableList, column_lst, title=" " + tag) ##save a temp value nominal = {} for i, syst in enumerate(syst_lst): #get the corresponding region outstr = "" outstr += syst.replace("_", " ") if syst is not "" else "Nominal" systpath = "_" + syst if syst is not "" else reweightpath inputtex = inputpath + inputdir + (systpath + "/" + "sum_" + inputdir + systpath + ".txt") f1 = open(inputtex, 'r') masterdic = json.load(f1) #save the noiminal values if (syst is ""): for Types in column_key_lst: nominal[Types] = helpers.round_sig(masterdic[Types][tag][region], 2) nominal[Types+"_err"] = helpers.round_sig(masterdic[Types][tag][region+"_err"], 2) #print masterdic, tag for j, Types in enumerate(column_key_lst): if j == 0: ##for the first entry value = masterdic[Types][tag][region] error = masterdic[Types][tag][region+"_err"] outstr += add_entry(value, error, percent=True) else: ##do percentage value = (masterdic[Types][tag][region]/nominal[Types] - 1) * 100 error = helpers.ratioerror(masterdic[Types][tag][region], nominal[Types], masterdic[Types][tag][region+"_err"], nominal[Types+"_err"]) * 100 outstr += add_entry(value, error, percent=True) #finish up del(masterdic) f1.close() #finish the current entry outstr+="\\\\" if (syst!=syst_lst[-1]): tableList.append(outstr) #finish the table add_table_tail(tableList, column_lst) #return the table for line in tableList: print line outFile.write(line+" \n")
def DataCutFlow(inputdic, outFile, samplename="region"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c|c|c|c}") tableList.append("Cut & Data & $m_{G}=1$TeV & $m_{G}=2$TeV & $m_{G}=3$TeV & $t\\bar{t}$ & $Z+jets$ \\\\") tableList.append("\\hline\\hline") tableList.append("& & & & & & \\\\") ### do the cuts based on cutflow table for i, cut in enumerate(datasel_lst): outstr = "" outstr += datasel_dic[cut] for k, sample in enumerate(sample_lst): outstr += " & " outstr += str(helpers.round_sig(inputdic[sample][cut], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[sample][cut+"_err"], 2)) outstr+="\\\\" tableList.append(outstr) ### do the cuts based on the number of entries in each plot for i, cut in enumerate(cut_lst): #get the corresponding region for j, region in enumerate(region_lst): outstr = "" outstr += cut_dic[cut] + ", " + region_dic[region] #get the mass plot for k, sample in enumerate(sample_lst): outstr += " & " #print sample, cut, region if sample == "data" and region == "Signal" and (("TwoTag_split" in cut) \ or ("ThreeTag" in cut) or ("FourTag" in cut)) and blind: outstr += " blinded " else: outstr += str(helpers.round_sig(inputdic[sample][cut][region], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[sample][cut][region + "_err"], 2)) outstr+="\\\\" tableList.append(outstr) tableList.append("& & & & & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line+" \n")
def WriteEvtCount(inputdic, outFile, samplename="region"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c}") tableList.append("%s & Sideband & Control & Signal \\\\" % samplename) tableList.append("\\hline\\hline") tableList.append("& & & \\\\") for i, cut in enumerate(dump_lst): #get the corresponding region outstr = "" outstr += cut.replace("_", " ") for j, region in enumerate(yield_region_lst): #get the mass plot outstr += " & " outstr += str(helpers.round_sig(inputdic[cut][region], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[cut][region + "_err"], 2)) if region + "_syst_up" in inputdic[cut].keys(): outstr += " $\\substack{" outstr += "+ " + str( helpers.round_sig(inputdic[cut][region + "_syst_up"], 2)) outstr += "\\\\" outstr += "- " + str( helpers.round_sig(inputdic[cut][region + "_syst_down"], 2)) outstr += "}$ " # if (ROOT.TMath.Sqrt(inputdic[cut][region]) > 0): # outstr += " rel " # outstr += " $\\substack{" # outstr += "+ " + str(helpers.round_sig(inputdic[cut][region+"_syst_up"]/ROOT.TMath.Sqrt(inputdic[cut][region]), 2)) # outstr += "\\\\" # outstr += "- " + str(helpers.round_sig(inputdic[cut][region+"_syst_down"]/ROOT.TMath.Sqrt(inputdic[cut][region]), 2)) # outstr += "}$ " else: outstr += " $\\pm$ sys" outstr += "\\\\" tableList.append(outstr) tableList.append("& & & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line + " \n")
def WriteEvtCount(inputdic, outFile, samplename="region"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c}") tableList.append("%s & Sideband & Control & Signal \\\\" % samplename) tableList.append("\\hline\\hline") tableList.append("& & & \\\\") for i, cut in enumerate(dump_lst): #get the corresponding region outstr = "" outstr += cut.replace("_", " ") for j, region in enumerate(yield_region_lst): #get the mass plot outstr += " & " outstr += str(helpers.round_sig(inputdic[cut][region], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[cut][region + "_err"], 2)) if region + "_syst_up" in inputdic[cut].keys(): outstr += " $\\substack{" outstr += "+ " + str(helpers.round_sig(inputdic[cut][region+"_syst_up"], 2)) outstr += "\\\\" outstr += "- " + str(helpers.round_sig(inputdic[cut][region+"_syst_down"], 2)) outstr += "}$ " # if (ROOT.TMath.Sqrt(inputdic[cut][region]) > 0): # outstr += " rel " # outstr += " $\\substack{" # outstr += "+ " + str(helpers.round_sig(inputdic[cut][region+"_syst_up"]/ROOT.TMath.Sqrt(inputdic[cut][region]), 2)) # outstr += "\\\\" # outstr += "- " + str(helpers.round_sig(inputdic[cut][region+"_syst_down"]/ROOT.TMath.Sqrt(inputdic[cut][region]), 2)) # outstr += "}$ " else: outstr += " $\\pm$ sys" outstr+="\\\\" tableList.append(outstr) tableList.append("& & & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line+" \n")
def add_entry(valuetuple, doerr=True, percent=False): '''add the entry: tuple or value, option of filling the error and as a percentage''' temstr = "" temstr += " & " if isinstance(valuetuple, tuple): if valuetuple[0] == 0: temstr += " - " return temstr else: temstr += str(helpers.round_sig(valuetuple[0] * (100 if percent else 1), 3)) if doerr: temstr += " $\\pm$ " temstr += str(helpers.round_sig(valuetuple[1] * (100 if percent else 1), 3)) #cause sqrt(a^2 + b^2) is sigma*a/sqrt(a^2 + b^2) else: temstr += str(helpers.round_sig(valuetuple * (100 if percent else 1), 3)) return temstr
def MCCutFlow(inputdic, outFile, keyword="RSG1"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c|c|c|c|c}") tableList.append( "Resonance Mass [GeV] & Mini-ntuple Skimming & 2 large-R jets & $\Delta\eta$ & Xhh < 1.6 & 2bs SR & 3b SR & 4b SR \\\\" ) tableList.append("\\hline\\hline") tableList.append("& & & & & & &\\\\") ### do the cuts based on the number of entries in each plot for i, mass in enumerate(mass_lst): #get the corresponding region outstr = "" outstr += str(mass) #get the mass plot for k, cut in enumerate(mcsel_lst): outstr += " & " value = 0 value_err = 0 if type(inputdic[keyword + "_%i" % mass][cut]) is dict: value = inputdic[keyword + "_%i" % mass][cut]["Signal"] value_err = inputdic[keyword + "_%i" % mass][cut]["Signal" + "_err"] else: value = inputdic[keyword + "_%i" % mass][cut] value_err = inputdic[keyword + "_%i" % mass][cut + "_err"] outstr += str(helpers.round_sig(value, 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(value_err, 2)) outstr += "\\\\" tableList.append(outstr) tableList.append("& & & & & & &\\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line + " \n")
def MCCutFlow(inputdic, outFile, keyword="RSG1"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c|c|c|c|c}") tableList.append("Resonance Mass [GeV] & Mini-ntuple Skimming & 2 large-R jets & $\Delta\eta$ & Xhh < 1.6 & 2bs SR & 3b SR & 4b SR \\\\") tableList.append("\\hline\\hline") tableList.append("& & & & & & &\\\\") ### do the cuts based on the number of entries in each plot for i, mass in enumerate(mass_lst): if mass == 2750 and keyword == "RSG2": continue; #get the corresponding region outstr = "" outstr += str(mass) #get the mass plot for k, cut in enumerate(mcsel_lst): outstr += " & " value = 0 value_err = 0 if type(inputdic[keyword + "_%i" % mass][cut]) is dict: value = inputdic[keyword + "_%i" % mass][cut]["Signal"] value_err = inputdic[keyword + "_%i" % mass][cut]["Signal"+"_err"] else: value = inputdic[keyword + "_%i" % mass][cut] value_err = inputdic[keyword + "_%i" % mass][cut+"_err"] outstr += str(helpers.round_sig(value, 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(value_err, 2)) outstr+="\\\\" tableList.append(outstr) tableList.append("& & & & & & &\\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line+" \n")
def WriteYield(inputdic, outFile, cut="Signal"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c}") tableList.append("%s & Sideband & Control & Signal \\\\" % cut.replace("_", " ")) tableList.append("\\hline\\hline") tableList.append("& & & \\\\") for i, file in enumerate(yield_lst): #get the corresponding region outstr = "" outstr += yield_dic[file] for j, region in enumerate(yield_region_lst): #print file, region outstr += " & " outstr += str(helpers.round_sig(inputdic[file][cut][region], 2)) outstr += " $\\pm$ " outstr += str( helpers.round_sig(inputdic[file][cut][region + "_err"], 2)) # if region + "_syst_up" in inputdic[file][cut].keys(): # outstr += " $\\substack{" # outstr += "+ " + str(helpers.round_sig(inputdic[file][cut][region+"_syst_up"], 2)) # outstr += "\\\\" # outstr += "- " + str(helpers.round_sig(inputdic[file][cut][region+"_syst_down"], 2)) # outstr += "}$ " # else: # outstr += " $\\pm$ sys" outstr += "\\\\" tableList.append(outstr) tableList.append("& & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: #print line outFile.write(line + " \n")
def WriteYield(inputdic, outFile, cut="Signal"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c}") tableList.append("%s & Sideband & Control & Signal \\\\" % cut.replace("_", " ")) tableList.append("\\hline\\hline") tableList.append("& & & \\\\") for i, file in enumerate(yield_lst): #get the corresponding region outstr = "" outstr += yield_dic[file] for j, region in enumerate(yield_region_lst): #print file, region outstr += " & " outstr += str(helpers.round_sig(inputdic[file][cut][region], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[file][cut][region+"_err"], 2)) # if region + "_syst_up" in inputdic[file][cut].keys(): # outstr += " $\\substack{" # outstr += "+ " + str(helpers.round_sig(inputdic[file][cut][region+"_syst_up"], 2)) # outstr += "\\\\" # outstr += "- " + str(helpers.round_sig(inputdic[file][cut][region+"_syst_down"], 2)) # outstr += "}$ " # else: # outstr += " $\\pm$ sys" outstr+="\\\\" tableList.append(outstr) tableList.append("& & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: #print line outFile.write(line+" \n")
def WriteYield(inputdic, outFile, cut="Signal"): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c}") tableList.append("%s & Sideband & Control & Signal \\\\") tableList.append("\\hline\\hline") tableList.append("& & & \\\\") for i, file in enumerate(yield_lst): #get the corresponding region outstr = "" outstr += yield_dic[file] for j, region in enumerate(yield_region_lst): #print file, region outstr += " & " outstr += str(helpers.round_sig(inputdic[file][cut][region], 2)) outstr += " $\\pm$ " outstr += str(helpers.round_sig(inputdic[file][cut][region+"_err"], 2)) outstr += " $\\pm$ " outstr += str("sys") outstr+="\\\\" tableList.append(outstr) tableList.append("& & & \\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: #print line outFile.write(line+" \n")
.fit_transform(inputs[0:nb_samples]) #parameters: im = True # whether or not to show images t = 9e-3 # how close the images should be shown print("An example LLE embedding:") fig = plt.figure(figsize=(7.5, 7.5)) ax = PL.plot_embedding(inputs, X_lle_19, targets[0:nb_samples], fig=fig, subplot_pos=111, images=im, im_thres=t, title="Number of neighbors: " + str(nb_neighbors[1]) + ", Regularization: " + str(HL.round_sig(regs[1]))) plt.show() input("press enter to continue\n") print("The best LLE-embedding:") fig = plt.figure(figsize=(7.5, 7.5)) ax = PL.plot_embedding(inputs, X_lle_5, targets[0:nb_samples], fig=fig, subplot_pos=111, images=im, im_thres=t, title="Number of neighbors: " + str(nb_neighbors[0]) + ", Regularization: " + str(HL.round_sig(regs[0]))) plt.show()
def WriteFitResult(inputdic, outFile, npar=3): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c|c|c|c}") tableList.append( "Region & $ a_{t\\bar{t}}$ & $ b_{t\\bar{t}}$ & $ c_{t\\bar{t}}$ & $ a_{qcd}$ & $ b_{qcd}$ & $c_{qcd}$ \\\\" ) tableList.append("\\hline\\hline") tableList.append("& & & & & &\\\\") for i, cut in enumerate(cut_lst): #get the mass plot outstr = "" outstr += cut.replace("_", " ") outstr += " & " #print inputdic[cut]["ttbar_est"]["paramerrs"][0] if not ignore_ttbar: outstr += str(round_sig(inputdic[cut]["ttbar_est"]["params"][0], 2)) outstr += " $\\pm$ " outstr += str( round_sig(inputdic[cut]["ttbar_est"]["paramerrs"][0], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["ttbar_est"]["params"][1], 2)) outstr += " $\\pm$ " outstr += str( round_sig(inputdic[cut]["ttbar_est"]["paramerrs"][1], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["ttbar_est"]["params"][2], 2)) outstr += " $\\pm$ " outstr += str( round_sig(inputdic[cut]["ttbar_est"]["paramerrs"][2], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["qcd_est"]["params"][0], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["qcd_est"]["paramerrs"][0], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["qcd_est"]["params"][1], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["qcd_est"]["paramerrs"][1], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["qcd_est"]["params"][2], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["qcd_est"]["paramerrs"][2], 2)) outstr += "\\\\" tableList.append(outstr) tableList.append("& & & & & &\\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line + " \n")
def WriteFitResult(inputdic, outFile, npar=3): ### tableList = [] ### tableList.append("\\begin{footnotesize}") tableList.append("\\begin{tabular}{c|c|c|c|c|c|c}") tableList.append("Region & $ a_{t\\bar{t}}$ & $ b_{t\\bar{t}}$ & $ c_{t\\bar{t}}$ & $ a_{qcd}$ & $ b_{qcd}$ & $c_{qcd}$ \\\\") tableList.append("\\hline\\hline") tableList.append("& & & & & &\\\\") for i, cut in enumerate(cut_lst): #get the mass plot outstr = "" outstr += cut.replace("_", " ") outstr += " & " #print inputdic[cut]["ttbar_est"]["paramerrs"][0] if not ignore_ttbar: outstr += str(round_sig(inputdic[cut]["ttbar_est"]["params"][0], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["ttbar_est"]["paramerrs"][0], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["ttbar_est"]["params"][1], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["ttbar_est"]["paramerrs"][1], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["ttbar_est"]["params"][2], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["ttbar_est"]["paramerrs"][2], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["qcd_est"]["params"][0], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["qcd_est"]["paramerrs"][0], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["qcd_est"]["params"][1], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["qcd_est"]["paramerrs"][1], 2)) outstr += " & " outstr += str(round_sig(inputdic[cut]["qcd_est"]["params"][2], 2)) outstr += " $\\pm$ " outstr += str(round_sig(inputdic[cut]["qcd_est"]["paramerrs"][2], 2)) outstr+="\\\\" tableList.append(outstr) tableList.append("& & & & & &\\\\") tableList.append("\\hline\\hline") tableList.append("\\end{tabular}") tableList.append("\\end{footnotesize}") tableList.append("\\newline") #return the table for line in tableList: print line outFile.write(line+" \n")