Exemplo n.º 1
0
def makePlots():
    '''
    Read csv into pandas dataframe
    '''
    data = pd.read_csv('ADhit.csv',delimiter=',')

    '''
    Make numpy arrays
    '''
    xwall = np.array(data['ADx'][(data['pdg'] == 13) | (data['pdg'] == -13)])
    zwall = np.array(data['ADz'][(data['pdg'] == 13) | (data['pdg'] == -13)])

    xstart = np.array(data['nux'][(data['pdg'] == 13) | (data['pdg'] == -13)])
    zstart = np.array(data['nuz'][(data['pdg'] == 13) | (data['pdg'] == -13)])

    '''
    Plotting
    '''
    import matplotlib.pyplot as plt
    from matplotlib.patches import Rectangle
    from matplotlib.patches import Circle
    from matplotlib.ticker import FormatStrFormatter
    from matplotlib.colors import LogNorm
    # I put this in your rootpy folder
    from plot_defaults import set_ticklines
    from plot_defaults import set_tick_sizes

    # set size of figure
    myfig = plt.figure(figsize=(10,8))
    # adjust whitesplace margins (1 = no margin)
    myfig.subplots_adjust(left=0.13)
    myfig.subplots_adjust(bottom=0.12)
    myfig.subplots_adjust(top=0.96)
    myfig.subplots_adjust(right=.97)

    # specify image name and save location
    file_name = "/NewBigDirt/wallhits_mu_zx.pdf"
    save_path = "/home/katherine/Documents/VetoWall/DirtMC/"

    # actual plot code ( plt.scatter(x,y, args), etc. )
    # dont forget to "label" each line, the label is used for the legend

    for i in range(len(xstart)):
        if zstart[i] < zwall[i]:
            plt.plot((zstart[i],zwall[i]),(xstart[i],xwall[i]),linewidth=0.2,color='steelblue',alpha=0.5)
        else:
            plt.plot((zstart[i],zwall[i]),(xstart[i],xwall[i]),linewidth=0.2,color='tomato',alpha=0.5)

    #plt.scatter(hZDirt,hXDirt, c=hEDirt, cmap='Greens', norm=LogNorm(), linewidth=0.,alpha=.5, s=10)
    #cb = plt.colorbar()
    #cb.set_label('Photon Energy [GeV]',fontsize=24)
    
    # label the axes (notice how to use latex) (label pad specifies how
    # space between the label and the plot outside axes
    plt.xlabel("Z [cm]",labelpad=10,fontsize=24)
    plt.ylabel("X [cm]",labelpad=5,fontsize=24)

    # define x and y ranges
    #xmin = 0
    #xmax = 1010
    #ymax = 200
    #ymin = 0
    # set the ranges
    #plt.axis([xmin,xmax,ymin,ymax])
    plt.xlim(-1100,1490)
    plt.ylim(-900,1400)

    # set locators of axis window tick marks
    xminorLocator = plt.MultipleLocator(50)
    xmajorLocator = plt.MultipleLocator(500)
    yminorLocator = plt.MultipleLocator(50)
    ymajorLocator = plt.MultipleLocator(500)
    # get axis object
    ax = plt.gca()
    #ax.set_yscale('log')
    ax.xaxis.set_major_locator(xmajorLocator)
    ax.xaxis.set_minor_locator(xminorLocator)
    ax.yaxis.set_minor_locator(yminorLocator)
    ax.yaxis.set_major_locator(ymajorLocator)
    #format axis labels
    majorFormatter = FormatStrFormatter('%g')
    ax.yaxis.set_major_formatter(majorFormatter)
    ax.xaxis.set_major_formatter(majorFormatter)
    # set size of tick marks
    set_ticklines(ax,2.0,0.75*2.0)
    set_tick_sizes(ax,13,7)


    # change size of axis labels
    ax.tick_params(axis='both', which='major', labelsize=24)
    ax.tick_params(axis='both', which='minor', labelsize=24)

    # Add boxes and stuff
    #ax.add_patch(Rectangle((0.,0.),1036.8,256.35,facecolor='none',alpha=.9))
    #ax.add_patch(Rectangle((-127.34,-64.825),1291.485,386,facecolor='none'))
    #ax.add_patch(Rectangle((0.,-116.5),1036.8,233.,facecolor='none',alpha=.9))
    #ax.add_patch(Rectangle((0.,-116.5),256.35,233.,facecolor='none',alpha=.9))
    #ax.add_patch(Rectangle((-127.34,-116.5-64.825),1291.485,386,facecolor='none'))
    #ax.add_patch(Rectangle((-273.98,-579.12),1584.96,1158.24,facecolor='none'))
    #ax.add_patch(Rectangle((-665.5,-579.12),1584.96,1158.24,facecolor='none'))
    #ax.add_patch(Circle((518.4,128.175),792.48,facecolor='none'))

    # apply the legend
    #plt.legend(loc='upper right',frameon=False, scatterpoints=1, fontsize=24, ncol=1)
    plt.text(-900,1150,'Muons in Tagger Wall',fontsize=24)

    # save the figure as pdf
    plt.savefig(save_path + file_name)
