Ejemplo n.º 1
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, kViolet - 1, kOrange + 2, kAzure + 1,
        kOrange - 7
    ]
    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, "---")
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()
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
    def draw_fit(self, save_name, flag_plot_message=None, shade_regions=False):
        #Draw
        self.histo_to_fit.GetXaxis().SetTitle("Invariant Mass L_{c}^{+}(GeV/c^{2})")
        self.histo_to_fit.SetStats(0)

        c1 = TCanvas('c1', 'The Fit Canvas', 700, 700)
        c1.cd()
        gStyle.SetOptStat(0)
        gStyle.SetCanvasColor(0)
        gStyle.SetFrameFillColor(0)
        c1.cd()
        self.histo_to_fit.GetXaxis().SetRangeUser(self.fit_range_low, self.fit_range_up)
        # Adjust y-range for good readability
        histo_min = self.histo_to_fit.GetMinimum() * 0.9
        histo_max = self.histo_to_fit.GetMaximum() + (self.histo_to_fit.GetMaximum() - histo_min)
        self.histo_to_fit.GetYaxis().SetRangeUser(histo_min, histo_max)
        self.histo_to_fit.SetMarkerStyle(20)
        self.histo_to_fit.SetMarkerSize(1)
        #histo.SetMinimum(0.)
        self.histo_to_fit.Draw("PE")
        self.bkg_tot_fit_func.Draw("same")
        self.tot_fit_func.Draw("same")
        c1.Update()

        # Shading sideband area
        sideband_fill_left = None
        sideband_fill_right = None
        sig_fill = None
        bkg_fill = None
        if shade_regions:
            sideband_fill_left = self.bkg_tot_fit_func.Clone("bkg_fit_fill_left")
            sideband_fill_left.SetRange(self.mean_fit - 9 * self.sigma_fit,
                                        self.mean_fit - self.nsigma_sideband * self.sigma_fit)
            sideband_fill_left.SetLineWidth(0)
            sideband_fill_left.SetFillColor(self.bkg_tot_fit_func.GetLineColor())
            sideband_fill_left.SetFillStyle(3001)
            sideband_fill_left.Draw("same fc")

            sideband_fill_right = self.bkg_tot_fit_func.Clone("bkg_fit_fill_right")
            sideband_fill_right.SetRange(self.mean_fit + self.nsigma_sideband * self.sigma_fit,
                                         self.mean_fit + 9 * self.sigma_fit)
            sideband_fill_right.SetLineWidth(0)
            sideband_fill_right.SetFillColor(self.bkg_tot_fit_func.GetLineColor())
            sideband_fill_right.SetFillStyle(3001)
            sideband_fill_right.Draw("same fc")

            # Shading bakground in signal region
            bkg_fill = self.bkg_tot_fit_func.Clone("bkg_fit_under_sig_fill")
            bkg_fill.SetRange(self.mean_fit - self.nsigma_sig * self.sigma_fit,
                              self.mean_fit + self.nsigma_sig * self.sigma_fit)
            bkg_fill.SetLineWidth(0)
            bkg_fill.SetFillColor(kRed + 2)
            bkg_fill.SetFillStyle(3001)
            bkg_fill.Draw("same fc")

            # Shading signal above background
            n_points = 100
            dx = (2 * self.nsigma_sig * self.sigma_fit) / n_points
            sig_fill = TGraph(2 * n_points)
            sig_fill.SetFillColor(kGreen + 2)
            sig_fill.SetFillStyle(3001)
            range_low = self.mean_fit - self.nsigma_sig * self.sigma_fit
            range_up = self.mean_fit + self.nsigma_sig * self.sigma_fit
            for ip in range(n_points):
                sig_fill.SetPoint(ip, range_low + ip * dx,
                                  self.tot_fit_func.Eval(range_low + ip * dx))
                sig_fill.SetPoint(n_points + ip, range_up - ip * dx,
                                  self.bkg_tot_fit_func.Eval(range_up - ip * dx))
            sig_fill.Draw("f")

        #write info.
        pinfos = TPaveText(0.12, 0.7, 0.47, 0.89, "NDC")
        pinfos.SetBorderSize(0)
        pinfos.SetFillStyle(0)
        pinfos.SetTextAlign(11)
        pinfos.SetTextSize(0.03)
        pinfom = TPaveText(0.5, 0.7, 1., .89, "NDC")
        pinfom.SetTextAlign(11)
        pinfom.SetBorderSize(0)
        pinfom.SetFillStyle(0)
        pinfom.SetTextColor(kBlue)
        pinfom.SetTextSize(0.03)
        chisquare_ndf = self.tot_fit_func.GetNDF()
        chisquare_ndf = self.tot_fit_func.GetChisquare() / chisquare_ndf if chisquare_ndf > 0. \
                else 0.
        pinfom.AddText("#chi^{2}/NDF = %f" % (chisquare_ndf))
        pinfom.AddText("%s = %.3f #pm %.3f" % (self.sig_fit_func.GetParName(1),\
            self.sig_fit_func.GetParameter(1), self.sig_fit_func.GetParError(1)))
        pinfom.AddText("%s = %.3f #pm %.3f" % (self.sig_fit_func.GetParName(2),\
            self.sig_fit_func.GetParameter(2), self.sig_fit_func.GetParError(2)))
        pinfom.Draw()
        flag_info = None
        if flag_plot_message is not None:
            flag_info = TPaveText(0.5, 0.5, 1., 0.68, "NDC")
            flag_info.SetBorderSize(0)
            flag_info.SetFillStyle(0)
            flag_info.SetTextAlign(11)
            flag_info.SetTextSize(0.03)
            for t in flag_plot_message:
                text = flag_info.AddText(t)
                text.SetTextColor(kRed + 2)
            flag_info.Draw()

        sig_text = pinfos.AddText("S = %.0f #pm %.0f " % (self.yield_sig, self.yield_sig_err))
        sig_text.SetTextColor(kGreen + 2)
        bkg_text = pinfos.AddText("B (%.0f#sigma) = %.0f #pm %.0f" % \
            (self.nsigma_sig, self.yield_bkg, self.yield_bkg_err))
        bkg_text.SetTextColor(kRed + 2)
        sig_over_back = self.yield_sig / self.yield_bkg if self.yield_bkg > 0. else 0.
        pinfos.AddText("S/B (%.0f#sigma) = %.4f " % (self.nsigma_sig, sig_over_back))
        pinfos.AddText("Signif (%.0f#sigma) = %.1f #pm %.1f " %\
            (self.nsigma_sig, self.significance, self.errsignificance))
        pinfos.Draw()

        c1.Update()
        c1.SaveAs(save_name)
        c1.Close()
