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);
Пример #2
0
            pad2.cd()
            #pad2.SetGridx(2)
            #pad2.SetGridy(2)
            bins = h_ratio.GetNbinsX()
            LowEdge = h_ratio.GetBinLowEdge(1)
            HighEdge = h_ratio.GetBinLowEdge(bins + 1)
            #LowEdge = h_ratio.GetBinLowEdge(0)
            #HighEdge = h_ratio.GetBinLowEdge(bins+2)
            line = TLine(LowEdge, 1, HighEdge, 1)
            line.SetLineColor(kBlack)
            h_ratio.GetXaxis().SetRangeUser(values["min"], values["max"])
            h_ratio.SetFillColor(kGray + 3)
            h_ratio.SetFillStyle(3001)
            h_ratio.Draw("E2")
            h_ratio.SetMinimum(0.0)
            h_ratio.SetMaximum(2.0)
            for i in range(len(hist_ratio_vars)):
                hist_ratio_vars[i].Draw("EPsame")
            line.Draw("same")

            c.SaveAs("%s%s_%s_SF%s_isNorm%s_wtStat%s.png" %
                     (outputdir, plotname, hist_nom_name, syst, normalization,
                      showStats))
    file.close()


# Draw all canvases
if __name__ == "__main__":
    gStyle.SetLegendTextSize(0.05)
    plotSysts()
Пример #3
0
def make_plot_all_rods(error_dict, rod_dict, name):
    

    leg = TLegend(0,0,0,0)
    if 'lock' in name:
        leg = TLegend(0.18,0.85,0.50,0.55)
    else:
        leg = TLegend(0.18,0.85,0.40,0.55)
    leg.SetLineColor(0)
    leg.SetFillStyle(0)
    leg.SetShadowColor(0)
    leg.SetBorderSize(0)
    leg.SetNColumns(3)
    gStyle.SetLegendTextSize(0.045)

   
    v_hists = []
    #for e,c in zip(error_bits, error_colors):
    for e in error_bits:
        h = TH1F('h'+e,'h'+e, len(rod_dict), 0, len(rod_dict))
        h.SetFillStyle(1001)
        h.SetLineWidth(0)
        v_hists.append(h)
        v_hists[-1].SetDirectory(0)
        if bin(int('0x'+e, 16))[2:].zfill(4) == '0111':
            leg.AddEntry(v_hists[-1],'GOL 3',"f");
        elif bin(int('0x'+e, 16))[2:].zfill(4) == '1011':
            leg.AddEntry(v_hists[-1],'GOL 2',"f");
        elif bin(int('0x'+e, 16))[2:].zfill(4) == '1101':
            leg.AddEntry(v_hists[-1],'GOL 1',"f");
        elif bin(int('0x'+e, 16))[2:].zfill(4) == '1110':
            leg.AddEntry(v_hists[-1],'GOL 0',"f");
        else:
            leg.AddEntry(v_hists[-1],bin(int('0x'+e, 16))[2:].zfill(4),"f");
    h = leg.GetY2()-leg.GetY1();
    w = leg.GetX2()-leg.GetX1()*.6;
    leg.SetMargin(leg.GetNColumns()*h/(leg.GetNRows()*w))
    

    for key,val in error_dict.items():
        idx_rod = 0
        for i, key2 in enumerate(rod_dict):
            if key2 == key[:8]:
                idx_rod = i
        v_hists[int(key[11:12], 16)].Fill(idx_rod, val)
  
    stack  = THStack("stack","stack")
    for hist in v_hists:
        stack.Add(hist)

    if 'buff' in name:
        c1 = TCanvas( 'c1', 'c1', 2000, 500)
    else:
        c1 = TCanvas( 'c1', 'c1', 1000, 500)


    h1 = TH1F('h_1','h_1', len(rod_dict), 0, len(rod_dict))
    for i, key in enumerate(rod_dict):
        h1.GetXaxis().SetBinLabel(i+1,key)
        h1.SetBinContent(i+1,rod_dict[key])

 
    h1.GetXaxis().LabelsOption("v")
    h1.GetXaxis().SetTitle("ROD")
    h1.GetXaxis().SetTitleOffset(2.2)
    h1.GetYaxis().SetTitle("# of rocketio errors")
    h1.SetLineColor(kRed)
    h1.SetLineWidth(1)

    leg.AddEntry(h1,'total',"l");
    
    c1.SetBottomMargin(0.23)  
    h1.GetXaxis().SetTitle("ROD")
    h1.Draw("HIST")
    stack.Draw("PFC PLC SAME HIST")
    h1.Draw("SAMEHIST")
    AtlasStyle.ATLAS_LABEL(0.19,.88, 1, "Internal")
    leg.Draw()
    c1.Update()
    c1.Print("plots/"+name +".pdf")
    c1.Clear()
