ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KF_timing.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KF_timing.py
1 import ROOT
2 import csv
3 import matplotlib.pyplot as plt
4 import numpy as np
5 
6 # Data preparation
7 ptDict = {}
8 
9 # Open the output file
10 with open('output.log', mode='r') as csv_file:
11  csv_reader = csv.reader(csv_file, delimiter=',')
12  # read lines and go for it
13  for csv_row in csv_reader :
14  if len(csv_row) > 1 :
15  # get the job id
16  jobID = csv_row[0]
17  # etabin, pt value, exec time
18  etabin = float(csv_row[1])
19  ptvalue = float(csv_row[2])
20  exectime = float(csv_row[3])
21 
22  # Make sure you have all the keys ready
23  try :
24  pdict = ptDict[ptvalue]
25  except :
26  ptDict[ptvalue] = {}
27  pdict = ptDict[ptvalue]
28 
29  # Now fill the sub dictionary
30  try :
31  vpdict = pdict[etabin]
32  except:
33  pdict[etabin] = []
34  vpdict = pdict[etabin]
35 
36  vpdict += [ exectime ]
37 
38 # plot the ptDict
39 plt.figure(figsize=(7, 5))
40 
41 ax = plt.subplot(111)
42 plt.loglog(ptDict.keys(),[i[0][0] for i in np.array(list(ptDict.values()))],'.-', label='0<$\eta$<0.5')
43 plt.loglog(ptDict.keys(),[i[1][0] for i in np.array(list(ptDict.values()))],'.-', label='0.5<$\eta$<1.0')
44 plt.loglog(ptDict.keys(),[i[2][0] for i in np.array(list(ptDict.values()))],'.-', label='1.0<$\eta$<1.5')
45 plt.loglog(ptDict.keys(),[i[3][0] for i in np.array(list(ptDict.values()))],'.-', label='1.5<$\eta$<2.0')
46 plt.loglog(ptDict.keys(),[i[4][0] for i in np.array(list(ptDict.values()))],'.-', label='2.0<$\eta$<2.5')
47 ax.set_xlabel('$p_T$ [GeV/c]')
48 ax.set_ylabel('time/track [sec]')
49 plt.yscale('log')
50 ax.set_xlim((0.09,105))
51 plt.legend(numpoints=1)
52 
53 plt.suptitle("KF timing vs. $p_T$")
54 
55 plt.show()