Exemplo n.º 2
0
def makePlots():
    '''
    Read csv into pandas dataframe
    '''
    data = pd.read_csv('photons/dirtGamShower.csv',delimiter=',')
    data = data[data['phErg'] >= .05]
    '''
    Plotting
    '''
    import matplotlib.pyplot as plt
    from matplotlib.patches import Rectangle
    from matplotlib.patches import Circle
    from matplotlib.ticker import FormatStrFormatter
    from matplotlib.colors import LogNorm
    # I put this in your rootpy folder
    from plot_defaults import set_ticklines
    from plot_defaults import set_tick_sizes

    # set size of figure
    myfig = plt.figure(figsize=(10,8))
    # adjust whitesplace margins (1 = no margin)
    myfig.subplots_adjust(left=0.13)
    myfig.subplots_adjust(bottom=0.12)
    myfig.subplots_adjust(top=0.96)
    myfig.subplots_adjust(right=.97)

    # specify image name and save location
    file_name = "/photons/phConvTag_zx.pdf"
    save_path = "/home/kate/Documents/dirtmc"

    # actual plot code ( plt.scatter(x,y, args), etc. )
    # dont forget to "label" each line, the label is used for the legend

    '''
    for i in range(len(data)):
        plt.plot((data['phstartz'][i],data['phendz'][i]),(data['phstartx'][i],data['phendx'][i]),linewidth=1,color='green',alpha=1.)
    plt.plot((data['phstartz'][0],data['phendz'][0]),(data['phstartx'][0],data['phendx'][0]),linewidth=0.2,color='green',alpha=0.5,label='Dirt photon tracks')
    '''
    
    #plt.hist2d(data['nuz'],data['nux'],bins=(np.linspace(-2500,3000,80),np.linspace(-2000,2300,80)))
    #plt.hist(data['phErg'],bins=50,alpha=0.6,label='Dirt Photons')
    
    plt.scatter(data['phstartz'],data['phstartx'], color='steelblue')
    plt.scatter(data['phstartz'][data['NumAD'] > 1],data['phstartx'][data['NumAD'] > 1], color='red')
    plt.scatter(-5000,5000, color='steelblue',s=80,label='Dirt Photon Start Position')
    plt.scatter(-5000,5000, color='red',s=80,label='Tagged Dirt Photon Start Position')
    
    #cb = plt.colorbar()
    #cb.set_label('Photon Energy [GeV]',fontsize=24)
    
    # label the axes (notice how to use latex) (label pad specifies how
    # space between the label and the plot outside axes
    plt.xlabel("Z [cm]",labelpad=10,fontsize=24)
    plt.ylabel("X [cm]",labelpad=5,fontsize=24)

    # define x and y ranges
    #xmin = 0
    #xmax = 1010
    #ymax = 200
    #ymin = 0
    # set the ranges
    #plt.axis([xmin,xmax,ymin,ymax])
    plt.xlim(-500,1500)
    plt.ylim(-700,1000)

    # set locators of axis window tick marks
    xminorLocator = plt.MultipleLocator(20)
    xmajorLocator = plt.MultipleLocator(200)
    yminorLocator = plt.MultipleLocator(20)
    ymajorLocator = plt.MultipleLocator(200)
    # get axis object
    ax = plt.gca()
    #ax.set_yscale('log')
    ax.xaxis.set_major_locator(xmajorLocator)
    ax.xaxis.set_minor_locator(xminorLocator)
    ax.yaxis.set_minor_locator(yminorLocator)
    ax.yaxis.set_major_locator(ymajorLocator)
    #format axis labels
    majorFormatter = FormatStrFormatter('%g')
    ax.yaxis.set_major_formatter(majorFormatter)
    ax.xaxis.set_major_formatter(majorFormatter)
    # set size of tick marks
    set_ticklines(ax,2.0,0.75*2.0)
    set_tick_sizes(ax,13,7)

    # change size of axis labels
    ax.tick_params(axis='both', which='major', labelsize=24)
    ax.tick_params(axis='both', which='minor', labelsize=24)

    # Add boxes and stuff
    ax.add_patch(Rectangle((0.,0.),1036.8,256.35,facecolor='none',alpha=.9))
    #ax.add_patch(Rectangle((-127.34,-64.825),1291.485,386,facecolor='none'))
    #ax.add_patch(Rectangle((0.,-116.5),1036.8,233.,facecolor='none',alpha=.9))
    #ax.add_patch(Rectangle((0.,-116.5),256.35,233.,facecolor='none',alpha=.9))
    #ax.add_patch(Rectangle((-127.34,-116.5-64.825),1291.485,386,facecolor='none'))
    #ax.add_patch(Rectangle((-273.98,-579.12),1584.96,1158.24,facecolor='none'))
    #ax.add_patch(Rectangle((-665.5,-579.12),1584.96,1158.24,facecolor='none'))
    ax.add_patch(Circle((518.4,128.175),792.48,facecolor='none'))

    # apply the legend
    plt.legend(loc='lower left',frameon=False, scatterpoints=1, fontsize=24, ncol=1)
    #plt.text(-900,1150,'Muons in Tagger Wall',fontsize=24)

    # save the figure as pdf
    plt.savefig(save_path + file_name)