def loadstyle():
     gStyle.SetOptStat(0)
     gStyle.SetOptStat(0000)
     gStyle.SetPalette(1)
     gStyle.SetNumberContours(100)
     gStyle.SetCanvasColor(0)
     gStyle.SetFrameFillColor(0)
 def __init__(self, run=22011, sourceDir='./', outputDir=''):
     print 'Creating AnalyseSelectionArea instance for run:', run
     self.run = run
     self.sourceDir = sourceDir
     self.outputDir = outputDir if outputDir != '' else '{s}/{r}/selectionAnalysis/'.format(
         r=self.run, s=self.sourceDir)
     self.rootFile = TFile(
         sourceDir +
         '/{r}/selectionAnalysis/root/histograms.{r}.{r}.root'.format(
             r=self.run))
     self.histo3D = TH3F(self.rootFile.Get('hChargeVsFidCut'))
     self.histo3D.GetXaxis().SetTitle('Silicon X/ch')
     self.histo3D.GetYaxis().SetTitle('Silicon Y/ch')
     self.histo1D = 0
     self.map = 0
     self.map_fid = 0
     self.sel_old = {
         'x_low': self.histo3D.GetXaxis().GetXmin(),
         'x_high': self.histo3D.GetXaxis().GetXmax(),
         'y_low': self.histo3D.GetYaxis().GetXmin(),
         'y_high': self.histo3D.GetYaxis().GetXmax()
     }
     self.fidcut = 0
     self.fidpoints = []
     self.nameFid = ''
     if not os.path.isdir('{dir}/Plots'.format(dir=self.outputDir)):
         os.makedirs('{dir}/Plots'.format(dir=self.outputDir))
     if not os.path.isdir('{dir}/root'.format(dir=self.outputDir)):
         os.makedirs('{dir}/root'.format(dir=self.outputDir))
     gStyle.SetPalette(55)
     gStyle.SetNumberContours(999)
     self.bla = []
Exemple #3
0
    def set2DStyle(self, opt="BasicRainBow"):

        gStyle.SetPadRightMargin(
            0.2
        )  # Leave more space to the right side of the current Pad to show the histogram scale

        if opt == "FancyRainBow":
            icol = 0
            gStyle.SetFrameBorderMode(icol)
            gStyle.SetFrameFillColor(icol)
            gStyle.SetCanvasBorderMode(icol)
            gStyle.SetCanvasColor(icol)
            gStyle.SetPadBorderMode(icol)
            gStyle.SetPadColor(icol)
            gStyle.SetStatColor(icol)
            gStyle.SetOptTitle(0)
            gStyle.SetOptStat(0)
            gStyle.SetOptFit(0)

            ncontours = 999

            s = array.array('d', [0.00, 0.34, 0.61, 0.84, 1.00])
            r = array.array('d', [0.00, 0.00, 0.87, 1.00, 0.51])
            g = array.array('d', [0.00, 0.81, 1.00, 0.20, 0.00])
            b = array.array('d', [0.51, 1.00, 0.12, 0.00, 0.00])

            npoints = len(s)
            TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
            gStyle.SetNumberContours(ncontours)

        if opt == "BasicRainBow":
            gStyle.SetPalette(
                1
            )  # This resets the color palette to a simple Rainbow Color Map w/ 50 colors. See https://root.cern.ch/doc/master/classTColor.html
Exemple #4
0
def set_palette(name="gray", ncontours=999):
    """Set a color palette from a given RGB list
    stops, red, green and blue should all be lists of the same length
    see set_decent_colors for an example"""

    if name == "gray" or name == "grayscale":
        stops = [0.00, 0.34, 0.61, 0.84, 1.00]
        red = [1.00, 0.84, 0.61, 0.34, 0.00]
        green = [1.00, 0.84, 0.61, 0.34, 0.00]
        blue = [1.00, 0.84, 0.61, 0.34, 0.00]
    # elif name == "whatever":
    # (define more palettes)
    else:
        # default palette, looks cool
        stops = [0.00, 0.34, 0.61, 0.84, 0.1]
        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]

    s = array('d', stops)
    r = array('d', red)
    g = array('d', green)
    b = array('d', blue)

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
    gStyle.SetNumberContours(ncontours)
def set_h2_color_style():
    n_rgb = 5
    n_contour = 255
    stops = np.array([0.00, 0.34, 0.61, 0.84, 1.00])
    reds = np.array([0.00, 0.00, 0.87, 1.00, 0.51])
    greens = np.array([0.00, 0.81, 1.00, 0.20, 0.00])
    blues = np.array([0.51, 1.00, 0.12, 0.00, 0.00])
    TColor.CreateGradientColorTable(n_rgb, stops, reds, greens, blues,
                                    n_contour)
    gStyle.SetNumberContours(n_contour)
    gPad.SetRightMargin(0.2)
Exemple #6
0
def set_palette(name="palette", n=100, ncontours=999):
    """Set a color palette from a given RGB list
    stops, red, green and blue should all be lists of the same length
    see set_decent_colors for an example"""

    if name == "gray" or name == "grayscale":
        stops = [0.00, 0.34, 0.61, 0.84, 1.00]
        red = [1.00, 0.84, 0.61, 0.34, 0.00]
        green = [1.00, 0.84, 0.61, 0.34, 0.00]
        blue = [1.00, 0.84, 0.61, 0.34, 0.00]
    elif name == "myPalette":
        # (define more palettes)
        stops = range(n)
        stops = [-3 + float(i) / n for i in stops]
        Cb = 0.4
        Cr = 0.6
        blue = [-1 / Cb * i + 1 for i in stops]
        green = stops
        red = [1 / (1 - Cr) * i for i in stops]
        for i in range(len(stops)):
            if stops[i] < Cb:
                green[i] = 0
                red[i] = 0
            if stops[i] > Cb and stops[i] < Cr:
                blue[i] = 0
                red[i] = 0
                if stops[i] < 0.5:
                    green[i] = stops[i] / (0.5 - Cb)
                else:
                    green[i] = stops[i] / (0.5 - Cr)
            if stops[i] > Cr:
                green[i] = 0
                blue[i] = 0


