Skip to content

Commit

Permalink
Update rnog example
Browse files Browse the repository at this point in the history
  • Loading branch information
fschlueter committed Feb 17, 2025
1 parent ae03521 commit 8d20aa4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions NuRadioMC/examples/08_RNO_G_trigger_simulation/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def __init__(self, *args, **kwargs):

self.highLowThreshold = highLowThreshold.triggerSimulator()
self.rnogADCResponse = triggerBoardResponse.triggerBoardResponse()
self.rnogADCResponse.begin(adc_input_range=2 * units.volt, clock_offset=0.0, adc_output="voltage")
self.rnogADCResponse.begin(
clock_offset=0.0, adc_output="counts")

# future TODO: Add noise
# self.channel_generic_noise_adder = channelGenericNoiseAdder.channelGenericNoiseAdder()
Expand Down Expand Up @@ -154,8 +155,17 @@ def _detector_simulation_trigger(self, evt, station, det):

for thresh_key, threshold in self.high_low_trigger_thresholds.items():

threshold_high = {channel_id: threshold * vrms for channel_id, vrms in zip(self.deep_trigger_channels, vrms_after_gain)}
threshold_low = {channel_id: -1 * threshold * vrms for channel_id, vrms in zip(self.deep_trigger_channels, vrms_after_gain)}
if self.rnogADCResponse.adc_output == "voltage":
threshold_high = {channel_id: threshold * vrms for channel_id, vrms
in zip(self.deep_trigger_channels, vrms_after_gain)}
threshold_low = {channel_id: -1 * threshold * vrms for channel_id, vrms
in zip(self.deep_trigger_channels, vrms_after_gain)}
else:
# We round here. This is not how an ADC works but I think this is not needed here.
threshold_high = {channel_id: int(round(threshold * vrms)) for channel_id, vrms
in zip(self.deep_trigger_channels, vrms_after_gain)}
threshold_low = {channel_id: int(round(-1 * threshold * vrms)) for channel_id, vrms
in zip(self.deep_trigger_channels, vrms_after_gain)}

self.highLowThreshold.run(
evt,
Expand Down Expand Up @@ -205,6 +215,8 @@ def _detector_simulation_trigger(self, evt, station, det):
"trigger_adc_sampling_frequency": 0.472,
"trigger_adc_nbits": 8,
"trigger_adc_noise_count": 5,
"trigger_adc_min_voltage": -1,
"trigger_adc_max_voltage": 1,
}

det = rnog_detector.Detector(
Expand Down
6 changes: 3 additions & 3 deletions NuRadioReco/modules/RNO_G/triggerBoardResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def begin(self, clock_offset=0.0, adc_output="voltage"):
"""
self._adc = analogToDigitalConverter(log_level=self._log_level)
self._clock_offset = clock_offset
self._adc_output = adc_output
self.adc_output = adc_output

# Table 21 in https://www.analog.com/media/en/technical-documentation/data-sheets/hmcad1511.pdf
self._triggerBoardAmplifications = np.array([1, 1.25, 2, 2.5, 4, 5, 8, 10, 12.5, 16, 20, 25, 32, 50])
Expand Down Expand Up @@ -216,7 +216,7 @@ def digitize_trace(self, station, det, trigger_channels, vrms):
adc_type="perfect_floor_comparator",
trigger_filter=None, # Applied already
clock_offset=self._clock_offset,
adc_output=self._adc_output,
adc_output=self.adc_output,
return_sampling_frequency=True,
)

Expand Down Expand Up @@ -265,7 +265,7 @@ def run(self, evt, station, det, trigger_channels, vrms=None, apply_adc_gain=Tru

if digitize_trace:
self.digitize_trace(station, det, trigger_channels, ideal_vrms)
if self._adc_output == "counts":
if self.adc_output == "counts":
lsb_voltage = self._adc_input_range / (2 ** self._nbits - 1)
# We do not floor/convert the vrms to integers here. But this has to happen before the trigger.
equalized_vrms = equalized_vrms / lsb_voltage
Expand Down

0 comments on commit 8d20aa4

Please sign in to comment.