コード例 #1
0
ファイル: part3.py プロジェクト: QuantumDancer/FP2
def makeGraphs():
    gStyle.SetPadTickY(0)
    files = os.listdir(os.path.join(os.getcwd(), '../data/part3/'))
    files.sort()
    files = files[0:]
    for file in files:
        if file.endswith('.tab'):
            makeTwoScalesGraph(file)
    gStyle.SetPadTickY(1)
コード例 #2
0
def load_joeys_style():
    from ROOT import gStyle, gROOT
    font_id = 12
    gStyle.SetOptStat(0)
    gStyle.SetTitleFont(font_id, "X") # LaTeX typeface
    gStyle.SetTitleFont(font_id, "Y")
    gStyle.SetTitleFont(font_id, "Z")
    gStyle.SetTitleFont(font_id, "T")
    gStyle.SetLabelFont(font_id, "X") # LaTeX typeface
    gStyle.SetLabelFont(font_id, "Y")
    gStyle.SetLabelFont(font_id, "Z")
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPadTopMargin(0.13)
    gStyle.SetPadBottomMargin(0.25)
    gStyle.SetPadLeftMargin(0.17)
    gStyle.SetPadRightMargin(0.25)
    gStyle.SetCanvasDefW(1500)
    gStyle.SetCanvasDefH(900)
    gStyle.SetTitleSize(0.06,"X")
    gStyle.SetTitleSize(0.06,"Y")
    gStyle.SetTitleSize(0.06,"Z")
    gStyle.SetTitleSize(0.06,"T") # for title
    gStyle.SetLabelSize(0.04,"X")
    gStyle.SetLabelSize(0.04,"Y")
    gStyle.SetLabelSize(0.04,"Z")
    gStyle.SetTitleOffset(1.5,"X")
    gStyle.SetTitleOffset(1.1,"Y")
    gStyle.SetTitleOffset(1.3,"Z")
    gROOT.ForceStyle()
コード例 #3
0
def TopMassStyle():
    """Set the style plot in order to create fancier plots!"""
    gStyle.SetPadTickX(1);
    gStyle.SetPadTickY(1);
    gStyle.SetHistLineWidth(3);
    gStyle.SetMarkerStyle(1);

    gStyle.SetTextSize(0.065);

    gStyle.SetOptFit(1111);
    gStyle.SetTitleSize(.05,"X");#.055
    gStyle.SetTitleOffset(1.1,"X");#1.2,0.9
    gStyle.SetLabelSize(.05,"X");

    gStyle.SetTitleSize(.05,"Y");#.055
    gStyle.SetTitleOffset(1.1,"Y");
    gStyle.SetLabelSize(.05,"Y");

    gStyle.SetPadLeftMargin(.16);
    gStyle.SetPadBottomMargin(.12);

    gStyle.SetTitleSize(.05,"Z");
    gStyle.SetTitleOffset(1.8,"Z");
    gStyle.SetLabelSize(0.06,"Z");

    gStyle.SetLegendTextSize(0.04);

    gStyle.SetOptStat(112210);

    gStyle.SetPadLeftMargin(.12);
    gStyle.SetPadRightMargin(.02);
    gStyle.SetPadBottomMargin(.12);
    gStyle.SetPadTopMargin(.07);
    gStyle.SetPadGridX(1);
    gStyle.SetPadGridY(1);
コード例 #4
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)
コード例 #5
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);
コード例 #6
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)
コード例 #7
0
def plot_dSigDe_all():

    # dSigma / dEgamma over all energies, ZEUS parametrization

    parse = ConfigParser.RawConfigParser()
    parse.add_section("main")
    parse.set("main", "emin", "0.1")  # GeV

    parse.set("main", "Ee", "18")
    parse.set("main", "Ep", "275")
    sig_top = gen_zeus(parse).dSigDe

    parse.set("main", "Ee", "10")
    parse.set("main", "Ep", "110")
    sig_mid = gen_zeus(parse).dSigDe

    parse.set("main", "Ee", "5")
    parse.set("main", "Ep", "41")
    sig_low = gen_zeus(parse).dSigDe

    gStyle.SetPadTickY(1)
    can = ut.box_canvas()

    frame = gPad.DrawFrame(0.1, 1, 19, 80)
    frame.Draw()

    ut.set_F1(sig_top)
    ut.set_F1(sig_mid, rt.kYellow + 1)
    ut.set_F1(sig_low, rt.kBlue)

    sig_top.Draw("same")
    sig_mid.Draw("same")
    sig_low.Draw("same")

    ytit = "d#sigma / d#it{E}_{#gamma} (mb/GeV)"
    xtit = "#it{E}_{#gamma} (GeV)"
    ut.put_yx_tit(frame, ytit, xtit, 1.6, 1.4)

    ut.set_margin_lbtr(gPad, 0.12, 0.1, 0.01, 0.01)

    frame.GetYaxis().SetMoreLogLabels()

    leg = ut.prepare_leg(0.65, 0.77, 0.24, 0.16, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(sig_top, "18 #times 275 GeV", "l")
    leg.AddEntry(sig_mid, "10 #times 100 GeV", "l")
    leg.AddEntry(sig_low, "5 #times 41 GeV", "l")
    leg.Draw("same")

    gPad.SetLogy()

    gPad.SetGrid()

    ut.invert_col(gPad)
    can.SaveAs("01fig.pdf")
コード例 #8
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)
コード例 #9
0
 def loadstyle2():
     gROOT.SetStyle("Plain")
     gStyle.SetOptStat(0)
     gStyle.SetOptStat(0000)
     gStyle.SetPalette(0)
     gStyle.SetCanvasColor(0)
     gStyle.SetFrameFillColor(0)
     gStyle.SetTitleOffset(1.15, "y")
     gStyle.SetTitleFont(42, "xy")
     gStyle.SetLabelFont(42, "xy")
     gStyle.SetTitleSize(0.042, "xy")
     gStyle.SetLabelSize(0.035, "xy")
     gStyle.SetPadTickX(1)
     gStyle.SetPadTickY(1)
