Difference between revisions of "CDC algo"

From GlueXWiki
Jump to: navigation, search
(Error codes with faulty channels included)
(Error codes with faulty channels included)
Line 123: Line 123:
 
|-
 
|-
 
| 0 || Good || 1304829 || 90% ||  
 
| 0 || Good || 1304829 || 90% ||  
 +
|}
 +
 +
 +
==Error codes with ,ost of faulty channels excluded from data==
 +
 +
Error codes are listed in the order that the event is removed from processing
 +
 +
{| border="1px" cellpadding="2" style="border-style:solid;"
 +
! q_code !! reason !! entries !! percent of total !! percent of q>0 entries
 +
|-
 +
| 5 || ADC value = 0 || 56990 || 3.9% || 41%
 +
|-
 +
| 6 || ADC value > 4095 || 0 || 0% || 0%
 +
|-
 +
| 7 || Pedestal > 511 || 57324 || 3.9% || 41%
 +
|-
 +
| 1 || ADC data did not go over threshold adc_thres_hi || 10734 || 0.7% || 7.7%
 +
|-
 +
| 2 || Leading edge time is too late in the buffer to upsample || 840 || 0.06% || 0.6%
 +
|-
 +
| 8 || Upsampled value is negative || 19 || 0.001% || 0.014%
 +
|-
 +
| 9 || Upsampling error sum > 30 || 12997 || 0.89% || 9.3%
 +
|-
 +
| 3 || Last upsampled point is too low (below or equal to low timing threshold) || 995 || 0.068% || 0.71%
 +
|-
 +
| 4 || Upsampled points are too high (did not go below low timing threshold) || 9 || 0.001% || 0.006%
 +
|-
 +
| 0 || Good || 1327050 || 90.5% ||
 
|}
 
|}
  

Revision as of 10:49, 2 February 2015

CDC time & integral algorithm

When the trigger signal arrives, the presample buffer contains NP (default value 16) samples for pedestal followed by NW (default 100, possibly up to 155) samples to contain full range of 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, all bits set if value > field max)
  • Signal integral (n bits, scaled down by factor 2^m, all bits set if greater than range; n,m are 14,4)
  • Signal maximum (p bits, scaled down by factor 2^q; p,q approx 8,2) 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 ~20)

  • NPED: number of samples in pedestal window (default 16, must be 2**integer)
  • WINDOW_START: position in buffer of first sample in hit search window, this is immediately after the pedestal window
  • WINDOW_END: position in buffer of last sample in hit search window
  • HIT_THRES: threshold to identify hit (default 5σ ~100, range 50 to 300)
  • NPED2: number of samples to use to calculate pedestal just before hit (default 16, must be 2**integer)
  • NSAMPLES: number of ADC samples in subset to pass to time finding module (default 15)
  • XTHR_SAMPLE: position in subset of first sample above hit_threshold (default 9, starts with 0)
  • PED_SAMPLE: position in subset of sample to be used as local pedestal (default 5, starts with 0)


Timing algorithm configuration constants

  • HIGH_THRESHOLD: High timing threshold (default 4σ ~ 80, range 40 to 270) must be lower than hit threshold
  • LOW_THRESHOLD: Low timing threshold (default 1σ ~ 20, range 5 to 30)
  • ROUGH_DT: rough time - if timing fails, return hit time of XTHR_SAMPLE - ROUGH_DT (default 24, units sample/10)
  • INT_SAMPLE: if timing fails, start integration with this sample (default 6).
  • NUPSAMPLED: number of upsampled values to calculate (default 8, minimum 8)
  • LIMIT_PED_MAX: do not calculate accurate time if any of samples 0 to PED_SAMPLE in subset exceeds this (default 511)
  • LIMIT_ADC_MAX: do not calculate accurate time if any sample in the subset exceeds this (default 4095)
  • SET_ADC_MIN: reduce chances of calculating a negative upsampled value by adding a constant offset to the subset values such that the minimum is equal to SET_ADC_MIN (default 20)
  • LIMIT_UPS_ERR: do not calculate accurate time if the sum of the error of the 2 upsampled values exceeds this (default 30)


