CDC algo

From GlueXWiki
Revision as of 10:38, 3 March 2014 by Nsjarvis (Talk | contribs)

Jump to: navigation, search

CDC time & integral algorithm

We will need to arrange the trigger timing so that when the trigger signal arrives, the presample buffer contains a number of samples for pedestal followed by the earliest possible CDC sample and then another 155 samples (for maximum drift time).


Quantities to be returned, if a hit is found

  • Leading edge time (11 bits, units of sample/10)
  • Time quality factor (1 bit) set to 0 if time is good, 1 if time is rough estimate
  • Pedestal immediately before the hit (8 bits, set to 255 if >254)
  • Signal integral (n bits, scaled down by factor 2^m; n,m approx 14,4, TBC)
  • Signal maximum (p bits, scaled down by factor 2^q; p,q approx 9,3, TBC) this is the first maximum in the signal after the threshold crossing
  • Overflow count (3 bits, set to 7 if >6)


Configuration constants (all values are integers, σ=pedestal width ~16)

  • window_start: start of hit search window as sample number relative to the trigger arrival, this is the earliest possible hit time
  • window_end: end of hit search window as sample number relative to the trigger arrival, approx 155 samples after window_start
  • hit_threshold: threshold to identify hit (default 5σ ~80, range 50 to 300)
  • high_threshold: High timing threshold (default 4σ ~ 64, range 40 to 270) must be lower than hit threshold
  • low_threshold: Low timing threshold (default 1σ ~ 16, range 5 to 30)
  • nsamples: number of ADC samples to pass to time finding module (default 14)
  • xthr_sample: sample number containing first sample (x) above hit_threshold (default 8)
  • ped_sample: sample number to be used as local pedestal (default 4)
  • rough_dt: if timing fails because ADC values do not exceed high_threshold, return hit time of xthr_sample-rough_dt (default 20, units sample/10)
  • integral_offset: number of samples before x to include in integration (default 3).


Hit finding module

  1. Wake up on trigger
  2. Calculate start_pedestal as mean of 4 samples window_start-5 to window_start-1
  3. Search from window_start to window_end for ADC value rising above start_pedestal + hit_threshold. If not found, go back to sleep. If found, continue.
  4. Call up time-finding module and send in nsamples ADC values from the hit threshold crossing region, with the threshold-crossing sample x as value number xthr_sample in the sequence (starting at 0)
  5. Call up signal maximum module
  6. Call up signal integral module
  7. Return local_pedestal as value of sample (x + ped_sample - xthr_sample), or 255 if local_pedestal>254
  8. Return integral and overflow count from integral module
  9. Return q_code from time module
  10. Return (x - xthr_sample)*10 + time returned from time module, units are 0.1*sample-period (0.8ns)


Time finding module

This returns an error code q_code and the hit time, relative to the threshold-crossing sample time

  1. Calculate thresholds from constants and local_pedestal, which is sent in as in sample number ped_sample
  2. Search the samples from ped_sample+1 to nsamples-1 for value >= high_threshold + local_pedestal. If this threshold is not exceeded, return bit q_code=1 and time x*10-rough_dt
  3. Search back from high_threshold crossing down toward ped_sample to find sample y where value <= low_threshold + local_pedestal
  4. Calculate 7 upsampled values, from y-0.2 to y+1.2
  5. Search the upsampled values from y+1.2 down to y-0.2 to find where the value <= low_threshold + local_pedestal
  6. Interpolate between the upsampled value just found and the next to find the crossing time in units of sample/10
  7. Return crossing time found and q_code=0


Signal maximum module

This returns the signal maximum

  1. Inspect ADC values after sample x, find the first value which is less than its predecessor
  2. Return value of the predecessor scaled down by 2^p


Signal integral module

This returns the signal integral and overflow count

  1. Sum signal-local_pedestal, from sample x-integral_offset to sample end_window, and count the number of samples with overflow bit set
  2. Return integral scaled down by 2^m (return all bits set if value exceeds that of bits available)
  3. Return overflow count (return 7 if count>6)





Upsampled data

ADC samples in (big circles) and upsampled data out (small blue dots)
ADC samples in (big circles) and upsampled data out (small blue dots)
ADC samples in (big circles) and upsampled data out (small blue dots)