Beispiel #1
0
def testIthr():
    lines = get_lines('DAC_scan_ithr_0x40to0xf0.dat')

    gr1 = TGraphErrors()
    gr2 = TGraphErrors()

    fUnit = 1000. / 0.7
    yUnit = 'e^{-}'

    for line in lines:
        if len(line) == 0: continue
        if line[0] in ['#', '\n']: continue
        fs = line.rstrip().split()

        ix = int(fs[0])
        gr1.SetPoint(ix, float(fs[1]), float(fs[2]) * fUnit)
        gr1.SetPointError(ix, 0, float(fs[3]) * fUnit)
        gr2.SetPoint(ix, float(fs[1]), float(fs[4]) * fUnit)
        gr2.SetPointError(ix, 0, float(fs[5]) * fUnit)

    useAtlasStyle()
    gStyle.SetMarkerStyle(20)

    gr1.SetMarkerStyle(20)
    gr1.Draw('AP')
    h1 = gr1.GetHistogram()
    h1.GetYaxis().SetTitle("Threshold [" + yUnit + "]")
    h1.GetXaxis().SetTitle("I_{Thre} code")
    # h1.GetYaxis().SetRangeUser(0,0.2)

    gPad.SetTicks(1, 0)
    gPad.SetRightMargin(0.16)

    y1b = 0
    y2b = 15
    x1 = h1.GetXaxis().GetXmax()
    y1 = h1.GetYaxis().GetXmin()
    y2 = h1.GetYaxis().GetXmax()
    raxis = TGaxis(x1, y1, x1, y2, y1b, y2b, 506, "+L")
    raxis.SetLineColor(2)
    raxis.SetLabelColor(2)
    raxis.SetTitleColor(2)
    raxis.SetTitle("ENC [" + yUnit + "]")
    raxis.Draw()

    nP = gr2.GetN()
    Ys = gr2.GetY()
    EYs = gr2.GetEY()
    Y = array(
        'd', [y1 + (y2 - y1) / (y2b - y1b) * (Ys[i] - y1b) for i in range(nP)])
    EY = array('d', [(y2 - y1) / (y2b - y1b) * EYs[i] for i in range(nP)])
    gr2x = TGraphErrors(nP, gr2.GetX(), Y, gr2.GetEX(), EY)
    gr2x.SetMarkerStyle(24)
    gr2x.SetLineColor(2)
    gr2x.SetMarkerColor(2)

    gr2x.Draw('Psame')

    waitRootCmdX()
Beispiel #2
0
def get_rank_section(directory):
    # do Rank histo png
    imgname = "RankSummary.png"
    gStyle.SetPadTickY(0)
    c = TCanvas("ranks", "ranks", 500, 400)
    #gStyle.SetOptStat(0)
    c.cd()

    h = directory.rank_histo
    rank_histof = TH1F(h.GetName(), "", h.GetNbinsX(),
                       h.GetXaxis().GetXmin(),
                       h.GetXaxis().GetXmax())
    rank_histof.SetLineWidth(2)
    for i in xrange(0, h.GetNbinsX() + 1):
        rank_histof.SetBinContent(i, h.GetBinContent(i))
    h.SetTitle("Ranks Summary;Rank;Frequency")
    h.Draw("Hist")
    c.Update()
    rank_histof.ComputeIntegral()
    integral = rank_histof.GetIntegral()
    rank_histof.SetContent(integral)

    rightmax = 1.1 * rank_histof.GetMaximum()
    scale = gPad.GetUymax() / rightmax
    rank_histof.SetLineColor(kRed)
    rank_histof.Scale(scale)
    rank_histof.Draw("same")

    #draw an axis on the right side
    axis = TGaxis(gPad.GetUxmax(), gPad.GetUymin(), gPad.GetUxmax(),
                  gPad.GetUymax(), 0, rightmax, 510, "+L")
    axis.SetTitle("Cumulative")
    axis.SetTitleColor(kRed)
    axis.SetLineColor(kRed)
    axis.SetLabelColor(kRed)
    axis.Draw()

    rank_histof.Draw("Same")

    c.Print(imgname)

    page_html = '<div class="span-20"><h2 class="alt"><a name="rank_summary">Ranks Summary</a></h2>'
    page_html += '<div class="span-19"><img src="%s"></div>' % imgname
    page_html += '</div> <a href="#top">Top...</a><hr>'

    return page_html
    hSyst.SetBinContent(iPt, syst)

cRMS = TCanvas('cRMS', '', 800, 800)
cRMS.DrawFrame(hRMS.GetBinLowEdge(1), 0.1, ptMax, 20.,
               ';#it{p}_{T} (GeV/#it{c});RMS (%)')
hRMS.DrawCopy('same')
axisSoverB = TGaxis(gPad.GetUxmax(), gPad.GetUymin(), gPad.GetUxmax(),
                    gPad.GetUymax(), 0.01, 20., 510, "+LG")
axisSoverB.SetLineColor(kRed + 1)
axisSoverB.SetLabelColor(kRed + 1)
axisSoverB.SetLabelFont(42)
axisSoverB.SetLabelSize(0.045)
axisSoverB.SetTitle('S/B (3#sigma)')
axisSoverB.SetTitleOffset(1.2)
axisSoverB.SetLabelOffset(0.012)
axisSoverB.SetTitleColor(kRed + 1)
axisSoverB.SetTitleFont(42)
axisSoverB.SetTitleSize(0.05)
axisSoverB.SetMaxDigits(3)
axisSoverB.Draw()
hSoverB.DrawCopy('same')
cRMS.Update()

cSyst = TCanvas('cSyst', '', 800, 800)
cSyst.DrawFrame(hSyst.GetBinLowEdge(1), 0.1, ptMax, 20.,
                ';#it{p}_{T} (GeV/#it{c}); Syst (%)')
SetObjectStyle(hRMS, color=kRed + 1, fillstyle=0, linewidth=3)
SetObjectStyle(hMeanShift, color=kBlack, fillstyle=0, linewidth=3)
SetObjectStyle(hSyst, color=kBlue + 1, fillstyle=0, linewidth=3)
hMeanShift.DrawCopy('same')
hSyst.DrawCopy('same')
Beispiel #4
0
xmin = hxE.GetXaxis().GetXmin()
xmax = hxE.GetXaxis().GetXmax()
dx = (xmax - xmin) / 0.8
#10 per cent margins left and right
pad2.Range(xmin - 0.1 * dx, ymin - 0.1 * dy, xmax + 0.1 * dx, ymax + 0.1 * dy)
pad2.Draw()
pad2.cd()
hxE.SetMarkerColor(ROOT.kViolet)
hxE.Draw("][scat same")
pad2.Update()
# draw axis on the right side of the pad
axis = TGaxis(xmax, ymin, xmax, ymax, ymin, ymax, 50510, "+L")
axis.SetLineColor(ROOT.kViolet)
axis.SetLabelColor(ROOT.kViolet)
axis.SetTitle("E [GeV]")
axis.SetTitleColor(ROOT.kViolet)
axis.SetLabelSize(0.035)
axis.SetTitleSize(0.035)
axis.Draw()
#### yz
cnv.cd(2)
ROOT.gPad.SetTicks(1, 1)
ROOT.gPad.SetLogz()
ROOT.gPad.SetGridy()
ROOT.gPad.SetGridx()
# hyz = tfile.Get("h2_z_vs_y")
hyz.SetTitle(ptitle + " for #it{B} = " + btitle)
hyz.Draw("col")
dipoleOutYZ.Draw("same")
dipoleInYZ.Draw("same")
for i in range(len(staveYZ)):