Run 12 T0 calibration

At the begining of Run12 I have checked the global T0 offset using a) prompt hit method and b) twist method.

 

a) prompt hit method

In this method we look at absolute position of the prompt hits in the TPC. You can see 2D scatter plots for East and West arms of the TPC in bottom panels and hit Z position distributions after integration over padrows in upper panels (black - total, blue - inner subsectors, red- outer subsectors).

 

According to the drawing of the TPC anode region (see below) absolute ideal position of the prompt hits is 209.5 cm for inner subsectors and 209.7 cm for outer subsectors. From plots above it is clear that hits are not at proper place (also it is arguable that we shall see prompt hist at their ideal position). Aditional observation is that inner and outer hits switched their places (outer anods wires are farther from the TPC center compare to the inner ones).

 

 

How to look at prompt hits:

I put several simple macroses that I use to the CVS: offline/users/mnaglis/prompt (will upload files some time later). One may need to change hardcoded filenames.

run_prompt.C - runs BF chain, usage:  root4star run_prompt.C > logifle.txt  (need to have PrintStEvent.C in working directory)

clear_log.sh - cleans log file, selecting only lines with info abut prompt hits

read_log.C - creates ntuple from the clean logfile

prompt.C - creates 4 panel figure shown above

 

b) twist method

The idea is to reconstruct primary vertex only using track build hits from East arm of TPC and only using track build hits from West arm. Then compare Z coordinates of the reconstructed vertices. The figure below indicates that there is substantial T0 offset - verteces reconstructed in East and vertices reconstructed in West are displaced (bottom panel). The T0 offset can be calculated as:

T0_offset = [ VE(0)-VW(0) ]/2/driftvelocity 

VE(0) and VW(0) are values of the red and blue fit functions at Z=0 (in cantimeters)

driftvelocity is TPC Drift Velocity in cm/mks

After calbiration we find that there is T0 offset of 6.79e-02 mks we need to correct for. Note that if red line is above the blue than offset is positive, so you add it to the existing T0 offset, and if blue line is above then offset is negative.

Results after aplying T0 correction show below.

 

How to perform this calibration:

I put several macroses and maker that I use to the CVS: offline/users/mnaglis/Twist . One may need to change hardcoded filenames. The maker is used based on the standard StAnalysisMaker. In this maker I fill the TTree with vertex information for the future analysis. Main info that is stored for each of the verteces is how many tracks are associated to the vertex, home many of asotiated tracks have TOF matching. Later by requiring vertex to have a significant fraction ot TOF matched tracks associated to it we can effectively suppress pileup verteces.

There are following macroces the working directory:

make_stevent.C - does reconstruction using hits from the whole TPC

make_steventE.C - does reconstruction using hits from only East arm of the TPC

make_steventW.C - does reconstruction using hits from only East arm of the TPC

submitter_m_all.sh - submits calibration jobs

submitter_m_east.sh - submits calibration jobs

submitter_m_west.sh - submits calibration jobs

twist_all.sh, twist_east.sh, twist_west.sh - shortcuts to run submitter_m_xxx.sh macroses, files, number of events and jobs to run is defined here

 

make_stevent_xxx.C macroses use custom StAnalysisMaker (stored under StRoot) to generate TTree with vertex information.

Generated files with TTrees have suffixes _all_, _east_, _west_ . One need to hadd those files in to something like all.root, east.root, west.root

Next step is to scan TTrees and store the vertex information in the ASCII files. For this purpose one can use macro scanTri.C located in offline/users/mnaglis/Twist/anal.

root -q 'scanTri("all.root")' > all.txt and smiliarly for East and West.

The default cut parameters for the scan should be working fine, but off couse one may want to check them for every new dataset.

rank1 - is the rank of the best vertex

ntr1 - is the number of primary tracks associated with the best vertex

ntrm1 - is the number of primary tracks associated with the best vertex that have matching with TOF

 

Then one needs to clean generated ASCII files from unnecessary information using grep and awk:

