DUNE-DAQ / fdreadoutlibs

fdreadoutlibs
0 stars 3 forks source link

TPG Threshold By Plane #177

Closed aeoranday closed 3 months ago

aeoranday commented 3 months ago

This PR adds the implementation of TPG thresholding by plane. There are related PRs in daqconf, fddaqconf, and readoutlibs to include the configurables for these thresholds.

By default, the implementation makes use of the general tpg_threshold value unless a specific threshold is given for collection_threshold, induction2_threshold, and induction1_threshold. These thresholds are then applied according to the plane identification from detchannelmaps.

Testing was done with short runs where two of the three planes have a high threshold and the last plane has a low threshold. This was repeated for each of SimpleThreshold, AbsRS, and StandardRS. Then I checked that the TriggerPrimitives in the generated TPStream were only from the low threshold plane and above the required threshold. The following snippet is the exact check.

from trgtools import TPReader
import detchannelmaps

channel_map = detchannelmaps.make_map("<TPCChannelMap>")
tps = TPReader("<TestTPStream>")
tps.read_all_fragments()
count = 0
for tp in tps.tp_data:
    if channel_map.get_plane_from_offline_channel(tp['channel']) == <plane> and tp['adc_peak'] >= <set_threshold>:
      count += 1
print(count == tps.tp_data.shape[0])

Testing was consistent for each of the three planes.

aeoranday commented 3 months ago

Latest commit made the word choice changes to match what is used in detchannelmaps. Configs and variables now refer to planes 0, 1, and 2 instead of induction 1, induction 2, and collection. Also prefixed with tpg_.