Пример #1
0
def _doProfile2d( solver, ipar1=0, type1="u", ipar2=1, type2= "m" ):
    from ConstrainedFit import clsq
    from ROOT import TGraph2D, TMarker, gPad
    from array import array
    global tg2d, hist, te1, te2, te3, tm
    par1= clsq.createClsqPar( ipar1, type1, solver )
    par2= clsq.createClsqPar( ipar2, type2, solver )
    parval1, parerr1, name1= _getUMParErrName( par1 )
    parval2, parerr2, name2= _getUMParErrName( par2 )
    print( "\nChi^2 profile plot " + name1 + " - " + name2 + ":" )
    corr= solver.getCorrMatrix()
    icorr1= ipar1
    icorr2= ipar2
    if type1 == "u" or type2 == "u":
        nmpar= len(solver.getMpars())
        if type1 == "u":
            icorr1= nmpar + ipar1
        if type2 == "u":
            icorr2= nmpar + ipar2
    rho= corr[icorr1,icorr2]
    te1= _makeEllipse( parval1, parval2, parerr1, parerr2, rho )
    te2= _makeEllipse( parval1, parval2, 2.0*parerr1, 2.0*parerr2, rho )
    te3= _makeEllipse( parval1, parval2, 3.0*parerr1, 3.0*parerr2, rho )
    ca= clsq.clsqAnalysis( solver )
    points= ca.profile2d( par1, par2 )
    npoints= len(points)
    tg2d= TGraph2D( npoints )
    for i in range( npoints ):
        point= points[i]
        tg2d.SetPoint( i, point[0], point[1], point[2] )
    hist= tg2d.GetHistogram()
    contourlevels= array( "d", [ 1.0, 4.0, 9.0 ] )
    hist.SetContour( 3, contourlevels )
    hist.GetXaxis().SetTitle( name1 )
    hist.GetYaxis().SetTitle( name2 )
    hist.SetTitle( "Triangle fit "+name2+" vs "+name1 )
    hist.Draw( "cont1" )
    tm= TMarker( parval1, parval2, 20 )
    tm.Draw( "s" )
    te1.Draw( "s" )
    te2.Draw( "s" )
    te3.Draw( "s" )
    gPad.Print( "triangle_errorellipse.png" )
    return
Пример #2
0
def myMarkerTextSmall2(x, y, lcolor, lstyle, mcolor, mstyle, msize, size,
                       text):

    l = TLatex()
    l.SetTextAlign(12)
    l.SetTextSize(size / 2.5)
    l.SetNDC()
    l.DrawLatex(x, y, text)

    yb1 = y - 0.15 * size
    yb2 = y + 0.15 * size
    xb1 = x - 0.28 * size - 0.45 * size
    xb2 = x + 0.28 * size - 0.45 * size

    print "box  = ", xb1, yb1, xb2, yb2

    #print "line = ",xl1,yl1,xl2,yl2
    mline1 = TLine(xb1, yb1, xb2, yb2)
    mline1.SetLineColor(lcolor)
    mline1.SetLineStyle(lstyle)
    mline1.SetLineWidth(2)
    y_new = (yb1 + yb2) / 2.
    mline1.DrawLineNDC(xb1, y_new, xb2, y_new)

    mline2 = TLine(xb1, yb1, xb2, yb2)
    mline2.SetLineColor(lcolor)
    mline2.SetLineStyle(lstyle)
    mline2.SetLineWidth(2)
    x_new = (xb1 + xb2) / 2.
    mline2.DrawLineNDC(x_new, yb1, x_new, yb2)

    marker = TMarker((xb1 + xb2) / 2.0, y, mstyle)
    marker.SetNDC()
    marker.SetMarkerColor(mcolor)
    marker.SetMarkerStyle(mstyle)
    marker.SetMarkerSize(msize)
    marker.Draw()

    return marker
Пример #3
0
        xp = -xp
    xm = math.sqrt(r2**2 - ym**2)
    if abs((xm - x1)**2 + (ym - y1)**2 - r1**2) > 1e-9:
        xm = -xm
    if switchxy:
        xm, ym = ym, xm
        xp, yp = yp, xp
    return xm, ym, xp, yp


if __name__ == '__main__':

    from ROOT import TEllipse, TH2F, TCanvas, TMarker

    can = TCanvas("can", "", 600, 600)
    suph = TH2F("suph", "", 10, -5, 5, 10, -5, 5)
    suph.Draw()
    x1, y1, r1, r2 = 0., 1.8, 1., 2.
    results = circle_intersection(x1, y1, r1, r2)
    c1 = TEllipse(x1, y1, r1)
    c1.Draw('same')
    c2 = TEllipse(0., 0., r2)
    c2.Draw('same')
    c1.SetFillStyle(0)
    c2.SetFillStyle(0)
    mm = TMarker(results[0], results[1], 8)
    mp = TMarker(results[2], results[3], 21)
    mm.Draw('same')
    mp.Draw('same')
    can.Update()
Пример #4
0
ROCwmass.SetLineColor(2)
ROCwmass.SetLineWidth(2)
ROCwmass.SetTitle(";signal efficiency;background rejection")
c2 = TCanvas("c2")



