Difference between revisions of "CDC algo"

From GlueXWiki
Jump to: navigation, search
Line 1: Line 1:
 
CDC time & integral algorithm.  This works very nicely with offline data.
 
CDC time & integral algorithm.  This works very nicely with offline data.
  
Data-scanning process starts up prompted by trigger signal, reads through ADC value to search for a hit. If a hit is found then it returns a time, sum of signal minus pedestal, and QF (Quality Factor) code.  The process is described for one ADC channel, it would be the same process running on all channels.  
+
Data-scanning process starts up prompted by trigger signal, reads through ADC value to search for a hit. If a hit is found then it returns a time, sum of signal minus pedestal, and QF (Quality Factor) code.  The process is described for one ADC channel, it would be the same process running on all channels. This can be implemented to scan ADC samples initially, but eventually it should use upsampled data.
  
 
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).   
 
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).   
Line 8: Line 8:
 
The following constants should be be passed in through software:
 
The following constants should be be passed in through software:
  
name <defaults, type> - description
+
name <defaults, type> description (sigma=pedestal width, approx 16 adc units)
  
#hit_threshold <5 or 6 sigma (sigma~16), real number, integer, range 10 to 300> threshold to identify that hit occurred
+
#hit_threshold <5 or 6 sigma, integer, range 10 to 300> threshold to identify that hit occurred
#high_threshold <4 or 5 sigma, real number, 1 dec place, range 10 to 300> smaller than hit threshold, use for timing, typically hit_threshold  
+
#high_threshold <4 or 5 sigma, integer, range 10 to 300> smaller than hit threshold, use for timing, typically hit_threshold-sigma
#low_threshold <1 sigma, real number, 1 dec place, range 0 to 30> low threshold, typically sigma
+
#low_threshold <1 sigma, integer, range 0 to 30> low threshold, use for timing
#time_tolerance <3, real number, 1 dec place, range 0.5 to 8> max # samples between hit threshold crossing and leading edge time, if this is exceeded then output hit threshold crossing time minus a constant
+
#time_tolerance <3, real number, 1 dec place, range 0.5 to 8> max number of samples between hit threshold crossing and leading edge time, if this is exceeded then output hit threshold crossing time minus a constant.  (Could express this as integer number of ns.)
#time_constant <6 samples, real number, 1 dec place, range 0 to 20> output hit threshold time minus this instead of leading edge time and a QF code if time_tolerance is exceeded
+
#time_constant <6 samples, real number, 1 dec place, range 0 to 20> output hit threshold time minus this value instead of leading edge time if time_tolerance is exceeded. (Could express this as integer number of ns.)
 
#integration_period <100, integer, range 0 to 200> number of samples to integrate signal over
 
#integration_period <100, integer, range 0 to 200> number of samples to integrate signal over
 
#pedestal_start <0, integer, range 0-100> first sample to use in event pedestal calculation
 
#pedestal_start <0, integer, range 0-100> first sample to use in event pedestal calculation
Line 28: Line 28:
 
#Jump ahead to sample 'jump'
 
#Jump ahead to sample 'jump'
 
#Continue reading through adc values in the presample buffer.
 
#Continue reading through adc values in the presample buffer.
##  Look for data over threshold (pedestal+ hit_threshold) for "integration_time" samples
+
##  Look for data over threshold (pedestal+ hit_threshold) for 'integration_time' samples
 
##  If data is not over threshold then output nothing, return (to search next channel)
 
##  If data is not over threshold then output nothing, return (to search next channel)
 
##  If data is over threshold then process hit as follows
 
##  If data is over threshold then process hit as follows

Revision as of 13:49, 30 July 2013

CDC time & integral algorithm. This works very nicely with offline data.

Data-scanning process starts up prompted by trigger signal, reads through ADC value to search for a hit. If a hit is found then it returns a time, sum of signal minus pedestal, and QF (Quality Factor) code. The process is described for one ADC channel, it would be the same process running on all channels. This can be implemented to scan ADC samples initially, but eventually it should use upsampled data.

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).


The following constants should be be passed in through software:

name <defaults, type> description (sigma=pedestal width, approx 16 adc units)

  1. hit_threshold <5 or 6 sigma, integer, range 10 to 300> threshold to identify that hit occurred
  2. high_threshold <4 or 5 sigma, integer, range 10 to 300> smaller than hit threshold, use for timing, typically hit_threshold-sigma
  3. low_threshold <1 sigma, integer, range 0 to 30> low threshold, use for timing
  4. time_tolerance <3, real number, 1 dec place, range 0.5 to 8> max number of samples between hit threshold crossing and leading edge time, if this is exceeded then output hit threshold crossing time minus a constant. (Could express this as integer number of ns.)
  5. time_constant <6 samples, real number, 1 dec place, range 0 to 20> output hit threshold time minus this value instead of leading edge time if time_tolerance is exceeded. (Could express this as integer number of ns.)
  6. integration_period <100, integer, range 0 to 200> number of samples to integrate signal over
  7. pedestal_start <0, integer, range 0-100> first sample to use in event pedestal calculation
  8. pedestal_end <9, integer, range 0-100> last sample to use in event pedestal calculation
  9. pedestal_lead <4, integer, range 0-25> take local pedestal as adc value this number of samples before hit threshold
  10. jump <12, integer, range 0-100> earliest sample to be scanned for hit data


Data-scan process

  1. Find mean of samples 'pedestal_start' to 'pedestal_end' in presample buffer and call this 'event pedestal'.
  2. Jump ahead to sample 'jump'
  3. Continue reading through adc values in the presample buffer.
    1. Look for data over threshold (pedestal+ hit_threshold) for 'integration_time' samples
    2. If data is not over threshold then output nothing, return (to search next channel)
    3. If data is over threshold then process hit as follows

Hit processing

We are now at the threshold crossing, sample number x where adc value first rises over pedestal+hit_threshold

  1. Find time:
    1. Store value of sample (x-'pedestal_lead') as 'local pedestal'
    2. Start at sample x and search back through progressively earlier samples to find sample y where adc value falls below pedestal+high_threshold
    3. Continue searching back to find sample z where adc value falls below pedestal+low_threshold
    4. Calculate le_time as value t where straight line through y and z intercepts local_pedestal
    5. Calculate x-t. if this is greater than time_tolerance, set le_time = x-time_constant
  2. Find integral:
    1. Return to first sample after le_time
    2. Calculate the sum of (sample value - local pedestal) for the next integration_period samples
    3. Calculate QF. This contains - as a starting point - a bit set if x-t > time_tolerance, and some measure of pedestal, maybe the lowest bits to cover the range 0-511.
  3. Return time, integral, QF.