コード例 #10
0
ファイル: __init__.py プロジェクト: gechen/BToKMuMu
def set_root_style(stat=1110,
                   grid=0,
                   PadTopMargin=0.08,
                   PadLeftMargin=0.10,
                   TitleOffsetY=1.2):
    # must be used in the beginning
    from ROOT import gROOT, gStyle
    gROOT.SetBatch(1)
    gROOT.Reset()

    gStyle.SetOptTitle(1)
    gStyle.SetTitleFillColor(0)
    gStyle.SetTitleBorderSize(0)

    # gStyle.SetTitleFont(22)
    # gStyle.SetStatFont(22)
    # gStyle.SetStatColor(1)
    # gStyle.SetLabelFont(22,"X")
    # gStyle.SetLabelFont(22,"Y")

    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetCanvasDefX(0)
    gStyle.SetCanvasDefY(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameBorderSize(1)
    gStyle.SetFrameFillColor(0)
    gStyle.SetFrameFillStyle(0)
    gStyle.SetFrameLineColor(1)
    gStyle.SetFrameLineStyle(1)
    gStyle.SetFrameLineWidth(1)

    gStyle.SetPadTopMargin(PadTopMargin)
    gStyle.SetPadLeftMargin(PadLeftMargin)
    gStyle.SetPadRightMargin(0.05)

    gStyle.SetLabelSize(0.03, "XYZ")
    gStyle.SetTitleSize(0.04, "XYZ")
    gStyle.SetTitleOffset(TitleOffsetY, "Y")

    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPadGridX(grid)
    gStyle.SetPadGridY(grid)

    gStyle.SetOptStat(stat)
    gStyle.SetStatColor(0)
    gStyle.SetStatBorderSize(1)
コード例 #11
0
def rootlogon():
    from ROOT import gStyle
    gStyle.SetOptStat(0)
    gStyle.SetPadTopMargin(0.07)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadBottomMargin(0.13)
    gStyle.SetPadLeftMargin(0.19)
    gStyle.SetTitleOffset(1.2, 'x')
    gStyle.SetTitleOffset(1.8, 'y')
    gStyle.SetTextSize(0.05)
    gStyle.SetLabelSize(0.05, 'xyz')
    gStyle.SetTitleSize(0.05, 'xyz')
    gStyle.SetTitleSize(0.05, 't')
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
コード例 #12
0
def load_root_style():
    """
    Set more advanced ROOT style for histograms
    """
    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetTitleOffset(1.15, "y")
    gStyle.SetTitleFont(42, "xy")
    gStyle.SetLabelFont(42, "xy")
    gStyle.SetTitleSize(0.042, "xy")
    gStyle.SetLabelSize(0.035, "xy")
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
コード例 #13
0
def plot_dSigDe():

    # dSigma / dEgamma according to ZEUS parametrization

    parse = ConfigParser.RawConfigParser()
    parse.add_section("main")
    parse.set("main", "emin", "6")
    parse.set("main", "Ee", "18")
    parse.set("main", "Ep", "275")
    gen = gen_zeus(parse)
    sig = gen.dSigDe

    gStyle.SetPadTickY(1)
    can = ut.box_canvas()

    #frame = gPad.DrawFrame(6, 0, 29, 6)
    frame = gPad.DrawFrame(5, 0, 19, 7.2)

    sig.SetLineWidth(3)
    sig.SetNpx(1000)
    sig.SetTitle("")
    sig.Draw("same")

    frame.GetXaxis().SetTitle("#it{E}_{#gamma} (GeV)")
    frame.GetYaxis().SetTitle("d#sigma / d#it{E}_{#gamma} (mb/GeV)")

    frame.GetYaxis().SetTitleOffset(1.1)
    frame.GetXaxis().SetTitleOffset(1.3)

    frame.SetTickLength(0.015, "X")
    frame.SetTickLength(0.015, "Y")

    gPad.SetTopMargin(0.02)
    gPad.SetRightMargin(0.01)
    gPad.SetLeftMargin(0.09)

    leg = ut.prepare_leg(0.65, 0.73, 0.24, 0.2, 0.035)  # x, y, dx, dy, tsiz
    leg.AddEntry(sig, "#frac{d#sigma}{d#it{E}_{#gamma}}", "l")
    leg.AddEntry(None, "", "")
    #leg.AddEntry(None, "#it{E}_{e} = 27.6 GeV", "")
    #leg.AddEntry(None, "#it{E}_{p} = 920 GeV", "")
    leg.AddEntry(None, "#it{E}_{e} = 18 GeV", "")
    leg.AddEntry(None, "#it{E}_{p} = 275 GeV", "")
    leg.Draw("same")

    ut.invert_col(gPad)
    can.SaveAs("01fig.pdf")
コード例 #14
0
def setStyle():
    gROOT.Reset()
    icol = 0
    # WHITE
    font = 42
    # Helvetica
    tsize = 0.05
    gStyle.SetFrameBorderMode(icol)
    gStyle.SetFrameFillColor(icol)
    gStyle.SetCanvasBorderMode(icol)
    gStyle.SetCanvasColor(icol)
    gStyle.SetPadBorderMode(icol)
    gStyle.SetPadColor(icol)
    gStyle.SetStatColor(icol)
    gStyle.SetPaperSize(20, 26)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadBottomMargin(0.15)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetTitleXOffset(1.05)
    gStyle.SetTitleYOffset(0.95)
    gStyle.SetTextFont(font)
    gStyle.SetTextSize(tsize)
    gStyle.SetLabelFont(font, "x")
    gStyle.SetTitleFont(font, "x")
    gStyle.SetLabelFont(font, "y")
    gStyle.SetTitleFont(font, "y")
    gStyle.SetLabelFont(font, "z")
    gStyle.SetTitleFont(font, "z")
    gStyle.SetLabelSize(tsize * 0.85, "x")
    gStyle.SetTitleSize(tsize * 1.10, "x")
    gStyle.SetLabelSize(tsize * 0.85, "y")
    gStyle.SetTitleSize(tsize * 1.10, "y")
    gStyle.SetLabelSize(tsize * 0.85, "z")
    gStyle.SetTitleSize(tsize * 1.10, "z")
    gStyle.SetMarkerStyle(20)
    gStyle.SetMarkerSize(1.)
    gStyle.SetHistLineWidth(2)
    gStyle.SetLineStyleString(2, "[12 12]")
    # postscript dashes
    gStyle.SetEndErrorSize(0.)
    # gStyle.SetOptTitle(0);
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPaintTextFormat("4.1f")
コード例 #15
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
コード例 #16
0
    def draw(self, elements):

        gROOT.SetBatch()

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

        c1 = TCanvas("c1", "c1", 1000, 700)
        frame = gPad.DrawFrame(self.zmin, self.xmin, self.zmax,
                               self.xmax)  # xmin, ymin, xmax, ymax in ROOT
        frame.SetTitle(";Length #it{z} (m);Horizontal #it{x} (cm)")
        siz = 0.035
        frame.SetTitleSize(siz)
        frame.SetLabelSize(siz)
        frame.SetTitleSize(siz, "Y")
        frame.SetLabelSize(siz, "Y")

        frame.GetYaxis().SetTitleOffset(1)
        frame.GetXaxis().SetTitleOffset(1.2)
        frame.GetYaxis().CenterTitle()
        frame.GetXaxis().CenterTitle()
        gPad.SetLeftMargin(0.07)
        gPad.SetRightMargin(0.01)
        gPad.SetTopMargin(0.02)
        gPad.SetBottomMargin(0.09)

        #loop over elements
        for el in elements.itervalues():
            if not hasattr(el, "draw_2d"): continue
            el.draw_2d()

        #redraw these elements on the top
        #draw_top = ["Q0EF", "beam_electron", "beam_hadron"]
        draw_top = ["ew"]
        for i in draw_top:
            el = elements.get(i)
            if el is not None: el.draw_2d()

        gPad.SetGrid()

        #self.invert_col(gPad)

        c1.SaveAs("01fig.pdf")
コード例 #17
0
    def __init__(self):
        '''
        Set up PlotStyle, set gStyle for things we always want no matter what.
        '''
        # CMS-approved everything
        tdrstyle.setTDRStyle()

        ### Differences from TDR standard:

        # Big canvas (can always shrink later)
        gStyle.SetCanvasDefH(1200)
        gStyle.SetCanvasDefW(1200)

        # Tick marks on all sides
        gStyle.SetPadTickX(1)
        gStyle.SetPadTickY(1)

        # Everything has white backgrounds
        gStyle.SetLegendFillColor(0)

        # Colors that don't suck
        gStyle.SetPalette(1)

        # Make axis title and labels just a little smaller and (for Y) closer to the axis
        gStyle.SetTitleSize(0.044, "XYZ")
        gStyle.SetLabelSize(0.033, "XYZ")
        gStyle.SetTitleYOffset(1.15)
        gStyle.SetTitleXOffset(0.95)
        gStyle.SetPadLeftMargin(0.1)
        gStyle.SetPadRightMargin(0.025)
        gStyle.SetPadBottomMargin(0.095)
        gStyle.SetTitleAlign(12)

        # Apply changes
        gROOT.ForceStyle()

        # Force exponentials when axes are over 3 digits
        TGaxis.SetMaxDigits(3)
        TGaxis.SetExponentOffset(-0.060, 0.008, "y")
        TGaxis.SetExponentOffset(
            -0.055, -0.062,
            "x")  # will overlap with title unless title is centered
コード例 #18
0
ファイル: plotResolution.py プロジェクト: libo929/CaloRec
    hist.Fit('myfun', 'q', '', mean - 1.5 * rms, mean + 1.5 * rms)

    mean = func.GetParameter('p1')
    rms = func.GetParameter('p2')

    #print(func.GetParError(0), func.GetParError(1), func.GetParError(1))
    meanerr = func.GetParError(1)
    rmserr  = func.GetParError(2)

    return (mean, rms, meanerr, rmserr)



#-----------------------------------------------------------------
gStyle.SetPadTickX(1)
gStyle.SetPadTickY(1)
gROOT.SetBatch(True)

c1 = TCanvas( 'c1', 'linearity', 300, 400 )
c1.SetGrid()

n = 8
energyVec = array( 'f' )
energyErrorVec = array( 'f' )

recoEnergyVec = array( 'f' )
recoEnergyErrorVec = array( 'f' )

deltaE_f = array( 'f' ) 
relEnergyErrorVec = array( 'f' ) 
   
コード例 #19
0
    def initialize2(self):
        # For the canvas:
        gStyle.SetCanvasBorderMode(0)
        gStyle.SetCanvasColor(kWhite)
        gStyle.SetCanvasDefH(600)  #Height of canvas
        gStyle.SetCanvasDefW(600)  #Width of canvas
        gStyle.SetCanvasDefX(0)  #POsition on screen
        gStyle.SetCanvasDefY(0)

        # For the Pad:
        gStyle.SetPadBorderMode(0)
        # gStyle.SetPadBorderSize(Width_t size = 1)
        gStyle.SetPadColor(kWhite)
        gStyle.SetPadGridX(False)
        gStyle.SetPadGridY(False)
        gStyle.SetGridColor(0)
        gStyle.SetGridStyle(3)
        gStyle.SetGridWidth(1)

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

        # For the histo:
        # gStyle.SetHistFillColor(1)
        # gStyle.SetHistFillStyle(0)
        gStyle.SetHistLineColor(1)
        gStyle.SetHistLineStyle(0)
        gStyle.SetHistLineWidth(1)
        # gStyle.SetLegoInnerR(Float_t rad = 0.5)
        # gStyle.SetNumberContours(Int_t number = 20)

        gStyle.SetEndErrorSize(2)
        # gStyle.SetErrorMarker(20)
        gStyle.SetErrorX(0.)

        gStyle.SetMarkerStyle(20)

        #For the fit/function:
        gStyle.SetOptFit(1)
        gStyle.SetFitFormat("5.4g")
        gStyle.SetFuncColor(2)
        gStyle.SetFuncStyle(1)
        gStyle.SetFuncWidth(1)

        #For the date:
        gStyle.SetOptDate(0)
        # gStyle.SetDateX(Float_t x = 0.01)
        # gStyle.SetDateY(Float_t y = 0.01)

        # For the statistics box:
        gStyle.SetOptFile(0)
        gStyle.SetOptStat(
            0)  # To display the mean and RMS:         SetOptStat("mr")
        gStyle.SetStatColor(kWhite)
        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.SetStatStyle(Style_t style = 1001)
        # gStyle.SetStatX(Float_t x = 0)
        # gStyle.SetStatY(Float_t y = 0)

        # Margins:
        gStyle.SetPadTopMargin(0.05)
        gStyle.SetPadBottomMargin(0.13)
        gStyle.SetPadLeftMargin(0.16)
        gStyle.SetPadRightMargin(0.02)

        # For the Global title:

        gStyle.SetOptTitle(0)
        gStyle.SetTitleFont(42)
        gStyle.SetTitleColor(1)
        gStyle.SetTitleTextColor(1)
        gStyle.SetTitleFillColor(10)
        gStyle.SetTitleFontSize(0.05)
        # gStyle.SetTitleH(0) # Set the height of the title box
        # gStyle.SetTitleW(0) # Set the width of the title box
        # gStyle.SetTitleX(0) # Set the position of the title box
        # gStyle.SetTitleY(0.985) # Set the position of the title box
        # gStyle.SetTitleStyle(Style_t style = 1001)
        # gStyle.SetTitleBorderSize(2)

        # For the axis titles:

        gStyle.SetTitleColor(1, "XYZ")
        gStyle.SetTitleFont(42, "XYZ")
        gStyle.SetTitleSize(0.06, "XYZ")
        # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size?
        # gStyle.SetTitleYSize(Float_t size = 0.02)
        gStyle.SetTitleXOffset(0.9)
        gStyle.SetTitleYOffset(1.25)
        # gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset

        # For the axis labels:

        gStyle.SetLabelColor(1, "XYZ")
        gStyle.SetLabelFont(42, "XYZ")
        gStyle.SetLabelOffset(0.007, "XYZ")
        gStyle.SetLabelSize(0.05, "XYZ")

        # For the axis:

        gStyle.SetAxisColor(1, "XYZ")
        gStyle.SetStripDecimals(True)
        gStyle.SetTickLength(0.03, "XYZ")
        gStyle.SetNdivisions(510, "XYZ")
        gStyle.SetPadTickX(
            1)  # To get tick marks on the opposite side of the frame
        gStyle.SetPadTickY(1)

        # Change for log plots:
        gStyle.SetOptLogx(0)
        gStyle.SetOptLogy(0)
        gStyle.SetOptLogz(0)

        # Postscript options:
        gStyle.SetPaperSize(20., 20.)
コード例 #20
0
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()
コード例 #21
0
ファイル: style.py プロジェクト: hroskes/makeDjetplot
def setTDRStyle(force):

  gStyle.SetCanvasBorderMode(0)
  gStyle.SetCanvasColor(kWhite)
  gStyle.SetCanvasDefH(600)
  gStyle.SetCanvasDefW(600)
  gStyle.SetCanvasDefX(0)
  gStyle.SetCanvasDefY(0)

  gStyle.SetPadBorderMode(0)
  gStyle.SetPadColor(kWhite)
  gStyle.SetPadGridX(False)
  gStyle.SetPadGridY(False)
  gStyle.SetGridColor(0)
  gStyle.SetGridStyle(3)
  gStyle.SetGridWidth(1)

  gStyle.SetFrameBorderMode(0)
  gStyle.SetFrameBorderSize(1)
  gStyle.SetFrameFillColor(0)
  gStyle.SetFrameFillStyle(0)
  gStyle.SetFrameLineColor(1)
  gStyle.SetFrameLineStyle(1)
  gStyle.SetFrameLineWidth(1)

  if force:
      gStyle.SetHistLineColor(1)
      gStyle.SetHistLineStyle(0)
      gStyle.SetHistLineWidth(1)


  gStyle.SetEndErrorSize(2)
  gStyle.SetErrorX(0.)

  gStyle.SetMarkerStyle(20)

  gStyle.SetOptFit(1)
  gStyle.SetFitFormat("5.4g")
  gStyle.SetFuncColor(2)
  gStyle.SetFuncStyle(1)
  gStyle.SetFuncWidth(1)

  gStyle.SetOptDate(0)

  gStyle.SetOptFile(0)
  gStyle.SetOptStat(0)
  gStyle.SetStatColor(kWhite)
  gStyle.SetStatFont(42)
  gStyle.SetStatFontSize(0.04)
  gStyle.SetStatTextColor(1)
  gStyle.SetStatFormat("6.4g")
  gStyle.SetStatBorderSize(1)
  gStyle.SetStatH(0.1)
  gStyle.SetStatW(0.2)


  gStyle.SetPadTopMargin(0.05)
  gStyle.SetPadBottomMargin(0.13)
  gStyle.SetPadLeftMargin(0.16)
  gStyle.SetPadRightMargin(0.04)


  gStyle.SetOptTitle(0)
  gStyle.SetTitleFont(42)
  gStyle.SetTitleColor(1)
  gStyle.SetTitleTextColor(1)
  gStyle.SetTitleFillColor(10)
  gStyle.SetTitleFontSize(0.05)


  gStyle.SetTitleColor(1, "XYZ")
  gStyle.SetTitleFont(42, "XYZ")
  gStyle.SetTitleSize(0.06, "XYZ")
  gStyle.SetTitleXOffset(0.9)
  gStyle.SetTitleYOffset(1.25)


  gStyle.SetLabelColor(1, "XYZ")
  gStyle.SetLabelFont(42, "XYZ")
  gStyle.SetLabelOffset(0.007, "XYZ")
  gStyle.SetLabelSize(0.05, "XYZ")


  gStyle.SetAxisColor(1, "XYZ")
  gStyle.SetStripDecimals(True)
  gStyle.SetTickLength(0.03, "XYZ")
  gStyle.SetNdivisions(510, "XYZ")
  gStyle.SetPadTickX(1)
  gStyle.SetPadTickY(1)

  gStyle.SetOptLogx(0)
  gStyle.SetOptLogy(0)
  gStyle.SetOptLogz(0)

  gStyle.SetPaperSize(20.,20.)


  gROOT.ForceStyle()
コード例 #22
0
def setStyle():
    gStyle.SetCanvasColor(0)
    gStyle.SetCanvasBorderSize(10)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasDefH(700)
    gStyle.SetCanvasDefW(700)

    gStyle.SetPadColor(0)
    gStyle.SetPadBorderSize(10)
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadBottomMargin(0.13)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    gStyle.SetFrameFillStyle(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetFrameLineColor(1)
    gStyle.SetFrameLineStyle(0)
    gStyle.SetFrameLineWidth(1)
    gStyle.SetFrameBorderSize(10)
    gStyle.SetFrameBorderMode(0)

    gStyle.SetNdivisions(505)

    gStyle.SetLineWidth(2)
    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetLegendFillColor(root.kWhite)
    gStyle.SetLegendFont(42)
    gStyle.SetMarkerSize(1.2)
    gStyle.SetMarkerStyle(20)

    gStyle.SetLabelSize(0.040, "X")
    gStyle.SetLabelSize(0.040, "Y")

    gStyle.SetLabelOffset(0.010, "X")
    gStyle.SetLabelOffset(0.010, "Y")

    gStyle.SetLabelFont(42, "X")
    gStyle.SetLabelFont(42, "Y")

    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleFont(42)
    gStyle.SetTitleFont(42, "X")
    gStyle.SetTitleFont(42, "Y")

    gStyle.SetTitleSize(0.045, "X")
    gStyle.SetTitleSize(0.045, "Y")

    gStyle.SetTitleOffset(1.4, "X")
    gStyle.SetTitleOffset(1.4, "Y")

    gStyle.SetTextSize(0.055)
    gStyle.SetTextFont(42)

    gStyle.SetOptStat(0)
コード例 #23
0
ファイル: draw_mt2.py プロジェクト: molamolabbb/delphys
from ROOT import gStyle, gROOT

color_list = {
    "tt": ROOT.kGreen + 2,
    "hh_SM": ROOT.kRed,
    "hh_B6": ROOT.kBlue + 1,
    "hh_B11": ROOT.kViolet
}

f = ROOT.TFile("plots.root")
cvs = ROOT.TCanvas()
cvs.SetGrid()
cvs.SetLeftMargin(0.15)
cvs.SetBottomMargin(0.12)
gStyle.SetPadTickX(True)
gStyle.SetPadTickY(True)
gStyle.SetLineWidth(2)

h_SM = f.Get("hh afc basic MT2 332 bbll")
h_B6 = f.Get("hh_B6 afc basic MT2 332 bbll")
h_B11 = f.Get("hh_B11 afc basic MT2 332 bbll")
h_tt = f.Get("tt afc basic MT2 332 blbl")
hlist = {"hh_SM": h_SM, "tt": h_tt, "hh_B6": h_B6, "hh_B11": h_B11}
legend = ROOT.TLegend(0.70, 0.55, 0.90, 0.90)
for sample in ["hh_SM", "tt", "hh_B6", "hh_B11"]:
    h = hlist[sample]
    h.SetLineColor(color_list[sample])
    h.SetTitle("")
    h.SetStats(False)
    h.SetLabelSize(0.05, "X")
    h.SetLabelSize(0.04, "Y")
コード例 #24
0
ファイル: plot_map_diff.py プロジェクト: stalbrec/JetMassUtil
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
コード例 #25
0
def log10_Q2_rto():

    #reconstructed and generated log_10(Q^2)

    #full range in Q^2
    lqbin = 0.04
    #lqmin = -8
    lqmin = -7
    #lqmax = -1.5
    lqmax = -1

    #minimal Q^2 for ratio plot
    #lrmin = -5
    lrmin = -5.2

    #can = ut.box_canvas()
    can = TCanvas("can", "can", 768, 768)
    gStyle.SetOptStat("")
    gStyle.SetPalette(1)
    gStyle.SetLineWidth(2)
    gStyle.SetPadTickY(1)

    hLog10Q2rec = ut.prepare_TH1D("hLog10Q2rec", lqbin, lqmin, lqmax)
    hLog10Q2gen = ut.prepare_TH1D("hLog10Q2gen", lqbin, lqmin, lqmax)

    #distributions for ratio plot
    hRecRto = ut.prepare_TH1D("hRecRto", lqbin, lrmin, lqmax)
    hGenRto = ut.prepare_TH1D("hGenRto", lqbin, lrmin, lqmax)
    hRtoPlot = ut.prepare_TH1D("hRtoPlot", lqbin, lrmin, lqmax)

    tree.Draw("rec_lq >> hLog10Q2rec")
    tree.Draw("true_lq >> hLog10Q2gen")

    #tree.Draw("lq2_rec >> hRecRto", "lq2_rec>"+str(lrmin))
    #tree.Draw("lq2_gen >> hGenRto", "lq2_rec>"+str(lrmin))
    #tree.Draw("lq2_rec >> hRecRto", "lq2_rec>"+str(lrmin)+" && lq2_gen>"+str(lrmin))
    #tree.Draw("lq2_gen >> hGenRto", "lq2_rec>"+str(lrmin)+" && lq2_gen>"+str(lrmin))
    tree.Draw("rec_lq >> hRecRto")
    tree.Draw("true_lq >> hGenRto")

    ut.line_h1(hLog10Q2gen, rt.kBlue)
    hLog10Q2gen.SetLineWidth(3)

    hLog10Q2rec.SetLineColor(rt.kRed)
    hLog10Q2rec.SetMarkerColor(rt.kRed)

    pdiv = 0.4
    pad1 = TPad("p1", "p1", 0., pdiv, 1., 1.)  # upper
    pad2 = TPad("p2", "p2", 0., 0., 1., pdiv)  # lower
    pad1.Draw()
    pad2.Draw()

    #upper plot

    pad1.cd()

    #frame1 = gPad.DrawFrame(lqmin, 1e-3, lqmax, 8e3)
    frame1 = gPad.DrawFrame(lqmin, 1e-3, lqmax, 6e3)
    #frame1 = gPad.DrawFrame(lqmin, 1e-3, lqmax, 1.4e3)
    siz = 0.045
    ut.set_H1_text_size(frame1, siz)
    frame1.Draw()

    frame1.SetYTitle("Events / {0:.3f}".format(lqbin))
    frame1.SetTitleOffset(1.4, "Y")

    hLog10Q2gen.Draw("same")
    hLog10Q2rec.Draw("e1same")

    lmg = 0.12
    rmg = 0.01

    ut.set_margin_lbtr(gPad, lmg, 0, 0.04, rmg)

    #leg = ut.prepare_leg(0.5, 0.75, 0.2, 0.15, siz)
    leg = ut.prepare_leg(0.2, 0.75, 0.2, 0.15, siz)
    leg.AddEntry(hLog10Q2gen, "Pythia6 generated events", "l")
    leg.AddEntry(hLog10Q2rec, "Reconstruction in low #it{Q}^{2} tagger", "lp")
    leg.Draw("same")

    ut.invert_col(rt.gPad)

    #lower plot

    pad2.cd()

    frame2 = gPad.DrawFrame(lqmin, 0.5, lqmax, 1.5 - 1e-5)
    siz2 = siz * (1. + (1. - pdiv))
    ut.set_H1_text_size(frame2, siz2)
    frame2.Draw()

    ut.put_yx_tit(frame2, "Reconstructed / generated", "log_{10}(Q^{2}) (GeV)",
                  0.85, 1.3)

    #line at one
    unity = TLine(lqmin, 1., lqmax, 1.)
    unity.SetLineColor(rt.kBlack)
    unity.SetLineWidth(1)
    unity.Draw()

    #ratio rec/gen
    hRto = hRecRto.Clone()
    hRto.Sumw2()
    hRto.Divide(hGenRto)

    for i in xrange(1, hRtoPlot.GetNbinsX() + 1):

        if hRtoPlot.GetBinLowEdge(i) < lrmin: continue

        hRtoPlot.SetBinContent(i, hRto.GetBinContent(i))
        hRtoPlot.SetBinError(i, hRto.GetBinError(i))

    #hRto.Draw("same")
    hRtoPlot.Draw("same")

    ut.set_margin_lbtr(gPad, lmg, 0.22, 0, rmg)

    leg2 = ut.prepare_leg(0.12, 0.83, 0.2, 0.1, siz2)
    leg2.AddEntry(hRto, "Ratio rec / gen", "lp")
    leg2.Draw("same")

    ut.invert_col(rt.gPad)
    can.SaveAs("01fig.pdf")
コード例 #26
0
def plot_hfptspectrum_ratios_comb(case_num, case_den, arraytype):

    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetOptStat(0000)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleOffset(1.15, "y")
    gStyle.SetTitleFont(42, "xy")
    gStyle.SetLabelFont(42, "xy")
    gStyle.SetTitleSize(0.042, "xy")
    gStyle.SetLabelSize(0.035, "xy")
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    with open("data/database_ml_parameters_%s.yml" % case_num,
              'r') as param_config_num:
        data_param_num = yaml.load(param_config_num, Loader=yaml.FullLoader)

    with open("data/database_ml_parameters_%s.yml" % case_den,
              'r') as param_config_den:
        data_param_den = yaml.load(param_config_den, Loader=yaml.FullLoader)

    folder_plots_num = data_param_num[case_num]["analysis"][
        "dir_general_plots"]
    folder_plots_den = data_param_den[case_den]["analysis"][
        "dir_general_plots"]
    if not os.path.exists(folder_plots_num):
        print("creating folder ", folder_plots_num)
        os.makedirs(folder_plots_num)
    if not os.path.exists(folder_plots_den):
        print("creating folder ", folder_plots_den)
        os.makedirs(folder_plots_den)

    folder_num_allperiods = \
        data_param_num[case_num]["analysis"][arraytype[0]]["data"]["resultsallp"]
    folder_den_allperiods = \
        data_param_den[case_den]["analysis"][arraytype[0]]["data"]["resultsallp"]
    folder_num_triggered = \
        data_param_num[case_num]["analysis"][arraytype[1]]["data"]["resultsallp"]
    folder_den_triggered = \
        data_param_den[case_den]["analysis"][arraytype[1]]["data"]["resultsallp"]

    binsmin_num = data_param_num[case_num]["analysis"][
        arraytype[0]]["sel_binmin2"]
    binsmax_num = data_param_num[case_num]["analysis"][
        arraytype[0]]["sel_binmax2"]
    name_num = data_param_num[case_num]["analysis"][
        arraytype[0]]["latexnamemeson"]
    name_den = data_param_den[case_den]["analysis"][
        arraytype[0]]["latexnamemeson"]
    latexbin2var = data_param_num[case_num]["analysis"][
        arraytype[0]]["latexbin2var"]
    plotbinMB = data_param_num[case_num]["analysis"][arraytype[0]]["plotbin"]
    plotbinHM = data_param_num[case_num]["analysis"][arraytype[1]]["plotbin"]
    br_num = data_param_num[case_num]["ml"]["opt"]["BR"]
    br_den = data_param_den[case_den]["ml"]["opt"]["BR"]
    sigmav0_num = data_param_num[case_num]["analysis"]["sigmav0"]
    sigmav0_den = data_param_den[case_den]["analysis"]["sigmav0"]

    file_num_allperiods = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                     (folder_num_allperiods, case_num, arraytype[0]))
    file_den_allperiods = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                     (folder_den_allperiods, case_den, arraytype[0]))
    file_num_triggered = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                      (folder_num_triggered, case_num, arraytype[1]))
    file_den_triggered = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                      (folder_den_triggered, case_den, arraytype[1]))

    if not file_num_allperiods or not file_num_triggered:
        print("---Warning: Issue with %s merged files. Meson ratio plot skipped (%s, %s)---" % \
                 (case_num, arraytype[0], arraytype[1]))
        return
    if not file_den_allperiods or not file_den_triggered:
        print("---Warning: Issue with %s merged files. Meson ratio plot skipped (%s, %s)---" % \
                 (case_den, arraytype[0], arraytype[1]))
        return

    rootfilename = "%s/ComparisonRatios_%s%s_%scombined%s.root" % \
                     (folder_plots_num, case_num, case_den, arraytype[0], arraytype[1])
    fileoutput = TFile.Open(rootfilename, "recreate")

    ccross = TCanvas('cRatioCross', 'The Fit Canvas')
    ccross.SetCanvasSize(1500, 1500)
    ccross.SetWindowSize(500, 500)
    maxplot = 1.0
    if case_num == "Dspp":
        maxplot = 0.5
    ccross.cd(1).DrawFrame(0.9, 0, 30, maxplot, ";#it{p}_{T} (GeV/#it{c});%s / %s" % \
                           (name_num, name_den))
    ccross.cd(1).SetLogx()

    legyield = TLegend(.4, .68, .8, .88)
    legyield.SetBorderSize(0)
    legyield.SetFillColor(0)
    legyield.SetFillStyle(0)
    legyield.SetTextFont(42)
    legyield.SetTextSize(0.025)

    colors = [kBlack, kRed, kGreen + 2, kBlue]
    for imult, iplot in enumerate(plotbinMB):
        if not iplot:
            continue
        hratio = file_num_allperiods.Get("histoSigmaCorr%d" % (imult))
        hratio.Scale(1. / (br_num * sigmav0_num * 1e12))
        hcross_den = file_den_allperiods.Get("histoSigmaCorr%d" % (imult))
        hcross_den.Scale(1. / (br_den * sigmav0_den * 1e12))
        hratio.Divide(hcross_den)
        hratio.SetLineColor(colors[imult % len(colors)])
        hratio.SetMarkerColor(colors[imult % len(colors)])
        hratio.SetMarkerStyle(21)
        hratio.SetTitle(";#it{p}_{T} (GeV/#it{c});%s / %s" %
                        (name_num, name_den))
        hratio.Draw("same")
        legyieldstring = "%.1f #leq %s < %.1f (MB)" % \
                    (binsmin_num[imult], latexbin2var, binsmax_num[imult])
        legyield.AddEntry(hratio, legyieldstring, "LEP")
        fileoutput.cd()
        hratio.Write("hratio_fromMB_%.1f_%s_%.1f" % \
                          (binsmin_num[imult], latexbin2var, binsmax_num[imult]))

    for imult, iplot in enumerate(plotbinHM):
        if not iplot:
            continue
        hratioHM = file_num_triggered.Get("histoSigmaCorr%d" % (imult))
        hratioHM.Scale(1. / (br_num * sigmav0_num * 1e12))
        hcrossHM_den = file_den_triggered.Get("histoSigmaCorr%d" % (imult))
        hcrossHM_den.Scale(1. / (br_den * sigmav0_den * 1e12))
        hratioHM.Divide(hcrossHM_den)
        hratioHM.SetLineColor(colors[imult % len(colors)])
        hratioHM.SetMarkerColor(colors[imult % len(colors)])
        hratioHM.SetTitle(";#it{p}_{T} (GeV/#it{c});%s / %s" %
                          (name_num, name_den))
        hratioHM.Draw("same")
        legyieldstring = "%.1f #leq %s < %.1f (HM)" % \
                (binsmin_num[imult], latexbin2var, binsmax_num[imult])
        legyield.AddEntry(hratioHM, legyieldstring, "LEP")
        fileoutput.cd()
        hratioHM.Write("hratio_fromHM_%.1f_%s_%.1f" % \
                          (binsmin_num[imult], latexbin2var, binsmax_num[imult]))
    legyield.Draw()

    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s_logx.eps" % \
                  (folder_plots_num, case_num, case_den, arraytype[0], arraytype[1]))
    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s_logx.eps" % \
                  (folder_plots_den, case_num, case_den, arraytype[0], arraytype[1]))

    ccross.cd(1).SetLogx(0)
    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s.eps" % \
                  (folder_plots_num, case_num, case_den, arraytype[0], arraytype[1]))
    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s.eps" % \
                  (folder_plots_den, case_num, case_den, arraytype[0], arraytype[1]))

    fileoutput.cd()
    ccross.Write()
    fileoutput.Close()

    rootfilenameden = "%s/ComparisonRatios_%s%s_%scombined%s.root" % \
                        (folder_plots_den, case_num, case_den, arraytype[0], arraytype[1])
    copyfile(rootfilename, rootfilenameden)
    print("---Output stored in:", rootfilename, "and", rootfilenameden, "---")
