import matplotlib.pyplot as plt
import numpy as np

Up = np.array([479914439.058,
	1009076374.27,
	122246330.086,
	777985432.313,
	820634075.82,
	1107475791.5])
Down = np.array([598379310.934,
	1034631179.15,
	162399079.411,
	842365021.118,
	862091032.419,
	1024617070.28])

#convert to 1/fb
Up = Up/10e8
Down = Down/10e8

#Get numbers per run
Up_Run = np.array([np.sum(Up[0:1]), np.sum(Up[2:5])])
Down_Run = np.array([np.sum(Down[0:1]), np.sum(Down[2:5])])


#Add together
Both = Up+Down
Both_Run = Up_Run+Down_Run
#print (Both)

#make a year array
years = np.array([2011,2012,2015,2016,2017,2018])

#make a run array
Run = [1,2]

#Plot luminosity vs year
title_xaxis = "Year"
title_yaxis = "Intgrated recorded luminosity 1/fb"

#set xtick sizes
plt.rcParams['xtick.labelsize'] = 14
plt.rcParams['ytick.labelsize'] = 14
plt.rcParams['legend.fontsize'] = 13

#Set axis labels
plt.ylabel(title_yaxis, fontsize = 15, labelpad=10)
plt.xlabel(title_xaxis, fontsize = 15, labelpad=10)

#Set axis range
plt.axis([2010,2019,0,2.9])

#plot three datasets
plt.plot(years,Up,'o', label = "Up")
plt.plot(years,Down,'o', label = "Down")
plt.plot(years,Both,'o', label = "Up+Down")

#plot legend
plt.legend()

#adjust margins
plt.subplots_adjust(left=0.15, right=0.96, top=0.95, bottom=0.15)

#Save
plt.savefig("./Lumi.pdf")

#Define a relative ratio
ratio = abs(Up-Down)/Both
ratioRun =(Down_Run/Up_Run)#/Both_Run

#Clear the plots
plt.clf()
plt.plot(Run,ratioRun, 'o', label = "abs(Up-Down)/(Up+Down)")

plt.show()