#        stops = [0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00]
#        red   = [0.00, 0.00, 0.00, 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 1.00]
#        green = [0.00, 0.10, 0.30, 0.60, 0.80, 0.60, 0.40, 0.20, 0.00, 0.00, 0.00]
#        blue  = [0.50, 0.60, 0.70, 0.80, 0.50, 0.30, 0.00, 0.00, 0.00, 0.00, 0.00]
    else:
        # default palette, looks cool
        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]

    s = array('d', stops)
    r = array('d', red)
    g = array('d', green)
    b = array('d', blue)

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
    gStyle.SetNumberContours(ncontours)
Exemple #7
0
def setpalette(name="rainbow", ncontours=99):
    """.. function::setpalette()
    
    Set a color palette from a given RGB list
    stops, red, green and blue should all be lists 
    of the same length 
    see set_decent_colors for an example"""
    from ROOT import TColor, gStyle
    from array import array

    if name == "gray" or name == "grayscale":
        stops = [0.00, 0.34, 0.61, 0.84, 1.00]
        red = [1.00, 0.84, 0.61, 0.34, 0.00]
        green = [1.00, 0.84, 0.61, 0.34, 0.00]
        blue = [1.00, 0.84, 0.61, 0.34, 0.00]
    elif name == 'darkbody':
        stops = [0.00, 0.25, 0.50, 0.75, 1.00]
        red = [0.00, 0.50, 1.00, 1.00, 1.00]
        green = [0.00, 0.00, 0.55, 1.00, 1.00]
        blue = [0.00, 0.00, 0.00, 0.00, 1.00]
    elif name == 'inv_darkbody':
        stops = [0.00, 0.25, 0.50, 0.75, 1.00]
        red = [1.00, 1.00, 1.00, 0.50, 0.00]
        green = [1.00, 1.00, 0.55, 0.00, 0.00]
        blue = [1.00, 0.00, 0.00, 0.00, 0.00]
    elif name == 'deepsea':
        stops = [0.00, 0.34, 0.61, 0.84, 1.00]
        red = [0.00, 0.09, 0.18, 0.09, 0.00]
        green = [0.01, 0.02, 0.39, 0.68, 0.97]
        blue = [0.17, 0.39, 0.62, 0.79, 0.97]
    elif name == 'forest':
        stops = [0.00, 0.25, 0.50, 0.75, 1.00]
        red = [0.93, 0.70, 0.40, 0.17, 0.00]
        green = [0.97, 0.89, 0.76, 0.64, 0.43]
        blue = [0.98, 0.89, 0.64, 0.37, 0.17]
    else:
        # default palette, looks cool
        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]

    s = array('d', stops)
    r = array('d', red)
    g = array('d', green)
    b = array('d', blue)

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
    gStyle.SetNumberContours(ncontours)
Exemple #8
0
def acustompalette(): 
    NRGBs = 7
    NCont = 100
    ncolors = array('i', [])
    gStyle.SetNumberContours(NCont);
    stops   = [ 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 ]
    red     = [ 1.00, 0.00, 0.00, 0.00, 0.97, 0.97, 0.10 ]
    green   = [ 1.00, 0.97, 0.30, 0.40, 0.97, 0.00, 0.00 ]
    blue    = [ 1.00, 0.97, 0.97, 0.00, 0.00, 0.00, 0.00 ]
    stopsArray = array('d', stops)
    redArray = array('d', red)
    greenArray = array('d', green)
    blueArray = array('d', blue)
    first_color_number = TColor.CreateGradientColorTable(NRGBs, stopsArray, redArray, greenArray, blueArray, NCont);
    gStyle.SetNumberContours(NCont)


    palsize = NCont
    palette = []
    for i in range(palsize):
        palette.append(first_color_number+i)
        palarray = array('i',palette)

    gStyle.SetPalette(palsize,palarray)
Exemple #9
0
def set_palette():
    """ Set a color palette from a given RGB list. stops, red, green and
    blue should all be lists of the same length. """

    stops = [0.00, 0.34, 0.61, 0.84, 1.00]
    red = [0.00, 0.00, 0.87, 1.00, 0.71]
    green = [0.10, 0.81, 1.00, 0.20, 0.10]
    blue = [0.61, 1.00, 0.12, 0.00, 0.00]

    s = array('d', stops)
    r = array('d', red)
    g = array('d', green)
    b = array('d', blue)

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, 100)
    gStyle.SetNumberContours(100)
Exemple #10
0
 def __init__(self, run=22011, sourceDir='./', outputDir=''):
     print 'Creating AnalyseTransparentArea instance for run:', run
     self.run = run
     self.sourceDir = sourceDir
     self.outputDir = outputDir if outputDir != '' else '{s}/{r}/transparentAnalysis/'.format(
         r=self.run, s=self.sourceDir)
     self.rootFile1 = TFile(
         sourceDir +
         '/{r}/transparentAnalysis/root/hLandau1HighestHitProfile_1OutOf10.{r}.root'
         .format(r=self.run))
     self.rootFile2 = TFile(
         sourceDir +
         '/{r}/transparentAnalysis/root/hLandau2HighestHitProfile_2OutOf10.{r}.root'
         .format(r=self.run))
     self.histo2D_1 = TProfile2D(
         self.rootFile1.Get('cRoot_hLandau1HighestHitProfile_1OutOf10').
         GetPrimitive('hLandau1HighestHitProfile_1OutOf10'))
     self.histo2D_2 = TProfile2D(
         self.rootFile2.Get('cRoot_hLandau2HighestHitProfile_2OutOf10').
         GetPrimitive('hLandau2HighestHitProfile_2OutOf10'))
     self.histo2D_1_fid = 0
     self.histo2D_2_fid = 0
     self.histo2D_1.GetXaxis().SetTitle('X/\mu m')
     self.histo2D_1.GetYaxis().SetTitle('Y/\mu m')
     self.histo2D_2.GetXaxis().SetTitle('X/\mu m')
     self.histo2D_2.GetYaxis().SetTitle('Y/\mu m')
     self.histo1D_1 = 0
     self.histo1D_2 = 0
     self.sel_old = {
         'x_low': self.histo2D_1.GetXaxis().GetXmin(),
         'x_high': self.histo2D_1.GetXaxis().GetXmax(),
         'y_low': self.histo2D_1.GetYaxis().GetXmin(),
         'y_high': self.histo2D_1.GetYaxis().GetXmax()
     }
     self.fidcut_1 = 0
     self.fidcut_2 = 0
     self.fidpoints = []
     self.nameFid = ''
     if not os.path.isdir('{dir}/Plots'.format(dir=self.outputDir)):
         os.makedirs('{dir}/Plots'.format(dir=self.outputDir))
     if not os.path.isdir('{dir}/root'.format(dir=self.outputDir)):
         os.makedirs('{dir}/root'.format(dir=self.outputDir))
     gStyle.SetPalette(55)
     gStyle.SetNumberContours(999)
     self.bla = []