コード例 #27
0
def setStyle():
    TColor.InitializeColors()
    stops = array('d', [
        0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000
    ])
    red = array('d', [
        0.9764, 0.9956, 0.8186, 0.5301, 0.1802, 0.0232, 0.0780, 0.0592, 0.2082
    ])
    green = array('d', [
        0.9832, 0.7862, 0.7328, 0.7492, 0.7178, 0.6419, 0.5041, 0.3599, 0.1664
    ])
    blue = array('d', [
        0.0539, 0.1968, 0.3499, 0.4662, 0.6425, 0.7914, 0.8385, 0.8684, 0.5293
    ])
    TColor.CreateGradientColorTable(9, stops, red, green, blue, 255, 1.0)
    gStyle.SetHatchesLineWidth(1)
    gStyle.SetNumberContours(255)
    gStyle.SetNdivisions(505, "xyz")
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleColor(1)
    gStyle.SetTitleStyle(3013)
    gStyle.SetTitleFillColor(0)
    gStyle.SetTitleX(0.05)
    gStyle.SetTitleW(0.4)
    gStyle.SetTitleY(0.965)
    gStyle.SetTitleH(0.065)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasBorderSize(3)
    gStyle.SetCanvasColor(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetFuncWidth(3)
    gStyle.SetPadGridY(False)
    gStyle.SetPadGridX(False)
    gStyle.SetFrameLineWidth(1)
    gStyle.SetMarkerSize(5)
    gStyle.SetPadTickX(True)
    gStyle.SetPadTickY(True)
    #gStyle.SetPalette(1)
    gStyle.SetHistLineWidth(3)
    gStyle.SetHistLineColor(1)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetStatW(0.25)
    gStyle.SetStatH(0.25)
    gStyle.SetStatX(0.9)
    gStyle.SetStatY(0.9)
    gStyle.SetStatColor(0)
    gStyle.SetStatFormat("6.4g")
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadBottomMargin(0.16)
    gStyle.SetPadLeftMargin(0.12)
    font = 42
    gStyle.SetTextSize(.055)

    gStyle.SetTextFont(font)
    gStyle.SetLabelFont(font, "x")
    gStyle.SetTitleFont(font, "x")
    gStyle.SetLabelFont(font, "y")
    gStyle.SetTitleFont(font, "y")
    gStyle.SetLabelFont(font, "z")
    gStyle.SetTitleFont(font, "z")

    gStyle.SetTitleSize(.055, "x")
    gStyle.SetTitleSize(.055, "y")
    gStyle.SetTitleSize(.05, "z")
    gStyle.SetLabelSize(.05, "x")
    gStyle.SetLabelSize(.05, "y")
    gStyle.SetLabelSize(.05, "z")
    gStyle.SetLabelOffset(0.014, "x")
    gStyle.SetLabelOffset(0.006, "y")
    gStyle.SetLabelOffset(0.008, "z")
    gStyle.SetTitleOffset(1, "y")
    gStyle.SetTitleXOffset(1.2)

    # use bold lines and markers
    gStyle.SetMarkerStyle(20)
    gStyle.SetMarkerColor(1)
    gStyle.SetMarkerSize(1.2)
    gStyle.SetLineStyleString(2, "[12 12]")
    # postscript dashes

    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
コード例 #28
0
ファイル: plot_m_pipi.py プロジェクト: BoZheng-usc/DDPIPI
__author__ = "Maoqiang JING <*****@*****.**>"
__copyright__ = "Copyright (c) Maoqiang JING"
__created__ = "[2019-11-05 Tue 16:27]"

import ROOT
from ROOT import TCanvas, gStyle, TTree, THStack
from ROOT import TFile, TH1F, TLegend, TArrow
import sys, os
import logging
from math import *
from tools import *
logging.basicConfig(level=logging.DEBUG,
                    format=' %(asctime)s - %(levelname)s- %(message)s')
gStyle.SetOptTitle(0)  # quench title
gStyle.SetPadTickX(1)  # dicide on boxing on or not of x and y axis
gStyle.SetPadTickY(1)  # dicide on boxing on or not of x and y axis


def set_legend(legend, h1, h2, h3, h4, h5, title):
    legend.AddEntry(h1, 'data')
    legend.AddEntry(h2, 'inclusive MC: open charm')
    legend.AddEntry(h3, 'inclusive MC: q#bar{q}')
    legend.AddEntry(h4, 'D_{1}(2420)D')
    legend.AddEntry(h5, '#psi(3770)#pi^{+}#pi^{-}')
    legend.SetHeader(title)
    legend.SetBorderSize(0)
    legend.SetFillColor(0)
    legend.SetLineColor(0)


def rm_pipi_fill(t1, t2, t3, t4, t5, h1, h2, h3, h4, h5, runNolow, runNoup):
コード例 #29
0
def main():
    # usage description
    usage = "Example: ./scripts/plotSignificance.py -l logs -f qq --massrange 1200 6000 100"
    # input parameters
    parser = ArgumentParser(
        description='Script that plots significance for specified mass points',
        epilog=usage)
    parser.add_argument('analysis', type=str, help='Analysis name')
    parser.add_argument('model', type=str, help='Model name')

    parser.add_argument("-M",
                        "--method",
                        dest="method",
                        choices=['ProfileLikelihood', 'HybridNew', 'theta'],
                        default='ProfileLikelihood',
                        help="Method to calculate upper limits",
                        metavar="METHOD")
    parser.add_argument(
        '--fit_function',
        type=str,
        default="dijet4",
        help="Name of fit function used for background estimate")

    parser.add_argument(
        "--sigRange",
        dest="sigRange",
        type=float,
        default=2.5,
        help="Significance range to plot (default: %(default)f)")

    parser.add_argument(
        "--postfix",
        dest="postfix",
        default='',
        help="Postfix for the output plot name (default: %(default)s)")

    parser.add_argument(
        "--fileFormat",
        dest="fileFormat",
        default='pdf',
        help="Format of the output plot (default: %(default)s)")

    parser.add_argument("--extraText",
                        dest="extraText",
                        default='Preliminary',
                        help="Extra text on the plot (default: %(default)s)")

    parser.add_argument(
        "--lumi_sqrtS",
        dest="lumi_sqrtS",
        default='19.7 fb^{-1} (13 TeV)',
        help=
        "Integrated luminosity and center-of-mass energy (default: %(default)s)"
    )

    parser.add_argument("--printResults",
                        dest="printResults",
                        default=False,
                        action="store_true",
                        help="Print results to the screen")
    parser.add_argument('--fitTrigger',
                        action='store_true',
                        help="Use trigger fit")
    parser.add_argument('--correctTrigger',
                        action='store_true',
                        help="Use trigger correction")
    parser.add_argument('--useMCTrigger',
                        action='store_true',
                        help="Use MC trigger emulation")
    parser.add_argument("--noSyst",
                        action="store_true",
                        help="Make plots for limits without systematics")
    parser.add_argument(
        "--freezeNuisances",
        type=str,
        help="Make plots for limits with frozen nuisance parameters")

    mass_group = parser.add_mutually_exclusive_group(required=True)
    mass_group.add_argument(
        "--mass",
        type=int,
        nargs='*',
        default=1000,
        help=
        "Mass can be specified as a single value or a whitespace separated list (default: %(default)i)"
    )
    mass_group.add_argument(
        "--massrange",
        type=int,
        nargs=3,
        help="Define a range of masses to be produced. Format: min max step",
        metavar=('MIN', 'MAX', 'STEP'))
    mass_group.add_argument("--masslist",
                            help="List containing mass information")

    args = parser.parse_args()

    # mass points for which resonance shapes will be produced
    input_masses = []

    if args.massrange != None:
        MIN, MAX, STEP = args.massrange
        input_masses = range(MIN, MAX + STEP, STEP)
    elif args.masslist != None:
        # A mass list was provided
        print "Will create mass list according to", args.masslist
        masslist = __import__(args.masslist.replace(".py", ""))
        input_masses = masslist.masses
    else:
        input_masses = args.mass
    # sort masses
    input_masses.sort()

    # arrays holding results
    masses = array('d')
    significances = array('d')
    p0_values = array('d')

    for mass in input_masses:
        masses.append(mass)
        #print ">> Reading results for resonance with m = %i GeV..."%(int(mass))
        log_file = open(
            limit_config.get_combine_log_path(
                args.analysis,
                args.model,
                mass,
                args.fit_function,
                args.method,
                what="significance",
                systematics=(not args.noSyst),
                frozen_nps=args.freezeNuisances,
                fitTrigger=args.fitTrigger,
                correctTrigger=args.correctTrigger,
                useMCTrigger=args.useMCTrigger), 'r')

        if args.method == 'theta':
            logName = logName.replace('significance_', '')

        # read the log file
        for line in log_file:
            if args.method == 'theta':
                if re.search("^{'signal': {'Z':", line):
                    significances.append(
                        float(line.split()[-1].lstrip('[').rstrip('}').rstrip(
                            ']')))
            else:
                if re.search("^Significance:", line):
                    significances.append(float(line.split()[1]))
                elif re.search("^Null p-value:", line):
                    p0_values.append(float(line.split()[2]))

        if len(masses) != len(significances):
            print "** ERROR: ** Could not find significance for m =", int(
                mass), "GeV. Aborting."
            sys.exit(1)
        if len(masses) != len(p0_values):
            print "** ERROR: ** Could not find p0 value for m =", int(
                mass), "GeV. Aborting."
            sys.exit(1)
        # Allow only positive fluctuations
        if significances[-1] < 0:
            significances[-1] = 0.

    if args.printResults:
        print "masses =", masses.tolist()
        print "significances =", significances.tolist()
        print "p0_values =", p0_values.tolist()

    # import ROOT stuff
    from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraph, TCanvas, TLegend
    from ROOT import kGreen, kYellow, kWhite, kRed, kBlue

    gROOT.SetBatch(kTRUE)
    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.06, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelSize(0.05, "XYZ")
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasColor(kWhite)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.15)
    gROOT.ForceStyle()

    graph_sig = TGraph(len(masses), masses, significances)
    graph_sig.GetXaxis().SetTitle("Resonance mass [GeV]")
    graph_sig.GetYaxis().SetTitle("p_0")
    graph_sig.GetYaxis().SetTitleOffset(1.2)
    graph_sig.GetYaxis().SetRangeUser(0., args.sigRange)
    graph_sig.SetLineWidth(2)
    graph_sig.SetLineColor(kRed)
    graph_sig.SetMarkerStyle(21)
    graph_sig.SetMarkerSize(1)
    graph_sig.SetMarkerColor(kBlue)

    c = TCanvas("c", "", 800, 800)
    c.cd()

    graph_sig.Draw("ALP")

    # draw the lumi text on the canvas
    CMS_lumi.extraText = args.extraText
    CMS_lumi.lumi_sqrtS = args.lumi_sqrtS  # used with iPeriod = 0 (free form)
    iPos = 11
    iPeriod = 0

    CMS_lumi.CMS_lumi(c, iPeriod, iPos)

    gPad.RedrawAxis()

    c.SetGridx()
    c.SetGridy()
    fileName = limit_config.paths[
        "limit_plots"] + '/significance_%s_%s_%s_%s.%s' % (
            args.method, args.analysis, args.model + args.postfix,
            args.fit_function, args.fileFormat.lower())
    c.SaveAs(fileName)
    #print "Significance plot saved to '%s'"%(fileName)

    graph_p0 = TGraph(len(masses), masses, p0_values)
    graph_p0.GetXaxis().SetTitle("Resonance mass [GeV]")
    graph_p0.GetYaxis().SetTitle("p_{0} (local)")
    graph_p0.GetYaxis().SetTitleOffset(1.2)
    graph_p0.GetYaxis().SetRangeUser(1.e-3, 1.)
    graph_p0.SetLineWidth(2)
    graph_p0.SetLineColor(kRed)
    graph_p0.SetMarkerStyle(21)
    graph_p0.SetMarkerSize(1)
    graph_p0.SetMarkerColor(kBlue)
    c_p0 = TCanvas("c_p0", "", 800, 800)
    c_p0.SetLogy()
    c_p0.cd()

    graph_p0.Draw("ALP")

    # draw the lumi text on the canvas
    # draw the lumi text on the canvas
    CMS_lumi.extraText = args.extraText
    CMS_lumi.lumi_sqrtS = args.lumi_sqrtS  # used with iPeriod = 0 (free form)
    iPos = 11
    iPeriod = 0

    CMS_lumi.CMS_lumi(c, iPeriod, iPos)

    #Root.CMSLabel(0.2, 0.2, "Internal", 1, 0.65)

    gPad.RedrawAxis()

    c_p0.SetGridx()
    c_p0.SetGridy()
    fileName = limit_config.paths["limit_plots"] + '/p0_%s_%s_%s_%s.%s' % (
        args.method, args.analysis, args.model + args.postfix,
        args.fit_function, args.fileFormat.lower())
    c_p0.SaveAs(fileName)
    print "p0 plot saved to '%s'" % (fileName)
