Difference between revisions of "Data Analysis - Hodoscope Calibration"

From Xem2
Jump to navigationJump to search
(Created page with " ==Calibration Procedure== This section outlines the hodoscope calibration procedure in hallc_replay_XEM. A standalone CALIBRATION script has been made for the HMS and SHMS t...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
__NOTOC__
 +
==Hodoscope Construction==
 +
See Carlos Yero's hodo calib document on the Doc DB for a brief overview of the hodoscope construction and general calibration principles.<br>
 +
https://hallcweb.jlab.org/DocDB/0009/000970/002/hodo_calib_v2.pdf
 +
:'''You should familiarize yourself with the above document before attempting to follow the hodoscope calibration procedures below.'''
 +
==SHMS Hodoscope Calibration Procedure==
 +
The instructions in this section are specific for the XEM analysis.<br>
 +
;Timing windows and reference time cuts must be applied before the hodoscope can be calibrated.
 +
:See [[Data Analysis - Timing Windows and Reference Times]]
 +
'''NOTE:''' 1-2 Million evens are required to get a good fits of the time-walk (TW) and propagation velocity parameters (Vp). 
 +
 +
A standalone single-arm DAQ SCRIPT has been made to calibrate the SHMS hodoscope.<br>
 +
: <code>SCRIPTS/SHMS/CALIBRATION/replay_hodoscope_shms.C</code>
 +
''If a COIN DAQ is used, a full replay will need to be used as no specific DEF-file has been created for the hodoscope calibration yet.''  Ideally, the standalone calibration script should be used because it is about 10 times faster since only the required branches are added to the output tree.  This will also speed up the following calibration steps.
 +
;The output root file will follow the naming convention:
 +
: <code>ROOTfiles/SHMS/CALIBRATION/shms_replay_hodoscope_<runNumber>_<Nevents>.root</code>
 +
 +
# Hall C SHMS Hodo Calibration Codes
 +
 +
A set of ROOT scripts to determine the time offset parameters for the SHMS hodoscope.  The next script determines the effective propagation speed in the paddle, the time difference between the positive and negative PMTs and then the relative time difference of all paddles compared to paddle 7 in plane S1X.  This calibration requires at least 1-2M events.
 +
 +
 +
This calibration procedure supercedes an older calibration code. The parameters from the outdated code are
 +
used flag ptofusinginvadc is set to 1.  The ptofusinginvadc has been set to zero by default for at least the past 4 years.
 +
 +
The two codes have different parameters and it is possible to switch between the parameters of the two calibration codes using the  parameter flag ptofusinginvadc.  Do not use the old calibration code unless instructed to by an expert. 
 +
 +
## Instructions
 +
 +
1. Replay the data with SCRIPTS/SHMS/CALIBRATION/replay_hodoscope_shms.C  or SCRIPTS/COIN/CALIBRATION/replay_hodoscope_coin.C depending on the DAQ configuration in use.
 +
  Note: This script sets the parameter phodo_debug_adc = 1 automatically.  If you are using a different script, you will need to change phodo_debug_adc = 1 in PARAM/SHMS/GEN/p_fadc_debug.param.    phodo_debug_adc = 1 ---> Use the correct hodo raw leaf variables
 +
 +
    a. Open root with 'root -l' and load the script with .L SCRIPT/SHMS/CALIBRATION/replay_hodoscope_shms.C or .L SCRIPT/COIN/CALIBRATION/replay_hodoscope_coin.C depending on the DAQ.
 +
    i. Run the script as replay_hodoscope_shms(Run_Number, N_events, replay_step=1)
 +
          ii. The ROOTfile from these scripts is saved in either ROOTfiles/SHMS/CALIBRATION/ or ROOTfiles/COIN/CALIBRATION depending on the DAQ used.
 +
 +
2. Determine the time walk correction parameters
 +
 +
    a. Start "root -l" and then  .L timeWalkHistos.C
 +
            i. timeWalkHistos("path_to_file/replayed_file.root",Run_Number, "shms") ---> If doing coincidence, then "shms"->"coin"
 +
 +
    b. This creats the file: timeWalkHistos_<Run_Number>.root in the current directory.
 +
 +
    c. Start "root -l" and then .L timeWalkCalib.C
 +
            i. timeWalkCalib(Run_Number)
 +
 +
    d. This creates the parameter file "PARAM/SHMS/HODO/phodo_TWcalib_runnumber.param"
 +
            i.  Follow the naming convention outlined in the xem2wiki and move the renamed file to the proper location as outlined in the xem2wiki.
 +
 +
    e. It is likely the hodoscope calibration will only be done once per spectrometer.  In this case only the #include statement in DBASE/SHMS/default_det_calib_sp22.param file will need changed.
 +
          i. replace the existing line #include "PARAM/SHMS/HODO/phodo_TWcalib_fa22_startup.param" with the new file following the naming convention.  This needs to match exactly what you named it in step d.i.
 +
 +
3.  Replay using the same script as before and the new parameter files.  Make sure the new file phodo_TWcalib_*.param file is used by checking the loaded PARAM files.  You will again need around 1-2M events.
 +
    a. Load the script with .L SCRIPT/SHMS/CALIBRATION/replay_hodoscope_shms.C or .L SCRIPT/COIN/CALIBRATION/replay_hodoscope_coin.C depending on the DAQ.
 +
    i. Run the script as replay_hodoscope_shms(Run_Number, N_events, replay_step=2)
 +
 +
4. Determine the the effective propagation speed in the paddle, the time difference between the positive and negative PMTs and then the relative time difference of all paddles compared to paddle 7 in plane S1X. The script puts cuts on P.cal.etracknorm, P.ngcer.npeSum and P.hod.betanotrack to select electrons. These cuts are hard coded as  etrknrm_low_cut = 0.7, npngcer_npeSum_low_cut = 0.7 , betanotrack_low_cut = 0.5 and betanotrack_hi_cut = 1.5. These may need to be modified. The event must have a track.
 +
 +
    a.  Start "root -l" and then  .L  fitHodoCalib.C
 +
            i. fitHodoCalib("path_to_file/replayed_file.root",Run_Number)   
 +
 +
    b.  This creates the parameter file "PARAM/SHMS/HODO/phodo_Vpcalib_runnumber.param"
 +
            i. Rename this file and move it to the proper location according to the xem2wiki. 
 +
 +
    c. It also creates the root file HodoCalibPlots_runnumber.root
 +
        i. Move this root file to the appropriate location on the group disk to make it viewable online. 
 +
 +
Extra:
 +
    a. To analyze cosmic data :  .x  fitHodoCalib.C+("current_dir/to/ROOT_filename.root",Run_Number,kTRUE)
 +
 +
    b. For cosmic data the speed of light is set to -30 cm/ns and the PID cut is just on P.hod.betanotrack with the default of betanotrack_low_cut = -1.2 and betanotrack_hi_cut = -.7
  
==Calibration Procedure==
 
This section outlines the hodoscope calibration procedure in hallc_replay_XEM.  A standalone CALIBRATION script has been made for the HMS and SHMS to avoid manual setting of parameters.  This has been done to avoid forgetting to set or unset parameters during the calibration process.  Additionally, it is nice to be able to check if the calibration from several runs ago is still applicable to the current runs.
 
'''NOTE:''' 1-2 Million evens are required to get a good fits of the time-walk (TW) and propagation velocity parameters (Vp). 
 
  
 +
===Troubleshooting the calibration===
 +
:<Carlos's email plots>
 +
:<Calibration scripts currently in repo cannot be used for previous hodoscopes because calibration has been updated to match cuts / cable lengths for current hodoscope setup. >
  
*Set the flag h(p)tofusinginvadc = 0 to NOT use the hodo parameters from the previous hodoscope calibration
+
The file isnt there:
procedure. This flag is found on hallc replay/PARAM/H(S)MS/HODO/ directory.
+
found the file.
� Replay the raw data file, typically 1-2 M events is required for a good fit to be done.
 
� In the directory hallc replay/CALIBRATION/(s)hms hodo calib/, run the following code:
 
♦ root -l ’’timeWalkHistos.C(<run num>)’’
 
This script takes as input the ROOTfile replayed and creates another ROOTfile with histogram objects that are used
 
to perform the time-walk correction.
 
� To do the time-walk corrections, run the following code:
 
♦ root -l ’’timeWalkCalib.C(<run num>)’’
 
This script takes as input the ROOTfile containing the histogram objects produced by the previous script. A parameter
 
file containing the time-walk parameters will be produced at
 
♦ hallc replay/PARAM/(S)HMS/HODO/(p)hhodo TWcalib runNUM.param This parameter file name has
 
to be manually changed to exclude the run number, since hcana reads in the parameter file as (p)hhodo TWcalib.param
 
.
 
� Replay the raw data file, once again (1 - 2 M events), with the updated time-walk parameters.
 
� In the hodoscopoe calibration directory, run the following code:
 
♦ root -l fitHodoCalib.C The first part of this script performs a linear fit on the time-walk corrected time
 
vs. hodoscope track to determine the propagation velocity and the cable time difference across each paddle. The second
 
part of this code solves a matrix equation for the λ parameters mentioned in the previous section. A parameter file
 
containing the time-walk parameters will be produced at
 
♦ hallc replay/PARAM/(S)HMS/HODO/(p)hhodo Vpcalib runNUM.param
 
This parameter file name has to be manually changed to exclude the run number, since hcana reads in the parameter
 
file as (p)hhodo Vpcalib.param .
 
� Replay the raw data one last time, and check the hodoscope beta distribution. You may have to apply a calorimeter cut
 
(for example, (P)H.cal.etracknorm>0.7) A good calibration should have the beta centered at unity. (See Figure
 
9)
 

Latest revision as of 15:40, 10 January 2023

Hodoscope Construction

See Carlos Yero's hodo calib document on the Doc DB for a brief overview of the hodoscope construction and general calibration principles.
https://hallcweb.jlab.org/DocDB/0009/000970/002/hodo_calib_v2.pdf

You should familiarize yourself with the above document before attempting to follow the hodoscope calibration procedures below.

SHMS Hodoscope Calibration Procedure

The instructions in this section are specific for the XEM analysis.

Timing windows and reference time cuts must be applied before the hodoscope can be calibrated.
See Data Analysis - Timing Windows and Reference Times

NOTE: 1-2 Million evens are required to get a good fits of the time-walk (TW) and propagation velocity parameters (Vp).

A standalone single-arm DAQ SCRIPT has been made to calibrate the SHMS hodoscope.

SCRIPTS/SHMS/CALIBRATION/replay_hodoscope_shms.C

If a COIN DAQ is used, a full replay will need to be used as no specific DEF-file has been created for the hodoscope calibration yet. Ideally, the standalone calibration script should be used because it is about 10 times faster since only the required branches are added to the output tree. This will also speed up the following calibration steps.

The output root file will follow the naming convention
ROOTfiles/SHMS/CALIBRATION/shms_replay_hodoscope_<runNumber>_<Nevents>.root
  1. Hall C SHMS Hodo Calibration Codes

A set of ROOT scripts to determine the time offset parameters for the SHMS hodoscope. The next script determines the effective propagation speed in the paddle, the time difference between the positive and negative PMTs and then the relative time difference of all paddles compared to paddle 7 in plane S1X. This calibration requires at least 1-2M events.


This calibration procedure supercedes an older calibration code. The parameters from the outdated code are used flag ptofusinginvadc is set to 1. The ptofusinginvadc has been set to zero by default for at least the past 4 years.

The two codes have different parameters and it is possible to switch between the parameters of the two calibration codes using the parameter flag ptofusinginvadc. Do not use the old calibration code unless instructed to by an expert.

    1. Instructions

1. Replay the data with SCRIPTS/SHMS/CALIBRATION/replay_hodoscope_shms.C or SCRIPTS/COIN/CALIBRATION/replay_hodoscope_coin.C depending on the DAQ configuration in use.

  Note: This script sets the parameter phodo_debug_adc = 1 automatically.  If you are using a different script, you will need to change phodo_debug_adc = 1 in PARAM/SHMS/GEN/p_fadc_debug.param.    phodo_debug_adc = 1 ---> Use the correct hodo raw leaf variables
    a. Open root with 'root -l' and load the script with .L SCRIPT/SHMS/CALIBRATION/replay_hodoscope_shms.C or .L SCRIPT/COIN/CALIBRATION/replay_hodoscope_coin.C depending on the DAQ.
  	   i. Run the script as replay_hodoscope_shms(Run_Number, N_events, replay_step=1)
          ii. The ROOTfile from these scripts is saved in either ROOTfiles/SHMS/CALIBRATION/ or ROOTfiles/COIN/CALIBRATION depending on the DAQ used.

2. Determine the time walk correction parameters

    a. Start "root -l" and then  .L timeWalkHistos.C
           i. timeWalkHistos("path_to_file/replayed_file.root",Run_Number, "shms") ---> If doing coincidence, then "shms"->"coin"
    b. This creats the file: timeWalkHistos_<Run_Number>.root in the current directory.
    c. Start "root -l" and then .L timeWalkCalib.C
           i. timeWalkCalib(Run_Number)
    d. This creates the parameter file "PARAM/SHMS/HODO/phodo_TWcalib_runnumber.param"
           i.  Follow the naming convention outlined in the xem2wiki and move the renamed file to the proper location as outlined in the xem2wiki.
    e. It is likely the hodoscope calibration will only be done once per spectrometer.  In this case only the #include statement in DBASE/SHMS/default_det_calib_sp22.param file will need changed.
          i. replace the existing line #include "PARAM/SHMS/HODO/phodo_TWcalib_fa22_startup.param" with the new file following the naming convention.  This needs to match exactly what you named it in step d.i.

3. Replay using the same script as before and the new parameter files. Make sure the new file phodo_TWcalib_*.param file is used by checking the loaded PARAM files. You will again need around 1-2M events.

    a. Load the script with .L SCRIPT/SHMS/CALIBRATION/replay_hodoscope_shms.C or .L SCRIPT/COIN/CALIBRATION/replay_hodoscope_coin.C depending on the DAQ.
  	   i. Run the script as replay_hodoscope_shms(Run_Number, N_events, replay_step=2)

4. Determine the the effective propagation speed in the paddle, the time difference between the positive and negative PMTs and then the relative time difference of all paddles compared to paddle 7 in plane S1X. The script puts cuts on P.cal.etracknorm, P.ngcer.npeSum and P.hod.betanotrack to select electrons. These cuts are hard coded as etrknrm_low_cut = 0.7, npngcer_npeSum_low_cut = 0.7 , betanotrack_low_cut = 0.5 and betanotrack_hi_cut = 1.5. These may need to be modified. The event must have a track.

    a.  Start "root -l" and then  .L  fitHodoCalib.C
           i. fitHodoCalib("path_to_file/replayed_file.root",Run_Number)     
    b.  This creates the parameter file "PARAM/SHMS/HODO/phodo_Vpcalib_runnumber.param"
           i. Rename this file and move it to the proper location according to the xem2wiki.  
    c. It also creates the root file HodoCalibPlots_runnumber.root
    	    i. Move this root file to the appropriate location on the group disk to make it viewable online.  

Extra:

    a. To analyze cosmic data :  .x  fitHodoCalib.C+("current_dir/to/ROOT_filename.root",Run_Number,kTRUE) 
    b. For cosmic data the speed of light is set to -30 cm/ns and the PID cut is just on P.hod.betanotrack with the default of betanotrack_low_cut = -1.2 and betanotrack_hi_cut = -.7


Troubleshooting the calibration

<Carlos's email plots>
<Calibration scripts currently in repo cannot be used for previous hodoscopes because calibration has been updated to match cuts / cable lengths for current hodoscope setup. >

The file isnt there: found the file.