def set_palette(ncontours=999):
    """Set a color palette from a given RGB list
    stops, red, green and blue should all be lists of the same length
    see set_decent_colors for an example"""

    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]

    s = array('d', stops)
    r = array('d', red)
    g = array('d', green)
    b = array('d', blue)

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
    gStyle.SetNumberContours(ncontours)
    pass
Exemple #12
0
def set_palette(name="default", ncontours=999, id=1 ):

    """Set a color palette from a given RGB list
    stops, red, green and blue should all be lists of the same length
    see set_decent_colors for an example"""

    if name == "gray" or name == "grayscale":         # simple grayscale
        _palette[ name ] = id
        stops = [0.00, 0.34, 0.61, 0.84, 1.00]
        red   = [1.00, 0.84, 0.61, 0.34, 0.00]
        green = [1.00, 0.84, 0.61, 0.34, 0.00]
        blue  = [1.00, 0.84, 0.61, 0.34, 0.00]
    elif name == "diffs":                           # grayscale in abs(z)
        _palette[ name ] = id
        stops = [0.00, 0.08, 0.195,0.33, 0.50-0.0001,0.500, 0.500+0.0001, 0.670,0.805,0.920,1.000]
        red   = [0.00/1.5, 0.34/1.5, 0.61/1.5, 0.84/1.5, 1.00,       1.000, 1.00,         0.84/1.5, 0.61/1.5, 0.34/1.5, 0.00] 
#       green = [0.00/1.5, 0.34/1.5, 0.61/1.5, 0.84/1.5, 1.00,       1.000, 1.00,         0.84/1.5, 0.61/1.5, 0.34/1.5, 0.00] 
        green = [0.00/1.5, 0.00/1.5, 0.00/1.5, 0.00/1.5, 1.00,       1.000, 1.00,         0.00/1.5, 0.00/1.5, 0.00/1.5, 0.00] 
#       blue  = [0.00/1.5, 0.34/1.5, 0.61/1.5, 0.84/1.5, 0.60,       0.600, 0.60,         0.84/1.5, 0.61/1.5, 0.34/1.5, 0.00] 
        blue  = [0.00/1.5, 0.00/1.5, 0.00/1.5, 0.00/1.5, 0.60,       0.600, 0.60,         0.00/1.5, 0.00/1.5, 0.00/1.5, 0.00] 

    elif name == "bool":                               # simple 1 or 0
        _palette[ name ] = id
        stops = [0.00,0.000001,1.00000]
        red   = [0.00,         1.0,1.0]
        green = red
        blue  = red
    else:                                              # default smooth color gradient
        _palette[ name ] = id
        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]

    s = array('d', stops)
    r = array('d', red)
    g = array('d', green)
    b = array('d', blue)

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
    gStyle.SetNumberContours(ncontours)
Exemple #13
0
    def set_palette(name='', ncontours=999):
        if name == 'gray' or name == 'grayscale':
            stops = [0.00, 0.34, 0.61, 0.84, 1.00]
            red   = [1.00, 0.84, 0.61, 0.34, 0.00]
            green = [1.00, 0.84, 0.61, 0.34, 0.00]
            blue  = [1.00, 0.84, 0.61, 0.34, 0.00]
        else:
            # default palette, looks cool
            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]

        s = array('d', stops)
        r = array('d', red)
        g = array('d', green)
        b = array('d', blue)

        npoints = len(s)
        TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
        gStyle.SetNumberContours(ncontours)
    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)
Exemple #15
0
def set_fancy_2D_style():

    icol = 0
    gStyle.SetFrameBorderMode(icol)
    gStyle.SetFrameFillColor(icol)
    gStyle.SetCanvasBorderMode(icol)
    gStyle.SetCanvasColor(icol)
    gStyle.SetPadBorderMode(icol)
    gStyle.SetPadColor(icol)
    gStyle.SetStatColor(icol)
    gStyle.SetOptTitle(0)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)

    ncontours = 999

    s = array('d', [0.00, 0.34, 0.61, 0.84, 1.00])
    r = array('d', [0.00, 0.00, 0.87, 1.00, 0.51])
    g = array('d', [0.00, 0.81, 1.00, 0.20, 0.00])
    b = array('d', [0.51, 1.00, 0.12, 0.00, 0.00])

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
    gStyle.SetNumberContours(ncontours)
    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()
