MM's
G_{en}Tracking Programs Version II 
The programs, written entirely in FORTRAN 77 are developed under Digital
Unix Version 4 and should run as well on Solaris, HP/UX and Linux.
Contents  
The Coordinate SystemThe Program Modules
The Vertical Offset
The Target Magnetic Field
The Target TrackingThe Ready to Use Programs
The HMS Tracking
The Gen Tracking
TARGETHMSELECTRONVIRTUALMATRIX
RECON
RECONX
RECONG
VIEW
Making the Programs
Data Files Needed
Event Data nTuple Contents
Other Files You May Be Interested In
The Reconstruction  
In order to use still the knowledge on HMS accumulated so far at JLAB we decided to separate the two problems:
The
Coordinate System
The reconstruction uses three different coordinate systems  the focal
plane coordinates, the target
coordinates and the beam
coordinates, all of them right handed:
X_{Beam}  vertical coordinate (pointing downwards) 
Y_{Beam}  horizontal coordinate (__ on x,y) 
Z_{Beam}  coordinate along the beam axis (pointing downstream) 
Length is measured
in [cm] (module trg_track)
or in [m] (modules hms_track
and gen_track).
The
Vertical Offset
From the focal plane quantities (x, x', y, y') measured by HMS a vertical
beam offset can not distinguished from an offset in the electrons energy.
A beam offset of 1cm corresponds to a shift in energy of about 1%.
Therefore, the vertical beam offset has to be measured with some kind
of a beam monitor. The value measured is used to correct the measured focal
plane quantities. This allows to use the standard reconstruction function
optimized for the case where no vertical offest is present.
Step  Description 
1  Apply the standard reconstruction function R to
the measured focal plane quantities (x,x',y,y') to get a first estimate
for the target coordinates

2  Apply the forward transport function T to the estimated
target coordinates for both X=0 and X = X_{Beam }
to find the deviation of the focal plane coordinateds (dx,dx',dy,dy')
caused by the vertical beam offset X_{Beam}:

3  Apply the standart reconstruction function R to the corrected
focal plane quantities (xdx_{i},x'dx_{i}',ydy_{i},y'dy_{i}')
to get a better estimate for the target coordinates

4  Goto step #2 until the change in delta is smaller than a given epsilon

The
Target Magnetic Field
As the target magnetic field bends the electron track down (approx
1^{o}) the real vertical beam offset X_{Beam}ZX'
and the virtual beam offset X_{0} (no target field) used
in the procedure described above differ by about 1mm (corresponding
to a shift in energy of about 0.1%).
Therefore we designed an iterative procedure to find the virtual beam
offset X_{0}. in presence of the magnetic field. With this
knowledge we preform a reconstroction by appling the function V
(this includes the beam offset) to the focal plane coordinates and
to the target coordinates. This coordinates describe the track of the electron
outside HMS. As V does not include the target field this
track is only valid as long as the electron stays in the field free region.
To
include the effects of the field we track the particle from the field
free region
back into the target field to the intersection with the incident beam.
Step  Description 
1  Apply the reconstruction function V to the measured
quantities (x,x',y,y',X_{0,i=1}=X_{Beam})
to get a first estimate for the virtual target coordinates

2  Track the electron from the field free region (e.g. Z=1m) back
into the magnetic field to the intersection point with the incident beam
to get a first estimate for the real target coordinates

3  Find a better estimate for the virtual beam offset

4  Apply the reconstruction function V to the measured (corrected)
quantities (x,x',y,y',X_{0,i}) to get a better
estimate for the virtual target coordinates

5  Track the electron from the field free region (e.g. Z=1m) back
into the magnetic field to the intersection point with the incident beam
to get a better estimate for the real target coordinates

6  Goto step #3 until X_{i+}_{1} is equal to the
vertical beam offset

The Program Modules  
The
Target Tracking
The target tracking module "trg_track" solves the differential equations
of motion for a
charged particle in the target magnetic field via the 4th order runge
kutta methode.
The module provides the following subroutines:
subroutine trgInit (map,theta,phi)
subroutine trgTrack (u,E,dl,l)
subroutine trgXTrack (u,E,dl,l,Bdl,xfunc,id)
subroutine trgTrackToPlane
(u,E,dl,a,b,c,d)
map  char  I  name of the oxford field map (or empty = uniform field)  
theta  real  I  orientation of the field axis (inplane angle) [deg]  
phi  real  I  orientation of the field axis (out of plane angle; always = 0) [deg]  
u  real(6)  IO  particle coordinates


E  real  I  particle energy * unit charge (<0 for electrons) [MeV]  
dl  real  I  step size (<0 = time reversal) [cm]  
l  real  I  tracking distance [cm]  
Bdl  real  O  integrated Bxdl  
xfunc  ext int  I  external interger function called once per iteration step defined as
integer function xfunc (id,t,l,u) 

id  int  I  first argument passed to xfunc  
a,b,c,d  real  I  parameter for the intersection plane (ax+by+cz+d=0) 
trgTrack tracks a single particle with given start coordinates u over the distance l.
trgXTrack tracks a single particle with
given start coordinates u over the distance l.
and stores the track in a PAW/hbook ntuple.
trgTrackToPlane tracks a single
particle with given start parameters and finds the
intersection of the particle track with a given plane.
Before calling trgTrack, trgXTrack or trgTrackToPlane the target field map has to be loaded by a call to trgInit. 
The module provides the following subroutines:
subroutine hmsInitForward (map,order,path,p0)
subroutine hmsForward (uT,zT,u,z,lost)
subroutine hmsAccept (uT,zT,u,z,lost)
subroutine hmsInitRecon (map)
subroutine hmsReconInPlane (u,uT)
subroutine hmsReconOutOfPlane
(u,x,uT)
map  char  I  name of the forward or backward transport map  
order  int  I  maximal order to take into account  
path  bool  I  set to .true. in order to calculate the path length/TOF variation  
p0  real  I  central momentum of HMS  
uT
zT 
real(6)
real 
I
I 
target coordinates:


u
z 
real(6)
z 
O
O 
focal plane coordinates:


lost  bool  O  set to .true. if the particle is lost in the HMS, otherwise .false.  
u  real(4)  I  focal plane coordinates (reconstruction only):


x  real  I  vertical beam offset at the target [m] (z=0) (out of plane; downwards)  
uT  real(6)  O  target coordinates (reconstruction only):

hmsForward applies a single step cosy coordinate to find the focal plane coordinates (without treating the acceptance)
hmsAccept makes a multi step transport calculation in order to get the acceptance
hmsInitRecon initializes (loads) the reconstruction map
hmsReconInPlane reconstructs the target coordinates (delta, dx/dz, y, dy/dz) at z=0
hmsReconOutOfPlane reconstructs
the target coordinates (delta, dx/dz, y, dy/dz) at z=0
including the effects of a given vertical beam offset
Before calling hmsForward or hmsAccept the forward transport maps have to be loaded by a call to hmsInitForward.  
Before calling hmsReconInPlane or hmsReconOutOfPlaneAccept the reconstruction map has to be loaded by a call to hmsInitRecon.  
Before calling hmsReconOutOfPlane the forward transport maps have to be loaded by a call to hmsInitForward. 
The module provides the following subroutines:
subroutine genInitRecon (recon,field,thetaB,cosy,order,thetaE,p0)
subroutine genRecon
(u,x,y,uT)
recon  char  I  name of the forward or backward transport map  
field  char  I  name of the Oxford field map  
thetaB  real  I  orientation of the field axis (inplane angle) [deg]  
cosy  char  I  name of the forward transport maps  
order  int  I  maximal order to take into account  
thetaE  real  I  spectrometer angle (in plane) [deg]  
p0  real  I  central momentum of HMS  
u  real(4)  I  focal plane coordinates:


x  real  I  vertical beam offset [m] (out of plane coord.; downwards)  
y  real  I  horizontal beam offset [m] (inplane coord.; __ on x_{beam}, z_{beam})  
uT  real(6)  O  target coordinates:

genRecon reconstructs the target coordinates
(delta, dx/dz, y, dy/dz) including the effects of the targetr magnetic
field and the vertical beam offset
Before calling genRecon the target field map, the forward and backward maps have to be loaded by a call to genInitRecon. 
The Ready to Use Programs  
A summary of the first results can be viewed in the picture
gallery.
TARGET:
(target.f, trg_track.f,
CERNLIB)
tracking program  used to calculate electron/proton tracks within
the target.
1:  histogram with the input conditions 
10:  nTuple with all lost electrons (initial, focal coordinates) 
20:  nTuple with the detected ones (initial, focal coordinates) 
1:  histogram with the input conditions 
10:  nTuple with all lost electrons (initial, focal coordinates) 
20:  nTuple with the detected ones (initial, focal coordinates) 
1:  histogram with the input conditions 
10:  nTuple with all lost electrons (initial, focal coordinates) 
20:  nTuple with the detected ones (initial, focal coordinates) 
1:  histogram with the input conditions 
30:  nTuple with all lost electrons (initial, focal coordinates) 
20:  nTuple with the result of the reconstruction (initial, focal and reconstructed coordinates) 
1:  histogram with the input conditions 
30:  nTuple with all lost electrons (initial, focal coordinates) 
20:  nTuple with the result of the reconstruction (initial, focal and reconstructed coordinates) 
1:  histogram with the input conditions 
30:  nTuple with all lost electrons (initial, focal coordinates) 
20:  nTuple with the result of the reconstruction (initial, focal and reconstructed coordinates) 
1:  weight factors for the coefficients (calculated by powering the max. values of the focal plane coordinates with the corresponding exponents 
10:  coefficients for the delta reconstruction 
20:  coefficients for the dx/dz reconstruction 
30:  coefficients for the y reconstruction 
40:  coefficients for the dy/dz reconstruction 
field_map.dat  target field map 
fwd_maps.dat  forward matrix elements 
bwd_map.dat  original backward matrix elements 
x0,y0,z0,dx0/dz,dy0/dz,delta0  phase space coordinates at the target 
x,y,dx/dz,dy/dz  focal plane coordinates 
z  zcoordinate where the particle stops or 0 if it is detected 
x1,y1,z1,dx1/dz,dy1/dz,delta1  reconstructed target coordinates 
view_rc.kumac  kumac for viewing the reconstruction results 
view_map.kumac  kumac for visualizing a reconstruction matrix 
cmp_map.kumac  kumac for visualizing a reconstruction matrix 
gen_prog.tar  all the files mentioned above packed into a tar archive 