Пример #4
0
def make_time_rod_evo(error_dict, rod_dict, results, doLock):
 
    c2 = TCanvas( 'c2', 'c2', 1000, 600)
    leg = TLegend(0.18,0.85,0.45,0.55)
    leg.SetLineColor(0)
    leg.SetFillStyle(0)
    leg.SetShadowColor(0)
    leg.SetBorderSize(0)
    leg.SetNColumns(2)
     
    R15 = TLine(431,0,431,60)
    R15.SetLineColorAlpha(kPink+10,0.4)
    R15.SetLineWidth(4)

    R16 = TLine(1820,0,1820,60)
    R16.SetLineColorAlpha(kMagenta+10,0.4)
    R16.SetLineWidth(4)

    R17 = TLine(3376,0,3376,60)
    R17.SetLineColorAlpha(kGreen-3,0.4)
    R17.SetLineWidth(4)


    TS1 = TLine(431,0,432,60)
    TS1.SetLineColorAlpha(kPink+10,0.5)
    TS1.SetLineWidth(5)

    TS2 = TLine(1415,0,1415,60)
    TS2.SetLineColorAlpha(kMagenta+3,0.5)
    TS2.SetLineWidth(5)

    leg2 = TLegend(0.18,0.45,0.35,0.55)
    leg2.SetLineColor(0)
    leg2.SetFillStyle(0)
    leg2.SetShadowColor(0)
    leg2.SetBorderSize(0)
    gStyle.SetLegendTextSize(0.030)

    leg2.AddEntry(R15, "End of 2015", 'lf')
    leg2.AddEntry(R16, "End of 2016", 'lf')
    leg2.AddEntry(R17, "End of 2017", 'lf')
    #leg2.AddEntry(TS2, "TS2", 'lf')


    for key,val in rod_dict.items(): 
        TS1.SetY2(val*0.5)
        TS2.SetY2(val+1)

        R15.SetY2(val*0.3)
        R16.SetY2(val*0.5)
        R17.SetY2(val*0.8)

        times = {}
        times.clear()
        for e in error_bits:
            times['0x'+e] = [0] 
        for error in results:
            pos_rod  = error.text.find("ROD") + 4
            pos_lock = error.text.find("Lock") + 15
            pos_buff = error.text.find("buffer") + 17

            if error.msgID == 'TRT::ROD05Module':
                rod  = '0x'+str(error.text[pos_rod:pos_rod+6])
            else:
                rod  = str(error.text[pos_rod:pos_rod+8])

            lock = str(error.text[pos_lock:pos_lock+3])
            buff = str(error.text[pos_buff:pos_buff+3])

            if key == rod and doLock and lock != '0xf':
                times[lock].append(error.sb_total_time)


        leg.Clear()
        mg = TMultiGraph()

        for e in error_bits:
            errs = []
            for i,x in enumerate(times['0x'+e]):
                errs.append(i+0.0)
            errs.append(errs[-1])
            #times['0x'+e].append(1800.0)
            times['0x'+e].append(results[-1].sb_total_time)
            gr = TGraph(len(times['0x'+e]), array(times['0x'+e]), array(errs))
            gr.SetMarkerSize(0.7)
            if bin(int('0x'+e, 16))[2:].zfill(4) == '0111':
                leg.AddEntry(gr,'GOL 3',"lp");
            elif bin(int('0x'+e, 16))[2:].zfill(4) == '1011':
                leg.AddEntry(gr,'GOL 2',"lp");
            elif bin(int('0x'+e, 16))[2:].zfill(4) == '1101':
                leg.AddEntry(gr,'GOL 1',"lp");
            elif bin(int('0x'+e, 16))[2:].zfill(4) == '1110':
                leg.AddEntry(gr,'GOL 0',"lp");
            else:
                leg.AddEntry(gr,bin(int('0x'+e, 16))[2:].zfill(4),"lp");
            mg.Add(gr,"pl");

        mg.SetTitle("; Hours of stable beams; # of rocketio io lock errors");
        mg.Draw("PMC PLC a");
        R15.Draw()
        R16.Draw()
        R17.Draw()
        #TS1.Draw()
        #TS2.Draw()
        
        AtlasStyle.ATLAS_LABEL(0.19,.88, 1, "Internal")
        leg.Draw()
        leg2.Draw()
        AtlasStyle.myText(0.4, 0.88, kBlack, "ROD: " + key)
        
        
        leg.SetMargin(0.5)
        gPad.Modified()
        mg.GetXaxis().SetLimits(0,results[-1].sb_total_time)
        mg.SetMinimum(0.)
        mg.SetMaximum(val+1)
        c2.Update()
        c2.Print("plots/time_"+key+".pdf")
        c2.Clear()
