Difference between revisions of "Hallc optics optim"
From HallCWiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
− | New version of the Hall C optics optimization code. This is a slimmed down version of the old code. In addition, the new code takes into account the correction in the optic matrix for the vertical position of outgoing particle at the Z=0 optics axis when optimizing the xptar and delta matrix elements. | + | New version of the Hall C optics optimization code. This is a slimmed down version of the old code. In addition, the new code takes into account the correction in the optic matrix for the vertical position of outgoing particle at the Z=0 optics axis when optimizing the xptar and delta matrix elements. THe optimization is divided into two parts. First, one uses PAW kumacs to set cuts on nutples to define good events. The cuts are written to files and used by the optimization program. Second, one runs the optimization code. |
= Optimization Source Code = | = Optimization Source Code = |
Revision as of 10:46, 5 September 2011
New version of the Hall C optics optimization code. This is a slimmed down version of the old code. In addition, the new code takes into account the correction in the optic matrix for the vertical position of outgoing particle at the Z=0 optics axis when optimizing the xptar and delta matrix elements. THe optimization is divided into two parts. First, one uses PAW kumacs to set cuts on nutples to define good events. The cuts are written to files and used by the optimization program. Second, one runs the optimization code.
Optimization Source Code
- Code is available at /group/hallc/mkj/optimization_hallc_optics/source_code. On JLab ifarml64 machines, define the proper cernlib by executing setup cernlib/2005 before compiling using make .
- optimize.f
- Main program calls subroutines read_input, read_matrix, fit_init, fit_matrix.
- read_input.f
- reads in the input file.
- Presently hardcoded to use the input filename as input.db
- read_matrix.f
- Reads in the standard replay optics matrix data file
- Hardcode the constant offsets terms for xp,yp,y and delta.
- fit_init.f
- Hardcode collimator distance zcol = 166.+1.6
- Hardcode dflag=0 . Set dflag=1 for delta optimization.
- Hardcode the spec_type =1 for HMS which assumes 81 sieve holes. spec_type =2 could be used for SHMS. Need to have this a part of input.db
- Hardcoded to look for variables HSXPFP,HSYTAR,HSXPTAR, HSYPTAR, gbeam_y,eventID,xtar in the ntuple.
- If doing delta optimization set up for ep elastics. Assumes that in the ntuple the energy loss for the beam and scattering electron will be the 13th and 14th variable.
- Loops through the ntuples using 2d ytar/xfp and xsieve/ysieve cut to select events. Hardcoded to accept a maximum of 200 events per hole and 100000 events total.
- Fills arrays
- Focal plane quantities pts(i,ntotal) = i=1,4 (for xfp,xpfp,yfp,ypfp) for each event
- Known y (ydata) , xp (thdata) and yp (phdata) values.
zzero(ntotal) = ztarpos(k)*dcos(spec_ang)/100.0 ydata(ntotal) = ztarpos(k)*dsin(spec_ang)/100.0 If SHMS need to set ydata(ntotal) =−ztarpos(k)*dsin(spec_ang)/100.0 thdata(ntotal) = xsr(k,nh_found)/(zcol−zzero(ntotal)*100) phdata(ntotal) = (ysr(k,nh_found)−ydata(ntotal)*100)/(zcol−zzero(ntotal)*100) ydata(ntotal)=ydata(ntotal)−phdata(ntotal)*zzero(ntotal)
- fit_matrix.f
- Not setup for delta optimization
- Uses the read−in optics matrix to calculate the target quantities.
- First determine target xp,y,yp and delta using xtar=(−1.)*gbeam_y(nd)/100
- With estimate of target xp,y,yp calculating xtar as ztemp= ytar* ( cos(spangle) / tan(spangle − yptar) + sin(spangle)) and xtar= hut(5) = (−1.)*gbeam_y(nd)/100 − xptar*ztemp*cos(spangle)
- xtar correction is for xptar and delta calculation determine only target xp and delta again and keep track in "psum" of the contribution to xp and delta from the optic matrix elements which use xtar coefficients.
- The optic matrix elements to be fit are all terms except those that use xtar. Fill array "fit_term" which is (xfp)^i*(xpfp)^j*(yfp)^l*(ypfp)
- The array "fit_data" is filled with with the known target xp,y or yp (thdata,ydata,phdata) depending on which target quantity is be fitted. For xp fit , "psum" is subtracted from thdata.
- Calculates the average center position for each sieve hole using original matrix and compares to known position.
- Calls subroutine svdfit
- Writes new optics matrix to a file
- Calculates the average center position for each sieve hole using new matrix and compares to known position.
- svdfit.f
- Called by fit_matrix.f
- Least squares fitting routine
- Fitted coefficients stored in "fit_parm" array and determined in svbksb subroutine.