This file summarises changes to the sort subroutines. 

Changes from 1.0-beta to 1.0-beta2
----------------------------------

The following changes by SPGC:

sort-subs FAQ minor update.
egain : xdisp,edisp required as input

The following changes by SMS:

New vector package added for vector manipulation. In particular, it delays
expensive calculations until they are needed, if they are not needed then
the calculation is avoided.

Ev_struct changed to use vector package to store p and pcm. All ev_struct
accesses must now go via macros (in C). All programs changed to use macro
accesses. This means that later if we want to delay evaluation of ev_struct
elements until needed then we can play the same tricks as for the vector
package.

Calculation of q2 changed everywhere from:

	q2 = ((m+mr)*e - (mr-m1)*e1 - 2*sqrt(m1*m*e1*e)*cos(theta))/mr

to:

	q2 = ((m+mr)*e - (mr-m1)*e1 - p1*pz)/mr

since pz is already known we save a call to cos (and, if this is the only
reference to theta, a call to acos) and we also save a call to sqrt.

New make target - lint - added to check code for fluff.

All floating point variables upgraded from single to double precision
throughout the code.

New macro DEG added so that conversion to degrees can be done with *DEG
instead of /RAD.

Many array references of the form ev[n]. changed to evp = ev + n ... evp->

plot_spec: plot_hits and plot_chanspecs optimised and taught to use hidden
inc2d_tartan and inc2d_list entries into sunsort_lib.

punchthru: calculation of nearest vector changed to use dot product rather
	than delta-theta and delta-phi.

detector_event, markhits and markhitslist optimised.

hitbins array now allocated when needed, resolution may be altered. HITBINSIZE
symbol removed to reflect this change.

Compiled to shared library as well as static to improve memory usage if
several copies of sunsort running. Entailed splitting sunsort dependent
routines off from event-struct routines which don't require sunsort and which
may be used by stand alone programs. -lsortsubs gives the routines that are
safe for stand-alone use, -lsunsortsubs gives those which rely on sunsort.
Include files have been restructured. Include <evsubs.h> if you need the
non-sunsort dependent stuff, include <hitsubs.h> if you need the sunsort
dependent stuff, feel free to include both.

Because of change to shared libraries, versioning implemented so if sort-subs
version number changed all existing sort-codes must be recompiled before being
run again.

Ev-struct code now semi-intelligent. Can automatically derive values given
sufficient data, for example, you give it p and m and it will calculate e.
It remembers which values it's been told and which its derived. If you
give it e, p and m in that order then it will not attempt to recalculate e.
pcm and q2 are now wholly derived values and may not be set by the user.

Evhead, ev and reac global variables are now handled differently, see
source code in ev.c for more information.