Exemple #17
0
def make2DLimitPlot(xtitle, xvals, yvals, obs, exp, exp1plus, exp1minus,
                    exp2plus, exp2minus, theory, **kwargs):
    use_ctau = kwargs.pop('use_ctau', False)
    do_interpolation = kwargs.pop('do_interpolation', True)
    debug = kwargs.pop('debug', True)
    mass_splitting = kwargs.pop('mass_splitting', '0.1')

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

    axisTitleSize = 0.041
    axisTitleOffset = 1.2

    leftMargin = 0.15
    rightMargin = 0.18
    topMargin = 0.06
    bottomMargin = 0.14

    c1 = TCanvas("c1", "c1", 200, 10, 700, 600)
    c1.SetHighLightColor(2)
    c1.SetFillColor(0)
    c1.SetBorderMode(0)
    c1.SetBorderSize(2)
    c1.SetLeftMargin(leftMargin)
    c1.SetRightMargin(rightMargin)
    c1.SetTopMargin(topMargin)
    c1.SetBottomMargin(bottomMargin)
    c1.SetFrameBorderMode(0)
    c1.SetLogy(1)
    c1.SetLogx(1)
    c1.SetLogz(1)
    c1.SetTickx(1)
    c1.SetTicky(1)

    stops = np.array([0.00, 0.34, 0.61, 0.84, 1.00])
    red = np.array([0.50, 0.50, 1.00, 1.00, 1.00])
    green = np.array([0.50, 1.00, 1.00, 0.60, 0.50])
    blue = np.array([1.00, 1.00, 0.50, 0.40, 0.50])
    TColor.CreateGradientColorTable(len(stops), stops, red, green, blue, 255)
    gStyle.SetNumberContours(255)

    if debug:
        print "list of m1s:", xvals
        print "list of ys: ", yvals
        print "list of obs limits: ", obs

    if do_interpolation:
        data = interpolateObsLimit(xvals,
                                   yvals,
                                   obs,
                                   debug=debug,
                                   mass_splitting=mass_splitting)
    else:
        data = np.array([xvals, yvals, obs])

    widthx = sorted(data[0])[0] / 10
    widthy = sorted(data[1])[0] / 10

    lowXs = [xval - widthx / 2 for xval in data[0]]
    highXs = [xval + widthx / 2 for xval in data[0]]
    lowYs = [yval - widthy / 2 for yval in data[1]]
    highYs = [yval + widthy / 2 for yval in data[1]]
    binsX = sorted(list(dict.fromkeys(lowXs + highXs)))
    binsY = sorted(list(dict.fromkeys(lowYs + highYs)))
    binsX = [(binsX[i] + binsX[i + 1]) / 2 if i != len(binsX) - 1 else binsX[i]
             for i in range(1,
                            len(binsX) - 1, 2)]
    binsY = [(binsY[i] + binsY[i + 1]) / 2 if i != len(binsY) - 1 else binsY[i]
             for i in range(1,
                            len(binsY) - 1, 2)]
    binsX.insert(0, sorted(lowXs)[0])
    binsX.insert(len(binsX), sorted(highXs)[-1])
    binsY.insert(0, sorted(lowYs)[0])
    binsY.insert(len(binsY), sorted(highYs)[-1])

    if debug:
        print "binsX ", binsX
        print "binsY ", binsY

    obs_xsec = TH2D('', '',
                    len(binsX) - 1, array('d', binsX),
                    len(binsY) - 1, array('d', binsY))

    obs_xsec.GetXaxis().SetTitleSize(axisTitleSize)
    obs_xsec.GetXaxis().SetTitleOffset(axisTitleOffset - 0.3)
    obs_xsec.GetXaxis().SetTitle("m_{1} [GeV]")
    obs_xsec.GetXaxis().SetMoreLogLabels()

    obs_xsec.GetYaxis().SetTitleSize(axisTitleSize)
    obs_xsec.GetYaxis().SetTitleOffset(axisTitleOffset + 0.1)
    if use_ctau:
        obs_xsec.GetYaxis().SetTitle("c#tau [cm]")
    else:
        obs_xsec.GetYaxis().SetTitle(
            "y = #epsilon^{2} #alpha_{D} (m_{1}/m_{A'})^{4}")

    obs_xsec.GetZaxis().SetTitleSize(axisTitleSize - 0.005)
    obs_xsec.GetZaxis().SetTitleOffset(axisTitleOffset + 0.1)
    obs_xsec.GetZaxis().SetTitle(
        "#sigma_{95% CL} Br(A' #rightarrow #mu#mu) [pb]")

    obs_xsec.FillN(len(data[0]), array('d', data[0]), array('d', data[1]),
                   array('d', data[2]))
    obs_xsec.GetZaxis().SetRangeUser(1e-4, 1e2)

    if do_interpolation:
        obs_xsec.Draw("COLZ")
    else:
        obs_xsec.Draw("COLZ TEXT")

    obs_mu = [x / y for x, y in zip(obs, theory)]
    plotLimitBoundary(c1,
                      xvals,
                      yvals,
                      obs_mu, [1, kBlack],
                      debug=debug,
                      mass_splitting=mass_splitting)

    exp_mu = [x / y for x, y in zip(exp, theory)]
    plotLimitBoundary(c1,
                      xvals,
                      yvals,
                      exp_mu, [2, kRed],
                      debug=debug,
                      mass_splitting=mass_splitting)

    CMS_lumi(c1, "137.2 fb^{-1} (13 TeV)", 0)

    c1.RedrawAxis()
    c1.Draw()

    wait(True)
Exemple #18
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
Exemple #19
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)
Exemple #20
0
# 	p.SetMinimum(0.2)
# 	p.SetMaximum(5.5)
# 	p.GetZaxis().SetMoreLogLabels(1)

# 	p.Draw('colz')
# 	#p.GetZaxis().SetRangeUser(0.1,5.5)
# 	#p.SetMinimum(0.1)
# 	#p.SetMaximum(5.5)
# 	#c.Update()
# 	p.Write()
# 	plots.append(p)

# 	c.SetLogz(1)
# 	c.SaveAs('pdf/'+name+'.pdf')
gStyle.SetPalette(55)
gStyle.SetNumberContours(99)#999
#set_palette('',99)

