Skip to content
Snippets Groups Projects

Fix/da qoldformat corr

Merged Andrey Samartsev requested to merge fix/DAQoldformatCorr into master
4 unresolved threads
1 file
+ 32
18
Compare changes
  • Side-by-side
  • Inline
@@ -71,19 +71,28 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
if len(ctrlDataFiles) == 0:
print("No Control Slow Data found!")
return targetGainAll, encodedGainAll, operatingFreqAll
print(ctrlDataFiles)
daq_format = ''
ctrlloc = None
ctlrh5file = h5py.File(next(iter(ctrlDataFiles.values())), 'r')
filename = next(iter(ctrlDataFiles.values()))
print("filename: ", filename)
ctlrh5file = h5py.File(filename, 'r')
if '/METADATA/dataSources/deviceId' in ctlrh5file:
ctrlloc = ctlrh5file['/METADATA/dataSources/deviceId'][0]
daq_format = ctlrh5file['/METADATA/dataFormatVersion'][0].decode("utf-8")
elif '/METADATA/deviceId' in ctlrh5file:
ctrlloc = ctlrh5file['/METADATA/deviceId'][0]
else:
print("Control Slow Data not correct!")
print("No Slow Control Data found in files!")
return targetGainAll, encodedGainAll, operatingFreqAll
ctrlloc = ctrlloc.decode("utf-8")
ctrlloc = ctrlloc[:ctrlloc.find('/')]
print("ctrlloc: ", ctrlloc)
tGain = {}
encodedGain = {}
@@ -91,30 +100,35 @@ def get_dssc_ctrl_data(in_folder, slow_data_pattern,
for quadrant, file in ctrlDataFiles.items():
if len(file):
h5file = h5py.File(file)
if not f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value' in h5file:
print(f"Slow control data file {file} is not usable")
continue
epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\
.decode("utf-8")
epcConfig = epcConfig[epcConfig.rfind('/') + 1:]
print(f"EPC configuration: {epcConfig}")
targGain = _extr_gainparam_conffilename(epcConfig)
tGain[quadrant] = float(targGain) if targGain is not None else 0.0
# 0.0 is default value for TG
if daq_format != '':
epcConfig = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/epcRegisterFilePath/value'][0]\
.decode("utf-8")
epcConfig = epcConfig[epcConfig.rfind('/') + 1:]
print(f"EPC configuration: {epcConfig}")
targGain = _extr_gainparam_conffilename(epcConfig)
tGain[quadrant] = float(targGain) if targGain is not None else 0.0
# 0.0 is default value for TG
else:
tGain[quadrant] = 0.0
gainSettingsMap = {}
for coarseParam in ['fcfEnCap', 'csaFbCap', 'csaResistor']:
gainSettingsMap[coarseParam] = int(
h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/{coarseParam}/value'][0])
irampSettings = h5file[f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/irampFineTrm/value'][0]\
.decode("utf-8")
iramp_path = f'/RUN/{ctrlloc}/FPGA/PPT_Q{quadrant}/gain/irampFineTrm/value'
if daq_format != '':
irampSettings = h5file[iramp_path][0].decode("utf-8")
elif iramp_path in h5file:
irampSettings = h5file[iramp_path][0]
else:
irampSettings = "Various"
gainSettingsMap['trimmed'] = np.int64(
1) if irampSettings == "Various" else np.int64(0)
print('trimmed: ', gainSettingsMap['trimmed'])
encodedGain[quadrant] = _get_gain_encoded_val(gainSettingsMap)
Loading