-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsipmConnectionTest.py
52 lines (42 loc) · 1.47 KB
/
sipmConnectionTest.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
import sys
import getopt
from calutils import sipm_connectivity_check
from calutils import sipm_rms_check
def shelp():
print('\n Usage: sipmConnectionTest [-w waveforms] [-e elec -d dark] RUN')
print()
print(' Launch connectivity tests for SiPMs. ')
print()
print(' Options: ')
print(' * -w, --waveform: file with SiPM waveforms, RMS comparison ')
print(' * -e, --elec: electronics spectra file, requires -d be used ')
print(' * -d, --dark: dark noise spectra file, requires -e be used ')
if __name__ == '__main__':
try:
opts, args = getopt.getopt(sys.argv[1:], 'w:e:d:',
["waveform=", "elec=", "dark="])
except getopt.GetoptError as err:
print(err)
shelp()
sys.exit()
waveform_file = None
electronics_file = None
darkcurrent_file = None
for o, v, in opts:
if o in ('-w', '--waveform'): waveform_file = v
elif o in ('-e', '--elec'): electronics_file = v
elif o in ('-d', '--dark'): darkcurrent_file = v
try:
run_no = args[0]
except IndexError:
print('Wrong arguments!')
shelp()
sys.exit()
if electronics_file and darkcurrent_file:
sipm_connectivity_check(electronics_file, darkcurrent_file, run_no)
elif waveform_file:
sipm_rms_check(waveform_file)
else:
print('Processing not possible with arguments given')
shelp()
sys.exit()