Пример #1
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()
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);
Пример #3
0
def setStyle():
    NRGBs = 5
    NCont = 255

    #gErrorIgnoreLevel

    #Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
    #Double_t red[NRGBs]   = { 0.00, 0.00, 0.87, 1.00, 0.51 };
    #Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
    #Double_t blue[NRGBs]  = { 0.51, 1.00, 0.12, 0.00, 0.00 };
    #TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
    #gStyle.SetNumberContours(NCont);

    #  gStyle.SetPadBorderMode(0)
    #  gStyle.SetFrameBorderMode(0)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)

    #  gStyle.SetLabelSize(0.05,"X")
    #  gStyle.SetLabelSize(0.05,"Y")
    # 0.035
    #  gStyle.SetLabelSize(0.035,"XY")
    gStyle.SetTitleSize(AxisLabelSizeX, "X")
    gStyle.SetTitleSize(AxisLabelSizeY, "Y")

    gStyle.SetTitleOffset(kDefaultTitleOffsetX, "X")
    gStyle.SetTitleOffset(kDefaultTitleOffsetY, "Y")

    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleSize(0.035, "xy")
Пример #4
0
def SetStyle():
    gROOT.SetStyle('Plain')
    gROOT.ForceStyle()
    gStyle.SetTextFont(42)

    gStyle.SetOptTitle(0)
    gStyle.SetOptFit(1112)
    gStyle.SetOptStat(1110)

    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadTopMargin(0.11)
    gStyle.SetPadBottomMargin(0.12)

    gStyle.SetTitleFont(42, 'x')
    gStyle.SetTitleFont(42, 'y')
    gStyle.SetTitleFont(42, 'z')

    gStyle.SetTitleOffset(1.05, 'x')
    gStyle.SetTitleOffset(1.00, 'y')

    gStyle.SetTitleSize(0.05, 'x')
    gStyle.SetTitleSize(0.05, 'y')
    gStyle.SetTitleSize(0.05, 'z')

    gStyle.SetLabelFont(42, 'x')
    gStyle.SetLabelFont(42, 'y')
    gStyle.SetLabelFont(42, 'z')

    gStyle.SetLabelSize(0.05, 'x')
    gStyle.SetLabelSize(0.05, 'y')
    gStyle.SetLabelSize(0.05, 'z')

    TGaxis.SetMaxDigits(3)
    gStyle.SetStatY(0.9)
Пример #5
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)
Пример #6
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);
Пример #7
0
def looks():
    gROOT.ProcessLine('TGaxis::SetMaxDigits(3)')
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(0)
    gStyle.SetStatColor(0)
    gStyle.SetTitleFont(42, '')
    gStyle.SetLabelFont(42, 'x')
    gStyle.SetTitleFont(42, 'x')
    gStyle.SetLabelFont(42, 'y')
    gStyle.SetTitleFont(42, 'y')
    gStyle.SetLabelFont(42, 'z')
    gStyle.SetTitleFont(42, 'z')
    gStyle.SetLabelSize(0.048, 'x')
    gStyle.SetTitleSize(0.048, 'x')
    gStyle.SetLabelSize(0.048, 'y')
    gStyle.SetTitleSize(0.048, 'y')
    gStyle.SetLabelSize(0.048, 'z')
    gStyle.SetTitleSize(0.048, 'z')
    gStyle.SetTitleSize(0.048, '')
    gStyle.SetTitleAlign(23)
    gStyle.SetTitleX(0.5)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleFillColor(0)
    gStyle.SetTitleStyle(0)
    gStyle.SetOptStat('emr')
    gStyle.SetOptStat(0)
    gStyle.SetStatBorderSize(0)
    gStyle.SetStatFont(42)
    gStyle.SetStatFontSize(0.048)
    gStyle.SetStatY(0.9)
    gStyle.SetStatX(0.86)
    gStyle.SetHistLineColor(ROOT.kBlue + 2)
    gStyle.SetLegendBorderSize(0)
    gStyle.SetLegendFillColor(0)
    gStyle.SetFuncWidth(2)
    gStyle.SetFuncColor(2)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadBottomMargin(0.12)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetPadRightMargin(0.06)
    gStyle.SetCanvasDefX(400)
    gStyle.SetCanvasDefY(20)
    gStyle.SetCanvasDefH(420)
    gStyle.SetCanvasDefW(610)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetHistLineWidth(2)
    gStyle.SetTitleOffset(1.16, 'y')
    gStyle.SetTitleOffset(1.20, 'x')
