How to do timing scans for the EPD

I have tried to make this as clear as possible; if there are errors or confusing points, please let me know!

Preparing for the timing scan (Do these a few days ahead of time!)
  • If you don't already have it, get gateway access and verify that you can still log on.
  • Practice everything (really, just run through it once. There may be some small thing causing a code to fail or you may have an unexpected failure to log into the gateway; you don't want to be figuring that out in the moment.)
  • Get things ready to make mapped histogram files:
    • $ ssh -A -Y you@rssh.rhic.bnl.gov
    • $ ssh -t -A -Y stargw.starp.bnl.gov
    • $ rterm -i
    • $ stardev
    • $ mkdir TimingScan_(DDMMMYYYY)
    • $ cd TimingScan_(DDMMMYYYY)
    • $ cp -r /ldaphome/adams92/TimingScan_Master/* .
    • $ chmod +x runepdhist.sh
    • In map_EpdHistos.C, change "dbMk->SetDateTime(...)" so that the first argument is the date of the run.
    • $ stardev
    • $ cons
  • Ask Jeff which configuration file you should be editing and if he wants you to make a copy; make this copy in advance by going to the "Run Control" window in the control room, click "Copy Configuration", select the file you want and append "_EPD_Timing_Scan" to the name
  • Decide the range and delay step sizes you'll be using. Unless there is reason to believe that the timing has changed significantly, it is likely sufficient to scan around last years values with a step size of 10-20. (e.g. if a "Start_Delay" value was 30, you could try start delays of 0, 15, 30, 45, and 60). You will be analyzing these as they come out, so if something is wrong you can just continue scanning; there is no reason to do a full gate scan and then check the timing.
  • Decide the values of EPD_TACdiff_max and EPD_TACdiff_max
  • Familiarize yourself with the Run Control window in the STAR control room.
  • Familiarize yourself with the values you (the person at STAR) will be editing in the configuration file:
    • From the "Run Control" window: "Edit Configuration" -> Trigger Configuration: "Detail" -> "labels" -> "EPD"
    • Scrolling down past all the "...Mask…" labels, you'll find ten values:
      • EPD_QTb_E_Gate_End_Delay
      • EPD_QTb_E_Gate_Start_Delay
      • EPD_QTb_W_Gate_End_Delay
      • EPD_QTb_W_Gate_Start_Delay
      • EPD_QTc_E_Gate_End_Delay
      • EPD_QTc_E_Gate_Start_Delay
      • EPD_QTc_W_Gate_End_Delay
      • EPD_QTc_W_Gate_Start_Delay
      • EPD_QTc_E_TAC_Stop
      • EPD_QTc_W_TAC_Stop
    • These are what you'll be editing. There are two columns with numbers, "value" and "default"; you will edit the numbers in the "value" column (-1 means to take the value in the "default" column).
  • Verify which triggers you should use, and that they are available in the "Run Control" window. Likely, the only trigger is "bbc-tof1"


This is a (minimum) two-person job (including Mike). One person needs to be in the control room changing values in the run configuration, taking runs, and making shift-log entries. This person (or better yet, another person) will be taking the raw .daq files and turning them into mapped histogram files for Mike to analyze the ADC distributions. 
 
 
Taking the runs
 
1) Load the proper configuration file at the "Run Control" window (which may be a copy you made a few days ago - you asked Jeff, right?)

2) Set the triggers in the "Run Control" manual according to what everyone agreed to.

3) Set the start delays according to where everyone agreed to begin the scan, and the end delays and TAC stops according to 
  • EPD_QT_Gate_Start_delay
  • EPD_QT_Gate_Stop_delay = EPD_QT_Gate_Start_delay+16     (subtract N*108 as necessary to get in range [0,255])
  • EPD_QTc_Gate_Start_delay
  • EPD_QTc_Gate_Stop_delay = EPD_QTc_Gate_Start_delay+16     (subtract N*108 as necessary to get in range [0,255])
  • EPD_QTc_Gate_TAC_Stop = 18 + 2*EPD_QTc_Gate_Start_delay     (subtract N*2*108 as necessary to get in range [0,255])
(If your computer has the processing power (unlikely), you can be lazy and use this code:

void KeepGateDelayInRange256(){
int StartDelay;
while (1){
    cout<<"What's your start delay? ";
    cin>>StartDelay;
    while (StartDelay > 255) StartDelay -= 108;
    while (StartDelay < 0  ) StartDelay += 108;
    int StopDelay = StartDelay + 16;
    int TacStopDelay = 2*StartDelay + 18;
    while (StopDelay > 255) StopDelay -= 108;
    while (StopDelay < 0  ) StopDelay += 108;
    while (TacStopDelay > 255) TacStopDelay -= 216;
    while (TacStopDelay < 0  ) TacStopDelay += 216;
    cout<<"QT stop delay is  :"<<StopDelay<<endl;
    cout<<"TAC stop delay is :"<<TacStopDelay<<endl;
}
} // main

)

4) Start the run with 100k events

5) Make an entry in the shift log, no matter what! If successful, something along the lines of:
  • Timing scan for EPD
  • trg+daq; triggers: bbc-tof0; requesting 100k events
  • EPD_QTb_E_Gate_End_Delay: 48
  • EPD_QTb_E_Gate_Start_Delay: 32
  • EPD_QTb_W_Gate_End_Delay: 48
  • EPD_QTb_W_Gate_Start_Delay: 32
  • EPD_QTc_E_Gate_End_Delay: 39
  • EPD_QTc_E_Gate_Start_Delay: 23
  • EPD_QTc_W_Gate_End_Delay: 39
  • EPD_QTc_W_Gate_Start_Delay: 23
  • EPD_QTc_E_TAC_Stop: 64
  • EPD_QTc_W_TAC_Stop: 64
    If there was a problem, mistake, etc. indicate what it was.


6) Don't just sit around lollygagging! Prepare histogram files of previous timing-scan runs (if available) for Mike to start analyzing.

7) Repeat 3-6 as necessary

Preparing the histogram files for Mike

ln the following, W is the run "year", Y is the day, and Z is the run number (e.g. 20344029: W = 20, X = 344, Y = 029)

Go to the timing scan directory you created in the gatewa
y (see the "Preparing..." section at the beginning).

1) Find the largest number output with
$ ls /trg/data/trgdata/runWXY*.*.dat
or be lazy with
$ ls /trg/data/trgdata/runXYZ*.*.dat | awk -F '.' '{print $2}' | awk -v max=0 '{if($1>max){max=$1}}END{print max}'
This number is Z below. To save time, do Z = (Z > 10)?10:Z.

Step-by-step procedure prepost = 0 only
2) ./runepdhist.sh X Y Z
X = day (3 digits), Y = run (3 digits), Z = number of indices ( >= 1 digit) (10k events per index)
This creates a folder with name WXY
3) hadd /WX/epdhist.WXY* epdhist.WXY.root
4) In map_EpdHistos.C, change "dbMk->SetDateTime(...)" so that the first argument is the date of the run.
5) root4star -q -b 'map_EpdHistos.C("epdhist.WXY.root")'


Step-by-step procedure prepost range
From here:
"If you want to look at more than one prepost, you need to change the switches in the .h file (yes, I should make them toggles that the run macro picks up).  Once you have run the files, you then need to use the mapping macro to change the titles to the proper ew/pp/tt values.  I have written a script to assist."
2) Change the switches at the top of StEpdHist.h with your favorite editor (emacs!) for the range pre to post.
3) cons
4) ./runepdhist.sh X Y Z
X = day (3 digits), Y = run (3 digits), Z = number of indices ( >= 1 digit) (10k events per index)
This creates a folder with name WX
5) hadd /WX/epdhist.WXY* epdhist.WXY.root
6) In map_EpdHistos.C, change "dbMk->SetDateTime(...)" so that the first argument is the date of the run.
7) root4star -q -b 'map_EpdHistos.C("epdhist.WXY.root",pre,post,number_of_prepoststeps)'

6 or 8) Put the output file in a more accessible place with scp FileName you@rftpexp.rhic.bnl.gov:
(e.g. scp mapped_epdhist.WXY.root adams92@rftpexp.rhic.bnl.gov:)
Then Mike can copy it and download it with scp lisa@rftpexp.rhic.bnl.gov:mapped_epdhist.WXY.root .

He will analyze it with his "
TimingScan.C" See here, for example.