コード例 #30
0
def applyRootStyle():

    from ROOT import gROOT, gStyle, kWhite, kBlack, TColor

    # Start from a plain default
    gROOT.SetStyle("Plain")

    lhcbMarkerType = 8
    lhcbMarkerSize = 0.8
    lhcbFont = 62
    lhcbStatFontSize = 0.02
    lhcbStatBoxWidth = 0.12
    lhcbStatBoxHeight = 0.12
    lhcbWidth = 1
    lhcbTextSize = 0.05
    lhcbLabelSize = 0.035
    lhcbAxisLabelSize = 0.035
    lhcbForeColour = kBlack

    gStyle.SetFrameBorderMode(0)
    gStyle.SetPadBorderMode(0)

    # canvas options
    gStyle.SetCanvasBorderSize(0)
    gStyle.SetCanvasBorderMode(0)

    # fonts
    gStyle.SetTextFont(lhcbFont)
    gStyle.SetTextSize(lhcbTextSize)
    gStyle.SetLabelFont(lhcbFont, "x")
    gStyle.SetLabelFont(lhcbFont, "y")
    gStyle.SetLabelFont(lhcbFont, "z")
    gStyle.SetLabelSize(lhcbLabelSize, "x")
    gStyle.SetLabelSize(lhcbLabelSize, "y")
    gStyle.SetLabelSize(lhcbLabelSize, "z")
    gStyle.SetTitleFont(lhcbFont)
    gStyle.SetTitleSize(lhcbAxisLabelSize, "x")
    gStyle.SetTitleSize(lhcbAxisLabelSize, "y")
    gStyle.SetTitleSize(lhcbAxisLabelSize, "z")
    gStyle.SetTitleColor(kWhite)
    gStyle.SetTitleFillColor(kWhite)
    gStyle.SetTitleColor(kBlack)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleTextColor(kBlack)

    # set title position
    gStyle.SetTitleX(0.15)
    gStyle.SetTitleY(0.97)
    # turn off Title box
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleTextColor(lhcbForeColour)
    gStyle.SetTitleColor(lhcbForeColour)

    # use bold lines and markers
    gStyle.SetLineWidth(lhcbWidth)
    gStyle.SetFrameLineWidth(lhcbWidth)
    gStyle.SetHistLineWidth(lhcbWidth)
    gStyle.SetFuncWidth(lhcbWidth)
    gStyle.SetGridWidth(lhcbWidth)
    gStyle.SetLineStyleString(2, "[12 12]")
    gStyle.SetMarkerStyle(lhcbMarkerType)
    gStyle.SetMarkerSize(lhcbMarkerSize)

    # Grid
    # gStyle.SetGridStyle(3)

    # label offsets
    gStyle.SetLabelOffset(0.015)

    # by default, do not display histogram decorations:
    gStyle.SetOptStat(1111)
    # show probability, parameters and errors
    gStyle.SetOptFit(1011)

    # look of the statistics box:
    gStyle.SetStatBorderSize(1)
    gStyle.SetStatFont(lhcbFont)
    gStyle.SetStatFontSize(lhcbStatFontSize)
    gStyle.SetStatX(0.9)
    gStyle.SetStatY(0.9)
    gStyle.SetStatW(lhcbStatBoxWidth)
    gStyle.SetStatH(lhcbStatBoxHeight)

    # put tick marks on top and RHS of plots
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    # histogram divisions
    gStyle.SetNdivisions(505, "x")
    gStyle.SetNdivisions(510, "y")

    # Style for 2D zcol plots
    NRGBs = 5
    NCont = 255
    from array import array
    stops = array('d', [0.00, 0.34, 0.61, 0.84, 1.00])
    red = array('d', [0.00, 0.00, 0.87, 1.00, 0.51])
    green = array('d', [0.00, 0.81, 1.00, 0.20, 0.00])
    blue = array('d', [0.51, 1.00, 0.12, 0.00, 0.00])
    TColor().CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont)
    gStyle.SetNumberContours(NCont)

    # Force the style
    gROOT.ForceStyle()