Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Moving loop into another loop. Implementing a new condition to save t…
Browse files Browse the repository at this point in the history
…ime. If the number of triggers is less than the required coincidences, the coincidence window is not calculated
  • Loading branch information
daniel-zid committed Nov 13, 2019
1 parent 7065ed8 commit 3b05654
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions NuRadioReco/modules/ARA/triggerSimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,39 +248,42 @@ def run(self, evt, station, det,
# No coincidence requirement yet
trigger = {}
trigger_times = []
times_min = []
times_max = []
sampling_rates = []
number_triggered_channels = 0

for channel in station.iter_channels():
channel_id = channel.get_id()
if channel_id not in triggered_channels:
continue
trigger[channel_id] = self.has_triggered(channel)
if trigger[channel_id]:
number_triggered_channels += 1
times = channel.get_times()
trace_after_diode = self.tunnel_diode(channel)
arg_trigger = np.argmin(trace_after_diode)
trigger_times.append(times[arg_trigger])
times_min.append(np.min(times))
times_max.append(np.max(times))
sampling_rates.append(channel.get_sampling_rate())

has_triggered = False
trigger_time = None

times_min = []
times_max = []
sampling_rates = []
for channel in station.iter_channels():
times_min.append(np.min(channel.get_times()))
times_max.append(np.max(channel.get_times()))
sampling_rates.append(channel.get_sampling_rate())

trace_times = np.arange(np.min(times_min), np.max(times_max),
1/np.min(sampling_rates))

trigger_times = np.array(trigger_times)
slice_left = int(coinc_window/2/(trace_times[1]-trace_times[0]))
slice_right = len(trace_times)-slice_left
for trace_time in trace_times[slice_left:slice_right]:
if ( np.sum( np.abs(trace_time-trigger_times) <= coinc_window/2 ) >= number_concidences ):
has_triggered = True
trigger_time = np.min(trigger_times)
break
if (number_triggered_channels >= number_concidences):

trace_times = np.arange(np.min(times_min), np.max(times_max),
1/np.min(sampling_rates))

trigger_times = np.array(trigger_times)
slice_left = int(coinc_window/2/(trace_times[1]-trace_times[0]))
slice_right = len(trace_times)-slice_left
for trace_time in trace_times[slice_left:slice_right]:
if ( np.sum( np.abs(trace_time-trigger_times) <= coinc_window/2 ) >= number_concidences ):
has_triggered = True
trigger_time = np.min(trigger_times)
break

trigger = IntegratedPowerTrigger(trigger_name, power_threshold,
coinc_window, channels=triggered_channels,
Expand Down

0 comments on commit 3b05654

Please sign in to comment.