Ejemplo n.º 5
0
 def loadstyle():
     gStyle.SetOptStat(0)
     gStyle.SetOptStat(0000)
     gStyle.SetPalette(0)
     gStyle.SetCanvasColor(0)
     gStyle.SetFrameFillColor(0)
Ejemplo n.º 6
0
    def initStyle():
        gROOT.SetStyle("Plain")

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

        # For the line:
        gStyle.SetLineWidth(2)

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

        # For the frame:
        gStyle.SetFrameBorderMode(0)
        gStyle.SetFrameBorderSize(1)
        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(2)
        # gStyle.SetLegoInnerR(Float_t rad = 0.5)
        # gStyle.SetNumberContours(Int_t number = 20)

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

        gStyle.SetMarkerStyle(8)
        gStyle.SetMarkerSize(1)

        #For the fit/function:
        gStyle.SetOptFit(0)
        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.11)
        gStyle.SetPadBottomMargin(0.13)
        gStyle.SetPadLeftMargin(0.17)
        gStyle.SetPadRightMargin(0.07)

        # For the Global title:
        gStyle.SetOptTitle(0)
        gStyle.SetTitleFont(42)
        gStyle.SetTitleColor(1)
        gStyle.SetTitleTextColor(1)
        gStyle.SetTitleFillColor(10)
        gStyle.SetTitleFontSize(0.04)
        # gStyle.SetTitleH(0) # Set the height of the title box
        # gStyle.SetTitleW(0) # Set the width of the title box
        #gStyle.SetTitleX(0.35) # Set the position of the title box
        #gStyle.SetTitleY(0.986) # Set the position of the title box
        # gStyle.SetTitleStyle(Style_t style = 1001)
        #gStyle.SetTitleBorderSize(0)

        # For the axis titles:
        gStyle.SetTitleColor(1, "XYZ")
        gStyle.SetTitleFont(42, "XYZ")
        gStyle.SetTitleSize(0.05, "XYZ")
        # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size?
        # gStyle.SetTitleYSize(Float_t size = 0.02)
        gStyle.SetTitleXOffset(1.)
        gStyle.SetTitleYOffset(1.3)
        #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.035, "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)

        gStyle.SetPalette(1)  #(1,0)

        # another top group addition
        gStyle.SetHatchesSpacing(1.0)

        # Postscript options:
        gStyle.SetPaperSize(20., 20.)
        #gStyle.SetPaperSize(TStyle.kA4)
        #gStyle.SetPaperSize(27., 29.7)
        #TGaxis.SetMaxDigits(3)
        # gStyle.SetLineScalePS(Float_t scale = 3)
        # gStyle.SetLineStyleString(Int_t i, const char* text)
        # gStyle.SetHeaderPS(const char* header)
        # gStyle.SetTitlePS(const char* pstitle)
        #gStyle.SetColorModelPS(1)

        # gStyle.SetBarOffset(Float_t baroff = 0.5)
        # gStyle.SetBarWidth(Float_t barwidth = 0.5)
        # gStyle.SetPaintTextFormat(const char* format = "g")
        # gStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0)
        # gStyle.SetTimeOffset(Double_t toffset)
        # gStyle.SetHistMinimumZero(kTRUE)

        #gStyle.cd()
        print "TDR Style initialized"
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
                    *formats,
                    dir_output=f"output_{decay}",
                )


# TLatex labels of decay channels
labels = {
    "d0": "D^{0} #rightarrow #pi K",
    "lc": "#Lambda^{+}_{c} #rightarrow p K #pi"
}

# general settings
gROOT.SetBatch(True)
gStyle.SetOptStat(0)
gStyle.SetPalette(0)
gStyle.SetFrameFillColor(0)

# text attributes
textfont = 42
textsize = 0.05
labelsize = 0.05

# plotting range
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)
Ejemplo n.º 9
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
Ejemplo n.º 10
0
    def initialize(fitresults=True, grid=False):
        gROOT.SetStyle("Plain")
        gStyle.SetOptFit()
        gStyle.SetOptStat(0)
        # 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.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.SetFrameFillColor(kWhite)
        gStyle.SetFrameFillStyle(1000)
        gStyle.SetFrameLineColor(1)
        gStyle.SetFrameLineStyle(1)
        gStyle.SetFrameLineWidth(1)

        # For the histo:
        gStyle.SetHistLineColor(1)
        gStyle.SetHistLineStyle(0)
        gStyle.SetHistLineWidth(2)

        gStyle.SetEndErrorSize(2)
        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)

        # 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)

        # Margins:
        gStyle.SetPadTopMargin(0.05)
        gStyle.SetPadLeftMargin(0.16)
        gStyle.SetPadRightMargin(0.04) # top group adaption, original is 0.02
        gStyle.SetPadBottomMargin(0.13)

        # For the Global title:

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

        # For the axis titles:
        gStyle.SetTitleColor(1, "XYZ")
        gStyle.SetTitleFont(42, "XYZ")
        gStyle.SetTitleSize(0.06, "XYZ")
        gStyle.SetTitleXOffset(0.9)
        gStyle.SetTitleYOffset(1.25)

        # For the axis labels:

        gStyle.SetLabelColor(1, "XYZ")
        gStyle.SetLabelFont(42, "XYZ")
        gStyle.SetLabelOffset(0.007, "XYZ")
        gStyle.SetLabelSize(0.05, "XYZ")
        #gStyle.SetLabelSize(0.04, "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)

        gStyle.SetPalette(1) #(1,0)

        # another top group addition
        gStyle.SetHatchesSpacing(1.0)

        # Postscript options:
        gStyle.SetPaperSize(20., 20.)
        # For graphs
        gStyle.SetErrorX(0)  # suppress error along x

        if grid:
          gStyle.SetPadGridX(gridOn)
          gStyle.SetPadGridY(gridOn)
          gStyle.SetGridColor(kGray)
