Scalers Database
Experiment E852 records > 100 different scalers at BOS and EOS
(begin and end of spill). Some scalers are reset to zero
at every spill, some are not. Some scalers are 24-bit
CAMAC scalers, some are 32-bit Fastbus scalers and some
are 48-bit cascaded CAMAC scalers.
The data unpacking routine unpacks the scalers into GROUP_SCALERS.
In that group, each scaler has a unique "index".
The "Scalers Database" package described in this document was written
to make the use of GROUP_SCALERS easier. For example, it provides
functions to access the scalers using symbolic names, such
as "S", "S*DT", "Lev1_A1", etc...
Header files, Libraries, Sources and Map files
The C header file scalerDatabase.h defines
the data structures and functions used by the scalers database.
Programs using the scalers database should link with the libdata.a library.
The source code is located in the libdata subsystem.
The database data file is located in the map manager file db-files.Map,
subsystem db-files, item scalers.
Format of the Map file
The database data file has the following format:
scalers.nchannels: 236
scalers.1.name: CsI_H1
scalers.1.channel: 0
scalers.1.load: 1
scalers.1.reset: 1
scalers.2.name: CsI_H2
scalers.2.channel: 1
scalers.2.load: 1
scalers.2.reset: 1
...
The various fields have the following format:
- scalers.nchannels --- number of entries in the database
- scalers.NNN.name --- name of the scaler NNN. The name is empty for unused database slots.
- scalers.NNN.channel --- index of this scaler in GROUP_SCALERS
- scalers.NNN.load --- used by 'scalerWrite'. == 0 if this scaler is to be ignored by 'scalerWrite'.
- scalers.NNN.reset --- set to 1 if the scaler is reset on every spill, or 0 if the scaler is reset only once per run.
Format of the scalerDatabase_t array
typedef struct
{
int flags; /* flags defined and explained in the header file */
const char *name; /* name of the scaler */
int offset; /* offset into the GROUP_SCALERS group, counting from zero */
int resetAtBOS; /* 'true' is the scaler is reset at the begin of spill */
} scalerDatabaseEntry_t;
typedef struct
{
int nscalers; /* number of entries in the database */
scalerDatabaseEntry_t scaler[1]; /* array of entries */
} scalerDatabase_t;
Subroutines used to access the scalers database
scaler_getDatabase(int runNo)
Purpose:
- load the database file into a scalerDatabase_t array.
Arguments:
- runNo --- load the database for the given run
Return Value:
- a pointer to the database scalerDatabase_t array. This array is allocated
dynamically and should be deallocated after use by calling 'free()'.
int scaler_lookupScalerEntry(database,scalerName)
Purpose:
- find a scaler given it's symbolic name and return it's index in the scalerDatabase_t array.
Arguments:
- database --- the scaler database returned by the 'scaler_getDatabase() call.
- scalerName --- the scaler to find.
Return Value:
- < 0 --- the requested scaler was not found.
- >= 0 --- an index into the scalers database.
int scaler_lookupScalerOffset(database,scalerName)
Purpose:
- return the index of the named scaler in GROUP_SCALERS
Arguments:
- database --- the scaler database
- scalerName --- the requested scaler
Return Value:
- < 0 --- the scaler was not found in the database
- >= 0 --- index into GROUP_SCALERS
int scaler_getValue(scalers,offset)
Purpose:
- return the value of a scaler from GROUP_SCALERS, given it's offset. This function
performs bounds checking in GROUP_SCALERS.
Arguments:
- scalers --- pointer to GROUP_SCALERS
- offset --- offset of the requested scaler, for example returned by the 'scaler_lookupScalerOffset()' function.
Return Value:
- < 0 --- error: the 'offset' argument is invalid- either negative or too big.
- >= 0 --- the value of the scaler.
Author: K.Olchanski, 1996-Apr-13