Пример #8
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)
Пример #9
0
def set_pub_style():
    from ROOT import gStyle
    # No Canvas Border
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasBorderSize(0)
    # White BG
    gStyle.SetCanvasColor(10)
    # Format for axes
    gStyle.SetLabelFont(42, 'xyz')
    gStyle.SetLabelSize(0.05, 'xyz')
    gStyle.SetLabelOffset(0.01, 'xyz')
    # gStyle->SetNdivisions(510, 'xyz')
    gStyle.SetTitleFont(42, 'xyz')
    gStyle.SetTitleColor(1, 'xyz')
    gStyle.SetTitleSize(0.06, 'xyz')
    gStyle.SetTitleOffset(1.25, 'xyz')
    # No pad borders
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadBorderSize(0)
    # White BG
    gStyle.SetPadColor(10)
    # Margins for labels etc.
    gStyle.SetPadLeftMargin(0.155)
    gStyle.SetPadBottomMargin(0.155)
    gStyle.SetPadRightMargin(0.15)
    gStyle.SetPadTopMargin(0.1)
    # No error bars in x direction
    gStyle.SetErrorX(0)
    # Format legend
    gStyle.SetLegendBorderSize(0)
Пример #10
0
def rootSetup():
    from ROOT import gStyle
    gStyle.SetStatColor(0)
    gStyle.SetFillColor(38)
    gStyle.SetCanvasColor(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetOptStat(1110)
    gStyle.SetStatH(0.3)
    gStyle.SetStatW(0.3)

    gStyle.SetTitleFillColor(0)
    #gStyle.SetTitleY(1.)
    #gStyle.SetTitleX(.1)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameFillColor(0)
    #gStyle.SetLineWidth(2)
    #gStyle.SetTitleColor(0)
    #gStyle.SetTitleColor(1)
    gStyle.SetLabelSize(0.05, "x")
    gStyle.SetLabelSize(0.05, "y")
    gStyle.SetLabelOffset(0.02, "y")
    gStyle.SetTitleOffset(1.8, "y")
    gStyle.SetTitleSize(0.04, "y")
    gStyle.SetPadRightMargin(0.02)
    gStyle.SetPadLeftMargin(0.14)  # Used to be 0.20 --> Salva
    gStyle.SetPadBottomMargin(0.14)
Пример #11
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)
Пример #12
0
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)
Пример #13
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)
Пример #14
0
def plot_ROC_curve(ROC_curve, file_name_portion):

    gStyle.SetOptStat(0)
    gStyle.SetLabelSize(0.03, "xy")
    gStyle.SetTitleSize(0.03, "xy")
    gStyle.SetTitleOffset(1.2, "xy")
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadRightMargin(0.1)
    gStyle.SetPadTopMargin(0.1)
    gStyle.SetPadBottomMargin(0.15)

    canvas = TCanvas("c1", "c1", 800, 800)
    canvas.SetTickx()
    canvas.SetTicky()

    ROC_curve.GetYaxis().SetTitle('Background rejection')
    ROC_curve.GetXaxis().SetTitle('Signal efficiency')
    ROC_curve.SetLineColor(TColor.kAzure)
    ROC_curve.SetFillColor(TColor.kAzure - 2)
    ROC_curve.SetLineWidth(2)
    ROC_curve.SetFillStyle(0)

    from array import array
    x, y = array('d'), array('d')
    x.append(EFF_SIGNAL_DIRECT_CUT)
    y.append(1 - EFF_BACKGROUND_DIRECT_CUT)
    dot = TGraph(1, x, y)
    dot.SetMarkerColor(8)
    dot.SetMarkerSize(3)
    dot.SetMarkerStyle(21)

    legend = TLegend(0.2, 0.2, 0.4, 0.4)
    legend.SetTextSize(0.04)
    legend.SetTextFont(42)
    legend.SetFillColor(10)
    legend.SetLineColor(10)
    legend.SetBorderSize(0)
    legend.AddEntry(ROC_curve, "BDT 500 trees", "l")
    legend.AddEntry(dot, "m_{jj} > 500 GeV and |#Delta#eta_{jj}| > 3 cut", "P")

    ROC_curve.Draw("HIST")
    legend.Draw("same")
    dot.Draw("LPsame")
    canvas.RedrawAxis()
    canvas.Print(file_name_portion + "_ROC" + ".png")
    def __init__(self):
        # Setup argument parser
        self.parser = argparse.ArgumentParser()
        #self.parser.add_argument("--infile", default="histos.root", help="input file (default: %(default)s)")
        self.parser.add_argument(
            "--outdir",
            default="figures/",
            help="output directory (default: %(default)s)")
        self.parser.add_argument("-v",
                                 "--verbose",
                                 action="count",
                                 default=0,
                                 help="verbosity (default: %(default)s)")
        self.options = self.parser.parse_args()
        if not self.options.outdir.endswith("/"):
            self.options.outdir += "/"
        if not os.path.exists(self.options.outdir):
            os.makedirs(self.options.outdir)
        #if not os.path.isfile(self.options.infile):
        #  raise Exception("File does not exist: %s" % self.options.infile)
        #self.options.tfile = TFile.Open(self.options.infile)

        self.options.palette = ("#333333", "#377eb8", "#e41a1c", "#984ea3",
                                "#ff7f00", "#4daf4a")

        # Setup basic drawer
        gROOT.LoadMacro("tdrstyle.C")
        gROOT.ProcessLine("setTDRStyle();")
        #gROOT.ProcessLine("gErrorIgnoreLevel = kWarning;")
        gROOT.SetBatch(True)
        gStyle.SetNdivisions(510, "Y")
        gStyle.SetEndErrorSize(0)
        gStyle.SetPadGridX(True)
        gStyle.SetPadGridY(True)
        #gStyle.SetOptStat(111110)
        gStyle.SetPadRightMargin(0.05)
        gStyle.SetTitleOffset(1.1, "Y")
        gStyle.SetPalette(57)  # kBird
        gStyle.SetNumberContours(50)