Ejemplo n.º 11
0
def ratio(imult):

    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetOptStat(0000)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetOptTitle(0)

    ccross = TCanvas('cCross', 'The Fit Canvas', 100, 600)
    fileoutcrossd0pp = TFile.Open("finalcrossD0pp.root")
    fileoutcrossdspp = TFile.Open("finalcrossDspp.root")
    fileoutcrossLcpkpipp = TFile.Open("finalcrossLcpKpipp.root")
    fileoutcrossLcpk0s = TFile.Open("finalcrossLcpK0spp.root")

    with open("data/database_ml_parameters_D0pp.yml", 'r') as param_config:
        data_param = yaml.load(param_config, Loader=yaml.FullLoader)

    nbins = len(data_param["D0pp"]["analysis"]["sel_binmax2"])
    print("nbins", nbins)
    ccross = TCanvas('cCross', 'The Fit Canvas')
    ccross.SetCanvasSize(1500, 1500)
    ccross.SetWindowSize(500, 500)
    ccross.SetLogx()
    colorparticle = [[600, 632, 880], [600, 632, 880]]
    markerstyle = [[21, 21, 21], [22, 22, 22]]
    legendtxt = [["Ds < 20 tracklets", "LcK0s < 20 tracklets", "LcpKpi < 20 tracklets"], \
                   ["Ds > 20 tracklets", "LcK0s > 20 tracklets", "LcpKpi > 20 tracklets"]]

    leg = TLegend(.5, .65, .7, .85)
    leg.SetBorderSize(0)
    leg.SetFillColor(0)
    leg.SetFillStyle(0)
    leg.SetTextFont(42)
    leg.SetTextSize(0.035)

    hcrossD0pp = fileoutcrossd0pp.Get("hcross%d" % (imult))
    hcrossDspp = fileoutcrossdspp.Get("hcross%d" % (imult))
    hcrossLcpK0spp = fileoutcrossLcpk0s.Get("hcross%d" % (imult))
    hcrossLcpKpipp = fileoutcrossLcpkpipp.Get("hcross%d" % (imult))
    hcrossDspp.Divide(hcrossD0pp)
    hcrossLcpK0spp.Divide(hcrossD0pp)
    hcrossLcpKpipp.Divide(hcrossD0pp)
    hcrossDspp.SetMarkerStyle(markerstyle[imult-1][0])
    hcrossLcpK0spp.SetMarkerStyle(markerstyle[imult-1][1])
    hcrossLcpKpipp.SetMarkerStyle(markerstyle[imult-1][2])
    hcrossDspp.SetMarkerColor(colorparticle[imult-1][0])
    hcrossLcpK0spp.SetMarkerColor(colorparticle[imult-1][1])
    hcrossLcpKpipp.SetMarkerColor(colorparticle[imult-1][2])
    hcrossDspp.SetLineColor(colorparticle[imult-1][0])
    hcrossLcpK0spp.SetLineColor(colorparticle[imult-1][1])
    hcrossLcpKpipp.SetLineColor(colorparticle[imult-1][2])
    hcrossDspp.SetMarkerSize(2.5)
    hcrossLcpK0spp.SetMarkerSize(2.5)
    hcrossLcpKpipp.SetMarkerSize(2.5)
    hcrossDspp.GetXaxis().SetTitle("p_{T} (GeV)")
    hcrossDspp.GetYaxis().SetTitle("Particle ratio")
    hcrossDspp.GetYaxis().SetRangeUser(0., 1.)
    hcrossDspp.Draw()
    hcrossLcpKpipp.Draw("same")
    hcrossLcpK0spp.Draw("same")
    leg.AddEntry(hcrossDspp, legendtxt[imult-1][0], "LEP")
    leg.AddEntry(hcrossLcpKpipp, legendtxt[imult-1][1], "LEP")
    leg.AddEntry(hcrossLcpK0spp, legendtxt[imult-1][2], "LEP")

    leg.Draw()
    ccross.SaveAs("ComparisonRatios%d.eps" % imult)
Ejemplo n.º 12
0
def report():
    global freed_file
    print'    HeapMonReport.report(): heapmon_file=', freed_file
    
    #findStaticHoles()
          
    tfile = TFile(freed_file, "READ")
    print "   root compression factor = ", tfile.GetCompressionFactor()
   
    mem_canvas = TCanvas("HeapMon_report", "Memory Holes Statistics", 10, 10, 800, 1034);
    mem_canvas.SetFillColor(17);
    mem_canvas.cd()
    
    pad1 = TPad("pad1","pad1",0.01,0.57,0.50,0.93,33);
    pad2 = TPad("pad2","pad2",0.51,0.57,0.99,0.93,33);
    pad3 = TPad("pad3","pad3",0.01,0.01,0.99,0.50,33);
    pad3.SetPhi(210);
    pad3.SetTheta(25);

    pad1.Draw(); pad2.Draw(); pad3.Draw();
    memTree = tfile.Get("holeTree")
    infoTree = tfile.Get("infoTree")
    mallocTree = tfile.Get("mallocTree")
    #holesm_th1i =   TH1I('holesm_th1i', 'Holes size evolution', fcount, 0, fcount)    
    #holesn_th1i =   TH1I('holesn_th1i', 'Holes number evolution', fcount, 0, fcount)  
    #total_th1i  =   TH1I('total_th1i', 'Total memory size evolution', fcount, 0, fcount)
    
    max_hole_size = memTree.GetMaximum("hole_size")
    print "    max_hole_size=", max_hole_size, "    min_hole_size", memTree.GetMinimum("hole_size")
    max_scan_number = memTree.GetMaximum("scan_number")
    print "     max_scan_number=", max_scan_number
    
    memHist1  = TH2I("mem2d","Hole-sizes distribution evolution", 128, -0.5, max_hole_size - 0.5, 50, 0, max_scan_number) 
    memTree.Project("mem2d", "scan_number:hole_size"); 
    
    multiGraph1 = TMultiGraph();
    multiGraph2 = TMultiGraph();

    print " memHist.GetMaximum() = ",    memHist1.GetMaximum();
    
    # Working on a Report
    gStyle.SetOptStat(0);
    gStyle.SetPalette(1);
    gStyle.SetCanvasColor(33);
    gStyle.SetFrameFillColor(18);
    
    memHist1.SetFillColor(30);
    memHist1.SetFillStyle(0);
    memHist1.GetXaxis().SetTitle("Size of holes, kb");
    memHist1.GetXaxis().SetLabelOffset(0.02);
    memHist1.GetXaxis().SetLabelSize(0.02);
    memHist1.GetXaxis().SetTitleSize(0.04);
    memHist1.GetXaxis().SetTitleColor(2);
    memHist1.GetYaxis().SetTitle("Event number");
    memHist1.GetYaxis().SetLabelSize(0.04);
    memHist1.GetXaxis().SetLabelOffset(0.04);
    memHist1.GetYaxis().SetTitleSize(0.04);
    memHist1.GetYaxis().SetTitleColor(2);
    memHist1.GetZaxis().SetTitle("Number of holes");
    memHist1.GetZaxis().SetLabelSize(0.02);
    memHist1.GetZaxis().SetTitleSize(0.04);
    memHist1.GetZaxis().SetTitleColor(2);
    
    title = TPaveLabel(0.1,0.95,0.9,0.99, "Job Memory Usage Plots");
    title.SetFillColor(42);
    title.SetTextFont(42);
    title.Draw();
    
    text_box = TPaveText(0.1,0.51,0.9,0.54);
    text_box.AddText("Malloc freed ('marked') Heap Memory Profile");
    text_box.SetFillColor(42);
    text_box.SetTextAlign(12);
    text_box.SetTextFont(42);
    text_box.Draw();
    
    x1=0.2; y1=0.91; x2=0.8; y2=0.98;

#Drawing upper-left corner Pad1 of the report
    pad1.cd();
    pad1.SetGridx();pad1.SetGridy();
    infoTree.Draw("total_maps_memory:scan_number","", "goff")
    mapsGraph=TGraph(int(infoTree.GetSelectedRows()), infoTree.GetV2(), infoTree.GetV1());    
    mapsGraph.SetLineColor(1); mapsGraph.SetLineWidth(1); #mapsGraph.SetFillStyle(3001); mapsGraph.SetFillColor(2);
    mapsGraph.SetName("total_maps_memory");
    #VmSize, VmLck, VmRSS, VmData, VmStk, VmExe, VmLib;
    infoTree.Draw("VmSize:scan_number", "","goff"); 
    vmsizeGraph=TGraph(int(infoTree.GetSelectedRows()), infoTree.GetV2(), infoTree.GetV1());    
    vmsizeGraph.SetLineColor(2); vmsizeGraph.SetLineWidth(1); #vmsizeGraph.SetFillStyle(3002); vmsizeGraph.SetFillColor(3);
    vmsizeGraph.SetName("VmSize");
    
    infoTree.Draw("VmRSS:scan_number", "", "goff"); 
    vmrssGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1());
    vmrssGraph.SetLineColor(3); vmrssGraph.SetLineWidth(1); #vmrssGraph.SetFillStyle(3003); vmrssGraph.SetFillColor(4);
    vmrssGraph.SetName("VmRSS"); 
    
    infoTree.Draw("VmData:scan_number", "", "goff"); 
    vmdataGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1());
    vmdataGraph.SetLineColor(4); vmdataGraph.SetLineWidth(1); #vmdataGraph.SetFillStyle(3004); vmdataGraph.SetFillColor(4);
    vmdataGraph.SetName("VmData"); 
    
    infoTree.Draw("VmStk:scan_number", "", "goff"); 
    vmstkGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1());
    vmstkGraph.SetLineColor(5); vmstkGraph.SetLineWidth(1); #vmstkGraph.SetFillStyle(3005); vmstkGraph.SetFillColor(4);
    vmstkGraph.SetName("VmStk")
    
    infoTree.Draw("VmExe:scan_number", "", "goff"); 
    vmexeGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1());
    vmexeGraph.SetLineColor(6); vmexeGraph.SetLineWidth(1); #vmexeGraph.SetFillStyle(3003); vmexeGraph.SetFillColor(4);
    vmexeGraph.SetName("VmExe");
    
    infoTree.Draw("VmLib:scan_number", "", "goff"); 
    vmlibGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1());
    vmlibGraph.SetLineColor(7); vmlibGraph.SetLineWidth(1); #vmlibGraph.SetFillStyle(3003); vmlibGraph.SetFillColor(4);
    vmlibGraph.SetName("VmLib");
  
    infoTree.Draw("VmLck:scan_number", "", "goff"); 
    vmlckGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1());
    vmlckGraph.SetLineColor(8); vmlckGraph.SetLineWidth(1); #vmlckGraph.SetFillStyle(3003); vmlckGraph.SetFillColor(4);
    vmlckGraph.SetName("VmLck");

    infoTree.Draw("total_hole_memory:scan_number", "", "goff");
    holeGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1())    
    holeGraph.SetLineColor(9); holeGraph.SetLineWidth(1); #holeGraph.SetFillStyle(3004); holeGraph.SetFillColor(5);
    holeGraph.SetName("HolesSize"); 
        
    mallocTree.Draw("malloc_free:scan_number", "", "goff"); 
    freeGraph=TGraph(mallocTree.GetSelectedRows(), mallocTree.GetV2(), mallocTree.GetV1())    
    freeGraph.SetLineColor(11); freeGraph.SetLineWidth(1); freeGraph.SetFillStyle(3003); freeGraph.SetFillColor(4);
    freeGraph.SetName("malloc_free");
    
    mallocTree.Draw("malloc_inuse:scan_number", "", "goff"); 
    inuseGraph=TGraph(mallocTree.GetSelectedRows(), mallocTree.GetV2(), mallocTree.GetV1())    
    inuseGraph.SetLineColor(21); inuseGraph.SetLineWidth(1); inuseGraph.SetFillStyle(3003); inuseGraph.SetFillColor(4);
    inuseGraph.SetName("malloc_inuse");

    mallocTree.Draw("malloc_sbrk:scan_number", "", "goff"); 
    sbrkGraph=TGraph(mallocTree.GetSelectedRows(), mallocTree.GetV2(), mallocTree.GetV1())    
    sbrkGraph.SetLineColor(31); sbrkGraph.SetLineWidth(1); sbrkGraph.SetFillStyle(3003); sbrkGraph.SetFillColor(4);
    sbrkGraph.SetName("malloc_sbrk");
    
    mallocTree.Draw("malloc_mmap:scan_number", "", "goff"); 
    mmapGraph=TGraph(mallocTree.GetSelectedRows(), mallocTree.GetV2(), mallocTree.GetV1())    
    mmapGraph.SetLineColor(41); mmapGraph.SetLineWidth(1); mmapGraph.SetFillStyle(3003); mmapGraph.SetFillColor(4);
    mmapGraph.SetName("malloc_mmap");
    
    pad1.cd();
    multiGraph1.Add(mapsGraph);multiGraph1.Add(vmsizeGraph);
    multiGraph1.Add(vmrssGraph);multiGraph1.Add(vmdataGraph);
    multiGraph1.Add(vmlckGraph);multiGraph1.Add(vmexeGraph);
    multiGraph1.Add(vmstkGraph);#multiGraph1.Add(vmlibGraph);
    multiGraph1.Add(inuseGraph);
    multiGraph1.Add(sbrkGraph);multiGraph1.Add(mmapGraph);
    multiGraph1.Add(holeGraph);multiGraph1.Add(freeGraph);


    
    #multiGraph1.SetTitle("PROCESS VM and Malloc MEMORY USAGE"); 
    title.DrawPaveLabel(x1,y1,x2,y2,"PROCESS VM and Malloc MEMORY USAGE","brNDC");

    multiGraph1.Draw("ALg")
    hist = multiGraph1.GetHistogram(); hist.SetXTitle("Event Number"); hist.SetYTitle("Memory, kb");
    legend1 = TLegend(0.84,0.20,0.99,0.90);
    legend1.AddEntry(mapsGraph,  "Maps",            "l");
    legend1.AddEntry(vmsizeGraph,"VmSize",          "l");
    legend1.AddEntry(vmrssGraph, "VmRSS",           "l");
    legend1.AddEntry(vmdataGraph,"VmData",          "l");

    legend1.AddEntry(sbrkGraph,  "MallocSbrk",      "l");
    legend1.AddEntry(inuseGraph, "MallocInuse",     "l");    
    #legend1.AddEntry(vmlibGraph, "VmLib",          "l");
    legend1.AddEntry(mmapGraph,  "MallocMmap",      "l");    
    legend1.AddEntry(freeGraph,  "MallocFree",      "l");
    legend1.AddEntry(holeGraph,  "Freed-Holes",     "l");     
    legend1.AddEntry(vmstkGraph, "VmStk",           "l");
    legend1.AddEntry(vmexeGraph, "VmExe",           "l");
    legend1.AddEntry(vmlckGraph, "VmLck",           "l");
    legend1.Draw();

    #multiGraph1.Draw("ALg")    
    #title.DrawPaveLabel(x1,y1,x2,y2,"Process Memory Usage Charts","brNDC");
    
    
