Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CKF_timing_vs_mu.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CKF_timing_vs_mu.py
1 import csv
2 import matplotlib.pyplot as plt
3 import numpy as np
4 
5 # Data preparation
6 muDict = {}
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  # mu, mode, exec time
17  mode = float(csv_row[1])
18  mu = int(csv_row[2])
19  exectime = float(csv_row[3])
20 
21  # Make sure you have all the keys ready
22  try:
23  mdict = muDict[mu]
24  except:
25  muDict[mu] = {}
26  mdict = muDict[mu]
27 
28  # Now fill the sub dictionary
29  try:
30  vmdict = mdict[mode]
31  except:
32  mdict[mode] = []
33  vmdict = mdict[mode]
34 
35  vmdict += [exectime]
36 
37 # plot the muDict
38 plt.figure(figsize=(7, 5))
39 
40 ax = plt.subplot(111)
41 plt.plot(
42  muDict.keys(),
43  [i[0][0] for i in np.array(list(muDict.values()))],
44  "-+",
45  label="$\chi^{2}$<15, $n_{source link} <=10$",
46 )
47 plt.plot(
48  muDict.keys(),
49  [i[1][0] for i in np.array(list(muDict.values()))],
50  "-*",
51  label="$\chi^{2}$<10, $n_{source link}=1$",
52 )
53 ax.set_xlabel("$<\mu>$")
54 ax.set_ylabel("time/event [Sec]")
55 ax.set_xlim((0, 250))
56 plt.legend(numpoints=1)
57 
58 plt.suptitle("CKF timing vs. $<\mu>$")
59 
60 plt.show()