Пример #5
0
margin_low = 0.05
margin_high = 0.14

# canvas settings
gStyle.SetCanvasColor(0)
gStyle.SetPadLeftMargin(0.1)
gStyle.SetPadBottomMargin(0.12)
gStyle.SetPadRightMargin(0.05)
gStyle.SetPadTopMargin(0.1)
singlepad = False  # make one canvas per pT bin

# legend settings
gStyle.SetLegendFillColor(0)
# gStyle.SetLegendBorderSize(0)
gStyle.SetLegendFont(textfont)
gStyle.SetLegendTextSize(textsize)

formats = ["pdf", "png", "root"]  # output file formats
normalise = True
rebin = 1

path_file_sig = "../codeHF/AnalysisResults_O2.root"
path_file_bkg = "../codeHF/AnalysisResults_O2.root"

# variables = ["d0Prong0", "d0Prong1", "d0Prong2", "PtProng0", "PtProng1", "PtProng2", "CPA", "Eta", "Declength"]
variables = ["CPA", "Pt", "Eta"]

decays = ["d0"]

main()
def cebefo_style():
    #TStyle *gStyle = new TStyle("gStyle","gStyle");

    #our settings, maybe in the future we could create a more personal style
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetHistLineWidth(3)
    gStyle.SetMarkerStyle(1)

    gStyle.SetTextSize(0.065)

    gStyle.SetOptFit(1111)
    # axis
    gStyle.SetTitleSize(.05, "X")
    #.055
    gStyle.SetTitleOffset(1.1, "X")
    #1.2,0.9
    #gStyle.SetLabelOffset(0.003,"X");
    gStyle.SetLabelSize(.05, "X")
    #gStyle.SetLabelFont(42,"X");

    gStyle.SetTitleSize(.05, "Y")
    #.055
    gStyle.SetTitleOffset(1.1, "Y")
    #gStyle.SetLabelOffset(0.008,"Y");
    gStyle.SetLabelSize(.05, "Y")
    #gStyle.SetLabelFont(42,"Y");

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

    gStyle.SetTitleSize(.05, "Z")
    gStyle.SetTitleOffset(1.8, "Z")
    #gStyle.SetLabelOffset(0.008,"Z");
    gStyle.SetLabelSize(0.06, "Z")
    #gStyle.SetLabelFont(42,"Z");

    gStyle.SetLegendTextSize(0.04)
    #gStyle.SetStatFontSize(0.2);

    #histograms properties
    gStyle.SetOptStat(112210)

    #gStyle.SetStripDecimals(False)
    #gStyle.SetLineStyleString(11,"20 10")

    # canvas
    #gStyle.SetCanvasColor(0);
    #gStyle.SetCanvasBorderSize(10);
    #gStyle.SetCanvasBorderMode(0);
    #gStyle.SetCanvasDefW(600);
    #gStyle.SetCanvasDefH(600);

    # pads
    # gStyle.SetPadColor(0);
    # gStyle.SetPadBorderSize(10);
    # gStyle.SetPadBorderMode(0);
    gStyle.SetPadLeftMargin(.12)
    gStyle.SetPadRightMargin(.02)
    gStyle.SetPadBottomMargin(.12)
    gStyle.SetPadTopMargin(.07)
    gStyle.SetPadGridX(1)
    gStyle.SetPadGridY(1)
Пример #7
0
gStyle.SetTitleFont(font,"z");

gStyle.SetLabelSize(tsize,"x");
gStyle.SetTitleSize(tsize,"x");
gStyle.SetLabelSize(tsize,"y");
gStyle.SetTitleSize(tsize,"y");
gStyle.SetLabelSize(tsize,"z");
gStyle.SetTitleSize(tsize,"z");

gStyle.SetNdivisions(508);

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

legend_tsize=0.04
gStyle.SetLegendTextSize(legend_tsize);

class pixelGraph():
    def __init__(self, col, row , name='', title=''):
        self.col=col
        self.row=row
        self.x_list=[]
        self.y_list=[]
        self.y_min=0
        self.y_max=0
        self.x_min=0
        self.x_max=0
        self.y_offset=0
        self.bool_xrange=False
        self.bool_yrange=False