Single-arm simulation

From Hall A Wiki
Revision as of 17:19, 20 December 2016 by Shujie (Talk | contribs) (RUN THE CODE)

Jump to: navigation, search

Hall A single-arm simulation package

This page reflects my ongoing work on the single-arm simulation with Dien, Thir, under the guidance of Eric Christy. I don't own the code.

SUMMARY

The code comes with 3 directories:

 phase_space_fall16_LHRS/
 rad_corr/
 weighting/
  • phase_space_fall16_LHRS is the Monte Carlo phase space generator adapted from Hall C, which is essentially a single-arm version of SIMC with the updated spectrometer package for Hall A LHRS (lhrs/). It's now set up for optics tests of the left arm for the Fall run. The default target is single carbon foil. No multi-scattering and energy loss considered.
  • rad_corr is used to generate cross section tables with radiative correction factors. The code uses a new Born model from Eric Christy. That is an updated version of Bosted model. The radiation part of code is from Simona Malace.
  • weighting will weigh phase space variables with cross sections, and calculate the scaling factor.

RUN THE CODE

  • First generate the phase space.
 cd phase_space_fall16_LHRS/
 make clean;make

The code needs to read kinematics and target settings from infiles/<name>.inp. For example, to simulate a single carbon foil run 13900:

 ./mc_hrs_single 
 >>Enter input filename (assumed to be in infiles dir)
 >>carbon_foil_13900

The output ntuple is created in worksim/. To convert it to rootfile:

 h2root worksim/carbon_foil_13900.rzdat
  • The second step is to prepare the cross section table. The code may takes hours to run. But hopefully you need only run it once for one run settings. Update target radiation length in eg1b.targ before you run the code.
 cd ../rad_corr
 make clean; make
 ./radcorr.sh <run_number>

In the script radcorr.sh:

 #!/bin/csh
 #$1 is for run number it is expecting 5 digit run number
 echo "enter 5 digits run number"
 set RUN = $<
 rm infile.inp
 ln -s ../phase_space_fall16_LHRS/infiles/carbon_foil_${RUN}.inp infile.inp
 ./grid ${RUN}
 rm eg1b.inp
 ln -s table_${RUN}.inp eg1b.inp
 echo "--start generating cross section table. May take a while...\n"
 ./externals_all_new
 mv extern.out table_$(RUN).out
 echo "Done! Table is stored at table_${RUN}.out"

Two programs are called. grid.f reads kinematics from the simulation infile, and slices the phase space into grids of theta and W2. dtheta = 1 degree, and dW2 = 0.02 GeV2 is the defaut setting. Information of each grid points is stored in table_<run_number>.inp. Then externals_all_new.f will calculate Born cross section and radiative correction factor on each grid point, and write results in table_<run_number>.out.

  • Now we are ready for weighting. Before run the code, make sure you have:

1) the simulation infile (*.inp). Later ./create_input(called in weighting.sh) will read run information from it to generate input.dat;
2) simulation results (*.rzdat) from step 1;
3) the cross section table (table_*.out) from step 2;
4) targetdata.dat to provide your target information;
5) and reconmc.in to provide your run information. Make sure your target id here matches the id in targetdata.dat.

Then run:

 cd ../weighting
 make clean; make #compile create_input and recon_mc in the subdir SRC.new/
 ./weighting.sh <run_number>

The script weighting.sh called ./recon_mc to weigh each kinematic point in simulation. weighting factor for Kinematic points between grid points are obtained by interpolation.

You will find the MC scaling factor in screen output, and a new ntuple mc13900.root to be compared with data.
Note: 1. ntuple has a size limit. If you generated a large number of events like 1000k in the simulation, you will probably see the error message below when running ./weighting.sh. Along with this message you will get a wrong scaling factor.

  RZOUT: current RZ file cannot support > 64K records
                or individual directories > 64K
  RZOUT: previous cycle(s) for this key (      30)  deleted
  RZOUT: please consult ZEBRA manual for further details

2. the entry 'sigmac' in mc*.root is supposed to record the cross section along the central. It's not working right now.

HOW TO

RUN WITH A DIFFERENT TARGET

If it's another solid target, follow the steps above to update target information in:

 phase_space_fall16_LHRS/infiles/*.inp
 rad_corr/eg1b.targ
 weighting/reconmc.in targetdata.dat
 

If it's a target cell, you will need to modify the target definition in mc_hrs_single.f, and add multi-scattering and energy loss code (hint: borrow code from SIMC).

RUN WITH A DIFFERENT SPECTROMETER/OPTICS

Put your new spectrometer package (with forward/backward optics matrices) in phase_space_fall16_LHRS/, tell main code and Makefile to reach it. Again, you should be able to find packages for Hall A/C from SIMC.