Using variables in Sunsort

Sunsort provides a method for the user to pass variables to their sort code so that parameters may be altered without recompiling.

A typical example is that the user may have two runs of event-by-event data which were performed with different parameters, for example, the beam energy may have been different.

Instead of hard-coding these parameters in the sort code, the user may place them in a set of variables which may be altered at run time, and may be changed between the reading of different runs.

To do this, the user declares the variables in the *vars section of the sort code. An entry like this is typical:

      5 ebeam 75.0
    
The number is used inside the sort code to access the variable. The name is there to help the user remember what the variable does, and the value listed on the right is a default value used whenever the sort code is loaded.

At any time when Sunsort is not sorting data, the user can change the values of these variables. When sorting commences, the sort code will be able to see these values and take appropriate action. The user can change these variables through either the GUI or at the command line.

Changing variables with the GUI

To change a variable, pop up the variables window by pressing the Variables... button on the main window.

Select the variable you wish to modify from the scroll list, enter the new value in the field marked Value and press the button marked modify.

Changing variables from the command line or in a batch file

To change a variable from the command line (or in a batch file) use the var command. The syntax is:
      var variable_number new_value
    
For reasons which are too complex to explore here, changes in variables made at the command line are not visible from the variables window until you type the command update.

An example batch file may read:

      var 5 56.4
      update
      open tape run03
      sort 0 -1
      close
      save all run03 sdb 1
      var 5 65.3
      update
      open tape run04
      sort 0 -1
      close
      save all run04 sdb 1
    

If you want to get a list of all variables when you are at the command line, then type vars or printvars. Both commands are the same.

Saving and loading set of variables

If you have a lot of variables to change, you may prefer to set them up and save them to a file, that way you can load them en-masse later. To do this, use the spectrum saving and loading methods. When you save and load spectra, one of the options given (both in the GUI and at the command line) is to save or load the variables. That way you can save the variables along with the spectra that match.
Steven M. Singer
Last modified: Fri Sep 3 16:47:23 BST 1999