the_maximum=-100.0
the_minimum=1000000.0
the_maximum_obs=-100.0
the_minimum_obs=1000000.0
the_maximum_exp=-100.0
the_minimum_exp=1000000.0
for masspoint in range(len(signalWB_names)):
	the_minimum = min(min(values_obs[masspoint][2]+values_exp[masspoint][2]),the_minimum)
	the_maximum = max(max(values_obs[masspoint][2]+values_exp[masspoint][2]),the_maximum)
	the_minimum_obs = min(min(values_obs[masspoint][2]),the_minimum_obs)
	the_maximum_obs = max(max(values_obs[masspoint][2]),the_maximum_obs)
	the_minimum_exp = min(min(values_exp[masspoint][2]),the_minimum_exp)
	the_maximum_exp = max(max(values_exp[masspoint][2]),the_maximum_exp)
Exemple #21
0
def applyRootStyle():

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

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

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

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

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

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

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

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

    # Grid
    # gStyle.SetGridStyle(3)

    # label offsets
    gStyle.SetLabelOffset(0.015)

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

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

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

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

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

    # Force the style
    gROOT.ForceStyle()
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)
# plot response matrices
# (do this in the end as the normalization otherwise will mess up the unfolding result!)
# -------------------------------------------------------------------------------------

ncontours = 256
stops = [0.00, 1.00]
red = [0.99, 0.32]
green = [0.99, 0.42]
blue = [0.99, 0.9]
s = array('d', stops)
r = array('d', red)
g = array('d', green)
b = array('d', blue)
npoints = len(s)
TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
gStyle.SetNumberContours(ncontours)

# -------------------------------------------------------------------------------------
# one-step unfolding
# -------------------------------------------------------------------------------------

gStyle.SetPadRightMargin(0.12)
cr = TCanvas("c_response", "", 800, 600)

hEmpty2D = response.Hresponse().Clone()
hEmpty2D.SetName("empty2D")
hEmpty2D.Reset()
hEmpty2D.GetXaxis().SetTitle("Reconstructed top jet p_{T} (GeV)")
hEmpty2D.GetYaxis().SetTitle("Top quark p_{T} (GeV)")
hEmpty2D.GetXaxis().SetLabelSize(0.045)
hEmpty2D.GetYaxis().SetLabelSize(0.045)
Exemple #24
0
#gSystem = TSystem.gSystem
#gStyle = TROOT.gStyle
#gROOT = TROOT.gROOT
gROOT.SetStyle("Plain")

nColors = 51
s = [0.00, 0.25, 0.50, 0.75, 1.00]
r = [0.99, 0.00, 0.87, 1.00, 0.70]
g = [0.99, 0.81, 1.00, 0.20, 0.00]
b = [0.99, 1.00, 0.12, 0.00, 0.00]
ss = array('d', s)
rr = array('d', r)
gg = array('d', g)
bb = array('d', b)
TColor.CreateGradientColorTable(len(ss), ss, rr, gg, bb, nColors)
gStyle.SetNumberContours(nColors)


def exists(file):
    x = FileStat_t()
    return (not gSystem.GetPathInfo("%s" % (file), x))


def getData(runNumber, fstep, lstep, tsteps, islocal=False):
    print "Retrieving data..."
    if islocal:
        print "Searching in local cluster"
    else:
        print "Searching on CASTOR"

    preambles = {}
Exemple #25
0

NRGBs=5
NCont =255
stops = [0.00,0.34,0.61,1.00,1.00]
red = [0.00,0.00,0.87,1.00,1.00]
green = [0.00,1.00,0.80,0.20,0.00]
blue = [1.00,1.00,0.20,0.00,0.00]

stopsArray = array('d',stops)
redArray = array('d',red)
greenArray = array('d',green)
blueArray = array('d',blue)

ROOT.TColor.CreateGradientColorTable(NRGBs,stopsArray,redArray,greenArray,blueArray,NCont)
gStyle.SetNumberContours(NCont)
gPad.SetLogz(1)
#gStyle.SetOptStat(0)
gPad.SetRightMargin(0.15)




Correlation_plot.Draw("colz")
gr.Draw("same")
gStyle.SetStatX(0.85)
gStyle.SetStatY(0.95)
gPad.Update()


Exemple #26
0
def fSetPalette(name="palette", ncontours=999):

    from array import array
    from ROOT import TColor, gStyle
    """Set a color palette from a given RGB list
  stops, red, green and blue should all be lists of the same length
  see set_decent_colors for an example"""

    if name == "gray" or name == "grayscale":
        stops = [0.00, 0.34, 0.61, 0.84, 1.00]
        red = [1.00, 0.84, 0.61, 0.34, 0.00]
        green = [1.00, 0.84, 0.61, 0.34, 0.00]
        blue = [1.00, 0.84, 0.61, 0.34, 0.00]
        # elif name == "whatever":
        # (define more palettes)
    if name == "DeepSea":
        ncontours = 32
        stops = [0.00, 0.34, 0.61, 0.84, 1.00]
        red = [0.00, 0.09, 0.18, 0.09, 0.00]
        green = [0.01, 0.02, 0.39, 0.68, 0.97]
        blue = [0.17, 0.39, 0.62, 0.79, 0.97]
    if name == "DarkBodyRadiator":
        ncontours = 32
        stops = [0.00, 0.25, 0.50, 0.75, 1.00]
        red = [0.00, 0.50, 1.00, 1.00, 1.00]
        green = [0.00, 0.00, 0.55, 1.00, 1.00]
        blue = [0.00, 0.00, 0.00, 0.00, 1.00]
    if name == "BlueYellow":
        ncontours = 64
        stops = [0.00, 0.50, 1.00]
        red = [0.00, 0.50, 1.00]
        green = [0.00, 0.50, 1.00]
        blue = [0.50, 0.50, 0.00]
    if name == "Green":
        ncontours = 64
        stops = [0.00, 0.50, 1.00]
        red = [0.00, 0.00, 0.00]
        green = [0.50, 0.50, 0.50]
        blue = [0.00, 0.00, 0.00]
    if name == "Red":
        ncontours = 64
        stops = [0.00, 0.50, 1.00]
        red = [0.50, 0.50, 0.50]
        green = [0.00, 0.00, 0.00]
        blue = [0.00, 0.00, 0.00]
    if name == "RainBow":
        ncontours = 64
        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]
    else:
        # default palette, looks cool
        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]

    s = array('d', stops)
    r = array('d', red)
    g = array('d', green)
    b = array('d', blue)

    npoints = len(s)
    TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)

    # For older ROOT versions
    #gStyle.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
    gStyle.SetNumberContours(ncontours)
        if not libs[0].removeEta(movl) :
            print "WARNING: no",movl,"in lib"