grep "98765" west.txt | grep -v Row | awk '{print $4" "$6" "$8" "$10" "$12}' > ntupWest.txt (same for East and All)

After that we can use macros written by Gene Van Buren (latest version offline/users/genevb/match_lines.C) to find verteces for same event as reconstructed using all and only east/west arm hits in the TPC

root -l -b -q 'match_lines.C+("ntupWest.txt","ntupAll.txt",5,"ntupWA.txt",50000,0,0,1,0)'
root -l -b -q 'match_lines.C+("ntupEast.txt","ntupAll.txt",5,"ntupEA.txt",50000,0,0,1,0)'

The macro plot_twist.C located in offline/users/mnaglis/Twist/anal can be used to visualize the position of the reconstructed vertices as a function of Vz (one need to hardcode filenames used instead of ntupWA.txt and ntupEA.txt inside this macro).

When you execute this macro it will produce you 3-panels plot as one shown above and print information about the fit parametes similar to shown below (don't look at numbers, it just an example how things should look like):

PRINTING WEST Z
 FCN=143.055 FROM MINOS     STATUS=SUCCESSFUL     16 CALLS          61 TOTAL
                     EDM=2.53581e-20    STRATEGY= 1      ERROR MATRIX ACCURATE
  EXT PARAMETER                                   STEP         FIRST  
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  p0          -1.51228e-03   1.46617e-03   0.00000e+00  -7.00205e-06
   2  p1          -5.18550e-04   8.24708e-05   8.24708e-05   3.64516e-04
PRINTING EAST Z
 FCN=132.539 FROM MINOS     STATUS=SUCCESSFUL     20 CALLS          65 TOTAL
                     EDM=1.00714e-20    STRATEGY= 1      ERROR MATRIX ACCURATE
  EXT PARAMETER                                   STEP         FIRST  
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  p0           3.66685e-03   1.40236e-03   0.00000e+00  -2.65073e-05
   2  p1          -3.44474e-04   8.15922e-05   8.15922e-05  -2.18591e-04

Our interest here is p0 parameters for West and East, which are intercepts between Red (West) and Blue (East) lines at Vz=0 and (0.0) point, they were refered as VW(0) and VE(0) respectively above.  Just to make it simple I calulate offset dropping signs from the p0 parameters, then I look at the picture and if red line is above the blue than offset shall be added (+) to the existing T0 offset, and if blue line is above to subtracted (-).

One can obtain the drift velocity for the Run by grepping the logfile:

cat logfile.out | grep DriftVel
StMagUtilities::DriftVel      =  5.5074 cm/microsec
(don't look at numbers, it just an example how things should look like)

T0 offset parameters are stored in the DB in the table StarDb/Calibrations/tpc/tpcPadrowT0.XXXXXXXX.XXXXXX.C (one needs to put proper timestamp instead of XXXXXXXX.XXXXXX).

 

In the table file you have 24 lines like that (for each TPC sector)

tableSet->AddAt(&row);

Just insert something like that before each of these lines:

 for (Int_t k = 0; k < 45; k++)
    {
       row.T0[k] =
       row.T0[k]+my_new_T0_offset; //here shall go your calculated T0 offset
    }

You are done! 

Some additional information about T0 calibration can be found in the manual written by Renato Regrao attached to this page.

 

The recipe for T0 by the twist method as written above shall normaly work. However for the Run12 dataset the calibration hasn't gone very smoothly:

There was an unexpected time offset between inner and outer sector padrows, which can be clearly seen in the plot below showing the track residuals in Z direction (in cantimeters) as a function of the TPC radius (in cantimeters). 

From the plot above it is not possible to know which inner or outer padrows shall be moved in time, so I increased offset for inner ones. 

After 10 iterations I was able to remove the inner-to-outer time offset as demonstrated in the plot below (units are cantimeters).

 

After that I had to redo Global T0 calibrations using the TWIST method as was discussed above and here come final calibration results. 

 

final run12