MIDAS
Loading...
Searching...
No Matches
template.c
Go to the documentation of this file.
1/*
2
3This is a template file for a standard MIDAS - PAW analyzer module.
4
5Replace all <template> tags with the name of the module (like
6"adccalib" or "scaler") and all <TEMPLATE> tags with the uppercase
7name of them.
8
9It is assumed that the module uses parameters <template>_param, which
10appear in the ODB under /Analyzer/Parameters/<template>, a init
11routine which books histos and an event routine. The event routine
12looks for a bank "XXXX" and creates a result bank "YYYY" (have to be
13replaced with meaningful names).
14
15It is assumed that the result bank is a structured bank. Before it
16can be used, it has to be defined in the ODB with
17
18> cd /Equipment/Trigger/Variables
19> mkdir <YYYY>
20> cd <YYYY>
21> create float <item a>
22> create int <item b>
23> ....
24> make
25
26The "make" command generates <YYYY>_BANK in the file "experim.h",
27which is included in all module files.
28
29The same has to be done with the module parameters:
30
31> cd /Analyzer/Parameters
32> mkdir <template>
33> cd <template>
34> create float <parameter a>
35> create int <parameter b>
36> ....
37> make
38
39The success of the operation can be checked by looking at the
40"experim.h" file.
41
42*/
43
44/********************************************************************\
45
46 Name: <template>.c
47 Created by: Stefan Ritt
48
49 Contents: PiBeta Analyzer module for <template>
50
51 Revision history
52 ------------------------------------------------------------------
53 date by modification
54 --------- --- ------------------------------------------------
55 <date> <XX> created
56
57\********************************************************************/
58
59/*-- Include files -------------------------------------------------*/
60
61/* standard includes */
62#include <stdio.h>
63
64/* midas includes */
65#include "midas.h"
66#include "exprim.h"
67
68/*-- Parameters ----------------------------------------------------*/
69
71
72/*-- Static parameters ---------------------------------------------*/
73
74
75/*-- Module declaration --------------------------------------------*/
76
79
81
83 "<template>", /* module name */
84 "<Your Name>", /* author */
85 <template >, /* event routine */
86 NULL, /* BOR routine */
87 NULL, /* EOR routine */
88 <template > _init, /* init routine */
89 NULL, /* exit routine */
90 &<template > _param, /* parameter structure */
91 sizeof(<template > _param), /* structure size */
92 <template > _param_str, /* initial parameters */
93};
94
95/*-- init routine --------------------------------------------------*/
96
98{
99 /* book histos */
100
101 return SUCCESS;
102}
103
104/*-- event routine -------------------------------------------------*/
105
106INT < template > (EVENT_HEADER * pheader, void *pevent) {
107 int n;
110
111 /* look for <XXXX> bank, return if not present */
112 n = bk_locate(pevent, "XXXX", &xxxx);
113 if (n == 0)
114 return SUCCESS;
115
116 /* create calculated bank */
117 bk_create(pevent, "YYYY", TID_STRUCT, &yyyy);
118
119 /*---- perform calculations --------------------------------------*/
120
121 yyyy->x = xxxx->x * 2;
122
123 /*---- close calculated bank -------------------------------------*/
124 bk_close(pevent, yyyy + 1);
125
126 return SUCCESS;
127}
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
#define SUCCESS
Definition mcstd.h:54
#define TID_STRUCT
Definition midas.h:348
DWORD n[4]
Definition mana.cxx:247
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
ANA_MODULE< template > _module
Definition template.c:82
INT< template > _init(void)
Definition template.c:97
< TEMPLATE > _PARAM_STR(< template > _param_str)
INT< template >(EVENT_HEADER *, void *)
Definition template.c:106
< TEMPLATE > _PARAM< template > _param
Definition template.c:70