Analysis Software
Documentation for sPHENIX simulation 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 csv
2 import matplotlib.pyplot as plt
3 import numpy as np
4 
5 # Data preparation
6 ptDict = {}
7 
8 # Open the output file
9 with open("output.log", mode="r") as csv_file:
10  csv_reader = csv.reader(csv_file, delimiter=",")
11  # read lines and go for it
12  for csv_row in csv_reader:
13  if len(csv_row) > 1:
14  # get the job id
15  jobID = csv_row[0]
16  # etabin, pt value, exec time
17  etabin = float(csv_row[1])
18  ptvalue = float(csv_row[2])
19  exectime = float(csv_row[3])
20 
21  # Make sure you have all the keys ready
22  try:
23  pdict = ptDict[ptvalue]
24  except:
25  ptDict[ptvalue] = {}
26  pdict = ptDict[ptvalue]
27 
28  # Now fill the sub dictionary
29  try:
30  vpdict = pdict[etabin]
31  except:
32  pdict[etabin] = []
33  vpdict = pdict[etabin]
34 
35  vpdict += [exectime]
36 
37 # plot the ptDict
38 plt.figure(figsize=(7, 5))
39 
40 ax = plt.subplot(111)
41 plt.loglog(
42  ptDict.keys(),
43  [i[0][0] for i in np.array(list(ptDict.values()))],
44  ".-",
45  label="0<$\eta$<0.5",
46 )
47 plt.loglog(
48  ptDict.keys(),
49  [i[1][0] for i in np.array(list(ptDict.values()))],
50  ".-",
51  label="0.5<$\eta$<1.0",
52 )
53 plt.loglog(
54  ptDict.keys(),
55  [i[2][0] for i in np.array(list(ptDict.values()))],
56  ".-",
57  label="1.0<$\eta$<1.5",
58 )
59 plt.loglog(
60  ptDict.keys(),
61  [i[3][0] for i in np.array(list(ptDict.values()))],
62  ".-",
63  label="1.5<$\eta$<2.0",
64 )
65 plt.loglog(
66  ptDict.keys(),
67  [i[4][0] for i in np.array(list(ptDict.values()))],
68  ".-",
69  label="2.0<$\eta$<2.5",
70 )
71 ax.set_xlabel("$p_T$ [GeV/c]")
72 ax.set_ylabel("time/track [sec]")
73 plt.yscale("log")
74 ax.set_xlim((0.09, 105))
75 plt.legend(numpoints=1)
76 
77 plt.suptitle("KF timing vs. $p_T$")
78 
79 plt.show()