MIDAS
Loading...
Searching...
No Matches
scaler.cxx
Go to the documentation of this file.
1/********************************************************************\
2
3 Name: scaler.c
4 Created by: Stefan Ritt
5
6 Contents: Example scaler analyzer module. This module looks
7 for a SCLR banks and accumulates scalers into an
8 ACUM bank.
9
10 $Id:$
11
12\********************************************************************/
13
14/*-- Include files -------------------------------------------------*/
15
16/* standard includes */
17#include <stdio.h>
18#include <string.h>
19#include <time.h>
20
21/* midas includes */
22#include "midas.h"
23#include "experim.h"
24#include "analyzer.h"
25
26/*-- Module declaration --------------------------------------------*/
27
31
33 "Scaler accumulation", /* module name */
34 "Stefan Ritt", /* author */
35 scaler_accum, /* event routine */
36 scaler_clear, /* BOR routine */
37 scaler_eor, /* EOR routine */
38 NULL, /* init routine */
39 NULL, /* exit routine */
40 NULL, /* parameter structure */
41 0, /* structure size */
42 NULL, /* initial parameters */
43};
44
45/*-- accumulated scalers -------------------------------------------*/
46
47double scaler[32];
48
49/*-- BOR routine ---------------------------------------------------*/
50
52{
53 memset(scaler, 0, sizeof(scaler));
54 return SUCCESS;
55}
56
57/*-- EOR routine ---------------------------------------------------*/
58
60{
61 return SUCCESS;
62}
63
64/*-- event routine -------------------------------------------------*/
65
66INT scaler_accum(EVENT_HEADER * pheader, void *pevent)
67{
68 INT n, i;
69 DWORD *psclr;
70 double *pacum;
71
72 /* look for SCLR bank */
73 n = bk_locate(pevent, "SCLR", &psclr);
74 if (n == 0)
75 return 1;
76
77 /* create acummulated scaler bank */
78 bk_create(pevent, "ACUM", TID_DOUBLE, (void**)&pacum);
79
80 /* accumulate scalers */
81 for (i = 0; i < n; i++) {
82 scaler[i] += psclr[i];
83 pacum[i] = scaler[i];
84 }
85
86 /* close bank */
87 bk_close(pevent, pacum + n);
88
89 return SUCCESS;
90}
INT bk_close(void *event, void *pdata)
Definition midas.cxx:16780
INT bk_locate(const void *event, const char *name, void *pdata)
Definition midas.cxx:16889
void bk_create(void *event, const char *name, WORD type, void **pdata)
Definition midas.cxx:16561
unsigned int DWORD
Definition mcstd.h:51
#define SUCCESS
Definition mcstd.h:54
#define TID_DOUBLE
Definition midas.h:343
INT run_number[2]
Definition mana.cxx:246
DWORD n[4]
Definition mana.cxx:247
INT i
Definition mdump.cxx:32
int INT
Definition midas.h:129
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
ANA_MODULE scaler_accum_module
Definition scaler.cxx:32
INT scaler_clear(INT run_number)
Definition scaler.cxx:51
double scaler[32]
Definition scaler.cxx:47
INT scaler_accum(EVENT_HEADER *, void *)
Definition scaler.cxx:66
INT scaler_eor(INT run_number)
Definition scaler.cxx:59