Using windows in Sunsort

There are two steps to using windows in Sunsort. Firstly you must set up your sort code to access the window, and secondly, you must define the window.

Accessing windows in sort codes

The first step in using a window is to declare it. You do this by declaring a 2D spectrum in the *twod section of your sort code with a name that begins with the letter w. Almost always, a window refers to a particular spectrum and so it must be declared to be the same size as the spectrum.

Once the window is declared, you can access it in the sort code by using the win2d spectrum routines. Typically the code will look something like:

*twod
...
30 ede1 128
31 wede1 128
...
*sort
...
      double precision e1,de1
      logical inwin
      ...
C Increment the E-DE plot for detector 1
      call dinc2d(30,e1*2,de1*20)
C See if we're in the carbon banana
      call win2d(31,e1*2,de1*2,inwin)
      if (inwin) then
C We have a carbon in detector 1
        ...
    
The equivalent code in C would be:
*twod
...
30 ede1 128
31 wede1 128
...
*sort
...
    double e1, de1;
    int inwin;
...
/* Increment the E-DE plot for detector 1 */
    dinc2d(30, e1*2, de1*20);
/* See if we're in the carbon banana */
    inwin = win2d(31, e1*2, de1*2);
/* We have a carbon in detector 1 */
    if (inwin)
    {
        ...
    
In the C example, the variable inwin could be omitted if this was the only test of the window, that is:
      if (win2d(31, e1*2, de1*2))
    
but if a window needs to be tested more than once per event, it is more efficient to place the result of the win2d call in a variable.

The examples above show a typical use of windows where there is one window for one spectrum, but other uses are possible. You may choose to set several windows over a spectrum, for example, with an E-DE plot, you may set one window over the carbons, one over the oxygens and one over the alphas. In other cases it may be possible to have one window applied to several spectra. Once the window has been defined, the original spectrum is no longer needed except as a diagnostic. If memory considerations were to get tight, the the original spectrum could be deleted (spectrum 30 in the above examples) leaving just the window.

Once the windowing code is in place, you must then define the window.

Defining windows

Windows can only really be defined from the GUI. Although there is a command line commands to set windows, it only starts up the setting code in the 2D viewer. If you are running without the 2D viewer program then there is no way to set a window.

Before you can set a window, you need to have a suitable spectrum to set it over. Typically this will be obtained by sorting some data or loading a previously save spectrum. In the example given above, it is spectrum 30 that we want to set the window over. Note that our choice of which spectrum to set the window over here is independent of the choice in the sort code. It is up to the user to ensure that they match.

Having filled the spectrum with data, you should then go to Sunsort's window control window, select the window in the scroll list, select the spectrum in the text field marked View window over spectrum and press the button marked View and set window.

The 2D viewer should appear. Initially this is just in the normal viewing mode with the window also displayed. The Window menu is enabled. You should use the normal controls to get a good view of the spectrum. If you're previously set the window, you may want to select Window->Show without window to remove the window from the display. When you are ready to set the window, select Window->Set window. You may then draw the outline of the window by pressing the left mouse button to add a point to the outline, the middle mouse button to delete the last point and the right mouse button to close the window and finish the edit. If at any point you want to abort setting the window, then select Window->Abort set window.

Once the window has been set, the filtering code should then work. You should take this opportunity to save your windows using the save button on the main window. Follow the instructions given in the section on spectra.

Other notes

Don't forget to reload your windows every time you reload your sort code. Clearing spectra will not affect windows, but reloading your sort code or restarting Sunsort will.

If you want to check a window, then follow the procedure listed above for defining a window, just don't select Window->Set window. The View and set window button passes the current window definition to the 2D viewer for it to display for you. Use the options under the Window menu to have a look at which bits of the spectrum are inside and outside the window.


Steven M. Singer
Last modified: Fri Sep 3 16:48:03 BST 1999