if (len(options.output) > 0) :
    print "INFO: Saving file",options.output
    libs[0].writeToFile(options.output)

if (options.draw) :
    print "INFO: Drawing lib",options.output
    from ROOT import TCanvas
    from ROOT import gROOT, gStyle,gPad
    gROOT.Reset()
    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetPalette(1)
    gStyle.SetNumberContours(50)

    c1 = TCanvas( 'c1', "Library Viewer")
    #gStyle.SetOptLogx(1)
    gPad.SetLogx(1)

    hits,containmentZ,containmentR = libs[0].drawHits()

    hits.Draw()
    containmentZ.SetMarkerColor(2)
    containmentZ.Draw("SAME")
    containmentR.SetMarkerColor(4)
    containmentR.Draw("SAME")
    c1.Update()
    from time import sleep
    while not not(c1) :
Exemple #28
0
    def Simulate(self, save=None, draw=None):
        '''

        :param save: if True: saves the root file as well as the true signal distribution
        :param draw: if True draws the signal distribution
        :param ask:
        :return:
        '''

        # Settings:
        MPV = self.MCAttributes['Landau_MPV_bkg']  # background for Landau MPV distribution
        sigma = self.MCAttributes['Landau_Sigma']  # Landau scaling sigma
        NPeaks = self.MCAttributes['NPeaks']
        MCRunPath = self.MCAttributes['MCRunPath'].format(self.RunNumber)
        xmin = self.diamond.Position['xmin'] + 0.01
        xmax = self.diamond.Position['xmax'] - 0.01
        ymin = self.diamond.Position['ymin'] + 0.01
        ymax = self.diamond.Position['ymax'] - 0.01
        center_x = (xmax + xmin) / 2.
        center_y = (ymax + ymin) / 2.
        if draw != None:
            assert (type(draw) == t.BooleanType), "draw has to be boolean type"
            self.MCAttributes['DrawRealDistribution'] = draw
        if save != None:
            assert (type(save) == t.BooleanType), "save argument has to be of type boolean"
            self.MCAttributes['Save'] = save

        def ManualHitDistribution(x, par):
            '''
            Probability density function for hit distribution based on
            6 2d gaussian in a rectangular pattern. The PDF is NOT
            normalized to 1
            :param x: array, x[0]: x position, x[1]: y position
            :param par: parameter array;
            :return:
            '''
            result = 0.1  # bkg
            norm = 1.
            sigma = 0.04
            for i in range(len(par) / 2):
                result += norm * TMath.Gaus(x[0], par[2 * i], sigma) * TMath.Gaus(x[1], par[2 * i + 1], sigma)
            return result

        def CreateRandomPeaksConfig(xmin, xmax, ymin, ymax, bkg=120, peak_height=0.5, npeaks=NPeaks):
            '''
            Creates the input parameters for SignalShape, which describes the peak distribution in the
            Signal distribution
            :param xmin: window parameter
            :param xmax: window parameter
            :param ymin: window parameter
            :param ymax: window parameter
            :param bkg: background of signal response
            :param peak_height: height of one peak in % of bkg, if bkg==0: the peaks heights are set to 1
            :param npeaks: number of peaks in window - if none it picks random between 0 and 15
            :return: array containing the parameters
            '''
            if npeaks == None:
                npeaks = int(round(gRandom.Uniform(0, 15)))

            if self.MCAttributes['SpecialDistribution'] in ["Central", "central"]:
                npeaks = 1
                dxy = 0.02
                parameters = np.zeros(7)
                parameters[0] = npeaks
                parameters[1] = bkg
                parameters[2] = peak_height
                parameters[3] = gRandom.Uniform(center_x - dxy, center_x + dxy)
                parameters[4] = gRandom.Uniform(center_y - dxy, center_y + dxy)
                parameters[5] = gRandom.Uniform(self.MCAttributes['PeakSigmaX_min'], self.MCAttributes['PeakSigmaX_max'])
                parameters[6] = gRandom.Uniform(self.MCAttributes['PeakSigmaY_min'], self.MCAttributes['PeakSigmaY_max'])
            elif self.MCAttributes['SpecialDistribution'] in ["4Peaks", "4peaks", "L", "3Peaks"]:
                npeaks = 4
                dxy = 0.02
                parameters = np.zeros(3 + 4 * npeaks)
                parameters[0] = npeaks
                parameters[1] = bkg
                parameters[2] = peak_height
                # peaks:
                peaknr = 0
                for x in [center_x - 0.07, center_x + 0.07]:
                    for y in [center_y - 0.07, center_y + 0.07]:
                        parameters[3 + 4 * peaknr] = gRandom.Uniform(x - dxy, x + dxy)
                        parameters[4 + 4 * peaknr] = gRandom.Uniform(y - dxy, y + dxy)
                        parameters[5 + 4 * peaknr] = gRandom.Uniform(self.MCAttributes['PeakSigmaX_min'], self.MCAttributes['PeakSigmaX_max'])
                        parameters[6 + 4 * peaknr] = gRandom.Uniform(self.MCAttributes['PeakSigmaY_min'], self.MCAttributes['PeakSigmaY_max'])
                        peaknr += 1
                if self.MCAttributes['SpecialDistribution'] in ["L", "3Peaks"]:
                    npeaks = 3
                    parameters[0] = npeaks
                    parameters = parameters[:3 + 4 * npeaks]
            elif self.MCAttributes['SpecialDistribution'] in ["Testpattern", "testpattern", "Test", "test"]:
                npeaks = 8
                Center_x = gRandom.Uniform(center_x - 0.01, center_x + 0.01)
                Center_y = gRandom.Uniform(center_y - 0.01, center_y + 0.01)
                parameters = np.zeros(3 + 4 * npeaks)
                parameters[0] = npeaks
                parameters[1] = bkg
                parameters[2] = peak_height
                parameters[3] = Center_x - 0.1
                parameters[4] = Center_y + 0.08
                parameters[5] = 0.02
                parameters[6] = 0.02
                parameters[7] = Center_x - 0.04
                parameters[8] = Center_y + 0.08
                parameters[9] = 0.02
                parameters[10] = 0.02
                parameters[11] = Center_x - 0.1
                parameters[12] = Center_y
                parameters[13] = 0.025
                parameters[14] = 0.025
                parameters[15] = Center_x
                parameters[16] = Center_y
                parameters[17] = 0.02
                parameters[18] = 0.02
                parameters[19] = Center_x + 0.1
                parameters[20] = Center_y
                parameters[21] = 0.03
                parameters[22] = 0.03
                parameters[23] = Center_x - 0.04
                parameters[24] = Center_y - 0.06
                parameters[25] = 0.015
                parameters[26] = 0.015
                parameters[27] = Center_x - 0.12
                parameters[28] = Center_y - 0.12
                parameters[29] = 0.03
                parameters[30] = 0.03
                parameters[31] = Center_x + 0.08
                parameters[32] = Center_y - 0.12
                parameters[33] = 0.04
                parameters[34] = 0.04
            else:
                parameters = np.zeros(3 + 4 * npeaks)
                parameters[0] = npeaks
                parameters[1] = bkg
                parameters[2] = peak_height
                for i in range(npeaks):
                    parameters[3 + 4 * i] = gRandom.Uniform(xmin, xmax)
                    parameters[4 + 4 * i] = gRandom.Uniform(ymin, ymax)
                    parameters[5 + 4 * i] = gRandom.Uniform(0.02, 0.07)
                    parameters[6 + 4 * i] = gRandom.Uniform(0.02, 0.07)
            self.MCAttributes['NPeaks'] = npeaks
            return parameters

        def SignalShape(x, par):
            '''

            :param x:   x[0]: x position
                        x[1]: y position
            :param par: par[0]: number of peaks
                        par[1]: mean bkg signal
                        par[2]: peak height in percent of bkg
                        par[3]: peak1 x position
                        par[4]: peak1 y position
                        par[5]: peak1 sigma in x
                        par[6]: peak1 sigma in y
                        ...
                        par[3+4*n]: peakn x position
                        par[4+4*n]: peakn y position
                        par[5+4*n]: peakn sigma in x
                        par[6+4*n]: peakn sigma in y
            :return:
            '''
            norm = par[1] * par[2]
            result = par[1]
            if par[1] == 0:
                norm = 1
            for i in range(int(par[0])):
                result += norm * TMath.Gaus(x[0], par[3 + 4 * i], par[5 + 4 * i]) * TMath.Gaus(x[1], par[4 + 4 * i], par[6 + 4 * i])
            return result

        # Set seed for random number generator:
        today = datetime.today()
        seed = int((today - datetime(today.year, today.month, today.day, 0, 0, 0, 0)).total_seconds() % 1800 * 1e6)
        gRandom.SetSeed(seed)

        # create track_info ROOT file
        if not os.path.exists(MCRunPath):
            os.makedirs(MCRunPath)
        if self.MCAttributes['Save']:
            file = TFile(MCRunPath + 'track_info.root', 'RECREATE')
        self.track_info = TTree('track_info', 'MC track_info')
        track_x = array('f', [0])
        track_y = array('f', [0])
        integral50 = array('f', [0])
        calibflag = array('i', [0])
        calib_offset = array('i', [0])
        time_stamp = array('f', [0])
        self.track_info.Branch('track_x', track_x, 'track_x/F')
        self.track_info.Branch('track_y', track_y, 'track_y/F')
        self.track_info.Branch('integral50', integral50, 'integral50/F')
        self.track_info.Branch('calibflag', calibflag, 'calibflag/I')
        self.track_info.Branch('calib_offset', calib_offset, 'calib_offset/I')
        self.track_info.Branch('time_stamp', time_stamp, 'time_stamp/F')

        # Create Manual Hit Distribution:
        if self.MCAttributes['HitDistributionMode'] == 'Manual':
            dx = 0.08
            dy = 0.07
            f_lateral = TF2('f_lateral', ManualHitDistribution, xmin, xmax, ymin, ymax, 12)
            f_lateral.SetNpx(80)
            f_lateral.SetNpy(80)
            # 6 gaus centers:
            par = np.array([center_x - dx / 2.,  # x1
                            center_y + dy,  # y1
                            center_x + dx / 2.,  # x2
                            center_y + dy,  # y2
                            center_x + dx / 2.,  # x3
                            center_y,  # y3
                            center_x - dx / 2.,  # x4
                            center_y,  # y4
                            center_x - dx / 2.,  # x5
                            center_y - dy,  # y5
                            center_x + dx / 2.,  # x6
                            center_y - dy  # y6
                            ])
            f_lateral.SetParameters(par)
        a = Double()
        b = Double()

        # Generate Signal Distribution:
        if self.MCAttributes['SignalMode'] == 'Landau':
            self.SignalParameters = CreateRandomPeaksConfig(xmin, xmax, ymin, ymax, peak_height=self.MCAttributes['PeakHeight'], bkg=MPV)
        else:
            self.SignalParameters = CreateRandomPeaksConfig(xmin, xmax, ymin, ymax, peak_height=self.MCAttributes['PeakHeight'], bkg=100)
        f_signal = TF2('f_signal', SignalShape, xmin, xmax, ymin, ymax, len(self.SignalParameters))
        f_signal.SetNpx(40)  # Resolution
        f_signal.SetNpy(40)
        f_signal.SetParameters(self.SignalParameters)
        if self.MCAttributes['DrawRealDistribution']:
            canvas = TCanvas('canvas', 'canvas')
            canvas.cd()
            gStyle.SetPalette(55)  # a Rain Bow palette == used.
            gStyle.SetNumberContours(8)
            f_signal.Draw('surf1')
            gPad.Print(MCRunPath + 'RealSignalDistribution.png')
            if self.ShowAndWait:
                answer = input('for data creation, type `yes`: ')
            else:
                answer = 'yes'
        else:
            answer = 'yes'

        # Set the Hit distribution for Manual or Import
        if self.MCAttributes['HitDistributionMode'] == 'Manual':
            HitsTemplate = f_lateral
        elif self.MCAttributes['HitDistributionMode'] == 'Import':
            HitsTemplate = self.counthisto

        mc_start_timestamp = 42.  # arbitrary timestamp for the first MC event
        MCEventDeltaTime = 30. * 60. / 300000.  # 1800s/300000Hits = 0.006s/Hit
        tmp_time = mc_start_timestamp
        # Generate Toy Data:
        if answer == 'yes':
            if self.verbose:
                self.ShowMCConfig()
            self.verbose_print('Creating Toy Data with {0} Hits'.format(self.NumberOfHits))
            integral50_max = self.MCAttributes['integral50_max']  # Maximum of Signal response allowed (data: 500 ?)
            i = 0
            j = 0
            while i < self.NumberOfHits and j < 2 * self.NumberOfHits:
                # Get x and y
                if self.MCAttributes['HitDistributionMode'] == 'Uniform':
                    track_x[0] = gRandom.Uniform(xmin, xmax)
                    track_y[0] = gRandom.Uniform(ymin, ymax)
                else:
                    HitsTemplate.GetRandom2(a, b)
                    track_x[0] = gRandom.Gaus(a, self.MCAttributes['TrackResolution'])  # 0.002 = 20mu track resolution (first guess)
                    track_y[0] = gRandom.Gaus(b, self.MCAttributes['TrackResolution'])

                # Get Signal at x and y
                if self.MCAttributes['SignalMode'] == 'Landau':
                    integral50[0] = gRandom.Landau(f_signal(track_x[0], track_y[0]), sigma)
                else:
                    integral50[0] = gRandom.Gaus(f_signal(track_x[0], track_y[0]), 0.6 * f_signal(track_x[0], track_y[0]) - 33)

                # check if found values fulfill requirements
                if xmin < track_x[0] < xmax and ymin < track_y[0] < ymax and integral50[0] < integral50_max:
                    tmp_time += MCEventDeltaTime
                    time_stamp[0] = tmp_time
                    self.track_info.Fill()
                    self.Data['track_x'].append(track_x[0])
                    self.Data['track_y'].append(track_y[0])
                    self.Data['integral50'].append(integral50[0])
                    i += 1
                j += 1
            if not j < 2 * self.NumberOfHits:  # if too many times requirements were not fulfilled
                assert (False), "Bad MC Parameters"

            # Save root file and true Signal Shape:
            if self.MCAttributes['Save']:
                file.Write()
                f_signal.SaveAs(MCRunPath + 'RealSignalDistribution.root')
                self.verbose_print(MCRunPath + 'track_info.root has been written')
                self.TrackingPadAnalysis['ROOTFile'] = MCRunPath + 'track_info.root'

            # Print Settings of created data:
            if self.verbose:
                print("\nToydata containing {:.0f} peaks generated.".format(self.SignalParameters[0]))
                if self.MCAttributes['SignalMode'] == 'Landau':
                    for i in range(int(self.SignalParameters[0])):
                        x = self.SignalParameters[3 + 4 * i]
                        y = self.SignalParameters[4 + 4 * i]
                        print("Peak {0:.0f} at position: ({1:.3f}/{2:.3f}) with Laundau Response MPV: {3:.2f} Sigma: {4:.1f}".format(i + 1, x, y, f_signal(x, y), sigma))
                else:
                    integral50[0] = gRandom.Gaus(f_signal(track_x[0], track_y[0]), 0.6 * f_signal(track_x[0], track_y[0]) - 33)
                    for i in range(int(self.SignalParameters[0])):
                        x = self.SignalParameters[3 + 4 * i]
                        y = self.SignalParameters[4 + 4 * i]
                        print("Peak {0:.0f} at position: ({1:.3f}/{2:.3f}) with Gaussian Response Mean: {3:.2f} Sigma: {4:.1f}".format(i + 1, x, y, f_signal(x, y), 0.6 * f_signal(x, y) - 33))

            self.DataIsMade = True
            self.verbose_print('Monte Carlo Toy Data created.\n')
Exemple #29
0
from ROOT import TTree, TChain, TFile
from ROOT import TRandom3, TMath, TCanvas, TObject, TObjArray

#Load User Classes
from ROOT import DmtpcDataset, DmtpcEvent
from ROOT import DmtpcSkimDataset, DmtpcSkimEvent

gROOT.SetStyle("Pub")

#Reset color palette
stops = array('d', [0, 0.34, 0.61, 0.84, 1.0])
red = array('d', [0.0, 0.0, 0.87, 1.0, 0.51])
green = array('d', [0.0, 0.81, 1.00, 0.2, 0.0])
blue = array('d', [0.51, 1.0, 0.12, 0.0, 0.0])
ROOT.TColor.CreateGradientColorTable(5, stops, red, green, blue, 255)
gStyle.SetNumberContours(255)
stops = None
red = None
green = None
blue = None

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

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

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


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