-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpyPlotter.py
80 lines (61 loc) · 1.65 KB
/
pyPlotter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import numpy as np
import matplotlib.pyplot as plt
def get_digitized_bank(var_name, filename) -> [float]:
""" Parse the digitized variable variableName from filename and return a vector of floats
Example ft_cal digitized banK:
Detector <ft_cal> Digitized Bank {
Hit address: ih->18, iv->15 {
adc: 5525
component: 325
hitn: 1
layer: 1
order: 0
ped: 0
sector: 1
time: 7.10433
}
Hit address: ih->18, iv->16 {
adc: 4533
component: 347
hitn: 2
layer: 1
order: 0
ped: 0
sector: 1
time: 7.14856
}
}
"""
# Open the file
f = open(filename, "r")
# Read the file
lines = f.readlines()
# Close the file
f.close()
# Initialize the vector
vec = []
# Loop over the lines
for line in lines:
# Find the variableName
if var_name in line:
# Get the value
value = line.split(":")[1].split("{")[0].strip()
# Append the value to the vector
vec.append(value)
# Return the vector
return vec
def main():
# Get the digitized bank
N = 1000
# Get the digitized bank
adc = get_digitized_bank("adc", "events.txt")
com = get_digitized_bank("component", "events.txt")
# x is the first N numbers in adc
x = adc[:N]
y = com[:N]
area=np.pi*(15*np.random.rand(N))**2
colors=np.random.rand(N)
plt.scatter(x,y, s=area, c=colors, alpha=0.5)
plt.show()
if __name__ == "__main__":
main()