hyperk / MDT

C++ Stand-alone Codes for Merging, Digitizing, and Triggering PMT hits
0 stars 0 forks source link

Update Hit Finding Algorithm #8

Open kmtsui opened 1 month ago

kmtsui commented 1 month ago

Below are the description of pulsing finding for the IWCD mPMTs. We will need to implement it in the waveform fitting function to get digitized Q and T.


The general description of the hit finding algorithm was shown in the presentation on the meeting on 15 February 2024. Here is this description:

The extraction of related VHDL code is attached.

constant SAMPLE_NUMBER_BEFORE_MAXIMUM     : natural := 8;-- first sample number before
constant SAMPLE_NUMBER_AFTER_MAXIMUM      : natural := 7;--namber of samples after maximum kept in pipeline registers
constant INTEGRAL_PRECEDING_SAMPLE_NUMBER : natural := 2;
constant INTEGRAL_FOLLOWING_SAMPLE_NUMBER : natural := 4;
---------------------------------------------------------------
---- selected VHDL code describing the hit detection ----------

  adder_tree_v := (others => (others => (others => '0')));
  for channel in 0 to 19 loop
    -- integral computation using adder tree on moving window
    for i in SAMPLE_NUMBER_AFTER_MAXIMUM-1-INTEGRAL_PRECEDING_SAMPLE_NUMBER to SAMPLE_NUMBER_AFTER_MAXIMUM-1+INTEGRAL_FOLLOWING_SAMPLE_NUMBER loop 
      adder_tree_v(channel)(i+3-SAMPLE_NUMBER_AFTER_MAXIMUM) := adc_delay_r(i)(channel)(11) & adc_delay_r(i)(channel)(11) & adc_delay_r(i)(channel)(11) & adc_delay_r(i)(channel);
    end loop;
    -- first adder level
    for i in 0 to 3 loop
      adder_tree_v(channel)(i+8) := adder_tree_v(channel)(2*i) + adder_tree_v(channel)(2*i+1);
    end loop;
    adder_tree_v(channel)(12) := adder_tree_v(channel)(8) + adder_tree_v(channel)(9);
    adder_tree_v(channel)(13) := adder_tree_v(channel)(10) + adder_tree_v(channel)(11);
    adder_tree_v(channel)(14) := adder_tree_v(channel)(12) + adder_tree_v(channel)(13);
    sum_v(channel) := adder_tree_v(channel)(14) & "00";

    trigger_auto_v(channel) := '0';  
    if signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM-1)(channel)) >= signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM-2)(channel)) 
    and signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM-1)(channel)) > signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM)(channel))
    and signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM-1)(channel)) > signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM-3)(channel)) 
    and signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM-1)(channel)) > signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM+1)(channel)) 
    then
      maximum_condition_v(channel) := '1'; 
    end if;
    if signed(adc_delay_r(SAMPLE_NUMBER_AFTER_MAXIMUM-1)(channel)) > signed(integral_threshold_v(11 downto 3)) then
      amplitude_condition_v(channel) := '1'; 
    end if;
    if signed(sum_v(channel)) > signed(integral_threshold_v) then
      integral_condition_v(channel) := '1'; 
    end if;
    if estimator_r(channel).cycles_from_hit = 0 or estimator_r(channel).cycles_from_hit > config_r.hit_insensitivity_period then
      separation_condition_v(channel) := '1';
    end if;
  end loop;
  trigger_auto_v :=  maximum_condition_v and integral_condition_v and amplitude_condition_v and separation_condition_v and config_r.self_trigger_enable;
kmtsui commented 1 month ago

More technical details