def getXsec(mttbin): inFile = open('xsecFit_tab13TeV_mtt' + str(mttbin) + '.tex', 'r') l = inFile.read().splitlines() xsec = '' total = '' for line in l: if '$\\sigma_{t\\bar{t}}^{(\\mu_' + str( mttbin) in line and '\\hline' in line: xsec = line if 'Total' in line and not 'vis' in line: total = line xsec = xsec.split('&')[3] xsec = TString(xsec) xsec.ReplaceAll('pb \\\\ \\hline \\hline', '') xsec = float(str(xsec)) total = total.split('&')[3] total = TString(total) total.ReplaceAll('}_{', ' ') total.ReplaceAll(' $\mp^{', '') total.ReplaceAll(' $\pm^{', '') total.ReplaceAll('}$ \\\\', '') total.ReplaceAll(' \hline', '') total = str(total) total = total.split() err_up = float(total[0]) err_down = float(total[1]) err_up *= xsec / 100. err_down *= xsec / 100. h = rFile.Get('h_xsec_' + str(mttbin)) err_toys = h.GetRMS() err_up = (err_up**2 + err_toys**2)**.5 err_down = (err_down**2 + err_toys**2)**.5 err_up = round(err_up, 2) err_down = round(err_down, 2) return [xsec, err_up, err_down]
def read_file(arr, meas_type, mapsa_fitter_inst, path): if not os.path.isfile(str(path + arr[0])): print "Root file not found at", str(path + arr[0]) #sys.exit(1) return f = TFile(str(path + arr[0]), 'READ') if (f.IsZombie()): print "Error opening file" return else: print "Reading File ", arr[0] #f.ls() tree = f.Get('tree') f_GlobalData_Map = ROOT.TMap() f_GlobalData_Map.Add(ROOT.TObjString("tree"), tree) #tree.Print() outfile = TString(arr[0]) outfile.ReplaceAll(".root", "") outfile.ReplaceAll(" ", "") # print outfile if (meas_type == 0): outfile = "pedestal" if (not g.FindKey(str(outfile))): g.mkdir(str(outfile)) g.cd(str(outfile)) else: return channels = 288 if (arr[2] == 'inv'): channels = 96 mapsa_mat = [[1, 0, 0], [1, 0, 0]] elif (arr[2] == 'norm'): channels = 288 mapsa_mat = [[1, 1, 1], [1, 0, 1]] #print "channels", channels #print "mapsa_mat", mapsa_mat c1 = TCanvas('c1', 'Pixel Monitor ', 700, 900) c2 = TCanvas('c2', 'Pixel Monitor ', 500, 500) c3 = TCanvas('c3', 'Pixel Monitor ', 1280, 720) c4 = TCanvas('c4', 'Pixel Monitor ', 500, 500) c5 = TCanvas('c5', 'Pixel Monitor ', 500, 500) f_GlobalData_Map.Add(ROOT.TObjString("c1"), c1) f_GlobalData_Map.Add(ROOT.TObjString("c2"), c2) f_GlobalData_Map.Add(ROOT.TObjString("c3"), c3) f_GlobalData_Map.Add(ROOT.TObjString("c4"), c4) f_GlobalData_Map.Add(ROOT.TObjString("c5"), c5) # c2.Divide(2,1) #c2.cd(0) c1.Divide(3, 2) for i in range(1, 7): c1.cd(i) ROOT.gPad.SetGridx() ROOT.gPad.SetGridy() # channelcounts = TH2I('HitMap','Counts; Channel; DAC Value (1.456 mV)', 288, .5,288.5,256, .5, 256.5) channelcounts = TH2I('HitMap', 'Counts; Channel; DAC Value (a.u.)', 288, .5, 288.5, 256, .5, 256.5) channelcounts_norm = TH2F('HitMap_norm', 'Occupancy ; Channel; DAC Value (a.u.)', 288, .5, 288.5, 256, .5, 256.5) f_GlobalData_Map.Add(ROOT.TObjString("HitMap"), channelcounts) f_GlobalData_Map.Add(ROOT.TObjString("HitMap"), channelcounts_norm) norm_2d = TH2F('Norm2D', 'Normalization; Column; Row', 48, .5, 48.5, 6, .5, 6.5) mean_2d = TH2F('Mean2D', 'Mean; Column; Row', 48, .5, 48.5, 6, .5, 6.5) sigma_2d = TH2F('Sigma2D', 'Sigma; Column; Row', 48, .5, 48.5, 6, .5, 6.5) chisquare = TH2F('Chisquare2D', 'Chisquare; Column; Row', 48, .5, 48.5, 6, .5, 6.5) f_GlobalData_Map.Add(ROOT.TObjString("Norm2D"), norm_2d) f_GlobalData_Map.Add(ROOT.TObjString("Mean2D"), mean_2d) f_GlobalData_Map.Add(ROOT.TObjString("Sigma2D"), sigma_2d) f_GlobalData_Map.Add(ROOT.TObjString("Chisquare2D"), chisquare) objarr2d = [] objarr2d.append(norm_2d) objarr2d.append(mean_2d) objarr2d.append(sigma_2d) objarr2d.append(chisquare) normgraph = TGraphErrors() meangraph = TGraphErrors() sigmagraph = TGraphErrors() chisquaregraph = TGraphErrors() mean_corrgraph = TGraphErrors() f_GlobalData_Map.Add(ROOT.TObjString("normgraph "), normgraph) f_GlobalData_Map.Add(ROOT.TObjString("meangraph "), meangraph) f_GlobalData_Map.Add(ROOT.TObjString("sigmagraph "), sigmagraph) f_GlobalData_Map.Add(ROOT.TObjString("chisquaregraph"), chisquaregraph) f_GlobalData_Map.Add(ROOT.TObjString("mean_corrgraph"), mean_corrgraph) meanhist = TH1F('meanhist', 'Mean DAC; DAC Value (a.u.); counts', 2560, 0, 255) sigmahist = TH1F('sigmahist', 'Sigma DAC; DAC Value (a.u.); counts', 100, 0, 10) meanhist_std = TH1F('meanhist_std', 'Mean DAC Standard; DAC Value (a.u.); counts', 2560, 0, 255) sigmahist_std = TH1F('sigmahist_std', 'Sigma DAC Standard; DAC Value (a.u.); counts', 100, 0, 10) meanhist_double = TH1F('meanhist_double', 'Mean DAC Double; DAC Value (a.u.); counts', 2560, 0, 255) sigmahist_double = TH1F('sigmahist_double', 'Sigma DAC Double; DAC Value (a.u.); counts', 100, 0, 10) meanhist_double_neighbour = TH1F( 'meanhist_double_neighbour', 'Mean DAC Double Neighbour; DAC Value (a.u.); counts', 2560, 0, 255) sigmahist_double_neighbour = TH1F( 'sigmahist_double_neighbour', 'Sigma DAC Double Neighbour; DAC Value (a.u.); counts', 100, 0, 10) objarr = [] objarr.append(normgraph) objarr.append(meangraph) objarr.append(sigmagraph) objarr.append(chisquaregraph) objarr.append(mean_corrgraph) f_GlobalData_Map.Add(ROOT.TObjString('meanhist'), meanhist) f_GlobalData_Map.Add(ROOT.TObjString('sigmahist'), sigmahist) f_GlobalData_Map.Add(ROOT.TObjString('meanhist_std'), meanhist_std) f_GlobalData_Map.Add(ROOT.TObjString('sigmahist_std'), sigmahist_std) f_GlobalData_Map.Add(ROOT.TObjString('meanhist_double'), meanhist_double) f_GlobalData_Map.Add(ROOT.TObjString('sigmahist_double'), sigmahist_double) f_GlobalData_Map.Add(ROOT.TObjString('meanhist_double_neighbour'), meanhist_double_neighbour) f_GlobalData_Map.Add(ROOT.TObjString('sigmahist_double_neighbour'), sigmahist_double_neighbour) objarr.append(meanhist) objarr.append(sigmahist) objarr.append(meanhist_std) objarr.append(sigmahist_std) objarr.append(meanhist_double) objarr.append(sigmahist_double) objarr.append(meanhist_double_neighbour) objarr.append(sigmahist_double_neighbour) for objs in objarr: objs.SetMarkerColor(2) objs.SetMarkerStyle(20) objs.SetMarkerSize(1) normgraph.SetName('normgraph') meangraph.SetName('meangraph') sigmagraph.SetName('sigmagraph') chisquaregraph.SetName('chisquare') mean_corrgraph.SetName('mean_corr') normgraph.SetTitle('Normalization; Channel; Normalization') meangraph.SetTitle('Mean; Channel; DAC Value (a.u.)') sigmagraph.SetTitle('Sigma; Channel; DAC Value (a.u.)') chisquaregraph.SetTitle('Chisquared/NDF_gr; Channel; Chisquared/NDF ') ROOT.gStyle.SetOptFit(1111) stack = THStack('a', ';DAC Value (a.u.); Occupancy') f_GlobalData_Map.Add(ROOT.TObjString("stack"), stack) fitfuncs = [] fitparams = [] gr1 = [] for pixel in range(0, channels): gr1.append( TH1D( str(pixel).zfill(3), str(pixel + 1).zfill(3) + ';DAC Value (a.u.); Occupancy ', 256, 0.5, 256.5)) f_GlobalData_Map.Add(ROOT.TObjString(str(pixel).zfill(3)), gr1[pixel]) #gr2.append(TH1F('th1f_'+str(pixel).zfill(3),str(pixel+1).zfill(3)+';DAC Value (a.u.); Occupancy',256,0.5,256.5)) color = pixel % 8 + 1 formating_th1(gr1[pixel], color) if (meas_type == 0): fitfuncs.append( TF1('gauss' + str(pixel + 1).zfill(3), 'gaus(0)', 0, 256)) fitfuncs[pixel].SetNpx(256) fitfuncs[pixel].SetLineColor(color) f_GlobalData_Map.Add( ROOT.TObjString('gauss' + str(pixel).zfill(3)), fitfuncs[pixel]) #Here we read the data and fill the histogram for event in tree: eventstr = [] for counter, vals in enumerate(tree.AR_MPA): #eventstr.append(vals) channelcounts.Fill(counter, tree.THRESHOLD, vals) if (counter < channels): gr1[counter].Fill(tree.THRESHOLD, vals) #if tree.THRESHOLD%20==0 and tree.REPETITION==0: #print eventstr #print ("Threshold %d Repetion %d" % (tree.THRESHOLD,tree.REPETITION)) #print tree.AR_MPA #now we make a small analysis of the curves fitting different functions to it: print "Finished Reading the Tree\n Normalization of Histograms\n" for pixel in range(0, channels): #gr1[pixel].ResetStats() for j in range(0, gr1[pixel].GetXaxis().GetNbins() + 1): gr1[pixel].SetBinError( gr1[pixel].GetBin(j), TMath.Sqrt(gr1[pixel].GetBinContent(gr1[pixel].GetBin(j)))) #if(pixel==0): #gr1[pixel].Print("all") #gr1[pixel].Sumw2(ROOT.kTRUE) gr1[pixel].Scale(1 / arr[1]) #if(pixel==0): #gr1[pixel].Print("all") stack.Add(gr1[pixel]) #first create a THStack with histograms: iterator = stack.GetHists() if (meas_type == 0): for idx, it in enumerate(iterator): fitparams.append([]) if (it.Integral() > 0): if (idx < channels): #fitfuncs.append(TF1('combined'+str(idx),combined, 0,256,5)) #fitfuncs.append(TF1('combined_same_mean'+str(idx),combined_mean, 0,256,4)) #fitfuncs.append(TF1('double_gauss'+str(idx),'gaus(0)+gaus(3)',0,256)) #fitfuncs.append(TF1('gauss'+str(idx),'gaus(0)',0,256)) #fitfuncs.append(TF1('double_gauss_same_mean'+str(idx),double_gauss, 0,256,5)) #print it.GetName(), idx #fitfuncs[idx].SetParameters(it.GetMaximum(),it.GetMean()+1,it.GetRMS(),it.GetMean()-1,it.GetRMS()); #fitfuncs[idx].SetParameters(it.GetMaximum(),it.GetMean(),it.GetRMS()*0.1,it.GetRMS()*0.1); #print ("Channels %f\t%f\t%f\n" % (it.GetMaximum(),it.GetMean(),it.GetRMS())) fitfuncs[idx].SetParameters(it.GetMaximum(), it.GetMean(), it.GetRMS()) #fitfuncs[idx].SetParameters(0.999*it.GetMaximum(),it.GetMean(),.7*it.GetRMS(),0.001*it.GetMaximum(),it.GetMean(),10*it.GetRMS()); #fitfuncs[idx].SetParameters(0.999*it.GetMaximum(),it.GetMean(),.7*it.GetRMS(),0.001*it.GetMaximum(),10*it.GetRMS()); #it.Fit(fitfuncs[idx],'lr0 rob=0.95','same',0,256) #it.Fit(fitfuncs[idx],'lr0q ','',0,256) it.Fit(fitfuncs[idx], 'r0q ', '', 0, 256) fitparams[idx].append(fitfuncs[idx].GetParameter(0)) fitparams[idx].append(fitfuncs[idx].GetParameter(1)) fitparams[idx].append(fitfuncs[idx].GetParameter(2)) fitparams[idx].append(fitfuncs[idx].GetParError(0)) fitparams[idx].append(fitfuncs[idx].GetParError(1)) fitparams[idx].append(fitfuncs[idx].GetParError(2)) if (fitfuncs[idx].GetNDF() > 0): fitparams[idx].append(fitfuncs[idx].GetChisquare() / fitfuncs[idx].GetNDF()) else: for kk in range(0, 7): fitparams[idx].append(0) #print "fitparamarray" fitarray = np.array(fitparams) ## print fitarray for pointno, it in enumerate(fitarray): if (fitarray[pointno][0] > 0): normgraph.SetPoint(pointno, pointno + 1, fitarray[pointno][0]) normgraph.SetPointError(pointno, 0, fitarray[pointno][3]) meangraph.SetPoint(pointno, pointno + 1, fitarray[pointno][1]) meangraph.SetPointError(pointno, 0, fitarray[pointno][4]) meanhist.Fill(fitarray[pointno][1]) sigmagraph.SetPoint(pointno, pointno + 1, fitarray[pointno][2]) sigmagraph.SetPointError(pointno, 0, fitarray[pointno][5]) sigmahist.Fill(fitarray[pointno][2]) chisquaregraph.SetPoint(pointno, pointno + 1, fitarray[pointno][6]) chisquaregraph.SetPointError(pointno, 0, 0) ## iterator.ls() # Map the data to the pixel layout: tmp_objarr = [] tmp_objarr.extend( [meanhist_std, meanhist_double, meanhist_double_neighbour]) tmp_objarr.extend( [sigmahist_std, sigmahist_double, sigmahist_double_neighbour]) for i in tmp_objarr: print str(i.GetName()) fill2d(fitarray[:, 0], mapsa_mat, objarr2d[0]) fill2d(fitarray[:, 1], mapsa_mat, objarr2d[1]) fill2d(fitarray[:, 2], mapsa_mat, objarr2d[2]) fill2d(fitarray[:, 6], mapsa_mat, objarr2d[3]) fill1d_edges(objarr2d[1], tmp_objarr[0:3]) fill1d_edges(objarr2d[2], tmp_objarr[3:]) g.cd(str(outfile)) mapsa_fitter_inst.Make_dirs() mapsa_fitter_inst.Set_run_no(outfile) if (meas_type == 1): for idx, it in enumerate(iterator): if (it.Integral() > 0): if (idx < channels): mapsa_fitter_inst.Find_signal(it, idx, 0.0025, 3) g.cd() #g.mkdir(str(outfile)+"/Channels") #g.cd(str(outfile)+"/Channels") #iterator.Write() g.cd(str(outfile)) g.mkdir(str(outfile) + "/Overview") ## iterator.First().Print("all") Maximum = TMath.Power(10, (round(TMath.Log10(stack.GetMaximum())) - 1)) #Minimum = TMath.Power(10,(round(TMath.Log10(stack.GetMinimum()))+1)) Minimum = .1 ROOT.gStyle.SetLabelSize(0.06, "xyz") ROOT.gStyle.SetTitleSize(0.06, "xyz") ROOT.gStyle.SetTitleOffset(1.2, "y") ROOT.gStyle.SetTitleOffset(.825, "x") ROOT.gStyle.SetPadGridX(1) ROOT.gStyle.SetPadGridY(1) ROOT.gStyle.SetOptStat(0) # ROOT.gStyle.SetPadLeftMargin(.2); # ROOT.gStyle.SetPadRightMargin(.1); c1.cd(1) stack.Draw("nostack hist e1 x0") stack.GetXaxis().SetRangeUser(0, 256) stack.SetMinimum(Minimum) stack.SetMaximum(Maximum) ROOT.gPad.SetLogy() c2.cd(0) stack.Draw("nostack hist e1 x0") #if(outfile.Contains("SR_90_on_top")): #stack.GetXaxis().SetRangeUser(0,256) #else: #stack.GetXaxis().SetRangeUser(0,100) stack.SetMinimum(Minimum) stack.SetMaximum(Maximum) ROOT.gPad.SetLeftMargin(.15) ROOT.gPad.SetRightMargin(.05) ROOT.gPad.SetLogy() ROOT.gPad.Update() #for idx, it in enumerate(fitfuncs): ## if idx>0 and idx<7: #c1.cd(1) #fitfuncs[idx].Draw("same") #c2.cd(0) #fitfuncs[idx].DrawCopy("psame") ## it.SetLineColor(idx%9+1) ## it.Draw("same") #g.cd(str(outfile)+"/Channels") #it.Write("HitMap_py_"+str(idx+1)+"_fit") g.cd(str(outfile) + "/Overview") c1.cd(2) chisquaregraph.Draw("ap") c1.cd(3) normgraph.Draw("ap") c1.cd(4) sigmagraph.Draw("ap") sigmagraph.GetYaxis().SetRangeUser(0, 5) sigmagraph.GetXaxis().SetRangeUser(0, channels + 1) c2.cd(2) sigmagraph.Draw("ap") ROOT.gPad.SetLeftMargin(.15) ROOT.gPad.SetRightMargin(.05) c1.cd(5) meangraph.Draw("ap") c1.cd(6) channelcounts.Draw("colz") channelcounts.GetXaxis().SetRangeUser(0, channels + 1) # c2.cd(3) c3.cd(0) ROOT.gStyle.SetOptStat(0) ROOT.gPad.SetRightMargin(.15) ROOT.gPad.SetLeftMargin(.15) ROOT.gPad.SetGrid(0) copy = channelcounts.DrawCopy("colz") #f_GlobalData_Map.Add(ROOT.TObjString("copy"),copy) #if(outfile.Contains("SR_90_on_top")): #copy.SetMaximum(100) #copy.SetMinimum(1) copy.GetYaxis().SetTitle("DAC Value (a.u.)") c4.cd(0) ROOT.gStyle.SetOptStat(0) ROOT.gPad.SetRightMargin(.15) ROOT.gPad.SetLeftMargin(.15) ROOT.gPad.SetGrid(0) copy1 = sigma_2d.DrawCopy("colz") #f_GlobalData_Map.Add(ROOT.TObjString("copy1"),copy1) copy1.GetZaxis().SetTitle("Sigma (a.u.)") copy1.GetZaxis().SetTitleOffset(1.2) ROOT.gPad.SetRightMargin(.2) if (arr[2] == 'inv'): copy1.GetXaxis().SetRangeUser(.5, 16.5) copy1.SetMaximum(5) copy1.SetMinimum(0) c5.cd(0) ROOT.gStyle.SetOptStat(0) ROOT.gPad.SetRightMargin(.15) ROOT.gPad.SetLeftMargin(.15) ROOT.gPad.SetGrid(0) #copy1 = chisquare.DrawCopy("colz") #f_GlobalData_Map.Add(ROOT.TObjString("copy2"),copy1) copy1 = sigma_2d.DrawCopy("colz") #f_GlobalData_Map.Add(ROOT.TObjString("copy2"),copy1) copy1.GetZaxis().SetTitle("sigma (a.u.)") if (arr[2] == 'inv'): copy1.GetXaxis().SetRangeUser(.5, 16.5) copy1.SetMaximum(5) copy1.SetMinimum(0) c1.Update() c1.Modified() c2.Update() c2.Modified() c3.Update() c3.Modified() c4.Update() c4.Modified() c5.Update() c5.Modified() ## c1.SaveAs("double_gauss_same_mean.pdf") ## time.sleep(2) g.cd(str(outfile) + "/Overview") #for objs in objarr: #objs.Write(objs.GetName()) #norm_2d.GetZaxis().SetRangeUser(1E5,2E6) #mean_2d.GetZaxis().SetRangeUser(54,64) ## norm_2d.GetZaxis().SetRangeUser(TMath.Power(10,(round(TMath.Log10(norm_2d.GetStdDev(3))-2)), TMath.Power(10,(round(TMath.Log10(norm_2d.GetStdDev(3)))-1))) ## mean_2d.GetZaxis().SetRangeUser(TMath.Power(10,(round(TMath.Log10(mean_2d.mean_2d.GetStdDev(3)))-1))-5,TMath.Power(10,(round(TMath.Log10(mean_2d.GetStdDev(3)))-1))+5) #sigma_2d.GetZaxis().SetRangeUser(0,5) #chisquare.GetZaxis().SetRangeUser(0,10000 ) #for objs in objarr2d: #objs.Write(objs.GetName()) #c1.Write("c1") #outfile1=outfile+TString(".pdf") #c2.SaveAs(str(outfile1)) #c2.Write("c2") #c3.SaveAs("c3"+str(outfile1)) #c3.Write("c3") #c4.SaveAs("c4"+str(outfile1)) #c4.Write("c4") ## while (TObject(iterator.Next())): ## print iterator.Next().Title() #stack.Write("stack") #g.cd(str(outfile)) #channelcounts.Write(str(outfile)) #f.Close() c1.Close() c2.Close() c3.Close() c4.Close() c5.Close() f_GlobalData_Map.DeleteAll() f.Close()
ROOT.gPad.SetGridy() c1.Clear() c1.Divide(3, 2) for i in range(1, 7): c1.cd(i) ROOT.gPad.SetGridx() ROOT.gPad.SetGridy() f = TFile(files, 'READ') f.ls() tree = f.Get('tree') # tree.ls() # tree.Print() outfile = TString(files) outfile.ReplaceAll(".root", "") outfile.ReplaceAll(" ", "") # print outfile g.mkdir(str(outfile)) g.cd(str(outfile)) # channelcounts = TH2I('HitMap','Counts; Channel; DAC Value (1.456 mV)', 288, .5,288.5,256, .5, 256.5) channelcounts = TH2I('HitMap', 'Counts; Channel; DAC Value (a.u.)', 288, .5, 288.5, 256, .5, 256.5) norm_2d = TH2F('Norm2D', 'Normalization; Column; Row', 48, .5, 48.5, 6, .5, 6.5) mean_2d = TH2F('Mean2D', 'Mean; Column; Row', 48, .5, 48.5, 6, .5, 6.5) sigma_2d = TH2F('Sigma2D', '; Column; Row; Sigma (a.u.)', 48, .5, 48.5, 6, .5, 6.5) # sigma_2d = TH2F('Sigma2D','Sigma; Column; Row' , 48, .5,48.5,6, .5, 6.5) chisquare = TH2F('Chisquare2D', 'Chisquare; Column; Row', 48, .5, 48.5, 6,
def cleanName(inputString): st = TString(inputString) st.ReplaceAll(" ", "_") st.ReplaceAll(" ", "_") st.ReplaceAll(".", "_") st.ReplaceAll("/", "_") st.ReplaceAll("%", "_") st.ReplaceAll("+", "_") st.ReplaceAll("#", "_") st.ReplaceAll(",", "_") st.ReplaceAll("-", "_") st.ReplaceAll("*", "") st.ReplaceAll("(", "") st.ReplaceAll(")", "") st.ReplaceAll("{", "") st.ReplaceAll("}", "") st.ReplaceAll("<=", "lte") st.ReplaceAll(">=", "gte") st.ReplaceAll("<", "lt") st.ReplaceAll(">", "gt") st.ReplaceAll("=", "_") return st
def printCorrelations(): inFile = open('xsecFit_tabCorr.tex', 'r') l = inFile.read().splitlines() corrs = [] for line in l: if '\\sigma_{t\\bar{t}}' in line and not '{(\\mu_1)}' in line: corrs.append(line) corr_12 = corrs[0].split('&') corr_12 = corr_12[len(corr_12) - 4] corr_32 = corrs[1].split('&') corr_32 = corr_32[len(corr_32) - 3] corr_13 = corrs[1].split('&') corr_13 = corr_13[len(corr_13) - 4] corr_42 = corrs[2].split('&') corr_42 = corr_42[len(corr_42) - 3] corr_41 = corrs[2].split('&') corr_41 = corr_41[len(corr_41) - 4] corr_43 = corrs[2].split('&') corr_43 = corr_43[len(corr_43) - 2] corr_12 = TString(corr_12) corr_12.ReplaceAll('\\textbf{', '') corr_12.ReplaceAll('}', '') corr_12 = float(str(corr_12)) corr_32 = TString(corr_32) corr_32.ReplaceAll('\\textbf{', '') corr_32.ReplaceAll('}', '') corr_32 = float(str(corr_32)) corr_13 = TString(corr_13) corr_13.ReplaceAll('\\textbf{', '') corr_13.ReplaceAll('}', '') corr_13 = float(str(corr_13)) corr_42 = TString(corr_42) corr_42.ReplaceAll('\\textbf{', '') corr_42.ReplaceAll('}', '') corr_42 = float(str(corr_42)) corr_41 = TString(corr_41) corr_41.ReplaceAll('\\textbf{', '') corr_41.ReplaceAll('}', '') corr_41 = float(str(corr_41)) corr_43 = TString(corr_43) corr_43.ReplaceAll('\\textbf{', '') corr_43.ReplaceAll('}', '') corr_43 = float(str(corr_43)) print print 'corr_1_2 =', corr_12 print 'corr_3_2 =', corr_32 print 'corr_1_3 =', corr_13 print 'corr_4_2 =', corr_42 print 'corr_4_1 =', corr_41 print 'corr_4_3 =', corr_43 print return
def printXsecErrs(mttbin): inFile = open('xsecFit_tab13TeV_mtt' + str(mttbin) + '.tex', 'r') l = inFile.read().splitlines() lextr = [] tot_vis = '' xsec = '' for line in l: if '(extr)' in line: lextr.append(line) if 'Total vis' in line: tot_vis = line if '\\sigma_{t\\bar{t}}^{(\\mu_' + str( mttbin) in line and '\\hline' in line: xsec = line for i in range(0, 3): del l[0] l_short = [] for line in l: if '\\sigma_{t\\bar{t}}' in line: break l_short.append(line) name_all = [] contribution_all = [] for line in l_short: name, pull, constrain, contribution = line.split('&') name = str(TString(name).ReplaceAll('\\_', ' ')) name = str(TString(name).ReplaceAll('$t\\bar{t}$', 'ttbar')) name = str(TString(name).ReplaceAll('$p_{T}$', 'pT')) name = str(TString(name).ReplaceAll('$p_T$', 'pT')) name = str(TString(name).ReplaceAll('$\eta$', 'eta')) name = str(TString(name).ReplaceAll('bar{t}', 'tbar')) name = str( TString(name).ReplaceAll('Electron energy resolution', 'Electron ER')) name = str(TString(name).ReplaceAll('DY background', 'DY bg')) name = str(TString(name).ReplaceAll(' response', '')) name = str(TString(name).ReplaceAll('PDF', 'PDF ')) name = str(TString(name).ReplaceAll('$m_{t}^{MC}$', 'top mass')) if 'b-tag' in name: name = str(TString(name).ReplaceAll('fragmentation', 'fragm')) name = str(TString(name).ReplaceAll('correction', 'corr')) name = str(TString(name).ReplaceAll('template', 'templ')) name = str(TString(name).ReplaceAll('$D \to \mu X$', 'D to mu')) name = str(TString(name).ReplaceAll('splitting', 'split')) name = str(TString(name).ReplaceAll('production', 'prod')) name = str(TString(name).ReplaceAll('light to c', 'l/c')) name = str(TString(name).ReplaceAll('dependence', 'dep')) name = str(TString(name).ReplaceAll('statistical', 'stat')) name = str(TString(name).ReplaceAll('$', '')) name = str(TString(name).ReplaceAll('\\', '#')) name = str(TString(name).ReplaceAll('#to', 'tp')) name = str(TString(name).ReplaceAll('K_s^0', 'Ks0')) contribution = str(TString(contribution).ReplaceAll('\\', '')) contribution = str(TString(contribution).ReplaceAll('$', '')) contribution = str(TString(contribution).ReplaceAll('{', '')) contribution = str(TString(contribution).ReplaceAll('}', '')) name = TString(name).ReplaceAll(' ', '_') name.ReplaceAll(':_', '_') name.ReplaceAll('#DeltaR', 'DR') name.ReplaceAll('#mu', 'mu') name.ReplaceAll('(#Lambda)', 'Lambda') name.ReplaceAll('_-_', '_') name.ReplaceAll('_/_', '_') name.ReplaceAll('fragm.', 'fragm') name.ReplaceAll('_(', '_') name.ReplaceAll(')', '') if name.EndsWith('_'): name = str(name)[0:len(str(name)) - 1] name_all.append('\'' + str(name) + '\'') contribution_all.append(float(contribution)) extr_up = [] extr_down = [] extr_name = [] for line in lextr: extr = line.split('&')[3] name = line.split('&')[0] mp = False if '\mp' in line: mp = True extr = TString(extr) extr.ReplaceAll('}_{', ' ') extr.ReplaceAll(' $\mp^{', '') extr.ReplaceAll(' $\pm^{', '') extr.ReplaceAll('}$ \\\\', '') extr.ReplaceAll(' \hline', '') extr = str(extr) extr = extr.split() extr[0] = float(extr[0]) extr[1] = float(extr[1]) extr[1] *= -1 if (mp): extr_up.append(extr[1]) extr_down.append(extr[0]) else: extr_up.append(extr[0]) extr_down.append(extr[1]) name = TString(name) name.ReplaceAll(' (extr) ', '') name.ReplaceAll('$t\\bar{t}$ ', '') name.ReplaceAll('Top', 'top') name.ReplaceAll('$p_{T}$', 'pt') name.ReplaceAll('$m_{t}^{MC}$', 'mt') name.ReplaceAll(' ', '_') name = '\'' + str(name) + '\'' extr_name.append(name) tot_vis = tot_vis.split('&')[3] tot_vis = TString(tot_vis) tot_vis.ReplaceAll('}_{', ' ') tot_vis.ReplaceAll(' $\mp^{', '') tot_vis.ReplaceAll(' $\pm^{', '') tot_vis.ReplaceAll('}$ \\\\', '') tot_vis.ReplaceAll(' \hline', '') tot_vis = str(tot_vis) tot_vis = tot_vis.split() tot_vis[0] = float(tot_vis[0]) tot_vis[1] = float(tot_vis[1]) xsec = xsec.split('&')[3] xsec = TString(xsec) xsec.ReplaceAll('pb \\\\ \\hline \\hline', '') xsec = float(str(xsec)) h = rFile.Get('h_xsec_' + str(mttbin)) print print 'xsec_' + str(mttbin) + ' =', xsec print 'err_xsec_' + str(mttbin) + '_up =', tot_vis[0] print 'err_xsec_' + str(mttbin) + '_down =', tot_vis[1] print 'extr_' + str(mttbin) + '_up = [', for e in extr_up: print e, ',', print ']' print 'extr_' + str(mttbin) + '_down = [', for e in extr_down: print e, ',', print ']' print 'err_xsec_toys_' + str(mttbin) + ' =', round(h.GetRMS(), 3) print if mttbin == 1: print 'extr_name = [', for name in extr_name: print name, ',', print ']' print counter = 0 print 'syst_names = [', for name in name_all: counter += 1 if counter < 5: print name, ',', else: print name, ',' counter = 0 print ']' print