Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions larndsim/consts/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
ADC_HOLD_DELAY = 15
#: ADC busy delay in clock cycles
ADC_BUSY_DELAY = 9
#: periodic reset cycles in clock cycles
PERIODIC_RESET_CYCLES = -1
#: Reset time in clock cycles
RESET_CYCLES = 1
#: Clock cycle time in :math:`\mu s`
Expand Down Expand Up @@ -242,6 +244,7 @@ def set_detector_properties(detprop_file, pixel_file, response_file=None, i_modu
global MOD_IDS
global DISCRIMINATION_THRESHOLD
global ADC_HOLD_DELAY
global PERIODIC_RESET_CYCLES
global ADC_BUSY_DELAY
global RESET_CYCLES
global CLOCK_CYCLE
Expand Down Expand Up @@ -373,6 +376,7 @@ def set_detector_properties(detprop_file, pixel_file, response_file=None, i_modu

dis_threshold_bucket = detprop.get('discrimination_threshold', DISCRIMINATION_THRESHOLD)
DISCRIMINATION_THRESHOLD = set_multi_properties(dis_threshold_bucket, n_mod, i_module, message="larpix discrimination threshold")
PERIODIC_RESET_CYCLES = detprop.get('periodic_reset_cycles', PERIODIC_RESET_CYCLES)
ADC_HOLD_DELAY = detprop.get('adc_hold_delay', ADC_HOLD_DELAY)
ADC_BUSY_DELAY = detprop.get('adc_busy_delay', ADC_BUSY_DELAY)
RESET_CYCLES = detprop.get('reset_cycles', RESET_CYCLES)
Expand Down
1 change: 1 addition & 0 deletions larndsim/detector_properties/fsd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ discrimination_threshold: 5.0e3 # e-
v_cm: 478 # mV
v_ref: 1568 # mV
larpix_gain: 2.46e-3 # preliminary measurement by Stephen: https://indico.fnal.gov/event/71610
periodic_reset_cycles: 256 # nominal periodic reset cycles used in FSD run 1

## Light geometry parameters
n_op_channel: 240
Expand Down
28 changes: 26 additions & 2 deletions larndsim/fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import warnings

from numba import cuda
from numba.cuda.random import xoroshiro128p_normal_float32
from numba.cuda.random import xoroshiro128p_normal_float32, xoroshiro128p_uniform_float32
from math import exp, floor

from larpix.packet import Packet_v2, TimestampPacket, TriggerPacket, SyncPacket, PacketCollection
Expand Down Expand Up @@ -589,16 +589,30 @@ def get_adc_values(pixels_signals,
iadc = 0
adc_busy = 0
last_reset = 0
last_periodic_reset = 0
true_q = 0
apply_periodic_reset = detector.PERIODIC_RESET_CYCLES > 0
periodic_reset_phase = int(xoroshiro128p_uniform_float32(rng_states, ip) * (detector.PERIODIC_RESET_CYCLES + 1)) if apply_periodic_reset else 0
q_sum = xoroshiro128p_normal_float32(rng_states, ip) * detector.RESET_NOISE_CHARGE * e


while ic < curre.shape[0] or adc_busy > 0:

if iadc >= sim.MAX_ADC_VALUES:
print("More ADC values than possible,", sim.MAX_ADC_VALUES)
break

q = 0

if apply_periodic_reset and ic % detector.PERIODIC_RESET_CYCLES == periodic_reset_phase:
q_sum = xoroshiro128p_normal_float32(rng_states, ip) * detector.RESET_NOISE_CHARGE * e
true_q = 0
last_periodic_reset = ic
for itrk in range(current_fractions.shape[2]):
current_fractions[ip][iadc][itrk] = 0
ic += 1
continue

if detector.BUFFER_RISETIME > 0:
conv_start = max(last_reset, floor(ic - 10*detector.BUFFER_RISETIME/detector.TIME_SAMPLING))
for jc in range(conv_start, min(ic+1, curre.shape[0])):
Expand All @@ -617,7 +631,7 @@ def get_adc_values(pixels_signals,

q_sum += q
true_q += q

q_noise = xoroshiro128p_normal_float32(rng_states, ip) * detector.UNCORRELATED_NOISE_CHARGE * e
disc_noise = xoroshiro128p_normal_float32(rng_states, ip) * detector.DISCRIMINATOR_NOISE * e

Expand All @@ -633,6 +647,15 @@ def get_adc_values(pixels_signals,
while ic <= integrate_end:
q = 0

if apply_periodic_reset and ic % detector.PERIODIC_RESET_CYCLES == periodic_reset_phase:
q_sum = xoroshiro128p_normal_float32(rng_states, ip) * detector.RESET_NOISE_CHARGE * e
true_q = 0
last_periodic_reset = ic
for itrk in range(current_fractions.shape[2]):
current_fractions[ip][iadc][itrk] = 0
ic += 1
continue

if detector.BUFFER_RISETIME > 0:
conv_start = max(last_reset, floor(ic - 10*detector.BUFFER_RISETIME/detector.TIME_SAMPLING))
for jc in range(conv_start, min(ic+1, curre.shape[0])):
Expand All @@ -649,6 +672,7 @@ def get_adc_values(pixels_signals,
idx = total_backtracks * ic + offset_backtrack[ip] + itrk
current_fractions[ip][iadc][itrk] += pixels_signals_tracks[idx] * detector.TIME_SAMPLING


q_sum += q
true_q += q
ic+=1
Expand Down
Loading