[Bayern] MM's   
Gen-Tracking Programs 
Version II
[Freising]
 
<HR>
 
During the last months, I've developed the routines necessary for tracking a electron forward and backward through HMS and the Gen target including both large vertical beam offsets and the targets magnetic field.
 
A summary of the first results may be viewed in the picture gallery.

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.
 
 [top]
Contents
<HR>
[back] [forward]
 
The Reconstruction

The Coordinate System
The Vertical Offset
The Target Magnetic Field
The Program Modules
The Target Tracking
The HMS Tracking
The Gen Tracking
The Ready to Use Programs
TARGETHMSELECTRONVIRTUALMATRIX
RECON
RECONX
RECONG
VIEW
Making the Programs
Data Files Needed
Event Data nTuple Contents
Other Files You May Be Interested In
 
 [top]
The Reconstruction
<HR>
[back] [forward]
While tracking a charged particle through a magnetic field and the forward transport of the electron through HMS (mostly based mostly based on algorithms  given to me by Chris Cothran) is quite straight forward both the effects of the target field and the large vertical beam offset  due to the target raster makes the reconstruction rather complicated.

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:
 

Focal Plane and Target Coordinates
x,X vertical coordinate (pointing downwards)
y,Y horizontal coordinate (_|_ on x,y) 
z,Z coordinate along the axis of HMS (pointing from the target to the focal plane)
 
Beam Coordinates
XBeam vertical coordinate (pointing downwards)
YBeam horizontal coordinate (_|_ on x,y) 
ZBeam coordinate along the beam axis (pointing downstream)
Note: All angles are measured counter clock wise in degrees [deg].

Note: 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.
 
Treating the Vertical Beam Offset
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  
(X=0,X',Y,Y',delta)i=1  = R(x,x',y,y')
2 Apply the forward transport function T to the estimated target coordinates for both X=0 and X = XBeam  to find the deviation of the focal plane coordinateds (dx,dx',dy,dy') caused by the vertical beam offset XBeam
(dx,dx',dy,dy')i = T(X=X0,X',Y,Y',delta)i - T(X=0,X',Y,Y',delta)i 
with X0=XBeam-ZX' (minor correction due to the Z coordinate of the intersection point)
3 Apply the standart reconstruction function R to the corrected focal plane quantities (x-dxi,x'-dxi',y-dyi,y'-dyi') to get a better estimate for the target coordinates 
(X=0,X',Y,Y',delta)i+1  = R(x-dxi,x'-dxi',y-dyi,y'-dyi')
4 Goto step #2 until the change in delta is smaller than a given epsilon 
 | deltai - deltai+1| < epsilon 
Note: This iteration procedure is refered as reconstruction function V(x,x',y,y',X0) in further sections.

The Target Magnetic Field
As the target magnetic field bends the electron track down (approx 1o) the real vertical beam offset XBeam-ZX' and the virtual beam offset X0 (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 X0. 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.
 
Treating the Target Magnetic Field
Step Description
1 Apply the reconstruction function V to the measured quantities (x,x',y,y',X0,i=1=XBeam) to get a first estimate for the virtual target coordinates  
(X=X0,i=1,X',Y,Y',delta)V,i=1  = V(x,x',y,y',X0,i=1=XBeam)
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 
(X,X',Y,Y',Z,delta)i=1  = T(X-X'Z,X',Y-Y'Z,Y',Z,delta)V,i=1
3 Find a better estimate for the virtual beam offset 
X0,i+1 = (XBeam - (Xi -XBeam))-ZiXi'  = (2XBeam - Xi) -ZiXi
4 Apply the reconstruction function V to the measured (corrected) quantities (x,x',y,y',X0,i) to get a better estimate for the virtual target coordinates  
(X=X0,i+1,X',Y,Y',delta)V,i+1  = V(x,x',y,y',X0,i+1
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 
(X,X',Y,Y',Z,delta)i+1  = T(X-X'Z,X',Y-Y'Z,Y',Z,delta)V,i+1
6 Goto step #3 until Xi+1 is equal to the vertical beam offset 
 | Xi+1 - XBeam| < epsilon 
 
 [top]
The Program Modules 
<HR>
[back] [forward]
The Gen Electron arm package consists of the three main tracking modules "trg_track",
"hms_track" and "gen_track", the single value decomposition fit module and the
programs itself.

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 
u(1,2,3) x,y,z [cm]
u(4,5,6) dx/dt,dy/dt,dz/dt [cm/ns]
 
E real I particle energy * unit charge (<0 for electrons) [MeV]
dl real 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 track id
t real I time of flight [ns]
l real I path length [cm]
u real(6) I particle coordinates (see above)
 
id int I first argument passed to xfunc
a,b,c,d real I parameter for the intersection plane (ax+by+cz+d=0)
 
trgInit initializes (loads) the target field map.

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.
 
Note:  - Before calling trgTrack, trgXTrack or trgTrackToPlane the target field map has to be loaded by a call to trgInit. 

 
The HMS Tracking
The hms tracking module "hms_track" performs both, forward and backward tracking of electrons in the jlab HMS hall  C spectrometer. The vertical beam offsets are included in both directions.

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
target coordinates: 
uT(1,2) x [m],  dx/dz  = out of plane coordinate (downwards) 
uT(3,4) y [m],  dy/dz  = in plane coordinate (_|_ on x,z
uT(5) l [?] = pathlength deviation (?) 
uT(6) delta = relative deviation of the particle 
momentum from the central momentum 
zT z [m]; in axis coordinate (towards HMS)
 

z
real(6) 
z

O
focal plane coordinates: 
u(1,2) x [m],  dx/dz  = out of plane coordinate (downwards) 
u(3,4) y [m],  dy/dz  = in plane coordinate (_|_ on x,z
u(5) l [?] = pathlength deviation (?) 
u(6) delta = relative deviation of the particle 
momentum from the central momentum 
z z [m]; in axis coordinate (towards HMS) 
(position where the particle stops inside HMS)
 
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): 
u(1,2) x [m],  dx/dz  = out of plane coordinate (downwards) 
u(3,4) y [m],  dy/dz  = in plane coordinate (_|_ on x,z
 
x real vertical beam offset at the target [m] (z=0)  (out of plane; downwards)
uT real(6) O target coordinates (reconstruction only): 
u(1,2) x [m],  dx/dz  = out of plane coordinate (downwards) 
u(3,4) y [m],  dy/dz  = in plane coordinate (_|_ on x,z
u(5) z [m] = in axis coordinate (towards HMS) 
u(6) delta = relative deviation of the particle 
momentum from the central momentum
 

 
hmsInitForward initializes (loads) the forward transport maps

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
 
Note:  - 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 Gen Tracking
The Gen tracking module "gen_track" performs backward tracking of electrons in the jlab HMS hall  C spectrometer including the effects of the Gen's target magnetic field.

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: 
u(1,2) x [m],  dx/dz  = out of plane coordinate (downwards) 
u(3,4) y [m],  dy/dz  = in plane coordinate (_|_ on x,z
 
x real I vertical beam offset [m] (out of plane coord.; downwards)
y real I horizontal beam offset [m] (inplane coord.; _|_ on xbeam, zbeam)
uT real(6) O target coordinates: 
u(1,2) x [m],  dx/dz  = out of plane coordinate (downwards) 
u(3,4) y [m],  dy/dz  = in plane coordinate (_|_ on x,z
u(5) z [m] = in axis coordinate (towards HMS) 
u(6) delta = relative deviation of the particle 
momentum from the central momentum
 

 
genInitRecon initializes (loads) the oxford field map and the forward and backward transport maps

genRecon reconstructs the target coordinates (delta, dx/dz, y, dy/dz) including the effects of the targetr magnetic field and the vertical beam offset
 
Note:  - Before calling genRecon the target field map, the forward and backward maps have to be loaded by a call to genInitRecon.

 
 [top]
The Ready to Use Programs
<HR>
[back] [forward]
There are a couple of ready to use simulation and reconstruction programs to play with.  The individual programs read and write  event data in HBOOK/nTuple format and use transport/reconstruction matrices in COSY format.

A summary of the first results can be viewed in the picture gallery.
 
TARGET: (target.ftrg_track.f, CERNLIB)
tracking program - used to calculate electron/proton tracks within the target.

HMS: (hms.fhms_track.f, CERNLIB)
simulation of the electron arm (HMS only). ELECTRON: (electron.ftrg_track.fhms_track.f, CERNLIB)
simulation of the electron arm (both target and HMS). VIRTUAL: (virtual.ftrg_track.fhms_track.f, CERNLIB)
calcualtion of the virtual image due to the target field. MATRIX: (matrix.fsvdfit.f, CERNLIB)
find the reconstruction matrix for a given sample of events.  
RECON: (recon.fhms_track.f, CERNLIB)
performs the reconstruction for a given set of events (includes neither the vertical beam offset nor the target field). RECONX: (reconx.fhms_track.f,  CERNLIB)
performs the reconstruction for a given set of events (includes the  vertical beam offset only).  
RECONG: (recong.fhms_track.fgen_track.f,  CERNLIB)
performs the reconstruction for a given set of events (includes the vertical beam offset and the target field). VIEW: (view.f, CERNLIB)
generates a graphical representation of a reconstruction matrix. Making the Programs:
All the programs have to be linked against the CERN library (packlib, kernlib).
On UNIX systems you may use the Makefile to build the programs. Data Files Needed: Event Data nTuple Contents: Other Files You May Be Interested In:
 [top]
<HR>
[back]
 Markus Mühlbauer       June 5th 1998