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   $Log: scaler.c,v $
00011   Revision 1.5  2004/01/08 08:40:08  midas
00012   Implemented standard indentation
00013 
00014   Revision 1.4  2003/04/08 00:09:50  olchansk
00015   add required #include <string.h>
00016 
00017   Revision 1.3  1998/11/09 09:14:16  midas
00018   Removed printf("EOR scaler\n");
00019 
00020   Revision 1.2  1998/10/12 12:18:58  midas
00021   Added Log tag in header
00022 
00023 
00024 \********************************************************************/
00025 
00026 /*-- Include files -------------------------------------------------*/
00027 
00028 /* standard includes */
00029 #include <stdio.h>
00030 #include <string.h>
00031 #include <time.h>
00032 
00033 /* midas includes */
00034 #include "midas.h"
00035 #include "experim.h"
00036 #include "analyzer.h"
00037 
00038 /*-- Module declaration --------------------------------------------*/
00039 
00040 INT scaler_accum(EVENT_HEADER *, void *);
00041 INT scaler_clear(INT run_number);
00042 INT scaler_eor(INT run_number);
00043 
00044 ANA_MODULE scaler_accum_module = {
00045    "Scaler accumulation",       /* module name           */
00046    "Stefan Ritt",               /* author                */
00047    scaler_accum,                /* event routine         */
00048    scaler_clear,                /* BOR routine           */
00049    scaler_eor,                  /* EOR routine           */
00050    NULL,                        /* init routine          */
00051    NULL,                        /* exit routine          */
00052    NULL,                        /* parameter structure   */
00053    0,                           /* structure size        */
00054    NULL,                        /* initial parameters    */
00055 };
00056 
00057 /*-- accumulated scalers -------------------------------------------*/
00058 
00059 double scaler[32];
00060 
00061 /*-- BOR routine ---------------------------------------------------*/
00062 
00063 INT scaler_clear(INT run_number)
00064 {
00065    memset(scaler, 0, sizeof(scaler));
00066    return SUCCESS;
00067 }
00068 
00069 /*-- EOR routine ---------------------------------------------------*/
00070 
00071 INT scaler_eor(INT run_number)
00072 {
00073    return SUCCESS;
00074 }
00075 
00076 /*-- event routine -------------------------------------------------*/
00077 
00078 INT scaler_accum(EVENT_HEADER * pheader, void *pevent)
00079 {
00080    INT n, i;
00081    DWORD *psclr;
00082    double *pacum;
00083 
00084    /* look for SCLR bank */
00085    n = bk_locate(pevent, "SCLR", &psclr);
00086    if (n == 0)
00087       return 1;
00088 
00089    /* create acummulated scaler bank */
00090    bk_create(pevent, "ACUM", TID_DOUBLE, &pacum);
00091 
00092    /* accumulate scalers */
00093    for (i = 0; i < n; i++) {
00094       scaler[i] += psclr[i];
00095       pacum[i] = scaler[i];
00096    }
00097 
00098    /* close bank */
00099    bk_close(pevent, pacum + n);
00100 
00101    return SUCCESS;
00102 }

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