-
Notifications
You must be signed in to change notification settings - Fork 4
/
det_spec.py
127 lines (92 loc) · 4.47 KB
/
det_spec.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import jsonc as json
import config as cf
import os
import utils.filenames as fname
def is_concerned(key, run):
to_be_used = {}
for k in key:
if(k == 'default'):
to_be_used[k]=False
else:
r = k.split('-')
if(run >= int(r[0]) and run <= int(r[1])):
to_be_used[k]=True
else:
to_be_used[k]=False
return to_be_used
def configure(detector, run, do_pds):
""" access to files """
with open(cf.lardon_path+'/settings/'+detector+'/path.json','r') as f:
locations = json.load(f)
key = fname.get_data_path(locations, run)
if(key == "none"):
print("sorry but the data does not seem to exists in the paths provided ... bye")
exit()
cf.domain = key
cf.data_path = locations[key]
""" long term parameters """
with open(cf.lardon_path+'/settings/'+detector+'/geo.json','r') as f:
param = json.load(f)
to_be_used = is_concerned(param.keys(), int(run))
""" Load the default geometry settings """
data = param['default']
for k, v in to_be_used.items():
if(v == True):
custom = param[k]
for key, val in custom.items():
data[key] = val
cf.n_view = int(data['n_view'])
cf.n_module = int(data['n_module'])
cf.view_name = data['view_name']
cf.view_type = data['view_type']
cf.view_angle = [float(x) for x in data['view_angle']]
cf.view_pitch = [float(x) for x in data['view_pitch']]
cf.view_nchan = [int(x) for x in data['view_nchan']]
cf.view_capa = [float(x) for x in data['view_capa']]
cf.n_tot_channels = int(data['n_tot_channels'])
cf.module_nchan = int(cf.n_tot_channels/cf.n_module)
cf.n_sample = int(data['n_sample'])
cf.sampling = float(data['sampling'])
cf.e_per_ADCtick = [float(x) for x in data['e_per_ADCtick']]
cf.view_chan_repet = [int(x) for x in data['view_chan_repet']]
cf.view_offset_repet = [[[float(x) for x in xv] for xv in xm] for xm in data['view_offset_repet']]
cf.view_z_offset = [float(x) for x in data['view_z_offset']]
cf.drift_length = float(data['drift_length'])
cf.anode_z = [float(x) for x in data['anode_z']]
cf.view_length = [float(x) for x in data["view_length"]]
cf.view_offset = [[float(x) for x in xv ] for xv in data['view_offset']]
cf.x_boundaries = [[float(x) for x in xv] for xv in data['x_boundaries']]
cf.y_boundaries = [[float(x) for x in xv] for xv in data['y_boundaries']]
cf.strips_length = cf.lardon_path+"/settings/chmap/"+data['strips_length']
cf.e_drift = float(data["e_drift"])
cf.channel_map = cf.lardon_path+"/settings/chmap/"+data["chmap"]
cf.signal_is_inverted = [bool(int(x)) for x in data['signal_is_inverted']]
if(cf.n_module > 1):
cf.module_used = [bool(int(x)) for x in data['module_used']]
else:
cf.module_used = [True]
try:
cf.broken_channels = data["broken_channels"]
except KeyError:
print("No broken channels !")
try :
cf.channel_calib = cf.lardon_path+"/settings/calib/"+data['channel_calib']
except KeyError:
print('No Channel Calibration available - Constant value will be used')
cf.drift_direction = [float(x) for x in data["drift_direction"]]
cf.elec = [x for x in data["elec"]]
cf.daq = data["daq"]
if(do_pds == True):
try :
cf.n_pds_channels = data['n_pds_channels']
cf.pds_sampling = data['pds_sampling']
cf.n_pds_sample = data['n_pds_sample']
cf.pds_channel_map = cf.lardon_path+"/settings/chmap/"+data['pds_channel_map']
cf.pds_modules_type = [x for x in data['pds_modules_type']]
cf.pds_length = data['pds_length']
cf.pds_n_modules = data['pds_n_modules']
cf.pds_x_centers = [float(x) for x in data['pds_x_centers']]
cf.pds_y_centers = [float(y) for y in data['pds_y_centers']]
cf.pds_z_centers = [float(z) for z in data['pds_z_centers']]
except KeyError:
print('No pds information :-/')