def my_style():

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

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

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

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

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

    gStyle.SetCanvasColor(-1)
    gStyle.SetPadColor(-1)
    gStyle.SetFrameFillColor(-1)
    gStyle.SetTitleFillColor(-1)
    gStyle.SetFillColor(-1)
    gStyle.SetFillStyle(4000)
    gStyle.SetStatStyle(0)
    gStyle.SetTitleStyle(0)
    gStyle.SetCanvasBorderSize(0)
    gStyle.SetFrameBorderSize(0)
    gStyle.SetLegendBorderSize(0)
    gStyle.SetStatBorderSize(0)
    gStyle.SetTitleBorderSize(0)
    def __init__(self):
        # ROOT
        gROOT.LoadMacro("tdrstyle.C")
        gROOT.LoadMacro("../interface/HelperMath.h")
        gROOT.LoadMacro("../../AMSimulationIO/src/AMSimulationIOLinkDef.h")
        gROOT.ProcessLine("setTDRStyle()")

        gStyle.SetEndErrorSize(2)
        gStyle.SetPadRightMargin(0.05)
        gStyle.SetTitleOffset(1.1, "Y")
        gStyle.SetLabelSize(0.04, "Y")
        gStyle.SetLabelSize(0.04, "Z")
        gStyle.SetNdivisions(505, "XY")

        gStyle.SetPalette(55)  # rainbow color map
        gStyle.SetNumberContours(100)

        gStyle.SetOptStat(111110)
        gStyle.SetStatX(0.94)
        gStyle.SetStatY(0.93)
        gStyle.SetStatH(0.30)
        gStyle.SetStatW(0.28)

        TH1.SetDefaultSumw2()
