User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
itop:documentation:code [2013/06/03 17:44]
kurtisn [Timing Calibration Resolution Studies]
itop:documentation:code [2013/06/17 14:36] (current)
kurtisn
Line 3: Line 3:
 The latest version of the code is available here: The latest version of the code is available here:
  
-LINK ME+[[http://​www.phys.hawaii.edu/​~kurtisn/​software/​2013-06-07_conversion_code.tar.gz]] 
 + 
 +Calibration constants are posted [[itop:​documentation:​code#​previously_compiled_calibration_constants|below.]] 
 + 
 +(Please note that although there are some variables in this ROOT tree to handle crosstalk, they are not quite working right yet.  I will post an update when I debug them.)
  
 The following is the general procedure to produce summary ROOT files. ​ It is a number of steps, but each major step can usually be automated with simple scripts. The following is the general procedure to produce summary ROOT files. ​ It is a number of steps, but each major step can usually be automated with simple scripts.
Line 21: Line 25:
  
 Your next steps will depend on what you're trying to do.  I suggest below some things that I often do. Your next steps will depend on what you're trying to do.  I suggest below some things that I often do.
- 
 ===== Visual Waveform Checks ===== ===== Visual Waveform Checks =====
  
 If you want to look over a few waveforms by eye to see if they look reasonable, do the following: If you want to look over a few waveforms by eye to see if they look reasonable, do the following:
  
 +In ROOT, open the file produced with ConvertToRootNoAuxDataMultiScrod with a command like:
  
 +TFile *f1 = new TFile("<​filename>​.root"​)
 +
 +Load the script:
 +
 +.L scripts/​DrawWaveform4Segments.C+
 +
 +Then:
 +
 +DrawAll()
 +
 +And press enter to cycle through waveforms. ​ You can also edit the script to insert some cuts to only look at waveforms from a channel you're interested in, or satisfying some selection that you'd like to see.
 ===== Timing Calibration Resolution Studies ===== ===== Timing Calibration Resolution Studies =====
  
 The following are the best known procedures for performing timing calibration using the pulser, and performing MCP-PMT timing measurements. ​ The parameters of these procedures have only been roughly scanned, so further improvements are almost certainly possible. ​ If you find something that works better, let me know! The following are the best known procedures for performing timing calibration using the pulser, and performing MCP-PMT timing measurements. ​ The parameters of these procedures have only been roughly scanned, so further improvements are almost certainly possible. ​ If you find something that works better, let me know!
  
-==== Current Best Calibration Procedure ====+The calibration script can be loaded with: 
 + 
 +.L DrawWaveform4SegmentsWithCamac.C+ 
 + 
 +The arguments are: 
 + 
 +DrawWaveform4SegmentsWithCamac(<​col>,<​row>,<​ch>,<​SCROD ROOT file (single SCROD data only)>,<​CAMAC ROOT file>,<​amplitude calibration file>,<​timing calibration file>,<​pulse height calibration file>) 
 + 
 +The three calibration files can be left out by passing 0 or NULL as an argument in their place. ​ If you leave one of them out, the following files will be generated, respectively:​ 
 + 
 +  * amplitude.cal - Sample-to-sample amplitude correction (useful for pulser data, not recommended for laser data). 
 +  * pulser.cal - Correction for sample-to-sample timing (preferably based on high statistics pulser data). 
 +  * ph.cal - Correction for overall pulse timing based on pulse height. 
 + 
 +==== Previously compiled calibration constants ==== 
 + 
 +Calibration constants based on the 2013-05-26 Fuji Hall pulser data are available here: 
 + 
 +[[http://​www.phys.hawaii.edu/​~kurtisn/​software/​20130526_pulsertiming.tar.gz]] 
 + 
 +In the tarball of calibration constants posted here, these calibration files are renamed as scrod<​XX>​_<​row><​col><​ch>​[.amp/​.dt],​ with .amp corresponding to the amplitude calibration (to be used for pulser data only), and .dt to be used for the sample-to-sample calibration. 
 + 
 +Please note that we are currently assuming that all channels from the same ASIC use the same dt calibration,​ so even though all pulser data was taken for channel 1, it should be suitable for all channels on that ASIC. 
 + 
 +==== (My) Current Best Calibration Procedure ==== 
 + 
 +  * Data points are assumed to lie on a uniform grid with nominal sampling rate (2.7135 GSPS). 
 +  * All region-of-interest waveforms (sets of 4 windows) are aligned based on the first window. ​ If the first window is even, we align based on the number of sampling clock periods from the reference window. ​ One period is (1./​0.127216)*6.0 nanoseconds. ​ If the first window is odd, we align to the first window - 1 and project forward to the window boundary. ​ These should nominally match, but there are subtle potential differences between the two. 
 +  * Adjust all waveform times by the FTSW TDC measurement. ​ The scale per TDC count is (ftsw_clock_period / (1958.-914.)) ns.  This was extracted based on the known clock frequency and the width of the TDC distribution. ​ The resulting value is slightly different than the nominal 50 ps / count. 
 +  * Timing for fixed amplitude pulser data is obtained with the function FindTDCAndADC(). 
 +  * No interpolation is applied to data. 
 +  * Find the maximum waveform point and its corresponding ADC value with FindMax(). 
 +  * Collect data on the maximum pulse height as a function of the sample where the maximum was found. 
 +  * Use the above as a calibration to normalize pulse heights across all samples. 
 +  * Repeat all above steps with the calibration applied, then... 
 +  * Search backwards from the maximum for a fixed threshold using FindThresholdTime(). ​ For Fuji-hall pulser data the value was roughly optimized at 150 ADC counts, but may differ by dataset and pulse shape. 
 +  * Collect data on extracted timing versus sample number where the threshold edge was found. 
 +  * Any structure in the above plot is indicative of the timing calibration sample-to-sample. 
 +  
 +==== (My) Current Best MCP-PMT Timing Procedure ==== 
 + 
 +  * Do the alignment for first_window/​ref_window as above. 
 +  * Do the alignment for FTSW TDC value as above. 
 +  * Adjust each sample point time by the values obtained from the procedure above. 
 +  * Do NOT apply the amplitude corrections from above, as they'​re unlikely to be the same for MCP-PMT pulses. 
 +  * Apply a cubic spline to place the points back onto a uniform grid at the nominal sampling rate.  This is handled by InterpolateToUniformGrid(). 
 +  * Apply a simple IIR-style RC integrator with time constant of 5 times the nominal sampling rate.  This is handled by RCIntegrator(). 
 +  * Find the pulse maximum with FindMax(). 
 +  * Measure the baseline from the sample 50 before the max to the sample 15 before the max.  Truncate as necessary for the beginning of the ROI.  This is done with MeasureBaseline(). 
 +  * Subtract off this baseline from all samples. ​ This is done as part of the same function as above. 
 +  * Fit the leading edge of the pulse from 12 samples before the maximum to 6 samples before the maximum to obtain the timing. ​ This is done with FitThresholdEdge(). 
 + 
 +===== Produce Feature Extracted ROOT Trees ===== 
 + 
 +To do TOP analysis, the waveform is often superfluous information. ​ You may rather just have an estimate of a hit and a pulse height for each photon candidate. ​ The following is a way to produce such files: 
 + 
 +  - Use the code scripts/​ConvertFullEvents.C : 
 +    - .x scripts/​ConvertFullEvents.C+("<​input_base_file_name_up_to_first_dot>","<​output ROOT file>"​) 
 + 
 +The output file will have just the summary data, no waveforms. ​ It is convenient for plotting tdc:ch distributions,​ etc.  If you want to look at multiple such files, make many of them and then chain them together using TChain.
  
-==== Current Best MCP-PMT Timing Procedure ==== +For further analysis, here are the branch names and types (see [[http://​root.cern.ch/​root/​html/​TTree.html|TTree documentation]]):​
-===== Produce Summary Files =====+
  
 +  * "​evt/​i"​ (32-bit unsigned integer) - Event number, as written into the data stream. ​ The conversion code requires that all modules + CAMAC agree on an event number to write it to the summary output file.
 +  * "​nhits/​i"​ (32-bit unsigned integer) - Number of regions of interest passing the loose criteria in ConvertFullEvents.C.
 +  * "​raw_mod[nhits]/​s"​ (16-bit unsigned integer) - electronics module number (0-3) corresponding to each hit
 +  * "​raw_scrod[nhits]/​i"​ (32-bit unsigned integer) - SCROD ID of the module corresponding to each hit
 +  * "​raw_row[nhits]/​s"​ (16-bit unsigned integer) - electronics row (0-3) corresponding to each hit
 +  * "​raw_col[nhits]/​s"​ (16-bit unsigned integer) - electronics col (0-3) corresponding to each hit
 +  * "​raw_ch[nhits]/​s"​ (16-bit unsigned integer) - electronics ASIC ch (0-7) corresponding to each hit
 +  * "​hit_pmt[nhits]/​s"​ (16-bit unsigned integer) - PMT # in the [[https://​belle2.cc.kek.jp/​~twiki/​bin/​viewauth/​Detector/​TOP/​CRTIRS3BDevelopmentDataAnalysisCode#​Numbering_scheme_conversion|Belle II scheme]]
 +  * "​hit_pmt_ch[nhits]/​s"​ (16-bit unsigned integer) - channel # within a PMT in the [[https://​belle2.cc.kek.jp/​~twiki/​bin/​viewauth/​Detector/​TOP/​CRTIRS3BDevelopmentDataAnalysisCode#​Numbering_scheme_conversion|Belle II scheme]]
 +  * "​hit_ch[nhits]/​s"​ (16-bit unsigned integer) - flattened channel number, increasing by column, then by row.  So first 64 channels correspond to innermost row, next 64 to the second to innermost row, ..., last 64 to the outermost row.
 +  * "​hit_tdc[nhits]/​F"​ (32-bit floating point) - extracted time for this hit (uses CFD in posted version). ​ Includes the coarse time correction based on windows/​reference window as well as the time correction for the FTSW trigger phase.
 +  * "​hit_tdc_fwd[nhits]/​F"​ (32-bit floating point) - time defined by first zero crossing after the peak.  From previous studies, this is not a very high precision measurement of the pulse time, but the distance between hit_tdc and this time give some information about the pulse shape which may be useful in rejecting some non-pulses.
 +  * "​hit_tdc_samp[nhits]/​F"​ (32-bit floating point) - sample within the 128-samples of the ASIC sampling array corresponding to the location where the hit_tdc was found. ​ May be used to check quality of timing calibration or develop secondary calibrations to remove residual structures.
 +  * "​hit_adc[nhits]/​F"​ (32-bit floating point) - Peak ADC value found in the waveform. ​ Found by a simple search of the array.
 +  * "​ftsw_phase/​F"​ (32-bit floating point) - FTSW trigger phase from the CAMAC system, converted to ns already. ​ This is corrected out as part of the hit_tdc calculation,​ but may be interesting to look at either for residual structures or for identifying race conditions on the trigger that may cause timing slips by a full sampling period (47 ns).
  
 +Other CAMAC quantities can and should be added as we know what they correspond to.