Performing Dithering Corrections

From PREX Wiki
Jump to: navigation, search

This code uses data taken during beam modulation, or dithering. It uses 5 bpms diff_4aX, diff_4aY, diff_4eX, diff_4eY, and diff_11X as independent variables (IVs), and the 4 main detectors asym_usl, asym_usr, asym_dsl, and asym_dsr as dependent variables (DVs). It calculates the dithering slopes and uses either the slopes from a single run or the average slopes over a slug to correct the DVs.

Dithering correction chain

Getting Started

First, you will need to find the slopes that you will use to perform the correction.

  1. Login to the apar account on aonl2: ssh apar@aonl2
  2. cd ~/PREX/prompt/beam-mod/scripts
  3. If you haven't done a "gojapan" yet then source setup_japan.tcsh
  4. Choose a list of runs that you would like to analyze and put them in a file called "filename.list"
    • To analyze a slug, choose the corresponding list in ~/PREX/prompt/collector/run_list/
  5. Next, run ./ filename.list
    • NOTE: You can only run one ./ at a time ( Bug fixed: Now you can do it, but you don't have to)
    • This creates or update a root file called "dit_slopes_slug#.root" in the ~/PREX/prompt/beam-mod/rootfiles directory.
    • NOTE: In case, a slug data set is re-analyzed and you need to update exisiting run slopes, you should delete slopes rootfiles and re-run slope calculation.
    • The TTree "dit" contains the following variables:
      • run: The run number
      • "DV"_"IV": the slope of the graph of "DV" vs "IV"
        • Example: usr_4aY contains the slopes of asym_usr vs diff_bpm4aY
        • There is one for each pair of dependent and independent variables
  6. Open the root file and see if there are any outlier runs
    • If there is a slope that is very different from all of the others, we don't want to use it
  7. Add the outlier runs to the blacklist
    • ~/PREX/prompt/beam-mod/black.list
    • When taking slope averages, these runs will be skipped

Setting up for analysis

To get set up, you have to make sure you know the run number you would like to correct, and the run/slug number that contains the slopes you want to use for the correction.

Finding the slug number

In the ~/PREX/prompt/beam-mod/ directory, there is a macro called QuerySlugNumber.C . Give this macro your run number, and it will search the RCDB to tell you what slug it belongs to.

Finding japan root files

You will also need to know the japan root file that contains the data you want to correct. The main japan output files are in ~/PREX/japan/japanOutput , and have names that follow the convention prexPrompt_pass1/2_runNumber_segNumber.root . Or, you can also use your own personal japan files (see Setting up japan and Running prompt).

Finding dithering slopes root files

These files are in the ~/PREX/prompt/beam-mod/rootfiles directory. You can use the general slug root files if you know the slug number for the run whose slopes you want to use.

Running the analysis

There are two scripts in the ~/PREX/prompt/beam-mod/ directory that will use ditehring slopes to correct your data. They each have different options and outputs, so choose the one that is right for you.


This macro will use the slug average to correct the detector asymmetries. Give it a run number as an argument, and it will load the corresponding main japan file, search the RCDB for the corresponding slug number, and correct the run based on the slug averaged slopes. It saves the uncorrected and corrected detector asymmetries to a root file in the DitOutputs directory, with the naming convention "prexPrompt_dither_runNumber_segmentNumber.root". Example: root -l 'CorrectTree.C (3422, 003)'

To run this many times, create a list of run numbers. Note that this will choose all segment numbers = 000. Then run ./ filename.list


This macro will use slopes from either a specific run number or the average from a slug, and uses them to correct the detector asymmetries. It draws plots of the detector asymmetry before and after the correction, and does not create an output root file.

  1. To correct data using the average slopes of the dithering root file, give the japan file whose data you would like to correct, and the file whose slopes you would like to use:
    • Example: root -l 'DitAlias.C (3422)'
  2. To correct data using the slopes from a particular run, give the japan file whose data you would like to correct, and the file whose slopes you would like to use, and the run number of the slopes you would like to use:
    • Example: root -l 'DitAlias.C (3422, 3421)'
  3. Note that you can correct a run using the slopes of any other run or slug that you'd like