Skip to content
Snippets Groups Projects
Commit 75eb0bca authored by Laurent Mercadier's avatar Laurent Mercadier
Browse files

Add digitizer_type() function

parent 939d32b9
No related branches found
No related tags found
1 merge request!112Fastadc new mnemonics
......@@ -271,6 +271,7 @@ def get_peaks(run,
# 2. Use raw data from digitizer
# minimum pulse period @ 4.5MHz, according to digitizer type
digitizer = digitizer_type(source=source)
min_distance = 1
if digitizer == 'FastADC':
min_distance = 24
......@@ -346,8 +347,8 @@ def get_peaks(run,
extra_dim)
peaks = peaks.where(mask_on, drop=True)
return peaks.assign_coords({extra_dim: pid})
def channel_peak_params(run, source, key=None, channel=None, board=None):
"""
Extract peak-integration parameters used by a channel of the digitizer.
......@@ -410,7 +411,7 @@ def fastADC_channel_peak_params(run, source, channel=None):
'baseLength': ('baselineSettings.length.value',),
'enable': ('enablePeakComputation.value',),
'pulseStart': ('initialDelay.value',),
'pulseLength': ('peakSamples.value',),
'pulseLength': ('peakSamples.value',),
'npulses': ('numPulses.value',),
'period': ('pulsePeriod.value',)
}
......@@ -470,14 +471,12 @@ def adq412_channel_peak_params(run, source, key=None,
board = k[1]
baseName = f'board{board}.apd.channel_{channel}.'
source = source.split(':')[0]
adq412_keys = {
'baseStart': (baseName + 'baseStart.value',),
'baseStop': (baseName + 'baseStop.value',),
'enable': (baseName + 'enable.value',),
'pulseStart': (baseName + 'pulseStart.value',),
'pulseStop': (baseName + 'pulseStop.value',),
'npulses': (baseName + 'numPulses.value',),
'pulseStop': (baseName + 'pulseStop.value',),
'initialDelay': (baseName + 'initialDelay.value',),
'upperLimit': (baseName + 'upperLimit.value',),
'npulses': (f'board{board}.apd.numberOfPulses.value',)
......@@ -581,7 +580,8 @@ def get_peak_params(run, mnemonic, raw_trace=None, ntrains=200):
title = 'Digitizer peak params'
else:
mnemo_raw = mnemonic
min_distance = 24 if "FastADC" in mnemonic else 440
digitizer = digitizer_type(mnemonic, run_mnemonics)
min_distance = 24 if digitizer == "FastADC" else 440
title = 'Auto-find peak params'
if raw_trace is None:
sel = run.select_trains(np.s_[:ntrains])
......@@ -647,7 +647,8 @@ def check_peak_params(run, mnemonic, raw_trace=None, ntrains=200, params=None,
log.warning('The digitizer did not record peak-integrated data.')
if not plot:
return params
min_distance = 24 if "FastADC" in mnemonic else 440
digitizer = digitizer_type(mnemonic, run_mnemonics)
min_distance = 24 if digitizer == "FastADC" else 440
if 'bunchPatternTable' in run_mnemonics and bunchPattern != 'None':
sel = run.select_trains(np.s_[:ntrains])
bp_params = {}
......@@ -747,6 +748,24 @@ def plotPeakIntegrationWindow(raw_trace, params, bp_params, show_all=False):
return fig, ax
def digitizer_type(mnemonic=None, mnemo_dict=None, source=None):
if mnemonic is not None:
source = mnemo_dict[mnemonic]['source']
if ':channel' in source:
return 'FastADC'
if ':network' in source:
return 'ADQ412'
dic = {'XTD10_MCP': 'FastADC',
'FastADC': 'FastADC',
'PES': 'ADQ412',
'MCP': 'ADQ412'}
for k, v in dic.items():
if k in mnemonic:
return v
log.warning(f'Could not find digitizer type from mnemonic {mnemonic}.')
return 'ADQ412'
def get_tim_peaks(run, mnemonics=None, merge_with=None,
bunchPattern='sase3', integParams=None,
keepAllSase=False):
......
......@@ -83,7 +83,7 @@ def mnemonics_to_process(mnemo_list, merge_with, detector, func=None):
merge_with: xarray Dataset
Dataset that may contain non-processed arrays
detector: str
One in {'ADQ412', 'FastADC', 'XGM', 'BAM'}
One in {'ADQ412', 'FastADC', 'XGM', 'BAM', 'PES'}
func: function
function that takes one argument, an unprocessed mnemonic string,
and converts it into a processed one, i.e. from 'MCP2apd' to
......@@ -110,7 +110,8 @@ def mnemonics_to_process(mnemo_list, merge_with, detector, func=None):
default_mnemo = 'SCS_SA3'
default_processed = 'SCS_SA3'
if detector == 'ADQ412':
det_mnemos = [m for m in _mnemonics if 'MCP' in m]
det_mnemos = [m for m in _mnemonics if 'MCP' in m and
'XTD10_' not in m]
default_mnemo = 'MCP2apd'
default_processed = 'MCP2peaks'
if detector == 'FastADC':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment