TDC Calibration

Primary correction

The purpose of the primary TDC correction is to shift the X axis such that variations in cable delay between channels is compensated. The origin of the X axis is defined as the center of gravity of the self-timing peak for each channel.

These self-timing peaks are evaluated in the end-of-run routine of the tdccalib module ("tdc_calib_eor"). If the flag "/Analyzer/Parameters/TDC calibration/Correct offsets" in the ODB is on, all raw TDC histos (ID 2000+) are fitted with a gaussian. The result is stored in the arrays "Offset" and "Sigma" in the ODB. Since the algorithm need a clear selft-timing peak, this procedure should only be made on a run which contains only prompt events. Alternatively, for offline purposes, a normal data can can be filtered such that only prompt events are filled into the TDC histos which get analyzed at the end of the run.

From this point on all TDC values are shifted by subtracting the offset from them. Negative TDC values correspond to signals which come before the trigger, positive values after.

Usually, the flag "Correct offsets" is off, meaning that the old values in the ODB are kept untouched. To ensure that this values are still correct, the TDC spectra should be looked at from time to time to make sure that they have not shifted.

Secondary correction

The objective of this correction is to linearize the slewing of TDC time caused by different size of ADC signal. The problem is caused by the difference in rise time of signals to the fixed TDC threshold.

See the solution done after 1998 run.

During the 1999 run, the following solution has been implemented.
The basic functional form: TDC=Par1+Par3*(ADC-Par4)Par2 of the shape of the uncorrected TDC vs. ADC plot was kept from the last year. But the procedure is now more automated and also includes plastic veto counters.
The user-histogram file histo.c was rewritten so that when one includes it into the analyzer, TDC vs. ADC data files are produced. Then one can use the PAW macro tdcfit to make fits to the obtained data, and a macro reshuffle to produce files with parameters for ODB. Another product of the histo.c module is histograms 1980-1987 (ADC vs. TDC raw data for all PV's cut on individual triggers), and 1990-1997 (ADC vs. TDC data for all CsI's cut on individual triggers).

Overview of the method

The histo.c module is written to bin the TDC vs. ADC data into bins of ADC values. Since there are many more events with small ADC values than with large ADC values, the bin width increases linearly with increasing ADC value. This allows to have more or less the same number of points in each bin. The output files tdcXXX.dat (produced at the end of each run), contain the average TDC value, ADC value, TDC error, and ADC error in tabular form.
PAW macro tdcfit takes the tdcXXX.dat files, makes a fit to each set of data, and writes the parameters into tdcXXX.par files. Then, running macro reshuffle will produce 4 files par1.dat, par2.dat, par3.dat, and par4.dat, which contain the parameters for all 480 TDC channels. At this time, only parameters 0-279 are filled (CsI and PV). After attaching headers to parX.dat files, one can load the parameters into ODB under /Analyzer/Parameters/TDC Calibration/.

How to implement this solution in 10 steps!

  1. Copy files histo.c, tdcfit.kumac, reshuffle.kumac, checktdc.kumac, die.for, and tdcplot.kumac into your analyzer directory (make sure to save your own histo.c module).
    NOTE: Click right mouse button over the link to save the file.
  2. In your analyzer directory make subdirectories tdc_data (for histo.c to write the data files), and tdc_par (for tdcfit macro).
  3. Change histo.c if necessary. One can adjust: Right now, each file has between 90 and 130 points (N_MAX=130), which seems to be enough to do the fits.
  4. In ODBEdit, go to "/Analyzer/Parameters/TDC Calibration/" and type "set Par3[*] 0". Then no secondary correction will be performed. It could be useful to save the data base first, so that you would be able to return to old parameters.
  5. Run the analyzer. My experience shows that at least 5 runs (200k events each) should be used to have decent errors on ADC and TDC values; the errors don't change significantly with more than ~15 runs. At the end of each run, the analyzer will write the data into directory tdc_data and will inform the user as to which files have not been written due to lack of data.
  6. Start PAW. Execute macro tdcfit. It will make fits and write the parameters into directory tdc_par.
  7. It's a good idea to visualy evaluate the quality of the fits. Executing macro checktdc will display the data and the fits in 2 rows with 2 graphs per row. If you want to have, say 4 rows with 3 histograms in each row, then type (in PAW): "exec checktdc 3 4".
  8. Execute macro reshuffle. To make sure that parameters were not excessively limited by the bounds, type in "ve/pl p1(1:280)". (Vectors p1, p2, p3, and p4 are created by reshuffle.) I was usually getting a distribution centered around some value. The only exception was p3. Some values, it seems, should be indefinitely large for the best fit. I limited the parameter to 50000. It seems to work fine.
  9. Edit the file par1.dat, add the first line with would read "Par1 = FLOAT[480]:". Do the same for the other 3 *.dat files.
  10. Go to ODBEdit:/Analyzer/Parameters/TDC Calibration/, and type in "load par1.dat" to modify Par1 parameters. Do the same for the other 3 files. Save the new ODB.
  11. You are done!
For analyzer users
Get the ODB file with current parameters.
Same ODB, but containing parameters for individual targets.
Look at the raw data and the fits (PS format).

One may notice in the PostScript file that not all fits are perfect. Especially some plastic veto TDC's show a noticeable deviation from the fit. However, the results of the linearization that we saw online were quite good. CsI detectors looked rather symmetric sentered at 0+/-0.9ns, and PV's while having greater deviations from the mean, are also fairly symmetric. Most of them have a slight positive shift of the center of the peak.

How often should this procedure be done?

The parameters, having a TDC offset, are dependent on the primary TDC correction, therefore, every time primary TDC offsets are changed, new parameters should be found. The current set of parameters was satisfactorially correcting TDC's at all intensities, therefore, with a good deal of confidence, one can say that the parameters above are good for 1999 summer run.


S. Ritt and A. Lebedev. July 16, 1999.