Пример #18
0
def SetPaperStyle():

    ## histograms lines
    gStyle.SetHistFillColor(0)
    gStyle.SetHistFillStyle(0)

    gStyle.SetHistLineColor(1)
    gStyle.SetHistLineStyle(0)
    gStyle.SetHistLineWidth(1)

    ## suppress plot titles and fit box
    gStyle.SetOptTitle(0)
    gStyle.SetOptFit(0)

    ## axis settings
    gStyle.SetLabelFont(142, "xyz")
    gStyle.SetLabelSize(0.04, "xyz")

    gStyle.SetTitleFont(142, "xyz")
    gStyle.SetTitleOffset(1.2, "xyz")
    gStyle.SetTitleSize(0.05, "xyz")

    ## stat box
    gStyle.SetOptStat(0)  # suppress the stats box
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()
Пример #20
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)
Пример #21
0
gStyle.SetNdivisions(8, "z")
gStyle.SetTickLength(0.03, "x")
gStyle.SetTickLength(0.03, "y")
gStyle.SetTickLength(0.03, "z")
gStyle.SetFrameBorderSize(1)
gStyle.SetLegendBorderSize(1)
gStyle.SetCanvasBorderSize(1)
gStyle.SetPadBorderSize(1)
gStyle.SetStatBorderSize(1)
gStyle.SetTitleBorderSize(1)
gStyle.SetLabelOffset(0.005, "x")
gStyle.SetLabelOffset(0.005, "y")
gStyle.SetLabelOffset(0.005, "z")
gStyle.SetBarWidth(0.1)
gStyle.SetLineWidth(1)
gStyle.SetTitleOffset(1, "x")
gStyle.SetTitleOffset(0.8, "y")
gStyle.SetTitleOffset(1, "z")
gStyle.SetOptStat(0)

# User Options
listFiles = [
    "/afs/cern.ch/user/s/siborghi/cmtuser/Brunel_v37r1/Alignment/Escher/options/RunKalmSens61/Iter9/xml/Conditions/Velo/Alignment/Modules.xml"
]
compare2 = "Metrology"
fnamein2 = "/afs/cern.ch/user/s/siborghi/cmtuser/Alignment_v4r6/Alignment/Escher/scripts/AlignXml/ModulesMetrology.xml"

psfile = "ModConstDiff_wrt" + compare2 + ".ps"
ps = TPostScript(psfile, 112)
c1 = TCanvas('c1', '', 10, 10, 1200, 900)
c2 = TCanvas('c2', '', 10, 10, 1200, 900)
Пример #22
0
    rate_cdf.Draw("colz")
    cutFunction.Draw("lsame")

    c.Print("plots/"+c.GetName()+"_cdf.png")
    c.Clear()



if __name__ == '__main__' :
    gStyle.SetOptStat(0)
    gStyle.SetTitleFont(42, "p")
    gStyle.SetTitleColor(1)
    gStyle.SetTitleTextColor(1)
    gStyle.SetTitleFillColor(10)
    gStyle.SetTitleFontSize(0.05)
    gStyle.SetTitleOffset(1.2, "XYZ")
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")

    effFile = ROOT.TFile("egTriggerEff.root", "r")
    rateFile = ROOT.TFile("egTriggerRates.root", "r")
    eff = effFile.Get("analyzer/crystal_tree")
    rate = rateFile.Get("analyzer/crystal_tree")

    c = ROOT.TCanvas("canvas", "canvas", 1200, 600)

    c.SetName("hovere")
    c.SetTitle("H/E Value")
    # endcap: "22./x+0."
    drawCDFs(c, rate, eff, "cluster_hovere", "", "14/x+.05", 5)
Пример #23
0

# pylint: disable=import-error, no-name-in-module, unused-import
# pylint: disable=too-many-statements
# pylint: disable=too-many-branches
# pylint: disable=too-many-locals
def plot_hfmassfitter(case, 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,
              'r') as param_config:
        data_param = yaml.load(param_config, Loader=yaml.FullLoader)

    folder_plots = data_param[case]["analysis"]["dir_general_plots"]
    if not os.path.exists(folder_plots):
        print("creating folder ", folder_plots)
        os.makedirs(folder_plots)
Пример #24
0
from ROOT import gROOT, gStyle, TCanvas, TColor, TF1, TFile, TLegend, THStack, TGraph, TText, TLatex, kTRUE
from array import array

