Tower Gain Matching Procedure

    - Set TCL code to default settings 
    - Make sure RHIC clock= 80,70,40 for CRATES 3,4,5
    - Take 150-200K event files of calibration data 
    - log onto gateway  ssh -l eemcdb
    - log onto rcas60## ssh rcas60##
    - cd miniDaq/ and mkdir date/
    - log onto online@eemc-sc and go to ~online/mini/tree/date/
    - transfer calibration data to eemcdb account:
      scp *.root
    - on eemcdb account -- go to eeDisp directory
    - set stardev and libraries
    - run sorter --- ./code/eeDisp go.C on data
    - After processing all data save histos in format:
      date_run# (ie mar18_run00001-00003)a
    - mv date_run#.hist.root file ~/miniDaq/date/.
    - run ~eemcdb/eeDisp/plSoloReal.C(input) in Root. 
      The "input" is the complete directory structure of 
      date_run#.hist.root file .
    - plSoloReal.C is the macro which contains Jan's 
      algorithm to fit the slope of the tower histograms, 
      calculate the desired gain for that tower and then 
      output the amount ("gainfac") by which to change 
      the gain of each tower. Before running this program 
      hardcode gain cuts (ask Jan or Renee).
    - output is  date_run#.dat/.html in -> gainSearch/
    - date_run#.html has plots  of all tower slope fits
    - date_run#.dat has tower ID and gain changes 
    - cp date_run#.dat file to ~/HVchange/oldset*.dat 
      where * is the next letter which characterises the 
      iteration of gain matching.
    - cd ~/HVchange
    - grep manual oldset*.dat |nl
    - this is a list of the towers where the fit failed
      and you must personally evaluate these gains and set
      the appropriate value in the .dat file.
    - modify HVchange_list.dat which is the input file for hvmod.C macro:
      HVchange_list.dat is composed of four rows and four columns. Each 
      row corresponds to a different sector and thus a different q file. 
      The first column in each row is the oldset*.dat file name. The second 
      column in each row will be called set*.dat. This is an exact copy of 
      the oldset*.dat file with two extra pieces of info inside -- the old 
      HV voltage for that tower and the new one caluculated using the 
      gainfactor in oldset*.dat. The third column is the qfiles which contain 
      the tower ID number from the convert directoy. The fourth column is  
      the new q file still in the tower id format.  
    - Run root .x hvmod.C.:
      This program inputs jan's oldset*.dat file and calculates the new desired 
      voltages from the gainfactors in his files. It also outputs new q files.
    - New q files for all sectors should now be in ~/HVchange/.
    - scp new q files to online@eemc-sc:~online/VxWorks/indiana/HVsys/.
    - cp new q files to ~/HVchange/safe/ (this ensures against unintentional
      overwriting in the byzantine procedure outlined above.
    - Note: you will notice that the output files (ie setE.dat) will be sorted 
      according to PMT number instead of tower number. So for Sector 5 the Tower
      numbers will be backwards compared to the input files (ie oldsetE.dat). If
      you would like to resort them to look like the original then execute the 
      following unix command:
           sort -d +0 oldsetE.dat -o oldsetE.dat
      This command will place the columns headers at the bottom of the file
      so before posting on the web please edit the file to put the headers 
      at the top.