51 (
const char **)scaler_param_str,
70 INT nscaler, status, size;
73 cm_get_experiment_database(&hDB, NULL);
76 status = db_find_key(hDB, 0,
"/Equipment/Scaler/Variables/SCL0", &hkey);
77 if (status == DB_SUCCESS )
78 db_set_num_values(hDB, hkey, nscaler);
80 cm_msg(MERROR,
"scaler_init",
"Error setting array length of SCL0.");
82 status = db_find_key(hDB, 0,
"/Equipment/Scaler/Variables/SSUM", &hkey);
83 if (status == DB_SUCCESS )
84 db_set_num_values(hDB, hkey, nscaler);
86 cm_msg(MERROR,
"scaler_init",
"Error setting array length of SSUM.");
89 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/SlowMuonEvents", &
lem_events, &size, TID_DOUBLE, FALSE);
113 cm_get_experiment_database(&hDB, NULL);
119 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/SlowMuonEvents", &
lem_events, &size, TID_DOUBLE, FALSE);
142 INT n, i, size, sum_Ip_rate, mean_Ip_rate, *pmean_rate;
144 DWORD *psclr, mask_scaler[
N_SCALER];
149 double new_lem_events;
151 cm_get_experiment_database(&hDB, NULL);
154 n = bk_locate(pevent,
"SCL0", &psclr);
158 for ( i=0; i<n; i++){
160 mask_scaler[i] = psclr[i] &
MASK24;
162 mask_scaler[i] = psclr[i];
166 bk_create(pevent,
"SSUM", TID_DOUBLE, (
void**)&psum);
168 for (i=0 ; i<n ; i++){
169 if (
runinfo.state == STATE_RUNNING ){
170 scaler[i] += mask_scaler[i];
175 bk_close(pevent, psum+n);
178 bk_create(pevent,
"RATE", TID_STRUCT, (
void **)&prate);
187 for (i=0 ; i<n ; i++){
193 rate[i] = (int) rint(mask_scaler[i]/norm);
197 rate[i] = (int) rint(mask_scaler[i]/norm);
211 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/SlowMuonEvents", &
lem_events, &size, TID_DOUBLE, FALSE);
214 if (new_lem_events < 0.) new_lem_events = 0.;
216 rate[i] = (int) rint(new_lem_events/norm);
221 bk_close(pevent, prate+1);
228 bk_create(pevent,
"SRAT", TID_STRUCT, (
void **)&psrat);
229 psratio = &psrat->
ip;
235 for (i=0; i<n+1; i++)
236 *(psratio+i) = (int) rint(
IpSCALE * (
float) pd[i] / (float) pd[scaler_param.
ip_channel]);
239 for (i=0; i<n+1; i++)
248 bk_close(pevent, psrat+1);
271 bk_create(pevent,
"RAAV", TID_INT, (
void **)&pmean_rate);
272 *pmean_rate = mean_Ip_rate;
273 bk_close(pevent, pmean_rate+1);
291 const char *state[] = {
"",
"Stopped",
"Paused",
"Running" };
293 {
"--------------------------------------------------------------------------"};
294 const char *empty[] =
297 {
" # Label Total Rate/s "};
298 time_t now, difftime;
304 ss_printf(0, 0,
"%s", line[0]);
306 ss_printf(0,1,
" Run Number: %10d started at: %s",
309 if (
runinfo.state == STATE_STOPPED){
310 ss_printf(0,2,
" Run State : %10s last update: %s",
315 ss_printf(0,2,
" Run State : %10s last update: %s",
316 state[
runinfo.state], ctime(&now));
318 ss_printf(0,3,
"%s", empty[0]);
319 ss_printf(0,4,
"%s", top[0]);
320 ss_printf(0,5,
"%s", line[0]);
321 ss_printf(0,6,
"%s", empty[0]);
323 for (i=0 ; i<nscal ; i++){
325 ss_printf(0, i+7,
"%2d %-24s %15.5e\t\t %13d", i,
331 ss_printf(0, i+7,
"%2d %-24s %15.0f\t\t %13d", i,
334 ss_printf(0, 47,
"%s", line[0]);
335 if (
runinfo.state == STATE_STOPPED)
338 difftime = now -
runinfo.start_time_binary;
340 ss_printf(0, 49,
"Elapsed time: %dh%02dm%02ds",
341 difftime/3600, difftime%3600/60,difftime%60);
350 cm_get_experiment_database(&hDB, NULL);
351 if ( db_find_key(hDB, 0,
"/Info/Scaler Update time", &hKey) != DB_SUCCESS ){
352 if ( db_create_key(hDB, 0,
"/Info/Scaler Update time", TID_STRING) != DB_SUCCESS ){
353 cm_msg(MERROR,
"display_scaler",
"Cannot create \"/Info/Scaler Update time\" key in ODB");
359 sprintf(timestr,
"%s", ctime(&now));
361 db_set_value(hDB, 0,
"/Info/Scaler Update time", ×tr,
sizeof(timestr), 1, TID_STRING);
INT scaler_sum(EVENT_HEADER *, void *)
SCALERSUMRATE_PARAM_STR(scaler_param_str)
INT32 ip_threshold_current_ua_
SCALER_SETTINGS scaler_settings
static double last_lem_events
INT scaler_clear(INT run_number)
static INT * pring_buffer
INT scaler_eor(INT run_number)
static INT * pwrite_ring_buffer
static INT rate[N_SCALER]
static INT nwrite_ring_buffer
static INT ring_buffer_size
SCALERSUMRATE_PARAM scaler_param
ANA_MODULE scaler_rate_sum
#define N_SCALER
total number of scaler channels
static double scaler[N_SCALER]