Run 9 BTOW gain calibration

In this blog I describe the steps needed to reproduce the Run 9 BTOW gain calibration, and compare to the results that were put in the database.  All the necessary codes are in /star/u/aohlson/bemcCalib2009_new/ and will be placed in CVS later. 

Note: The old calibration was done with the old production, P10ic.  The new production is P11id, in which the TPC geometry is improved.  The production number does not have a significant effect on the BTOW calibration.  

1) Generate the list of runs with the following command
get_file_list.pl -keys "runnumber" -distinct -cond "production=P11id,filetype=daq_reco_MuDst,sanity=1,trgsetupname=production2009_200GeV_Single,filename~st_physics,tpx=1,emc=1,storage!=HPSS" -limit 0 | sort -u > runlist.txt

2) Run SubmitCalibJobs.pl, which will execute the bemcCalibMacro.C macro.  Make sure that the correct catalog query lines are commented in/out in the submit script.  Also ensure that the appropriate directories exist ($workingDir, $schedDir, $outDir, $logDir, $scriptDir) as specified at the top of the submit script. 

The trees created by this step are stored on HPSS here: /home/aohlson/bemcCalib2009_x.tar where x=0,...,9

3) Make the MIP histograms with runMIPjobs.sh, which executes mip_histogram_maker.C  Ensure that the correct output filenames are specified in the submit script.

4) Make a list of the output files from step (3) called mips.list.  Run mip_histogram_fitter.C

5) Make the electron histograms with runElecJobs.sh which will execute electron_tree_maker.C  Ensure that the correct output filenames are specified in the submit script.

6)
In the old calibration: Make a list of the output files from step (5) called electrons.list.  Run electron_master.C. 
---- OR ----
In the new calibration: Run runFinalElec.sh, which executes electron_master_temp.C (make sure that the input/output filenames and directories are correct).  Hadd the resulting output files, and use this file as the input to electron_drawfits.C

Here I compare the MIP and electron calibrations with those found in /star/u/staremc/2009/pp200/mip.gains.all and /star/u/staremc/2009/pp200/electron.all.gains.final

MIP  (old-new)/old

Electrons (old-new)/old


Compared to the plots shown in the previous blog, there is no longer an offset between the old and new gains, and the distribution of (old-new)/old is now narrower. 
Previously: offset = -4%, RMS = 4%
Now: offset = -0.1%, RMS = 1.5%

Part of the discrepancy (most of the offset) may have been due to a typo in my fitting code, although I still need to go back and check if fixing that typo was all that was required to remove the offset. 
Part of the discrepancy in certain crate-slices was due to to the fact that I assigned sqrt(N) uncertainties to the points in the histograms, and these errors were apparently large enough that the ROOT fitter just missed the points entirely.  When I made the uncertainties 1, then the fits described the data points much better in the crate-slices where they missed before. 
Some spread in the distribution of (old-new)/old is to be expected, because I use a slightly different event population than Matt did, i.e. He selected only high statistics runs whereas I took all runs, and I did not re-run failed jobs whereas I assume that he did.