#Drawing upper-left corner Pad1 of the report
    pad2.cd();
    pad2.SetGridx(); pad2.SetGridy();

    infoTree.Draw("total_hole_memory:scan_number", "", "goff");
    holeGraph=TGraph(infoTree.GetSelectedRows(), infoTree.GetV2(), infoTree.GetV1())    
    holeGraph.SetLineColor(9); holeGraph.SetLineWidth(1); holeGraph.SetFillStyle(3004); holeGraph.SetFillColor(5);
    holeGraph.SetName("total_hole_memory"); 

    mallocTree.Draw("malloc_free:scan_number", "", "goff");
    freeGraph=TGraph(mallocTree.GetSelectedRows(), mallocTree.GetV2(), mallocTree.GetV1())    
    freeGraph.SetLineColor(11); freeGraph.SetLineWidth(1); freeGraph.SetFillStyle(3004); freeGraph.SetFillColor(5);
    freeGraph.SetName("malloc_free");
    
    pad2.cd();
    multiGraph2.Add(holeGraph);
    multiGraph2.Add(freeGraph);
    #multiGraph2.Add(sbrkGraph);
    #multiGraph2.Add(mmapGraph);
    
    #multiGraph2.SetTitle("Free and Marked Holes Memory Graph"); 
    title.DrawPaveLabel(x1,y1,x2,y2,"Malloc Free and Marked Holes Memory","brNDC");
    
    multiGraph2.Draw("ALg")    
    hist = multiGraph2.GetHistogram(); hist.SetXTitle("Event Number"); hist.SetYTitle("Memory, kb");
    
    legend2 = TLegend(0.9,0.30,0.99,0.90);
    legend2.AddEntry(freeGraph,  "Free",   "l");
    legend2.AddEntry(holeGraph,  "Holes",  "l");
    #legend2.AddEntry(inuseGraph, "Inuse",  "l");
    #legend2.AddEntry(mmapGraph,  "Mmap",  "l");
    #legend2.AddEntry(sbrkGraph,  "Sbrk",  "l");

    legend2.Draw()
    #multiGraph2.Draw("ALg")    
    #title.DrawPaveLabel(x1,y1,x2,y2,"Malloc Memory Usage and Deallocation Charts","brNDC");  
  
  #PAD3
    pad3.cd()
    pad3.SetLogz()
    memHist1.Draw("lego2");
    #title.DrawPaveLabel(x1,y1,x2,y2,"TH2I-LEGO2","brNDC");

    mem_canvas.SetBorderSize(1);
    #mem_canvas.Modified()
    mem_canvas.Update()
    mem_canvas.Print(".pdf")
    mem_canvas.Print(".C")
