nscl_logo_small.gif (2463 bytes)

parameter - SpecTcl Command

HH00706_.wmf (6530 bytes)

SpecTcl Home  General Information User Guide Programmer's Guide Obtaining and Installing

Syntax

parameter [-new] name id resolution
parameter [-new] name id resolution {low high units}
parameter [-new] name id [units]
parameter -list [-byid]
parameter -list [pattern]
parameter -list -id id
parameter -delete name
parameter -delete -id id

Top

Synopsis

Manipulates the SpecTcl parameter dictionary.

Top

Detailed Description

SpecTcl maintains a parameter dictionary. The parameter dictionary creates a correspondence between elements in the Event dynamic array and named parameters which are used to create spectra. Each parameter has the following properties:

While the internal representation of a parameter is a floating point value, SpecTcl recognizes that many parameters are integer values (e.g. raw ADC conversions).  SpecTcl provides a rich set of parameter range definitions that cover the span of both real and integer valued parameters.

The spectrum command is used to create spectra which histogram parameters.

Top

parameter [-new] name id ...

Creates a new entry in the parameter dictionary. The -new flag is optional.  This comand has several forms, depending on whether the parameter is to be treated as an integer, a mapped integer or a real number.  All parameters have a name and an Id.  The name is an arbitrary text string (although since you are working within Tcl, using {}[] e.g.  in parameter names is strongly discouraged).

The name is the name you will use in future SpecTcl commands to refer to this parameter.  The id represents the slot in the parameter array in which your unpacking software will place the parameter.

Defining Integer Parameters:

An integer parameter is assumed to have a value from 0 to (2**n)-1.  n is said to be the scale of the parameter.  Two types of integer parameter may be defined, depending on the form of the parameter command:

parameter [-new] name id scale

Defines an integer parameter whose values represent the range [0,(2**scale) - 1].

parameter [-new] name id scale {low high units}

Defines a parameter with range defined as in the first form of the command, but whose values are assumed to linearly map to some real coordinate line in the range [low,high].  The command parameter low and high are floating point values.  The parameter is also assumed to have units (e.g. cm or MeV) described by the string unit.  Parameter of this sort are called mapped parameters and are useful when building histograms of simple calibrated parameters.

Defining Real Parameters:

A real parameter has an arbitrary range, and optional units.  It is defined as follows:

parameter [new] name id [units]

The units  parameter is a string valued command line parameter that represents the units of the parameter (e.g. "MeV").

Top

parameter -list [-byid]

Returns a list of the parameter definitions. If the optional -byid switch is included, the parameters are sorted by Id number. Otherwise the list is alphabetical by parameter name. The output is in a form which makes processing by other Tcl commands and scripts easy (see e.g. ParList). The output is a Tcl List of definitions.   Each element of the list is itself a list that describes one parameter.  In order to make the processing of this list simple, all parameter definitions have the following elements (in order):

Element Meaning
name Name of the parameter
id Index into the parameter array of the parameter.
scale Scale value of the parameter if it is an integer valued parameter else empty.
info This is a three element list containing in order
subelement Contains
lowlim For an integer mapped parameter, this is the low limit of the range represented by the parameter.   This is empty for real parameters.
hilim For an integer mapped parameter, this is the high limit of the range represented by the parameter.  This is empty for real parameters.
units The units for either an integer or real parameter.  If no units have been specified, this is empty.

Sample output:

{Distribution1 1 10 {{} {} {}}}
{hasunits 12 {} {{} {} {cm}}}
{real 7 {} {{} {} {}}}
{scaled 6 10 {10.000000 20.000000 MeV}}

This sample shows in order the output for a simple integer parameter, a real parameter with units, a real parameter with no units and a scaled integer parameter.

Top

parameter -list [-byid] [pattern]

Returns a parameter list of whose whose name matches the pattern. The pattern may include * as a wildcard. The -byid falg is optional and will cause the parameters to be sorted by id number instead of by name.

Top

parameter -list -id id

Returns the parameter definition for the parameter with the id id. If the parameter cannot be listed, the return value is an error message string.

Top

parameter -delete name

Removes the parameter named name from the parameter dictionary.

Top

parameter -delete -id id

Removes the parameter with the id id from the parameter dictionary.

Top

Examples:

parameter De1 0 12                     ;# Creates a 12 bit parameter named De1 in element 
#                                         zero of the event array.
parameter p1 1 10 {10 100 "MeV"}       ;# Creates a 10 bit parameter named p1 which will 
#                                         scale channel data to between 10 and 100, and 
#                                         will label its axis with "MeV".
parameter position 2 mm                ;# Defines a real valued parameter with units mm
parameter -list -byid                  ;# Creates a list sorted by Id of the defined 
#                                         parameters.
parameter -delete -id 0                ;# Deletes the parameter with the id 0.
ParList [parameter -list -byid]        ;# Uses the ParList script to create a nicely 
#                                         formatted list of parameters sorted by ID.
SaveParams setup.tcl [parameter -list] ;# Uses the Saveparams script to create a file 
#                                         called setup.tcl which contains definitions 
#                                         for all of the parameters known to SpecTcl. 
#                                         This script can then be sourced to re-define 
#                                         these parameters on subsequent runs.

Top

SpecTcl Home  General Information User Guide Programmer's Guide Obtaining and Installing


Last Modified: October 28, 2003 by: fox@nscl.msu.edu
© Copyright NSCL 1999, All rights reserved