scaler.c

Go to the documentation of this file.
00001 /********************************************************************\
00002 
00003   Name:         scaler.c
00004   Created by:   Stefan Ritt
00005 
00006   Contents:     Example scaler analyzer module. This module looks
00007                 for a SCLR banks and accumulates scalers into an
00008                 ACUM bank.
00009 
00010   $Id: scaler.c 2753 2005-10-07 14:55:31Z ritt $
00011 
00012 \********************************************************************/
00013 
00014 /*-- Include files -------------------------------------------------*/
00015 
00016 /* standard includes */
00017 #include <stdio.h>
00018 #include <string.h>
00019 #include <time.h>
00020 
00021 /* midas includes */
00022 #include "midas.h"
00023 #include "experim.h"
00024 #include "analyzer.h"
00025 
00026 /*-- Module declaration --------------------------------------------*/
00027 
00028 INT scaler_accum(EVENT_HEADER *, void *);
00029 INT scaler_clear(INT run_number);
00030 INT scaler_eor(INT run_number);
00031 
00032 ANA_MODULE scaler_accum_module = {
00033    "Scaler accumulation",       /* module name           */
00034    "Stefan Ritt",               /* author                */
00035    scaler_accum,                /* event routine         */
00036    scaler_clear,                /* BOR routine           */
00037    scaler_eor,                  /* EOR routine           */
00038    NULL,                        /* init routine          */
00039    NULL,                        /* exit routine          */
00040    NULL,                        /* parameter structure   */
00041    0,                           /* structure size        */
00042    NULL,                        /* initial parameters    */
00043 };
00044 
00045 /*-- accumulated scalers -------------------------------------------*/
00046 
00047 double scaler[32];
00048 
00049 /*-- BOR routine ---------------------------------------------------*/
00050 
00051 INT scaler_clear(INT run_number)
00052 {
00053    memset(scaler, 0, sizeof(scaler));
00054    return SUCCESS;
00055 }
00056 
00057 /*-- EOR routine ---------------------------------------------------*/
00058 
00059 INT scaler_eor(INT run_number)
00060 {
00061    return SUCCESS;
00062 }
00063 
00064 /*-- event routine -------------------------------------------------*/
00065 
00066 INT scaler_accum(EVENT_HEADER * pheader, void *pevent)
00067 {
00068    INT n, i;
00069    DWORD *psclr;
00070    double *pacum;
00071 
00072    /* look for SCLR bank */
00073    n = bk_locate(pevent, "SCLR", &psclr);
00074    if (n == 0)
00075       return 1;
00076 
00077    /* create acummulated scaler bank */
00078    bk_create(pevent, "ACUM", TID_DOUBLE, &pacum);
00079 
00080    /* accumulate scalers */
00081    for (i = 0; i < n; i++) {
00082       scaler[i] += psclr[i];
00083       pacum[i] = scaler[i];
00084    }
00085 
00086    /* close bank */
00087    bk_close(pevent, pacum + n);
00088 
00089    return SUCCESS;
00090 }

Midas DOC Version 1.9.5 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk