Example #1
0
def set_pub_style():
    from ROOT import gStyle
    # No Canvas Border
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasBorderSize(0)
    # White BG
    gStyle.SetCanvasColor(10)
    # Format for axes
    gStyle.SetLabelFont(42, 'xyz')
    gStyle.SetLabelSize(0.05, 'xyz')
    gStyle.SetLabelOffset(0.01, 'xyz')
    # gStyle->SetNdivisions(510, 'xyz')
    gStyle.SetTitleFont(42, 'xyz')
    gStyle.SetTitleColor(1, 'xyz')
    gStyle.SetTitleSize(0.06, 'xyz')
    gStyle.SetTitleOffset(1.25, 'xyz')
    # No pad borders
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadBorderSize(0)
    # White BG
    gStyle.SetPadColor(10)
    # Margins for labels etc.
    gStyle.SetPadLeftMargin(0.155)
    gStyle.SetPadBottomMargin(0.155)
    gStyle.SetPadRightMargin(0.15)
    gStyle.SetPadTopMargin(0.1)
    # No error bars in x direction
    gStyle.SetErrorX(0)
    # Format legend
    gStyle.SetLegendBorderSize(0)
Example #2
0
def set_style():
    gStyle.SetPadRightMargin(0.035)
    gStyle.SetPadLeftMargin(0.18)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetTitleSize(0.045, 'xy')
    gStyle.SetLabelSize(0.040, 'xy')
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetLegendBorderSize(0)
    gStyle.SetOptStat(0)
Example #3
0
    def Init():
        from ROOT import gStyle
        from ROOT import gROOT

        gROOT.ProcessLine("gErrorIgnoreLevel = 2000;")
        gStyle.SetCanvasColor(0);
        gStyle.SetCanvasBorderMode(0);
        gStyle.SetCanvasBorderSize(3);

        gStyle.SetPadLeftMargin(0.125);
        gStyle.SetPadBottomMargin(0.12);
        gStyle.SetPadColor(0);
        gStyle.SetPadBorderMode(0);

        gStyle.SetFrameBorderMode(0);
        gStyle.SetFrameBorderSize(0);
        gStyle.SetFrameFillColor(0);
        gStyle.SetOptStat(0);

        gStyle.SetLabelOffset(0.005,"X");
        gStyle.SetLabelSize(0.03,"X");
        gStyle.SetLabelFont(42,"X");

        gStyle.SetTitleOffset(.85,"X");
        gStyle.SetTitleSize(0.04,"X");
        gStyle.SetTitleFont(42,"X");

        gStyle.SetLabelOffset(0.005,"Y");
        gStyle.SetLabelSize(0.03,"Y");
        gStyle.SetLabelFont(42,"Y");

        gStyle.SetTitleOffset(.98,"Y");
        gStyle.SetTitleSize(0.04,"Y");
        gStyle.SetTitleFont(42,"Y");

        gStyle.SetStatColor(0);
        gStyle.SetStatBorderSize(0);
        gStyle.SetTextFont(2);
        gStyle.SetTextSize(.05);
        gStyle.SetLegendBorderSize(1);
        gStyle.SetHistLineWidth(2);
        gStyle.SetTitleFillColor(0);
        gStyle.SetTitleFontSize(0.06);
        gStyle.SetTitleBorderSize(0);
        gStyle.SetTitleAlign(13);
        gStyle.SetTextAlign(22);

	#RJ
	gStyle.SetPadTickX(1);                         
	gStyle.SetPadTickY(1);  

        gStyle.SetPadTopMargin(0.05);
        gStyle.SetPadBottomMargin(0.13);
        gStyle.SetPadLeftMargin(0.16);
        gStyle.SetPadRightMargin(0.03);
Example #4
0
def Styling():
    # Center title
    gStyle.SetTitleAlign(22)
    gStyle.SetTitleX(.5)
    gStyle.SetTitleY(.95)
    gStyle.SetTitleBorderSize(0)
    # Remove stats box
    gStyle.SetOptStat(0)
    # Set background color to white
    gStyle.SetFillColor(10)
    gStyle.SetFrameFillColor(10)
    gStyle.SetCanvasColor(10)
    gStyle.SetPadColor(10)
    gStyle.SetTitleFillColor(0)
    gStyle.SetStatColor(10)
    # No colored frames around plots
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    # Set the default line color for a fit function to be red
    gStyle.SetFuncColor(2)
    # Marker settings
    gStyle.SetMarkerStyle(20)
    # No border on legends
    gStyle.SetLegendBorderSize(0)
    # Disabled for violating NOvA style guidelines
    # Scientific notation on axes
    TGaxis.SetMaxDigits(3)
    # Axis titles
    gStyle.SetTitleSize(.055, "xyz")
    gStyle.SetTitleOffset(2.2, "xyz")
    gStyle.SetTitleOffset(2.2, "y")
    gStyle.SetTitleSize(.05, "")
    gStyle.SetTitleOffset(2.2, "")
    # Axis labels (numbering)
    gStyle.SetLabelSize(.05, "xyz")
    gStyle.SetLabelOffset(.005, "xyz")
    # Thicker lines
    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    # Set the number of tick marks
    gStyle.SetNdivisions(506, "xyz")
    # Set tick marks on all sides
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    # Fonts
    kNovaFont = 42
    gStyle.SetStatFont(kNovaFont)
    gStyle.SetLabelFont(kNovaFont, "xyz")
    gStyle.SetTitleFont(kNovaFont, "xyz")
    gStyle.SetTitleFont(kNovaFont, "")
    # Apply same settings to titles
    gStyle.SetTextFont(kNovaFont)
    gStyle.SetLegendFont(kNovaFont)
Example #5
0
def looks():
    gROOT.ProcessLine('TGaxis::SetMaxDigits(3)')
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(0)
    gStyle.SetStatColor(0)
    gStyle.SetTitleFont(42, '')
    gStyle.SetLabelFont(42, 'x')
    gStyle.SetTitleFont(42, 'x')
    gStyle.SetLabelFont(42, 'y')
    gStyle.SetTitleFont(42, 'y')
    gStyle.SetLabelFont(42, 'z')
    gStyle.SetTitleFont(42, 'z')
    gStyle.SetLabelSize(0.048, 'x')
    gStyle.SetTitleSize(0.048, 'x')
    gStyle.SetLabelSize(0.048, 'y')
    gStyle.SetTitleSize(0.048, 'y')
    gStyle.SetLabelSize(0.048, 'z')
    gStyle.SetTitleSize(0.048, 'z')
    gStyle.SetTitleSize(0.048, '')
    gStyle.SetTitleAlign(23)
    gStyle.SetTitleX(0.5)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleFillColor(0)
    gStyle.SetTitleStyle(0)
    gStyle.SetOptStat('emr')
    gStyle.SetOptStat(0)
    gStyle.SetStatBorderSize(0)
    gStyle.SetStatFont(42)
    gStyle.SetStatFontSize(0.048)
    gStyle.SetStatY(0.9)
    gStyle.SetStatX(0.86)
    gStyle.SetHistLineColor(ROOT.kBlue + 2)
    gStyle.SetLegendBorderSize(0)
    gStyle.SetLegendFillColor(0)
    gStyle.SetFuncWidth(2)
    gStyle.SetFuncColor(2)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadBottomMargin(0.12)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetPadRightMargin(0.06)
    gStyle.SetCanvasDefX(400)
    gStyle.SetCanvasDefY(20)
    gStyle.SetCanvasDefH(420)
    gStyle.SetCanvasDefW(610)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetHistLineWidth(2)
    gStyle.SetTitleOffset(1.16, 'y')
    gStyle.SetTitleOffset(1.20, 'x')
Example #6
0
def PlotDen(templates):
    print "Plotting Denominator Template"
    data = templates["Data"].histo.Clone()
    gjets = templates["GJets"].histo.Clone()
    cleaned = templates["Cleaned"].histo.Clone()

    c = TCanvas("c", "canvas", 800, 800)
    gStyle.SetOptStat(0)
    gStyle.SetLegendBorderSize(0)
    # c.SetLeftMargin(0.15);
    c.SetLogy()
    #c.cd();

    temp_style(cleaned, kRed)
    temp_style(gjets, kGreen + 2)
    DataStyle(data)

    leg = getLegend(xmax=0.7, ymin=0.55, ymax=0.75, scale=0.75)

    cleaned.Draw("hist")
    hslist = [cleaned]

    cleaned.SetTitle("")
    cleaned.GetYaxis().SetTitle("Events")

    if templates.variable.xaxis_title == "":
        templates.variable.xaxis_title = next(
            (vartitle for var, vartitle in xaxismap.items()
             if var in templates.variable.variable), "")
    cleaned.GetXaxis().SetTitle(templates.variable.xaxis_title)

    gjets.Draw("hist same")
    data.Draw("pex0 same")
    hslist = hslist + [gjets, data]

    leg.AddEntry(data, "Data_{Non-ISO}", "lp")
    leg.AddEntry(gjets, "GJets_{Non-ISO}", "l")
    leg.AddEntry(cleaned, "Data_{Non-ISO} - GJets_{Non-ISO}", "l")
    leg.Draw()

    VarBounds(templates.variable.variable, hslist)

    lumi_label = '%s' % float('%.3g' % (templates.lumi / 1000.)) + " fb^{-1}"
    texLumi, texCMS = getCMSText(lumi_label, templates.year, scale=0.8)

    if re.search("(\d+to\d+|\d+toInf)", templates.variable.variable):
        ptrange = templates.variable.variable.split("_")[1].split("to")
        rtext = PtRangeText(ptrange=ptrange, scale=0.75)

    SaveAs(c,
           "den_template_%s" % templates.varname,
           year=templates.year,
           sub="GammaPurity")
Example #7
0
def setPlotStyle():
	gStyle.SetPadGridX(1)
	gStyle.SetPadGridY(1)
	gStyle.SetOptStat(1110)
	gStyle.SetLineWidth(2)
	gStyle.SetHistLineWidth(3)
	gStyle.SetPadTickX(1)
	gStyle.SetPadTickY(1)
	gStyle.SetTextFont(62)
	gStyle.SetLabelFont(62)
	gStyle.SetTitleFont(62)
	gStyle.SetLegendBorderSize(1)
	gStyle.SetLegendFont(62)
Example #8
0
def createCanvasPads():
    c = ROOT.TCanvas("c", "canvas", 800, 800)
    gStyle.SetOptStat(0)
    gStyle.SetLegendBorderSize(0)
    # Upper histogram plot is pad1
    pad1 = ROOT.TPad("pad1", "pad1", 0.01, 0.25, 0.99, 0.99)
    pad1.Draw()
    pad1.cd()
    pad1.SetFillColor(0)
    pad1.SetFrameBorderMode(0)
    pad1.SetBorderMode(0)
    pad1.SetBottomMargin(0)  # joins upper and lower plot
    return c, pad1
def PlotFakeRatio(ratio):
    c = TCanvas("c", "canvas", 800, 800)
    gStyle.SetOptStat(0)
    gStyle.SetLegendBorderSize(0)

    pad = TPad("pad", "pad", 0.01, 0.01, 0.99, 0.99)
    pad.Draw()
    pad.cd()
    pad.SetGrid()
    pad.SetFillColor(0)
    pad.SetFrameBorderMode(0)
    pad.SetBorderMode(0)

    xaxis_title = "Photon P_{T} [GeV]"

    leg = getLegend(xmin=0.5, ymin=0.7, scale=0.75)

    fake_style(ratio)
    ratio.SetTitle("")
    ratio.GetYaxis().SetTitle("Fake Ratio")
    # ratio.GetYaxis().SetTitleOffset(0.5)
    ratio.GetXaxis().SetTitle(xaxis_title)
    # ratio.GetYaxis().SetRangeUser(0.75,1.2)
    print SetBounds([ratio], scale=1)

    ratio.Draw("p same")

    leg.AddEntry(ratio, "#frac{Data_{ISO}}{Data_{Non-ISO}}", "lp")
    leg.Draw()

    lumi_label = '%s' % float('%.3g' %
                              (max(config.lumi.values()) / 1000.)) + " fb^{-1}"
    texLumi, texCMS = getCMSText(lumi_label, config.version, scale=0.8)

    SaveAs(c,
           "fake_ratio_%s" % parser.args.variable,
           year=config.version,
           sub="GammaPurity/FakeRatio/")
def my_style():

    gStyle.SetLabelSize(fontsize, "x")
    gStyle.SetLabelSize(fontsize, "y")
    gStyle.SetLabelSize(fontsize, "z")

    gStyle.SetTitleFontSize(1.5 * fontsize)
    gStyle.SetTitleSize(fontsize, "x")
    gStyle.SetTitleSize(fontsize, "y")
    gStyle.SetTitleSize(fontsize, "z")
    gStyle.SetTickLength(0, "Y")

    gStyle.SetTitleOffset(1.5, "xy")
    gStyle.SetTitleFont(62, "bla")

    gStyle.SetPadBottomMargin(0.15)
    gStyle.SetPadTopMargin(0.10)
    gStyle.SetPadLeftMargin(0.32)
    gStyle.SetPadRightMargin(0.05)

    gStyle.SetStatX(0.88)
    gStyle.SetStatY(0.87)
    gStyle.SetNdivisions(505)

    gStyle.SetCanvasColor(-1)
    gStyle.SetPadColor(-1)
    gStyle.SetFrameFillColor(-1)
    gStyle.SetTitleFillColor(-1)
    gStyle.SetFillColor(-1)
    gStyle.SetFillStyle(4000)
    gStyle.SetStatStyle(0)
    gStyle.SetTitleStyle(0)
    gStyle.SetCanvasBorderSize(0)
    gStyle.SetFrameBorderSize(0)
    gStyle.SetLegendBorderSize(0)
    gStyle.SetStatBorderSize(0)
    gStyle.SetTitleBorderSize(0)
Example #11
0
def CLICdpStyle():
    gROOT.SetStyle("Plain")
    gStyle.SetCanvasColor(root.kWhite)
    gStyle.SetFrameFillColor(root.kWhite)
    gStyle.SetStatColor(root.kWhite)
    gStyle.SetPadColor(root.kWhite)
    gStyle.SetFillColor(10)
    gStyle.SetTitleFillColor(root.kWhite)

    gStyle.SetPaperSize(20, 26)

    gStyle.SetDrawBorder(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetLegendBorderSize(0)

    gStyle.SetTextSize(0.05)
    gStyle.SetTitleSize(0.06, "xyz")
    gStyle.SetLabelSize(0.06, "xyz")

    gStyle.SetLabelOffset(0.015, "xyz")
    gStyle.SetTitleOffset(1.2, "yz")
    gStyle.SetTitleOffset(1.17, "x")

    font = 42
    gStyle.SetTitleFont(font)
    gStyle.SetTitleFontSize(0.06)
    gStyle.SetStatFont(font)
    gStyle.SetStatFontSize(0.07)
    gStyle.SetTextFont(font)
    gStyle.SetLabelFont(font, "xyz")
    gStyle.SetTitleFont(font, "xyz")
    gStyle.SetTitleBorderSize(0)
    gStyle.SetStatBorderSize(1)
    gStyle.SetMarkerStyle(1)
    gStyle.SetLineWidth(2)
    gStyle.SetMarkerSize(1.2)
    gStyle.SetPalette(1)

    gStyle.SetOptTitle(0)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetEndErrorSize(5)

    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    gStyle.SetHistLineColor(root.kBlack)
    gStyle.SetFuncColor(root.kBlack)
    gStyle.SetLabelColor(root.kBlack, "xyz")

    gStyle.SetPadBottomMargin(0.18)
    gStyle.SetPadTopMargin(0.11)
    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadLeftMargin(0.17)

    gStyle.SetNdivisions(506, "xy")

    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)

    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    gStyle.SetCanvasDefW(800)
    gStyle.SetCanvasDefH(700)

    gROOT.ForceStyle()
Example #12
0
def scanV():
    ### test

def scanKK():
    '''Used to test the scan of one or more parameters'''
    nChips = 19 # the magic number
#     nChan = len(chans)

    iP = 1
    cd = CommonData()
    cd.setupConnection()
    sc1 = SensorConfig(cd)

    ### get list of chains to be updated
#     chains = set([sc1.tms1mmX19chainSensors[sc1.tms1mmX19sensorInChain[c]][0] for c in chans])

    chan = 5
#     cd.inputVs = [3., 0., 3., 0., 0., 0.]
#     cd.inputVs = [3., 0., 0.732, 1.68, 0., 0.]
#     cd.inputVs = [0.75, 2.15, 0.7, 0., 0., 0.]

    show = True
    g1 = None
    if show:
        g1 = TGraphErrors()

    xj = open('scan_KK_6.ttl','w')

    ### point insert scan
    ipar = 2
    pts = [(0.,None),(3.,None)]
    while True:
        print pts
        pt, xy, r1, k = insertPoint(pts)
        print '-'*30
        print pt,xy,r1, k
        print '-'*30
        if xy<3 and (r1<0.01 or xy/r1<0.1 or k<0.007): break

        cd.inputVs[ipar] = pt
        cd.updatePars(chan, None, False)
        sc1.update_sensor(chan)
        time.sleep(3)
        cd.fetch()

        m,v = getMeanVar(cd.adcData[chan])
        print ' '.join([str(x) for x in [chan, m, v]+cd.inputVs])
        xj.write(' '.join([str(x) for x in [chan, m, v]+cd.inputVs])+'\n')

        if g1:
            n1 = g1.GetN()
            g1.SetPoint(n1, pt, m)
            g1.SetPointError(n1, 0, v)

        if xy == 999:
            pts[r1] = (pt,m)
        else:
            pts.append((pt,m))

    ### simple scan
#     while cd.inputVs[0]>0.001:
#         cd.updatePars(chan, None, False)
#         sc1.update_sensor(chan)
#         time.sleep(2)
#         cd.fetch()
# 
#         m,v = getMeanVar(cd.adcData[chan])
#         print ' '.join([str(x) for x in [chan, m, v]+cd.inputVs])
#         xj.write(' '.join([str(x) for x in [chan, m, v]+cd.inputVs])+'\n')
# 
#         if g1:
#             g1.SetPoint(g1.GetN(), cd.inputVs[0], m)
#         cd.inputVs[0] *= 2./3
    if g1:
        g1.SetMarkerStyle(4)
        g1.SetMarkerColor(2)
        g1.SetLineColor(2)
        g1.Draw("AP")
        h1 = g1.GetHistogram()
        h1.GetXaxis().SetTitle(cd.voltsNames[ipar]+' [V]')
        h1.GetYaxis().SetTitle("V_{out} [V]")
        lt = TLatex()
        lt.DrawLatexNDC(0.2,0.92,"Chip %d"%chan)
        waitRootCmdX()

def insertPoint(lx):
    '''Insert a point [(x,y)]'''
    for k in lx:
        if k[1] is None: return k[0],999,lx.index(k), 1
    j1 = sorted(lx, key=lambda a:a[0])
    print j1
    vx = [p[1] for p in j1]
    maxd = max(vx)-min(vx)

    dxm = -1
    pt = -1
    k  = 3
    for x in range(len(j1)-1):
        dx = abs(j1[x][1]-j1[x+1][1])
        if dx>dxm:
            dxm = dx
            pt = 0.5*(j1[x][0]+j1[x+1][0])
            k = 0.5*abs(j1[x][0]-j1[x+1][0])
    return pt, dxm, maxd, k

if __name__ == '__main__':
    savehistory('./')
    gStyle.SetOptTitle(0)
    gStyle.SetNdivisions(506,'XYZ')
#     gStyle.SetPadTickX(1);
#     gStyle.SetPadTickY(1);
    gStyle.SetLegendBorderSize(0);
#     scanY()
    getPars()
Example #13
0
def plot_map(out_file_path, hist):
    map_name = out_file_path if '/' not in out_file_path else out_file_path.split(
        '/')[-1]
    map_name = map_name.replace('.pdf', '')
    rho_min = -6.0
    rho_max = -2.6
    pt_min = 500.
    pt_max = 1200.
    # rho_min = -10
    # rho_max = 0
    # pt_min = 200
    # pt_max = 5000
    disc_min = 0.12
    disc_max = 0.3
    left_margin = 0.14
    right_margin = 0.16
    top_margin = 0.08
    bottom_margin = 0.12

    gStyle.SetPadTickY(1)
    gStyle.SetPadTickX(1)
    gStyle.SetLegendBorderSize(0)

    gROOT.SetBatch(True)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetTitleOffset(0.86, "X")
    gStyle.SetTitleOffset(1.6, "Y")
    gStyle.SetPadLeftMargin(left_margin)
    gStyle.SetPadBottomMargin(bottom_margin)
    gStyle.SetPadTopMargin(top_margin)
    gStyle.SetPadRightMargin(right_margin)

    gStyle.SetMarkerSize(0.5)
    gStyle.SetHistLineWidth(1)
    gStyle.SetTitleSize(0.05, "XYZ")
    gStyle.SetLabelSize(0.04, "XYZ")
    gStyle.SetNdivisions(506, "XYZ")
    gStyle.SetNumberContours(25)
    gStyle.SetLegendBorderSize(0)

    hist.GetXaxis().SetTitle("#rho")
    hist.GetYaxis().SetTitle("p_{T} [GeV]")
    if ('n2' in map_name.lower()):
        hist.GetZaxis().SetTitle("N2^{DDT} X% quantile")
    else:
        hist.GetZaxis().SetTitle("DeepBoosted WvsQCD X% quantile")
        disc_max = 1
    hist.GetXaxis().SetRangeUser(rho_min, rho_max)
    hist.GetYaxis().SetRangeUser(pt_min, pt_max)
    # if(disc_max>hist.GetMaximum()):
    #     hist.GetZaxis().SetRangeUser(disc_min, disc_max)

    Font = 43
    TitleSize = 24.0
    TitleOffset = 1.3
    LabelSize = 18.0
    hist.GetYaxis().SetTitleFont(Font)
    hist.GetYaxis().SetTitleSize(TitleSize)
    hist.GetYaxis().SetTitleOffset(TitleOffset)
    hist.GetYaxis().SetLabelFont(Font)
    hist.GetYaxis().SetLabelSize(LabelSize)

    hist.GetXaxis().SetTitleFont(Font)
    hist.GetXaxis().SetTitleSize(TitleSize)
    hist.GetXaxis().SetTitleOffset(TitleOffset)
    hist.GetXaxis().SetLabelFont(Font)
    hist.GetXaxis().SetLabelSize(LabelSize)

    hist.GetZaxis().SetTitleFont(Font)
    hist.GetZaxis().SetTitleSize(TitleSize)
    hist.GetZaxis().SetTitleOffset(TitleOffset)
    hist.GetZaxis().SetLabelFont(Font)
    hist.GetZaxis().SetLabelSize(LabelSize)

    # hist.GetZaxis().SetNdivisions(20)

    hist.SetTitle(map_name.replace('_', ' '))
    hist.SetTitleFont(43)
    hist.SetTitleSize(18.0)

    # isomasses = [20,55,80,120,200]
    # isomasses = [20,65,80,125,200]
    # isomasses = range(40,200,20)
    isomasses = [40, 80, 110, 120, 200]
    str_isomass = "%.2f*TMath::Exp(-x/2)"
    tf1_isomasses = []
    for i in range(len(isomasses)):
        msd = isomasses[i]
        new_isomass = TF1('isomass_%i' % int(msd), str_isomass % msd, rho_min,
                          rho_max)
        # new_isomass.SetLineColor(920+i)
        new_isomass.SetLineColorAlpha(1, 0.4)
        tf1_isomasses.append(new_isomass)

    c1 = TCanvas("c1", "c1", 700, 600)
    c1.cd()
    hist.Draw("colz")
    latex_border = TLatex()
    latex_border.SetNDC(1)
    latex_border.SetTextColor(1)
    latex_border.SetTextFont(43)
    latex_border.SetTextSize(15.5)
    latex_border.SetTextAngle(297)
    latex = TLatex()
    latex.SetNDC(1)
    latex.SetTextColor(920)
    latex.SetTextFont(43)
    latex.SetTextSize(15)
    # latex.SetTextAngle(297)
    for i in range(len(isomasses)):
        x_pitch = (1 - left_margin - right_margin) / (rho_max - rho_min)
        y_pitch = (1 - bottom_margin - top_margin) / (pt_max - pt_min)
        msd = isomasses[i]
        pt = msd * np.exp(-rho_min / 2)
        pt = 800 if pt > pt_max else pt
        angle = ((180 / np.pi) * np.arctan(2 * x_pitch / (pt * y_pitch))) + 272
        latex.SetTextAngle(angle)
        latex_border.SetTextAngle(angle)
        tf1_isomass = tf1_isomasses[i]
        tf1_isomass.Draw('SAME')
        x_pos = left_margin + (
            (2 * np.log(msd / pt) - rho_min)) * x_pitch + 0.01
        y_pos = bottom_margin + (pt - pt_min) * y_pitch + 0.01
        latex_border.DrawLatex(x_pos, y_pos, 'm_{SD} = %.1f GeV' % msd)
        # latex.DrawLatex(x_pos,y_pos,'m_{SD} = %.1f GeV'%msd)
    c1.SaveAs(out_file_path + ".pdf")
    c1.SaveAs(out_file_path + ".png")
    c1.SaveAs(out_file_path + ".C")
    del c1
Example #14
0
h_mass5.SetLineColor(7)

h_mass6.SetXTitle("M_{bb #tilde}[GeV]")
h_mass6.SetYTitle("Events")
h_mass6.SetLineColor(8)

h_mass1.DrawNormalized()
h_mass2.DrawNormalized("Hist&SAME")
h_mass3.DrawNormalized("Hist&SAME")
h_mass4.DrawNormalized("Hist&SAME")
h_mass5.DrawNormalized("Hist&SAME")
h_mass6.DrawNormalized("Hist&SAME")

legend=TLegend(.63,.69,.87,.89,"","brNDC")
legend.SetHeader("Legend")
gStyle.SetLegendBorderSize(2);
legend.AddEntry(h_mass1,"run_01","l")
legend.AddEntry(h_mass2,"run_02","l")
legend.AddEntry(h_mass3,"run_03","l")
legend.AddEntry(h_mass4,"run_04","l")
legend.AddEntry(h_mass5,"run_05","l")
legend.AddEntry(h_mass6,"run_06","l")
legend.Draw("Same")

gStyle.SetOptTitle(0)
title=TPaveLabel(.63,.69,.87,.89,"Inv.Mass of A0","brndc")
title.SetFillColor(10)
title.Draw("Same")

c.SaveAs("Mass Of A0 Combined.png")
c.SaveAs("Mass Of A0 Combined.root")
Example #15
0
def tdrstyle():
    gROOT.SetStyle("Plain")
    
    gStyle.SetAxisColor(1, "XYZ")
    
    gStyle.SetCanvasColor(0)
    #gStyle.SetCanvasBorderSize(10)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasDefH(700)
    gStyle.SetCanvasDefW(700)
    gStyle.SetCanvasDefX(0)
    gStyle.SetCanvasDefY(0)
    
    gStyle.SetFitFormat("5.4g")
    gStyle.SetFuncColor(2)
    gStyle.SetFuncStyle(1)
    gStyle.SetFuncWidth(1)
    
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameBorderSize(1)
    gStyle.SetFrameFillStyle(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetFrameLineColor(1)
    gStyle.SetFrameLineStyle(1)  # 0?
    gStyle.SetFrameLineWidth(1)  # 1?
    
    gStyle.SetGridColor(0)
    gStyle.SetGridStyle(3)
    gStyle.SetGridWidth(1)
    
    #gStyle.SetHistFillColor(1)
    #gStyle.SetHistFillStyle(0)
    gStyle.SetHistLineColor(1)
    gStyle.SetHistLineStyle(0)
    gStyle.SetHistLineWidth(1)
    
    gStyle.SetLabelColor(1, "XYZ")
    gStyle.SetLabelFont(42,"XYZ")
    gStyle.SetLabelOffset(0.007,"XYZ")  # 0.010?
    gStyle.SetLabelSize(0.05,"XYZ")  # 0.04?
    
    gStyle.SetLegendBorderSize(0)
    gStyle.SetLegendFillColor(0)
    gStyle.SetLegendFont(42)
    
    gStyle.SetMarkerSize(1.0)
    gStyle.SetMarkerStyle(20)
    
    gStyle.SetLineColor(1)
    gStyle.SetLineWidth(2)
    #gStyle.SetLineScalePS(2)
    
    gStyle.SetOptDate(0)
    gStyle.SetOptFile(0)
    gStyle.SetOptFit(1)
    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    #gStyle.SetOptLogx(0)
    #gStyle.SetOptLogy(0)
    #gStyle.SetOptLogz(0)
    
    gStyle.SetPadColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadBorderSize(10)
    gStyle.SetPadTopMargin(0.05)  # 0.08?
    gStyle.SetPadBottomMargin(0.13)
    gStyle.SetPadLeftMargin(0.16)
    gStyle.SetPadRightMargin(0.03)  # 0.05?
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    
    gStyle.SetStatColor(0)
    gStyle.SetStatFont(42)
    gStyle.SetStatFontSize(0.025)
    gStyle.SetStatTextColor(1)
    gStyle.SetStatFormat("6.4g")
    gStyle.SetStatBorderSize(1)
    gStyle.SetStatH(0.1)
    gStyle.SetStatW(0.15)
    #gStyle.SetStatX(0)
    #gStyle.SetStatY(0)
    
    #gStyle.SetTextSize(0.055)
    gStyle.SetTextFont(42)
    
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleColor(1)
    gStyle.SetTitleFont(42)
    gStyle.SetTitleColor(1,"XYZ")
    gStyle.SetTitleFont(42,"XYZ")
    gStyle.SetTitleSize(0.06,"XYZ")  # 0.05?
    #gStyle.SetTitleOffset(1.4,"XYZ")
    gStyle.SetTitleOffset(0.9,"X")
    gStyle.SetTitleOffset(1.20,"Y")
    gStyle.SetTitleFillColor(10)
    gStyle.SetTitleFontSize(0.05)
    gStyle.SetTitleTextColor(1)
    #gStyle.SetTitleH(0)
    #gStyle.SetTitleW(0)
    #gStyle.SetTitleX(0)
    #gStyle.SetTitleY(0.985)
    #gStyle.SetTitleStyle(1001)
    
    gStyle.SetPalette(1)
    #gStyle.SetNdivisions(510, "XYZ")  # 505?
    gStyle.SetNdivisions(505, "XYZ")
    gStyle.SetEndErrorSize(2)  # 2?
    #gStyle.SetErrorMarker(20)
    #gStyle.SetErrorX(0.)
    #gStyle.SetPaperSize(20.,20.)
    gStyle.SetStripDecimals(1)
    gStyle.SetTickLength(0.03, "XYZ")
    return 1
def set_root_env():
    #//TStyle* genieStyle = new TStyle("genieStyle", "GENIE Style")
    #//set the background color to white
    gStyle.SetFillColor(10)
    gStyle.SetFrameFillColor(10)
    gStyle.SetCanvasColor(10)
    gStyle.SetPadColor(10)
    gStyle.SetTitleFillColor(0)
    gStyle.SetStatColor(10)

    #dont put a colored frame around the plots
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetLegendBorderSize(3)

    #use the primary color palette
    #gStyle.SetPalette(1,0)

    #set the default line color for a histogram to be black
    gStyle.SetHistLineColor(ROOT.kBlack)

    #set the default line color for a fit function to be red
    gStyle.SetFuncColor(ROOT.kRed)

    #make the axis labels black
    gStyle.SetLabelColor(ROOT.kBlack, "xyz")

    #set the default title color to be black
    gStyle.SetTitleColor(ROOT.kBlack)

    #set the margins
    gStyle.SetPadBottomMargin(0.18)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadLeftMargin(0.17)

    #set axis label and title text sizes
    gStyle.SetLabelFont(42, "xyz")
    gStyle.SetLabelSize(0.04, "xyz")
    gStyle.SetLabelOffset(0.015, "xyz")
    gStyle.SetTitleFont(42, "xyz")
    gStyle.SetTitleSize(0.04, "xyz")
    gStyle.SetTitleOffset(1.4, "y")
    gStyle.SetTitleOffset(1.3, "x")
    gStyle.SetStatFont(42)
    gStyle.SetStatFontSize(0.07)
    gStyle.SetTitleBorderSize(1)
    gStyle.SetStatBorderSize(0)
    gStyle.SetTextFont(42)
    gStyle.SetTitleW(0.5)
    gStyle.SetTitleH(0.1)

    #set line widths
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    gStyle.SetHistLineWidth(2)

    #set the number of divisions to show
    gStyle.SetNdivisions(506, "xy")
    #gStyle.SetPadTickX(-50202)

    #turn off xy grids
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)

    #set the tick mark style
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    #turn off stats
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)

    #marker/line settings
    #gStyle.SetMarkerStyle(20)
    gStyle.SetMarkerSize(.95)  #0.7
    gStyle.SetLineWidth(2)
    gStyle.SetErrorX(0)
    gStyle.SetHistLineStyle(0)  #It was 3 for a dotted line

    #done
    gStyle.cd()
    gROOT.ForceStyle()
Example #17
0
def PlotSig(templates, sideband_templates):
    print "Plotting Signal Template"
    data = templates["Data"].histo.Clone()
    gjets = templates["GJets"].histo.Clone()
    sideband = sideband_templates["Sideband"].histo.Clone()
    full = gjets.Clone()
    full.Add(sideband)

    c = TCanvas("c", "canvas", 800, 800)
    gStyle.SetOptStat(0)
    gStyle.SetLegendBorderSize(0)
    # c.SetLeftMargin(0.15);
    # c.SetLogy();
    #c.cd();

    pad1 = TPad("pad1", "pad1", 0.01, 0.25, 0.99, 0.99)
    pad1.SetBottomMargin(0.)
    pad1.Draw()
    pad1.cd()
    pad1.SetLogy()
    pad1.SetFillColor(0)
    pad1.SetFrameBorderMode(0)
    pad1.SetBorderMode(0)

    temp_style(gjets, kGreen + 2)
    temp_style(sideband, kRed)
    temp_style(full, kBlue + 2)
    DataStyle(data)

    leg = getLegend(xmax=0.7, ymin=0.55, ymax=0.75)

    gjets.Draw("hist")

    gjets.SetTitle("")
    gjets.GetYaxis().SetTitle("Events")

    if templates.variable.xaxis_title == "":
        templates.variable.xaxis_title = next(
            (vartitle for var, vartitle in xaxismap.items()
             if var in templates.variable.variable), "")
    gjets.GetXaxis().SetTitle(templates.variable.xaxis_title)

    sideband.Draw("hist same")
    full.Draw("hist same")
    data.Draw("pex0 same")
    hslist = [data, gjets, sideband]

    leg.AddEntry(data, "Data", "lp")
    leg.AddEntry(gjets, "Real GJets", "l")
    leg.AddEntry(sideband, "QCD Fake Template", "l")
    leg.AddEntry(full, "Full", "l")

    VarBounds(templates.variable.variable, hslist)
    leg.Draw()

    lumi_label = '%s' % float('%.3g' % (templates.lumi / 1000.)) + " fb^{-1}"
    texLumi, texCMS = getCMSText(lumi_label, templates.year)

    if re.search("(\d+to\d+|\d+toInf)", templates.variable.variable):
        ptrange = templates.variable.variable.split("_")[1].split("to")
        rtext = PtRangeText(ptrange=ptrange)

    c.cd()
    pad2 = TPad("pad2", "pad2", 0.01, 0.01, 0.99, 0.25)
    pad2.SetGridy()
    pad2.Draw()
    pad2.cd()
    pad2.SetFillColor(0)
    pad2.SetFrameBorderMode(0)
    pad2.SetBorderMode(0)
    pad2.SetTopMargin(0)
    pad2.SetBottomMargin(0.35)

    ratio = GetRatio(data, full)

    RatioStyle(ratio,
               rymin=-0.25,
               rymax=2.25,
               xname=templates.variable.xaxis_title,
               yname="Data/Full")
    ratio.Draw("pex0")
    line = getRatioLine(data.GetXaxis().GetXmin(), data.GetXaxis().GetXmax())
    line.Draw("same")

    SaveAs(c,
           "real_template_%s" % templates.varname,
           year=templates.year,
           sub="GammaPurity")
Example #18
0
def initialization(batch=True, font=default_font):
    '''-- ROOT initialization --'''

    print "Initializing ROOT ..."

    # general
    gROOT.Reset()
    gROOT.SetBatch(batch)
    gROOT.SetStyle("Plain")

    # gStyle
    gStyle.SetFillColor(0)
    gStyle.SetCanvasColor(10)
    gStyle.SetLineWidth(1)
    gStyle.SetPalette(8)
    gStyle.SetTextFont(font)
    #gStyle.SetTextSize(30)

    # Frame
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameFillColor(0)

    # Pad
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadBottomMargin(0.1)
    gStyle.SetPadTopMargin(0.01)
    gStyle.SetPadLeftMargin(0.1)
    gStyle.SetPadRightMargin(0.01)
    gStyle.SetPadTickX(1)  # make ticks be on all 4 sides.
    gStyle.SetPadTickY(1)
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)

    # histogram
    gStyle.SetHistFillStyle(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleSize(0.22)
    gStyle.SetTitleFontSize(10)
    gStyle.SetTitleFont(font)
    gStyle.SetTitleFont(font, "xyz")
    gStyle.SetTitleYOffset(1.0)
    gStyle.SetTitleXOffset(1.0)
    gStyle.SetTitleXSize(0.04)
    gStyle.SetTitleYSize(0.04)
    gStyle.SetTitleX(.15)
    gStyle.SetTitleY(.98)
    gStyle.SetTitleW(.70)
    gStyle.SetTitleH(.05)

    # statistics box
    gStyle.SetOptStat(0)
    gStyle.SetStatFont(font)
    gStyle.SetStatFontSize(10)
    gStyle.SetStatX(.91)
    gStyle.SetStatY(.90)
    gStyle.SetStatW(.15)
    gStyle.SetStatH(.15)

    # axis labels
    gStyle.SetLabelFont(font)
    gStyle.SetLabelFont(font, "xyz")
    gStyle.SetLabelSize(10, "xyz")
    # gStyle.SetGridColor(1)
    gStyle.SetLegendBorderSize(1)
def SetGlobalStyle(**kwargs):
    '''
    Method to set global style.

    Parameters
    ----------

    - padrightmargin (float), default = 0.035
    - padleftmargin (float), default = 0.12
    - padtopmargin (float), default = 0.035
    - padbottommargin (float), default = 0.12

    - titlesize (float), default = 0.050
    - titlesizex (float), default = 0.050
    - titlesizey (float), default = 0.050
    - titlesizez (float), default = 0.050

    - labelsize (float), default = 0.045
    - labelsizex (float), default = 0.045
    - labelsizey (float), default = 0.045
    - labelsizez (float), default = 0.045

    - titleoffset (float), default = 1.2
    - titleoffsetx (float), default = 1.2
    - titleoffsey (float), default = 1.2
    - titleoffsetz (float), default = 1.2

    - opttitle (int), default = 0
    - optstat (int), default = 0

    - padtickx (int), default = 1
    - padticky (int), default = 1

    - maxdigits (int), default no max value

    - palette (int), default kBird
    '''

    # pad margins
    if 'padrightmargin' in kwargs:
        gStyle.SetPadRightMargin(kwargs['padrightmargin'])
    else:
        gStyle.SetPadRightMargin(0.035)

    if 'padleftmargin' in kwargs:
        gStyle.SetPadLeftMargin(kwargs['padleftmargin'])
    else:
        gStyle.SetPadLeftMargin(0.12)

    if 'padtopmargin' in kwargs:
        gStyle.SetPadTopMargin(kwargs['padtopmargin'])
    else:
        gStyle.SetPadTopMargin(0.035)

    if 'padbottommargin' in kwargs:
        gStyle.SetPadBottomMargin(kwargs['padbottommargin'])
    else:
        gStyle.SetPadBottomMargin(0.1)

    # title sizes
    if 'titlesize' in kwargs:
        gStyle.SetTitleSize(kwargs['titlesize'], 'xyz')
    else:
        gStyle.SetTitleSize(0.050, 'xyz')

    if 'titlesizex' in kwargs:
        gStyle.SetTitleSize(kwargs['titlesizex'], 'x')
    if 'titlesizey' in kwargs:
        gStyle.SetTitleSize(kwargs['titlesizex'], 'y')
    if 'titlesizez' in kwargs:
        gStyle.SetTitleSize(kwargs['titlesizex'], 'z')

    # label sizes
    if 'labelsize' in kwargs:
        gStyle.SetLabelSize(kwargs['labelsize'], 'xyz')
    else:
        gStyle.SetLabelSize(0.045, 'xyz')

    if 'labelsizex' in kwargs:
        gStyle.SetLabelSize(kwargs['labelsizex'], 'x')
    if 'labelsizey' in kwargs:
        gStyle.SetLabelSize(kwargs['labelsizex'], 'y')
    if 'labelsizez' in kwargs:
        gStyle.SetLabelSize(kwargs['labelsizex'], 'z')

    # title offsets
    if 'titleoffset' in kwargs:
        gStyle.SetTitleOffset(kwargs['titleoffset'], 'xyz')
    else:
        gStyle.SetTitleOffset(1.2, 'xyz')

    if 'titleoffsetx' in kwargs:
        gStyle.SetTitleOffset(kwargs['titleoffsetx'], 'x')
    if 'titleoffsety' in kwargs:
        gStyle.SetTitleOffset(kwargs['titleoffsety'], 'y')
    if 'titleoffsetz' in kwargs:
        gStyle.SetTitleOffset(kwargs['titleoffsetz'], 'z')

    # other options
    if 'opttitle' in kwargs:
        gStyle.SetOptTitle(kwargs['opttitle'])
    else:
        gStyle.SetOptTitle(0)

    if 'optstat' in kwargs:
        gStyle.SetOptStat(kwargs['optstat'])
    else:
        gStyle.SetOptStat(0)

    if 'padtickx' in kwargs:
        gStyle.SetPadTickX(kwargs['padtickx'])
    else:
        gStyle.SetPadTickX(1)

    if 'padticky' in kwargs:
        gStyle.SetPadTickY(kwargs['padticky'])
    else:
        gStyle.SetPadTickY(1)

    gStyle.SetLegendBorderSize(0)

    if 'maxdigits' in kwargs:
        TGaxis.SetMaxDigits(kwargs['maxdigits'])

    if 'palette' in kwargs:
        gStyle.SetPalette(kwargs['palette'])

    gROOT.ForceStyle()
Example #20
0
def plot_map_root(file_path, map_name, wp):
    from ROOT import gStyle, gROOT, TFile, TCanvas, TF1, TLatex
    import os
    # rho_min = -6.0
    # rho_max = -2.1
    # pt_min = 200
    # pt_max = 1200
    rho_min = -10
    rho_max = 0
    pt_min = 0
    pt_max = 1500
    disc_min = 0.12
    disc_max = 0.3
    left_margin = 0.14
    right_margin = 0.16
    top_margin = 0.08
    bottom_margin = 0.12
    out_dir = os.path.dirname(file_path)
    out_file_path = out_dir+("/" if len(out_dir)>0 else "")+map_name;
    gStyle.SetPadTickY(1)
    gStyle.SetPadTickX(1)
    gStyle.SetLegendBorderSize(0)
    
    gROOT.SetBatch(True)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetTitleOffset(0.86,"X")
    gStyle.SetTitleOffset(1.6,"Y")
    gStyle.SetPadLeftMargin(left_margin)
    gStyle.SetPadBottomMargin(bottom_margin)
    gStyle.SetPadTopMargin(top_margin)
    gStyle.SetPadRightMargin(right_margin)
    
    gStyle.SetMarkerSize(0.5)
    gStyle.SetHistLineWidth(1)
    gStyle.SetTitleSize(0.05, "XYZ")
    gStyle.SetLabelSize(0.04, "XYZ")
    gStyle.SetNdivisions(506, "XYZ")
    gStyle.SetNumberContours(25)
    gStyle.SetLegendBorderSize(0)
    f = TFile(file_path)
    hist = f.Get(map_name)
  
    hist.GetXaxis().SetTitle("#rho")
    hist.GetYaxis().SetTitle("p_{T} [GeV]")
    if('n2' in map_name.lower()):
        hist.GetZaxis().SetTitle("N2^{DDT} %.1f"%(wp*100)+"% quantile")
    else:
        hist.GetZaxis().SetTitle("DeepBoosted WvsQCD %.1f"%(wp*100)+"% quantile")
        disc_max=1
    hist.GetXaxis().SetRangeUser(rho_min, rho_max)
    hist.GetYaxis().SetRangeUser(pt_min, pt_max)
    if(disc_max>hist.GetMaximum()):
        hist.GetZaxis().SetRangeUser(disc_min, disc_max)

    Font=43
    TitleSize=24.0
    TitleOffset=1.3
    LabelSize=18.0
    hist.GetYaxis().SetTitleFont(Font)
    hist.GetYaxis().SetTitleSize(TitleSize)
    hist.GetYaxis().SetTitleOffset(TitleOffset)
    hist.GetYaxis().SetLabelFont(Font)
    hist.GetYaxis().SetLabelSize(LabelSize)

    hist.GetXaxis().SetTitleFont(Font)
    hist.GetXaxis().SetTitleSize(TitleSize)
    hist.GetXaxis().SetTitleOffset(TitleOffset)
    hist.GetXaxis().SetLabelFont(Font)
    hist.GetXaxis().SetLabelSize(LabelSize)
    
    hist.GetZaxis().SetTitleFont(Font)
    hist.GetZaxis().SetTitleSize(TitleSize)
    hist.GetZaxis().SetTitleOffset(TitleOffset)
    hist.GetZaxis().SetLabelFont(Font)
    hist.GetZaxis().SetLabelSize(LabelSize)
    
    hist.GetZaxis().SetNdivisions(510)
    
    hist.SetTitle(map_name.replace('_',' '))
    hist.SetTitleFont(43)
    hist.SetTitleSize(18.0)
	
    # isomasses = [20,55,80,120,200]
    # isomasses = [20,65,80,125,200]
    # isomasses = range(40,200,20)
    isomasses = [40,80,120,200]
    str_isomass = "%.2f*TMath::Exp(-x/2)"
    tf1_isomasses = []
    for i in range(len(isomasses)):
        msd = isomasses[i]
        new_isomass = TF1('isomass_%i'%int(msd),str_isomass%msd,rho_min,rho_max)
        # new_isomass.SetLineColor(920+i)
        new_isomass.SetLineColorAlpha(1,0.4)
        tf1_isomasses.append(new_isomass)


    c1 = TCanvas("c1","c1",700,600)
    c1.cd()
    hist.Draw("colz")
    latex = TLatex()
    latex.SetNDC(1)
    latex.SetTextColor(1)
    latex.SetTextFont(43)
    latex.SetTextSize(15.5)
    latex.SetTextAngle(297)
    for i in range(len(isomasses)):
        x_pitch = (1-left_margin-right_margin)/(rho_max-rho_min)
        y_pitch = (1-bottom_margin-top_margin)/(pt_max-pt_min)
        msd = isomasses[i]
        pt=msd*np.exp(-rho_min/2)
        pt = 0.5*(pt_max-pt_min)+pt_min if pt > pt_max else pt
        angle = ((180/np.pi)*np.arctan(2*x_pitch/(pt*y_pitch)))+272
        latex.SetTextAngle(angle)
        tf1_isomass = tf1_isomasses[i]
        tf1_isomass.Draw('SAME')
        x_pos = left_margin+((2*np.log(msd/pt)-rho_min))*x_pitch+0.01
        y_pos = bottom_margin+(pt-pt_min)*y_pitch +0.01
        latex.DrawLatex(x_pos,y_pos,'m_{SD} = %.1f GeV'%msd)
    c1.SaveAs(out_file_path+".pdf")
    del c1
Example #21
0
gStyle.SetOptStat(0)
gStyle.SetOptFit(0)
gStyle.SetOptTitle(0)

gStyle.SetTitleOffset(1.4, "Y")
gStyle.SetPadLeftMargin(0.18)
gStyle.SetPadBottomMargin(0.15)
gStyle.SetPadTopMargin(0.08)
gStyle.SetPadRightMargin(0.08)
gStyle.SetMarkerSize(0.5)
gStyle.SetHistLineWidth(1)
gStyle.SetTitleSize(0.06, "XYZ")
gStyle.SetLabelSize(0.05, "XYZ")
gStyle.SetNdivisions(506, "XYZ")
gStyle.SetLegendBorderSize(0)

if (__name__ == "__main__"):
    SFile = TFile(
        "/nfs/dust/cms/user/albrechs/UHH2_Output/parameterscan/uhh2.AnalysisModuleRunner.MC.MC_aQGC_ZZjj_hadronic.root"
    )
    BFile = TFile(
        "/nfs/dust/cms/user/albrechs/UHH2_Output/parameterscan/uhh2.AnalysisModuleRunner.MC.MC_QCD.root"
    )

    #rebin stuff

    boundaries = [
        1, 3, 6, 10, 16, 23, 31, 40, 50, 61, 74, 88, 103, 119, 137, 156, 176,
        197, 220, 244, 270, 296, 325, 354, 386, 419, 453, 489, 526, 565, 606,
        649, 693, 740, 788, 838, 890, 944, 1000, 1058, 1118, 1181, 1246, 1313,
Example #22
0
def setgstyle():
    # Zero horizontal error bars
    gStyle.SetErrorX(0)

    # For the canvas
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetCanvasDefH(800)  # Height of canvas
    gStyle.SetCanvasDefW(800)  # Width of canvas
    gStyle.SetCanvasDefX(0)  # Position on screen
    gStyle.SetCanvasDefY(0)

    # For the frame
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameBorderSize(1)
    gStyle.SetFrameFillColor(1)
    gStyle.SetFrameFillStyle(0)
    gStyle.SetFrameLineColor(1)
    gStyle.SetFrameLineStyle(0)
    gStyle.SetFrameLineWidth(1)

    # For the Pad
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadGridX(False)
    gStyle.SetPadGridY(False)
    gStyle.SetGridColor(0)
    gStyle.SetGridStyle(3)
    gStyle.SetGridWidth(1)

    # Margins
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadBottomMargin(0.19)
    gStyle.SetPadLeftMargin(0.17)
    #gStyle.SetPadRightMargin(0.07)

    # For the histo:
    gStyle.SetHistLineColor(1)
    gStyle.SetHistLineStyle(0)
    gStyle.SetHistLineWidth(2)
    gStyle.SetMarkerSize(1.4)
    gStyle.SetEndErrorSize(4)

    # For the statistics box:
    gStyle.SetOptStat(0)

    # For the axis
    gStyle.SetAxisColor(1, "XYZ")
    gStyle.SetTickLength(0.03, "XYZ")
    gStyle.SetNdivisions(510, "XYZ")
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetStripDecimals(False)

    # For the axis labels and titles
    gStyle.SetTitleColor(1, "XYZ")
    gStyle.SetLabelColor(1, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelOffset(0.007, "XYZ")
    gStyle.SetLabelSize(0.045, "XYZ")
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.06, "XYZ")

    # For the legend
    gStyle.SetLegendBorderSize(0)