Etot is no longer stored in evhead. Call evhead_etot() to have etot calculated
for you (this value isn't cached). It just sums the energies of all particles
between evhead.p[1] and evhead.p[1] + evhead.n[1] -1 inclusive.

Mass excess library is now on-line, see getmass.c in the directory
masses for more information. As well as returning mass excesses, it can also
do isotope name <-> A,Z conversion eg. "16O"->A=16, Z=8 or A=40 Z=20->"40Ca"
For convenience, a neutron may be specified as both "1 n" and "1.n" the
latter version is usful in files where the space in the former may confuse
parsing routines.

Scanga modified to use mass library. Now specify those nuclei invloved by
name in input file. No need to specify Q-values in input file, scanga will
calculate them. Neutrons must be sepcified as "1.n" not "1 n".

Dedx calculations are available on-line. Quick summary: in init routine do

	dedx_t cookie;

	cookie = dedx_setup(medium, ion, flags, thickness);

Then in main code do:

	de = dedx(cookie, energy);

Cookie is an opaque data type that encodes the information about the reaction.
Medium is specified as:

     2 letter standard compound id, for example, pp
     1 or 2 letter element name, for example, c
     FO:chemical_formula, for example, C3H8
     OT:list_of_elements, for example, 3,6,12,8,1,1

Medium may be suffixed with:
     /density
     @pressure
     !gaseous
     !solid

Ion is the name of the ion.

Flags are DEDX_AFTER for de as a function of energy after passage through
the medium (sort codes) or DEDX_BEFORE for de as a function of energy
before passage through the medium (simulation).

Thickness is in cm for gasses, mm for solids.

For example:

	cookie = dedx("pp@60", "12C", DEDX_AFTER, 5);
	cookie = dedx("si", "4He", DEDX_BEFORE, 0.5);
	cookie = dedx("FO:Bi4Ge3O12/7.13!solid", "1H", DEDX_AFTER, 1);
		/* though actually bismuth germanate is a standard compund */

Results are cached in the file sunsort_dedx.cache in the current directory
to save recalculation each time you call dedx_setup(). If you specify an energy
thats outside the range already calculated for an ion when you call dedx() then
it will automatically re-run dedx to get the new values (and cache them).

Functions dedx_emax, dedx_estep and dedx_tolerance may be used to set the
default maximum energies calculations are performed up to, the step size
used (default 100 keV) and the tolerance allowed for the fits (default 10 keV).
All values are in MeV.

FORTRAN compatability routines for dedx and getmass are in place.

First attempt made to support multi-threaded code - much slower so #defined
out at the moment.

Changes from 1.0-alpha to 1.0-beta
-----------------------------------

Bugfix: New return flags RD_ABORT and RD_SKIP in simple-c.srt
        (The previous ABORT and SKIP did not handle return values correctly.)

Scanga: Hitpat now defined for particles 3 to n (previously fixed to max of 12)

Scanga: Input deck (see sort-subs/simulations/eg_input.sca) now
        incorporates detector position resolution entered as a fraction 
        for x and y (in-detector coords). e.g. For a 50mm x 50mm PSSD 
        with 200 um resolution in x and 3 mm in y the resolution values 
        are entered as 0.004 (x) 0.06 (y).
	New options for simulation including Punchthrough calculation.

Scanga: evhead.pmult[det] now incremented properly for each detector hit
missing_p: Put reconstructed missing particle in next slot in event array.
           Previously it was written to the next slot after singles hits.

Error return flags applied consistently.

punchthru(): Recalculates kinematics for a punchthru event.

Changes from birth to 1.0-alpha
--------------------------------

Corrected error in c.m. momentum calc in corr-sub.f and rp-sub.f
Started conversion to C
Moved fortran files to directory oldfortran (These are no longer supported)
Fortran callable copies of functions messy and mostly untested to date. 
Event-structure stuff reworked. PARTIAL file auto generation in a 
sub directory.
Can set and read the event structure from the fortran by using the
include file subs.i which points to ev.i.

New files...
rp.c    subroutine ``rp'' reconstructs resonant particle kinematics
nrp.c   subroutine ``nrp'' runs rp correlating particles in each n-hit event
rhit.c  subroutine ``rhit'' recalculates hit for new mass assignment
files.c handles input of data files
corr.c  subroutine ``corr'' reconstructs correlation phase space in various 
                            co-ordinate systems.
nrp.c  same operation but modified to handle N>6 
nrhit.c recalculates all dependencies for new mass assignment

simulations   scanga/rps/mcarlo/efficiency simulations

event_dump.c subroutine to format and dump sunsort event data
`z' charge of particle added to event structure

scanga simulation linked in with sunsort!
coords        coordinate definitions and routines 

``Pandoras box'' of next generation routines linked in
structure.c
properties.c
loadadcs.c
markhits.c
fortprop.c

reac_init now loads only m0,m1,m2
coords tidied into sort-subs and calib-routines
calib-routines tidied with an example calibration procedure
bug fix in event_dump.c
updated simulation code to write hits into event array in random sequence
wrtev.c generalised
missing_p.c  subroutine to create a particle from the missing momentum
ridgeproj  routines to project out ridges in basel coordinates
bin : links to all executables now in bin directory
nrp() now called as nrp(fold) to generate up to fold resonant particles only. 
The call "nrp(evhead.n[1])" will give the same operation as before.
chit(old,new): copies hit in ev array from old to new.
crhit(newmass,old,new): copies hit then recalculates the copy for newmass. 
updated simulation code for multiple l' values in Basel coordinates
Makefile updated
updated simulation code for different k,k' contributions for each l'
rp() q calc now independent of daughter grouping into hi and li
implemented using new variable in event structure "ev[].etot" to
keep running sum of daughter particle energies. 
Scanga updated to allow for widths of excited states.
missing_p updated to calculate missing mass NB previously assumed hitmass
Fixed error message in scanga_input
Modified scanga reaction input to handle all breakup permutations 
Tidied files in simulations and calib-routines
File version.h contains the sort-subs version number
corr now called with (ev,#particle number).
Scanga detection simulation now has option : Energy (T)hreshold only
reac_init() now called with reac_init(REAC_SIM) or reac_init(REAC_SORT)
Tidied scanga output
Scanga option added...
Y       #Put Pseudodata in random order (Y)es,(N)o?

vcm added to reac structure
plot_spec.c  routines to plot spectra
detprocs.c contains template detector_init/event procedure calls
rewrite of example calib-inputs and sort files
FAQ/NEWS To be finished!
Standalone scanga updated