Hit finding module

  1. Calculate start_pedestal as mean of NPED samples from WINDOW_START-NPED-1 to WINDOW_START-1
  2. Search from WINDOW_START to WINDOW_END for the earliest sample with ADC value >= start_pedestal + HIT_THRES. If not found, go back to sleep. If found, continue, this is sample X.
  3. Call up time-finding module and send in NSAMPLES ADC values from the hit threshold crossing region, with sample X in position XTHR_SAMPLE (starting at 0)
  4. Call up signal maximum module
  5. Call up signal integral module
  6. Return pedestal_at_hit as mean of NPED2 samples ending with sample number X + PED_SAMPLE - XTHR_SAMPLE, or 255 if pedestal_at_hit > field max
  7. Return overflow count from integral module
  8. Return q_code from time module
  9. Return total integral: sum of contributions from time module and integral module
  10. Return time = (X - XTHR_SAMPLE)*10 + le_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 leading edge time le_time, in units of sample/10 and relative to the first sample in the subset. The hit time returned falls into one of three categories: an accurate estimate of the leading edge time, where the low threshold crossing time was found using upsampled data, a midpoint time, where the low threshold crossing time was found using sample data, and a rough time estimate, XTHR_SAMPLE*10 - ROUGH_DT. If the time returned is the accurate leading edge time, q_code is set to 0, otherwise it is set to 1.

  1. Inspect ADC samples 0 to PED_SAMPLE. If any sample values are 0 or greater than LIMIT_PED_MAX, return the rough time, XTHR_SAMPLE*10 - ROUGH_DT, and q_code=1.
  2. Inspect ADC samples PED_SAMPLE+1 to NSAMPLES-1. If any sample values are 0 or greater than LIMIT_ADC_MAX, return the rough time and q_code=1.
  3. Find the minimum sample value in the subset. Subtract a constant offset from all sample values so that the minimum value is now SET_ADC_MIN. This is to decrease the likelihood of calculating any negative upsampled values.
  4. Calculate the timing thresholds thres_hi = value of sample PED_SAMPLE + HIGH_THRESHOLD and thres_lo = value of sample PED_SAMPLE + LOW_THRESHOLD
  5. Search the samples from PED_SAMPLE+1 to NSAMPLES-1 for the first sample with value >= thres_hi. If this threshold is not met, return the rough time and q_code=1.
  6. Search the samples from the first sample with value >= thres_hi down to PED_SAMPLE to find the first sample (Y) with value <= thres_lo
  7. If Y is > NSAMPLES-7, there are not enough samples to calculate upsampled values, return the rough time and q_code=1.
  8. Calculate NUPSAMPLED (8) upsampled values, starting with Y-0.2.
  9. If any upsampled value is negative, return the midpoint time, Y*10+5, and q_code=1.
  10. Calculate two upsampling errors, as the difference between upsampled point 1 and sample Y, and the difference between upsampled point 2 and sample Y+1
  11. Sum the errors and compare them with LIMIT_UPS_ERR, if this is exceeded then return the midpoint time, Y*10+5, and q_code=1.
  12. Calculate the mean of the 2 errors, ups_err and the adjusted threshold, thres_adj = thres_lo + ups_err
  13. Search the upsampled values from NUPSAMPLED-1 down to 0 to find upsampled point Z where the value <= thres_adj
  14. If Z=NUPSAMPLED-1 or Z is not found, return the midpoint time, Y*10+5, and q_code=1.
  15. Interpolate between the upsampled points Z and Z+1 to find the crossing time in units of sample/10 and relative to the first upsampled point
  16. Calculate the leading edge time, le_time, as the crossing time found in previous step + Y*10-2, in units of sample/10 and relative to subset sample 0
  17. Return time=le_time 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 ADC values from sample X to sample WINDOW_END, 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 range maximum)
  3. Return overflow count (return 7 if count>6)




Error codes from Run 1602

Error codes with faulty channels included

Error codes are listed in the order that the event is removed from processing

q_code reason entries percent of total percent of q>0 entries
5 ADC value = 0 56938 3.9% 41%
6 ADC value > 4095 0 0% 0%
7 Pedestal > 511 57213 4.0% 41%
1 ADC data did not go over threshold adc_thres_hi 10550 0.7% 7.6%
2 Leading edge time is too late in the buffer to upsample 836 0.06% 0.6%
8 Upsampled value is negative 0 0% 0%
9 Upsampling error sum > 30 12959 0.9% 9.4%
3 Last upsampled point is too low (below or equal to low timing threshold) 20 0.001% 0.01%
4 Upsampled points are too high (did not go below low timing threshold) 2 0.0001% 0.001%
0 Good 1304829 90%


Error codes with ,ost of faulty channels excluded from data

Error codes are listed in the order that the event is removed from processing

q_code reason entries percent of total percent of q>0 entries
5 ADC value = 0 56990 3.9% 41%
6 ADC value > 4095 0 0% 0%
7 Pedestal > 511 57324 3.9% 41%
1 ADC data did not go over threshold adc_thres_hi 10734 0.7% 7.7%
2 Leading edge time is too late in the buffer to upsample 840 0.06% 0.6%
8 Upsampled value is negative 19 0.001% 0.014%
9 Upsampling error sum > 30 12997 0.89% 9.3%
3 Last upsampled point is too low (below or equal to low timing threshold) 995 0.068% 0.71%
4 Upsampled points are too high (did not go below low timing threshold) 9 0.001% 0.006%
0 Good 1327050 90.5%

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)