Ejemplo n.º 13
0
def setStyle():

    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetPadBottomMargin(0.12)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetCanvasColor(ROOT.kWhite)
    gStyle.SetCanvasDefH(600)
    #Height of canvas
    gStyle.SetCanvasDefW(600)
    #Width of canvas
    gStyle.SetCanvasDefX(0)
    #POsition on screen
    gStyle.SetCanvasDefY(0)

    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.15)
    #0.13);
    gStyle.SetPadLeftMargin(0.15)
    #0.16);
    gStyle.SetPadRightMargin(0.05)
    #0.02);

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

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

    gStyle.SetAxisColor(1, "XYZ")
    gStyle.SetStripDecimals(ROOT.kTRUE)
    gStyle.SetTickLength(0.03, "XYZ")
    gStyle.SetNdivisions(505, "XYZ")
    gStyle.SetPadTickX(1)
    # To get tick marks on the opposite side of the frame
    gStyle.SetPadTickY(1)
    gStyle.SetGridColor(0)
    gStyle.SetGridStyle(3)
    gStyle.SetGridWidth(1)

    gStyle.SetTitleColor(1, "XYZ")
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.05, "XYZ")
    # gStyle.SetTitleXSize(Float_t size = 0.02); # Another way to set the size?
    # gStyle.SetTitleYSize(Float_t size = 0.02);
    gStyle.SetTitleXOffset(1.15)
    #0.9);
    gStyle.SetTitleYOffset(1.3)
    # => 1.15 if exponents
    gStyle.SetLabelColor(1, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelOffset(0.007, "XYZ")
    gStyle.SetLabelSize(0.045, "XYZ")

    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetTitleTextColor(1)
    gStyle.SetTitleFillColor(10)
    gStyle.SetTitleFontSize(0.05)
Ejemplo n.º 14
0
    def draw_fits(self, save_dir, root_dir=None):
        """
        Draw all fits one-by-one
        Args:
            save_dir: directory where to save plots
            root_dir: TDirectory where to save summary plots
        """
        gStyle.SetOptStat(0)
        gStyle.SetOptStat(0000)
        gStyle.SetPalette(1)
        gStyle.SetCanvasColor(0)
        gStyle.SetFrameFillColor(0)

        bins2 = self.get_bins2()
        bins1_ranges = self.pars_factory.bins1_edges_low.copy()
        bins1_ranges.append(self.pars_factory.bins1_edges_up[-1])
        n_bins1 = len(bins1_ranges) - 1

        # Summarize in mult histograms in pT bins
        yieldshistos = {ibin2: TH1F("hyields%d" % (ibin2), "", \
                n_bins1, array("d", bins1_ranges)) for ibin2 in bins2}
        means_histos = {ibin2:TH1F("hmeanss%d" % (ibin2), "", \
                n_bins1, array("d", bins1_ranges)) for ibin2 in bins2}
        sigmas_histos = {ibin2: TH1F("hsigmas%d" % (ibin2), "", \
                n_bins1, array("d", bins1_ranges)) for ibin2 in bins2}
        have_summary_pt_bins = []
        means_init_mc_histos = TH1F("hmeans_init_mc", "", n_bins1,
                                    array("d", bins1_ranges))
        sigmas_init_mc_histos = TH1F("hsigmas_init_mc", "", n_bins1,
                                     array("d", bins1_ranges))
        means_init_data_histos = TH1F("hmeans_init_data", "", n_bins1,
                                      array("d", bins1_ranges))
        sigmas_init_data_histos = TH1F("hsigmas_init_data", "", n_bins1,
                                       array("d", bins1_ranges))

        nx = 4
        ny = 2
        canvy = 533
        if n_bins1 > 12:
            nx = 5
            ny = 4
            canvy = 1200
        elif n_bins1 > 8:
            nx = 4
            ny = 3
            canvy = 800

        canvas_init_mc = TCanvas("canvas_init_mc", "MC", 1000, canvy)
        canvas_init_data = TCanvas("canvas_init_data", "Data", 1000, canvy)
        canvas_data = {ibin2: TCanvas("canvas_data%d" % (ibin2), "Data", 1000, canvy) \
                       for ibin2 in bins2}
        canvas_init_mc.Divide(nx, ny)
        canvas_init_data.Divide(nx, ny)

        for c in canvas_data.values():
            c.Divide(nx, ny)

        # Need to cache some object for which the canvas is only written after the loop...
        for (ibin1, ibin2), fit in self.central_fits.items():
            bin_id_match = self.pars_factory.bin_matching[ibin1]

            # Some variables set for drawing
            title = f"{self.pars_factory.bins1_edges_low[ibin1]:.1f} < #it{{p}}_{{T}} < " \
                    f"{self.pars_factory.bins1_edges_up[ibin1]:.1f}" \
                    f"(prob > {self.pars_factory.prob_cut_fin[bin_id_match]:.2f})"

            x_axis_label = "#it{M}_{inv} (GeV/#it{c}^{2})"
            n_sigma_signal = self.pars_factory.n_sigma_signal

            suffix_write = self.pars_factory.make_suffix(ibin1, ibin2)

            kernel = fit.kernel
            histo = fit.histo

            # Central fits
            y_axis_label = \
                    f"Entries/({histo.GetBinWidth(1) * 1000:.0f} MeV/#it{{c}}^{{2}})"
            canvas = TCanvas("fit_canvas", suffix_write, 700, 700)
            fit.draw(canvas,
                     sigma_signal=n_sigma_signal,
                     x_axis_label=x_axis_label,
                     y_axis_label=y_axis_label,
                     title=title)
            if self.pars_factory.apply_weights is False:
                canvas.SaveAs(
                    make_file_path(save_dir, "fittedplot", "eps", None,
                                   suffix_write))
            else:
                canvas.SaveAs(
                    make_file_path(save_dir, "fittedplotweights", "eps", None,
                                   suffix_write))
            canvas.Close()
            fit.draw(canvas_data[ibin2].cd(ibin1 + 1),
                     sigma_signal=n_sigma_signal,
                     x_axis_label=x_axis_label,
                     y_axis_label=y_axis_label,
                     title=title)

            if fit.success:
                # Only fill these summary plots in case of success
                yieldshistos[ibin2].SetBinContent(ibin1 + 1,
                                                  kernel.GetRawYield())
                yieldshistos[ibin2].SetBinError(ibin1 + 1,
                                                kernel.GetRawYieldError())

                means_histos[ibin2].SetBinContent(ibin1 + 1, kernel.GetMean())
                means_histos[ibin2].SetBinError(ibin1 + 1,
                                                kernel.GetMeanUncertainty())

                sigmas_histos[ibin2].SetBinContent(ibin1 + 1,
                                                   kernel.GetSigma())
                sigmas_histos[ibin2].SetBinError(ibin1 + 1,
                                                 kernel.GetSigmaUncertainty())

                # Residual plot
                c_res = TCanvas('cRes', 'The Fit Canvas', 800, 800)
                c_res.cd()
                h_pulls = histo.Clone(f"{histo.GetName()}_pull")
                h_residual_trend = histo.Clone(
                    f"{histo.GetName()}_residual_trend")
                h_pulls_trend = histo.Clone(f"{histo.GetName()}_pulls_trend")
                _ = kernel.GetOverBackgroundResidualsAndPulls( \
                        h_pulls, h_residual_trend, h_pulls_trend, \
                        self.pars_factory.fit_range_low[ibin1], \
                        self.pars_factory.fit_range_up[ibin1])
                h_residual_trend.Draw()
                c_res.SaveAs(
                    make_file_path(save_dir, "residual", "eps", None,
                                   suffix_write))
                c_res.Close()

            # Summary plots to be done only once per pT bin
            if ibin1 in have_summary_pt_bins:
                continue

            have_summary_pt_bins.append(ibin1)

            # Pre-fit MC
            suffix_write = self.pars_factory.make_suffix(
                ibin1, self.pars_factory.bins2_int_bin)

            pre_fit_mc = self.pre_fits_mc[ibin1]
            kernel = pre_fit_mc.kernel
            histo = pre_fit_mc.histo
            y_axis_label = \
                    f"Entries/({histo.GetBinWidth(1) * 1000:.0f} MeV/#it{{c}}^{{2}})"
            canvas = TCanvas("fit_canvas_mc_init", suffix_write, 700, 700)
            pre_fit_mc.draw(canvas,
                            x_axis_label=x_axis_label,
                            y_axis_label=y_axis_label,
                            title=title)

            canvas.SaveAs(
                make_file_path(save_dir, "fittedplot_integrated_mc", "eps",
                               None, suffix_write))
            canvas.Close()
            pre_fit_mc.draw(canvas_init_mc.cd(ibin1 + 1),
                            x_axis_label=x_axis_label,
                            y_axis_label=y_axis_label,
                            title=title)

            if pre_fit_mc.success:
                # Only fill these summary plots in case of success
                means_init_mc_histos.SetBinContent(ibin1 + 1,
                                                   kernel.GetParameter(1))
                means_init_mc_histos.SetBinError(ibin1 + 1,
                                                 kernel.GetParError(1))
                sigmas_init_mc_histos.SetBinContent(ibin1 + 1,
                                                    kernel.GetParameter(2))
                sigmas_init_mc_histos.SetBinError(ibin1 + 1,
                                                  kernel.GetParError(2))

            pre_fit_data = self.pre_fits_data[ibin1]
            kernel = pre_fit_data.kernel
            histo = pre_fit_data.histo

            # Pre-fit data
            y_axis_label = \
                    f"Entries/({histo.GetBinWidth(1) * 1000:.0f} MeV/#it{{c}}^{{2}})"
            canvas = TCanvas("fit_canvas_data_init", suffix_write, 700, 700)
            pre_fit_data.draw(canvas,
                              sigma_signal=n_sigma_signal,
                              x_axis_label=x_axis_label,
                              y_axis_label=y_axis_label,
                              title=title)
            canvas.SaveAs(
                make_file_path(save_dir, "fittedplot_integrated", "eps", None,
                               suffix_write))
            canvas.Close()
            pre_fit_data.draw(canvas_init_data.cd(ibin1 + 1),
                              sigma_signal=n_sigma_signal,
                              x_axis_label=x_axis_label,
                              y_axis_label=y_axis_label,
                              title=title)

            if pre_fit_data.success:
                # Only fill these summary plots in case of success
                means_init_data_histos.SetBinContent(ibin1 + 1,
                                                     kernel.GetMean())
                means_init_data_histos.SetBinError(ibin1 + 1,
                                                   kernel.GetMeanUncertainty())
                sigmas_init_data_histos.SetBinContent(ibin1 + 1,
                                                      kernel.GetSigma())
                sigmas_init_data_histos.SetBinError(
                    ibin1 + 1, kernel.GetSigmaUncertainty())

        canvas_init_mc.SaveAs(make_file_path(save_dir, "canvas_InitMC", "eps"))
        canvas_init_mc.Close()
        canvas_init_data.SaveAs(
            make_file_path(save_dir, "canvas_InitData", "eps"))
        canvas_init_data.Close()
        for ibin2 in bins2:
            suffix2 = f"ibin2_{ibin2}"
            canvas_data[ibin2].SaveAs(
                make_file_path(save_dir, "canvas_FinalData", "eps", None,
                               suffix2))
            if root_dir:
                root_dir.cd()
                yieldshistos[ibin2].Write()
                means_histos[ibin2].Write()
                sigmas_histos[ibin2].Write()
            #canvas_data[ibin2].Close()

        latex_bin2_var = self.ana_config["latexbin2var"]
        latex_hadron_name = self.ana_config["latexnamehadron"]
        # Plot some summary historgrams
        leg_strings = [f"{self.pars_factory.bins2_edges_low[ibin2]} #leq {latex_bin2_var} < " \
                       f"{self.pars_factory.bins2_edges_up[ibin2]}" for ibin2 in bins2]
        save_name = make_file_path(save_dir, "Yields", "eps", None,
                                   [self.case, self.ana_type])
        # Yields summary plot
        plot_histograms(
            [yieldshistos[ibin2] for ibin2 in bins2], True, True, leg_strings,
            "uncorrected yields", "#it{p}_{T} (GeV/#it{c})",
            f"Uncorrected yields {latex_hadron_name} {self.ana_type}",
            "mult. / int.", save_name)
        save_name = make_file_path(save_dir, "Means", "eps", None,
                                   [self.case, self.ana_type])
        # Means summary plot
        plot_histograms([means_histos[ibin2] for ibin2 in bins2], False, True,
                        leg_strings, "Means", "#it{p}_{T} (GeV/#it{c})",
                        "#mu_{fit} " + f"{latex_hadron_name} {self.ana_type}",
                        "mult. / int.", save_name)
        save_name = make_file_path(save_dir, "Sigmas", "eps", None,
                                   [self.case, self.ana_type])
        #Sigmas summary plot
        plot_histograms([sigmas_histos[ibin2]
                         for ibin2 in bins2], False, True, leg_strings,
                        "Sigmas", "#it{p}_{T} (GeV/#it{c})", "#sigma_{fit} " +
                        f"{latex_hadron_name} {self.ana_type}", "mult. / int.",
                        save_name)

        # Plot the initialized means and sigma for MC and data
        save_name = make_file_path(save_dir, "Means_mult_int", "eps", None,
                                   [self.case, self.ana_type])
        plot_histograms([means_init_mc_histos, means_init_data_histos], False,
                        False, ["MC", "data"], "Means of int. mult.",
                        "#it{p}_{T} (GeV/#it{c})",
                        "#mu_{fit} " + f"{latex_hadron_name} {self.ana_type}",
                        "", save_name)

        save_name = make_file_path(save_dir, "Sigmas_mult_int", "eps", None,
                                   [self.case, self.ana_type])
        plot_histograms([sigmas_init_mc_histos, sigmas_init_data_histos],
                        False, False, ["MC", "data"], "Sigmas of int. mult.",
                        "#it{p}_{T} (GeV/#it{c})", "#sigma_{fit} " +
                        f"{latex_hadron_name} {self.ana_type}", "", save_name)
Ejemplo n.º 15
0
def validatetrigger():

    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetOptStat(0000)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetOptTitle(0)

    ccross = TCanvas('cCross', 'The Fit Canvas', 100, 600)
    ccross = TCanvas('cCross', 'The Fit Canvas')
    ccross.SetCanvasSize(1500, 1500)
    ccross.SetWindowSize(500, 500)
    ccross.SetLogx()

    legyield = TLegend(.3, .65, .7, .85)
    legyield.SetBorderSize(0)
    legyield.SetFillColor(0)
    legyield.SetFillStyle(0)
    legyield.SetTextFont(42)
    legyield.SetTextSize(0.035)

    files = [
        "resultsSPDvspt/finalcrossD0pptestSPDvsptmult3Weight.root",
        "resultsSPDvspt/finalcrossD0pptestSPDvsptmult3NoWeight.root",
        "resultsMBvspt_ntrkl/finalcrossD0pptestMBvspt_ntrklmult3.root"
    ]
    legends = [
        "triggered weight ntracklets 60-100",
        "triggered no weight ntracklets 60-100", "MB ntracklets 60-100"
    ]
    hempty = TH1F("hempty", "hempty", 100, 0, 30)
    hempty.GetYaxis().SetTitleOffset(1.2)
    hempty.GetYaxis().SetTitleFont(42)
    hempty.GetXaxis().SetTitleFont(42)
    hempty.GetYaxis().SetLabelFont(42)
    hempty.GetXaxis().SetLabelFont(42)
    hempty.GetXaxis().SetRangeUser(1, 30)
    hempty.GetYaxis().SetTitle("Corrected yield (AU)")
    hempty.GetXaxis().SetTitle("p_{T} (GeV)")
    hempty.SetMinimum(1e5)
    hempty.SetMaximum(1e9)
    hempty.Draw()

    legyield = TLegend(.3, .65, .7, .85)
    legyield.SetBorderSize(0)
    legyield.SetFillColor(0)
    legyield.SetFillStyle(0)
    legyield.SetTextFont(42)
    legyield.SetTextSize(0.035)
    hempty.Draw()
    gPad.SetLogy()
    myfileWeight = TFile.Open(files[0], "read")
    myfileNoWeight = TFile.Open(files[1], "read")
    myfileMB = TFile.Open(files[2], "read")

    hWeight = myfileWeight.Get("histoSigmaCorr")
    hNoWeight = myfileNoWeight.Get("histoSigmaCorr")
    hMB = myfileMB.Get("histoSigmaCorr")

    hWeight.SetLineColor(1)
    hNoWeight.SetLineColor(2)
    hMB.SetLineColor(4)

    hWeight.Draw("same")
    hNoWeight.Draw("same")
    hMB.Draw("same")

    legyield.AddEntry(hWeight, legends[0], "LEP")
    legyield.AddEntry(hNoWeight, legends[1], "LEP")
    legyield.AddEntry(hMB, legends[2], "LEP")
    legyield.Draw()
    ccross.SaveAs("ccrossSPD.eps")
Ejemplo n.º 16
0
def setStyle():

    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetPadBottomMargin(0.12)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetCanvasColor(ROOT.kWhite)
    gStyle.SetCanvasDefH(600)
    #Height of canvas
    gStyle.SetCanvasDefW(600)
    #Width of canvas
    gStyle.SetCanvasDefX(0)
    #POsition on screen
    gStyle.SetCanvasDefY(0)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.15)
    #0.13);
    gStyle.SetPadLeftMargin(0.11)
    #0.16);
    gStyle.SetPadRightMargin(0.05)
    #0.02);

    # For the Pad:
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(ROOT.kWhite)
    gStyle.SetPadGridX(ROOT.kFALSE)
    gStyle.SetPadGridY(ROOT.kFALSE)
    gStyle.SetGridColor(0)
    gStyle.SetGridStyle(3)
    gStyle.SetGridWidth(1)

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

    gStyle.SetAxisColor(1, "XYZ")
    gStyle.SetStripDecimals(ROOT.kTRUE)
    gStyle.SetTickLength(0.03, "XYZ")
    gStyle.SetNdivisions(505, "XYZ")
    gStyle.SetPadTickX(1)
    # To get tick marks on the opposite side of the frame
    gStyle.SetPadTickY(1)
    gStyle.SetGridColor(0)
    gStyle.SetGridStyle(3)
    gStyle.SetGridWidth(1)

    gStyle.SetTitleColor(1, "XYZ")
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.05, "XYZ")
    gStyle.SetTitleXOffset(1.15)
    #0.9);
    gStyle.SetTitleYOffset(1.3)
    # => 1.15 if exponents

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

    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetTitleTextColor(1)
    gStyle.SetTitleFillColor(10)
    gStyle.SetTitleFontSize(0.05)

    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetOptFit(1)

    NRGBs = 5
    NCont = 255
    stops = [0.00, 0.34, 0.61, 0.84, 1.00]
    red = [0.00, 0.00, 0.87, 1.00, 0.51]
    green = [0.00, 0.81, 1.00, 0.20, 0.00]
    blue = [0.51, 1.00, 0.12, 0.00, 0.00]
    stopsArray = array('d', stops)
    redArray = array('d', red)
    greenArray = array('d', green)
    blueArray = array('d', blue)
    TColor.CreateGradientColorTable(NRGBs, stopsArray, redArray, greenArray,
                                    blueArray, NCont)
    gStyle.SetNumberContours(NCont)
Ejemplo n.º 17
0
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()
Ejemplo n.º 18
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.SetHistLineColor(1)

    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.6, "Y")

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

    gStyle.SetOptStat(0)
    setNormalColorTable()
Ejemplo n.º 19
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)