ptlimstrs = [str(int(2000.0*ptlims[0])),str(int(2000.0*ptlims[1]))]
ROCwmass.Draw()
prelim.DrawLatex( 0.15, 0.85, ptlimstrs[0]+" GeV < p_{T} < "+ptlimstrs[1]+" GeV" )
if (cust=="w" or cust=="top") and Drawmarker:
	if cust=="w":
		prelim.DrawLatex( 0.44, 0.55, "N_{2}^{DDT}+msd" )
		TM = TMarker(0.4, 0.01, 23)
	if cust=="top":
		prelim.DrawLatex( 0.44, 0.60, "#tau_{32}+msd+subjetb" )
		TM = TMarker(0.4, 0.017, 23)
	TM.SetMarkerSize(2)
	TM.SetMarkerColor(4)
	TM.Draw()
c2.SetLogy()
c2.Write("rocwmass")
ROC.Draw()

c2.Write("roccomp")

dnnsig.Write()
dnnbkg.Write()
output.Write()
output.Close()
Пример #5
0
l_5percent.SetLineWidth(3)
l_10percent.SetLineColor(2)
l_10percent.SetLineWidth(3)
l_10percent.SetLineStyle(2)
l_25percent.SetLineColor(2)
l_25percent.SetLineStyle(3)
l_25percent.SetLineWidth(3)

p_5percent.SetMarkerStyle(20)
p_5percent.SetMarkerColor(2)
p_10percent.SetMarkerStyle(21)
p_10percent.SetMarkerColor(2)
p_25percent.SetMarkerStyle(22)
p_25percent.SetMarkerColor(2)

p_5percent.Draw()
l_5percent.Draw()
p_10percent.Draw()
l_10percent.Draw()
p_25percent.Draw()
l_25percent.Draw()

g_width.GetXaxis().SetTitle('1/tan(#beta)^{2}')  #  #prop coupling^{2}
g_width.GetYaxis().SetTitle('Width (GeV)')
g_width.GetYaxis().SetTitleSize(0.05)
g_width.GetYaxis().SetLabelSize(0.05)
g_width.GetYaxis().SetTitleOffset(0.8)
g_width.GetYaxis().SetRangeUser(0., mass * 0.12)

g_width.GetXaxis().SetTitleSize(0.05)
g_width.GetXaxis().SetLabelSize(0.05)
Пример #6
0
def MuFit(Nbins,irebin=1.):
	# Get histrograms
	h_bgr = GetMassDistribution(1)
	h_data = GetMassDistribution(2)
	h_sig = GetMassDistribution(125)

	h_bgr.Rebin(irebin)
	h_data.Rebin(irebin)
	h_sig.Rebin(irebin)

	h_sf = TH2D("scalefactor","title",Nbins,0.5,2.,Nbins,0.,5.)

	for i in range(1,h_sf.GetNbinsX()+1):
		for j in range(1,h_sf.GetNbinsY()+1):

			sf_bgr = h_sf.GetXaxis().GetBinCenter(i)
			sf_sig = h_sf.GetYaxis().GetBinCenter(j)

			# Loop over bins, compute likelihood
			loglik = 0.

			for iDataBin in range(1,h_data.GetNbinsX()+1):

				m4lepBin = h_data.GetBinCenter(iDataBin)
				NObsBin = h_data.GetBinContent(iDataBin)

				MeanBin = sf_bgr*h_bgr.GetBinContent(iDataBin) + sf_sig*h_sig.GetBinContent(iDataBin)

				if (MeanBin>0): loglik += TMath.Log( TMath.Poisson(NObsBin,MeanBin) )

			h_sf.SetBinContent(i,j,-2.*loglik)

	# Get best SF parameters

	x=ctypes.c_int(0)
	y=ctypes.c_int(0)
	z=ctypes.c_int(0)
	h_sf.GetBinXYZ(h_sf.GetMinimumBin(),x,y,z)
	Minimum = h_sf.GetBinContent(x.value,y.value)
	best_alpha = h_sf.GetXaxis().GetBinCenter(x.value)
	best_mu = h_sf.GetYaxis().GetBinCenter(y.value)
	print(Minimum,best_alpha,best_mu)
	

	# Rescale histogram
	for i in range(1,h_sf.GetNbinsX()+1):
		for j in range(1,h_sf.GetNbinsY()+1):
			h_sf.SetBinContent( i,j, h_sf.GetBinContent(i,j)-Minimum )


	canvas = TCanvas("canvas","Standard Canvas",600,400)
	canvas.cd()
	Min = TMarker(best_alpha,best_mu,29)
	Min.SetMarkerSize(2)
	h_sf.SetStats(kFALSE)
	h_sf.SetTitle("HIGGS PRODUCTION CROSS SECTION - PARAMETERS")
	h_sf.GetXaxis().SetTitle(r"#alpha")
	h_sf.GetYaxis().SetTitle(r"#mu")
	h_sf.Draw("COLZ")

	h_sigma = h_sf.Clone("h_sigma")
	h_sigma.Reset()
	for i in range(1,h_sigma.GetNbinsX()+1):
		for j in range(1,h_sigma.GetNbinsY()+1):
			if( h_sf.GetBinContent(i,j)<=1.): h_sigma.SetBinContent(i,j, 1.)
	h_sigma.SetMarkerColorAlpha(kRed,0.40)

	h_sigma.SetMarkerSize(10)
	h_sigma.Draw("same L")
	Min.Draw()
	leg1 = TLegend(0.65,0.85,0.85,0.75)
	leg1.SetBorderSize(1); leg1.SetFillColor(0);
	leg1a = leg1.AddEntry(Min, r"optimal (#alpha,#mu)", "p"); leg1a.SetTextSize(0.04);
	leg1.Draw()
	canvas.Print("Plots/MuFit.pdf")