gROOT.SetBatch(True)

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

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

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

    #rebin stuff
Пример #25
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, "---")
Пример #26
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)
Пример #27
0
import ROOT
from ROOT import gROOT, gStyle
import argparse, os, json
import numpy as np

gROOT.SetBatch(True)
gStyle.SetOptStat(0)
gStyle.SetOptFit(0)
gStyle.SetOptTitle(0)

gStyle.SetTextFont(43)

gStyle.SetTitleOffset(0.86, "X")
gStyle.SetTitleOffset(1.8, "Y")
# gStyle.SetPadLeftMargin(0.18)
gStyle.SetPadLeftMargin(0.19)
# gStyle.SetPadBottomMargin(0.15)
gStyle.SetPadBottomMargin(0.12)
gStyle.SetPadTopMargin(0.08)
# gStyle.SetPadRightMargin(0.08)
gStyle.SetPadRightMargin(0.1)
gStyle.SetMarkerSize(0.5)
gStyle.SetHistLineWidth(2)
gStyle.SetTitleSize(0.05, "XYZ")
gStyle.SetLabelSize(0.04, "XYZ")
gStyle.SetNdivisions(506, "XYZ")
gStyle.SetLegendBorderSize(0)

leftMargin = 0.14

colors = {
Пример #28
0
def plot_map(out_file_path, hist):
    map_name = out_file_path if '/' not in out_file_path else out_file_path.split(
        '/')[-1]
    map_name = map_name.replace('.pdf', '')
    rho_min = -6.0
    rho_max = -2.6
    pt_min = 500.
    pt_max = 1200.
    # rho_min = -10
    # rho_max = 0
    # pt_min = 200
    # pt_max = 5000
    disc_min = 0.12
    disc_max = 0.3
    left_margin = 0.14
    right_margin = 0.16
    top_margin = 0.08
    bottom_margin = 0.12

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

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

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

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

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

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

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

    # hist.GetZaxis().SetNdivisions(20)

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

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

    c1 = TCanvas("c1", "c1", 700, 600)
    c1.cd()
    hist.Draw("colz")
    latex_border = TLatex()
    latex_border.SetNDC(1)
    latex_border.SetTextColor(1)
    latex_border.SetTextFont(43)
    latex_border.SetTextSize(15.5)
    latex_border.SetTextAngle(297)
    latex = TLatex()
    latex.SetNDC(1)
    latex.SetTextColor(920)
    latex.SetTextFont(43)
    latex.SetTextSize(15)
    # latex.SetTextAngle(297)
    for i in range(len(isomasses)):
        x_pitch = (1 - left_margin - right_margin) / (rho_max - rho_min)
        y_pitch = (1 - bottom_margin - top_margin) / (pt_max - pt_min)
        msd = isomasses[i]
        pt = msd * np.exp(-rho_min / 2)
        pt = 800 if pt > pt_max else pt
        angle = ((180 / np.pi) * np.arctan(2 * x_pitch / (pt * y_pitch))) + 272
        latex.SetTextAngle(angle)
        latex_border.SetTextAngle(angle)
        tf1_isomass = tf1_isomasses[i]
        tf1_isomass.Draw('SAME')
        x_pos = left_margin + (
            (2 * np.log(msd / pt) - rho_min)) * x_pitch + 0.01
        y_pos = bottom_margin + (pt - pt_min) * y_pitch + 0.01
        latex_border.DrawLatex(x_pos, y_pos, 'm_{SD} = %.1f GeV' % msd)
        # latex.DrawLatex(x_pos,y_pos,'m_{SD} = %.1f GeV'%msd)
    c1.SaveAs(out_file_path + ".pdf")
    c1.SaveAs(out_file_path + ".png")
    c1.SaveAs(out_file_path + ".C")
    del c1
Пример #29
0
def efficiencytracking(var):
    # plots the efficiency vs pT, eta and phi for all the species(it extracts the
    # Efficiency from qa - tracking - efficiency if you have ran with-- make - eff)
    hadron_list = [
        "pion",
        "proton",
        "kaon",
        "electron",
        "muon",
    ]
    color_list = [1, 2, 4, 6, 8]
    marker_list = [20, 21, 22, 34, 45]
    fileo2 = TFile("../codeHF/AnalysisResults_O2.root")

    c1 = TCanvas("c1", "Efficiency")
    gStyle.SetOptStat(0)
    gStyle.SetErrorX(0)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetTitleSize(0.045, "x")
    gStyle.SetTitleSize(0.045, "y")
    gStyle.SetMarkerSize(1)
    gStyle.SetLabelOffset(0.015, "x")
    gStyle.SetLabelOffset(0.02, "y")
    gStyle.SetTickLength(-0.02, "x")
    gStyle.SetTickLength(-0.02, "y")
    gStyle.SetTitleOffset(1.1, "x")
    gStyle.SetTitleOffset(1.0, "y")

    c1.SetCanvasSize(800, 600)
    c1.cd()
    c1.SetGridy()
    c1.SetGridx()
    eff_list = []

    if var == "Pt":
        hempty = TH1F("hempty", ";Transverse Momentum(GeV/c);Efficiency", 100,
                      0.05, 10)
        gPad.SetLogx()
    elif var == "Eta":
        hempty = TH1F("hempty", ";Pseudorapidity;Efficiency", 100, -4.0, 4.0)
    elif var == "Phi":
        hempty = TH1F("hempty", ";Azimuthal angle(rad);Efficiency", 100, 0.0,
                      6.0)

    hempty.GetYaxis().CenterTitle()
    hempty.GetXaxis().CenterTitle()
    hempty.GetXaxis().SetNoExponent()
    hempty.GetXaxis().SetMoreLogLabels(1)
    hempty.Draw()
    leg = TLegend(0.55, 0.15, 0.89, 0.35, "P")
    leg.SetNColumns(2)
    leg.SetHeader("Minimum bias KrKr #sqrt{s} = 6.46TeV", "C")
    leg.SetFillColor(0)

    for i, had in enumerate(hadron_list):
        leff = fileo2.Get("qa-tracking-efficiency-%s/Efficiency" % had)
        if var == "Pt":
            eff = leff.At(0)
        elif var == "Eta":
            eff = leff.At(1)
        elif var == "Phi":
            eff = leff.At(2)
        gPad.Update()
        eff.Paint("p")
        gr = eff.GetPaintedGraph().Clone()
        for j in range(0, gr.GetN()):
            gr.GetEXlow()[j] = 0
            gr.GetEXhigh()[j] = 0

        gr.SetLineColor(color_list[i])
        gr.SetMarkerColor(color_list[i])
        gr.SetMarkerStyle(marker_list[i])
        eff_list.append(gr)
        gr.Draw(" same p")
        leg.AddEntry(eff_list[i], had, "p")
    leg.Draw()
    saveCanvas(c1, "efficiency_tracking_%s" % var)
Пример #30
0
#Note for v3:
#The script is used to plot the comparison of B field distribution in Calculation and Simulation
#
#By Aiqiang Guo -- 2016/06/08
#===============================================================================================

from ROOT import gStyle, gSystem, gROOT, TCanvas, TF1, TFile, TTree, gRandom, TH1F, TH2F, TH1, kRed, kBlue, kBlack, kGreen, kYellow, TLegend
import numpy as np
#import rootnotes
#import rootprint
#import utils

gROOT.Reset()
gStyle.SetOptStat(0)
gStyle.SetPalette(1)
gStyle.SetTitleOffset(1.5,"xyz")
gSystem.Load("libMathMore")
#====================================================================
#Strategy: 1. build the list by selected data
#          2. transform the list to be array by array command
#	   3. loop the array to calculat the grediant of the B field.
#====================================================================

Bz2D = TH2F("Bz2D","Bz", 301,-2.0,1.0, 121,0,1.2)
Bz2D.GetXaxis().SetTitle("Z / m")
Bz2D.GetYaxis().SetTitle("R / m")
Bz2D.GetZaxis().SetTitle("Bz / T")
Bz2D.GetXaxis().CenterTitle()
Bz2D.GetYaxis().CenterTitle()
Bz2D.GetZaxis().CenterTitle()