MIDAS
Loading...
Searching...
No Matches
analyzer.cxx File Reference
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "midas.h"
#include "experim.h"
#include "analyzer.h"
Include dependency graph for analyzer.cxx:

Go to the source code of this file.

Functions

 ASUM_BANK_STR (asum_bank_str)
 
INT analyzer_init ()
 
INT analyzer_exit ()
 
INT ana_begin_of_run (INT run_number, char *error)
 
INT ana_end_of_run (INT run_number, char *error)
 
INT ana_pause_run (INT run_number, char *error)
 
INT ana_resume_run (INT run_number, char *error)
 
INT analyzer_loop ()
 

Variables

const charanalyzer_name = "Analyzer"
 
INT analyzer_loop_period = 0
 
INT odb_size = DEFAULT_ODB_SIZE
 
RUNINFO runinfo
 
GLOBAL_PARAM global_param
 
EXP_PARAM exp_param
 
TRIGGER_SETTINGS trigger_settings
 
ANA_MODULE scaler_accum_module
 
ANA_MODULE adc_calib_module
 
ANA_MODULE adc_summing_module
 
ANA_MODULEscaler_module []
 
ANA_MODULEtrigger_module []
 
BANK_LIST ana_trigger_bank_list []
 
BANK_LIST ana_scaler_bank_list []
 
ANALYZE_REQUEST analyze_request []
 

Function Documentation

◆ ana_begin_of_run()

INT ana_begin_of_run ( INT  run_number,
char error 
)

Definition at line 199 of file analyzer.cxx.

200{
201 return CM_SUCCESS;
202}
#define CM_SUCCESS
Definition midas.h:582
Here is the caller graph for this function:

◆ ana_end_of_run()

INT ana_end_of_run ( INT  run_number,
char error 
)

Definition at line 206 of file analyzer.cxx.

207{
208 FILE *f;
209 time_t now;
210 char str[256];
211 int size;
212 double n;
213 HNDLE hDB;
214 BOOL flag;
215
217
218 /* update run log if run was written and running online */
219
220 size = sizeof(flag);
221 db_get_value(hDB, 0, "/Logger/Write data", &flag, &size, TID_BOOL, TRUE);
222 if (flag && runinfo.online_mode == 1) {
223 /* update run log */
224 size = sizeof(str);
225 str[0] = 0;
226 db_get_value(hDB, 0, "/Logger/Data Dir", str, &size, TID_STRING, TRUE);
227 if (str[0] != 0)
228 if (str[strlen(str) - 1] != DIR_SEPARATOR)
230 strcat(str, "runlog.txt");
231
232 f = fopen(str, "a");
233
234 time(&now);
235 strcpy(str, ctime(&now));
236 str[10] = 0;
237
238 fprintf(f, "%s\t%3d\t", str, runinfo.run_number);
239
240 strcpy(str, runinfo.start_time);
241 str[19] = 0;
242 fprintf(f, "%s\t", str + 11);
243
244 strcpy(str, ctime(&now));
245 str[19] = 0;
246 fprintf(f, "%s\t", str + 11);
247
248 size = sizeof(n);
249 db_get_value(hDB, 0, "/Equipment/Trigger/Statistics/Events sent", &n, &size,
251
252 fprintf(f, "%5.1lfk\t", n / 1000);
253 fprintf(f, "%s\n", exp_param.comment);
254
255 fclose(f);
256 }
257
258 return CM_SUCCESS;
259}
EXP_PARAM exp_param
Definition analyzer.cxx:51
RUNINFO runinfo
Definition analyzer.cxx:49
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
Definition midas.cxx:3011
#define TID_DOUBLE
Definition midas.h:343
#define TID_BOOL
Definition midas.h:340
#define TID_STRING
Definition midas.h:346
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
Definition odb.cxx:5415
DWORD n[4]
Definition mana.cxx:247
HNDLE hDB
main ODB handle
Definition mana.cxx:207
#define DIR_SEPARATOR
Definition midas.h:193
INT HNDLE
Definition midas.h:132
DWORD BOOL
Definition midas.h:105
#define DIR_SEPARATOR_STR
Definition midas.h:194
#define TRUE
Definition midas.h:182
#define ctime
Definition msystem.h:264
char str[256]
Definition odbhist.cxx:33
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
char comment[80]
Definition experim.h:27
char start_time[32]
Definition midas.h:1404
INT online_mode
Definition midas.h:1399
INT run_number
Definition midas.h:1400
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ana_pause_run()

INT ana_pause_run ( INT  run_number,
char error 
)

Definition at line 263 of file analyzer.cxx.

264{
265 return CM_SUCCESS;
266}
Here is the caller graph for this function:

◆ ana_resume_run()

INT ana_resume_run ( INT  run_number,
char error 
)

Definition at line 270 of file analyzer.cxx.

271{
272 return CM_SUCCESS;
273}
Here is the caller graph for this function:

◆ analyzer_exit()

INT analyzer_exit ( void  )

Definition at line 192 of file analyzer.cxx.

193{
194 return CM_SUCCESS;
195}
Here is the caller graph for this function:

◆ analyzer_init()

INT analyzer_init ( void  )

Definition at line 137 of file analyzer.cxx.

138{
139 HNDLE hDB, hKey;
140 char str[80];
141
146
147 /* open ODB structures */
149 db_create_record(hDB, 0, "/Runinfo", strcomb1((const char **)runinfo_str).c_str());
150 db_find_key(hDB, 0, "/Runinfo", &hKey);
151 if (db_open_record(hDB, hKey, &runinfo, sizeof(runinfo), MODE_READ, NULL, NULL) !=
152 DB_SUCCESS) {
153 cm_msg(MERROR, "analyzer_init", "Cannot open \"/Runinfo\" tree in ODB");
154 return 0;
155 }
156
157 db_create_record(hDB, 0, "/Experiment/Run Parameters", strcomb1((const char **)exp_param_str).c_str());
158 db_find_key(hDB, 0, "/Experiment/Run Parameters", &hKey);
160 DB_SUCCESS) {
161 cm_msg(MERROR, "analyzer_init",
162 "Cannot open \"/Experiment/Run Parameters\" tree in ODB");
163 return 0;
164 }
165
166 sprintf(str, "/%s/Parameters/Global", analyzer_name);
167 db_create_record(hDB, 0, str, strcomb1((const char **)global_param_str).c_str());
168 db_find_key(hDB, 0, str, &hKey);
171 NULL) != DB_SUCCESS) {
172 cm_msg(MERROR, "analyzer_init", "Cannot open \"%s\" tree in ODB", str);
173 return 0;
174 }
175
176 db_create_record(hDB, 0, "/Equipment/Trigger/Settings", strcomb1((const char **)trigger_settings_str).c_str());
177 db_find_key(hDB, 0, "/Equipment/Trigger/Settings", &hKey);
178
181 NULL) != DB_SUCCESS) {
182 cm_msg(MERROR, "analyzer_init",
183 "Cannot open \"/Equipment/Trigger/Settings\" tree in ODB");
184 return 0;
185 }
186
187 return SUCCESS;
188}
TRIGGER_SETTINGS trigger_settings
Definition analyzer.cxx:52
GLOBAL_PARAM global_param
Definition analyzer.cxx:50
const char * analyzer_name
Definition analyzer.cxx:40
#define EXP_PARAM_STR(_name)
Definition experim.h:30
#define GLOBAL_PARAM_STR(_name)
Definition experim.h:96
#define TRIGGER_SETTINGS_STR(_name)
Definition experim.h:166
#define DB_SUCCESS
Definition midas.h:631
#define SUCCESS
Definition mcstd.h:54
#define MERROR
Definition midas.h:559
#define MODE_READ
Definition midas.h:370
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
INT db_open_record(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
Definition odb.cxx:13291
std::string strcomb1(const char **list)
Definition odb.cxx:598
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4079
INT db_create_record(HNDLE hDB, HNDLE hKey, const char *orig_key_name, const char *init_str)
Definition odb.cxx:12800
HNDLE hKey
#define RUNINFO_STR(_name)
Definition midas.h:1410
Here is the call graph for this function:
Here is the caller graph for this function:

◆ analyzer_loop()

INT analyzer_loop ( void  )

Definition at line 277 of file analyzer.cxx.

278{
279 return CM_SUCCESS;
280}
Here is the caller graph for this function:

◆ ASUM_BANK_STR()

ASUM_BANK_STR ( asum_bank_str  )

Variable Documentation

◆ adc_calib_module

ANA_MODULE adc_calib_module
extern

Definition at line 49 of file adccalib.cxx.

49 {
50 "ADC calibration", /* module name */
51 "Stefan Ritt", /* author */
52 adc_calib, /* event routine */
53 adc_calib_bor, /* BOR routine */
54 adc_calib_eor, /* EOR routine */
55 adc_calib_init, /* init routine */
56 NULL, /* exit routine */
57 &adccalib_param, /* parameter structure */
58 sizeof(adccalib_param), /* structure size */
59 adc_calibration_param_str, /* initial parameters */
60};
INT adc_calib(EVENT_HEADER *, void *)
Definition adccalib.cxx:107
ADC_CALIBRATION_PARAM adccalib_param
Definition adccalib.cxx:36
INT adc_calib_bor(INT run_number)
Definition adccalib.cxx:93
INT adc_calib_init(void)
Definition adccalib.cxx:72
INT adc_calib_eor(INT run_number)
Definition adccalib.cxx:100

◆ adc_summing_module

ANA_MODULE adc_summing_module
extern

Definition at line 54 of file adcsum.cxx.

54 {
55 "ADC summing", /* module name */
56 "Stefan Ritt", /* author */
57 adc_summing, /* event routine */
58 NULL, /* BOR routine */
59 NULL, /* EOR routine */
60 adc_summing_init, /* init routine */
61 NULL, /* exit routine */
62 &adc_summing_param, /* parameter structure */
63 sizeof(adc_summing_param), /* structure size */
64 adc_summing_param_str, /* initial parameters */
65};
ADC_SUMMING_PARAM adc_summing_param
Definition adcsum.cxx:39
INT adc_summing_init(void)
Definition adcsum.cxx:73
INT adc_summing(EVENT_HEADER *, void *)
Definition adcsum.cxx:88

◆ ana_scaler_bank_list

BANK_LIST ana_scaler_bank_list[]
Initial value:
= {
{"SCLR", TID_UINT32, N_ADC, NULL},
{"ACUM", TID_DOUBLE, N_ADC, NULL},
{""},
}
#define N_ADC
Definition deferredfe.c:49
#define TID_UINT32
Definition midas.h:337

Definition at line 88 of file analyzer.cxx.

88 {
89 /* online banks */
90 {"SCLR", TID_UINT32, N_ADC, NULL},
91
92 /* calculated banks */
93 {"ACUM", TID_DOUBLE, N_ADC, NULL},
94 {""},
95};

◆ ana_trigger_bank_list

BANK_LIST ana_trigger_bank_list[]
Initial value:
= {
{"ADC0", TID_UINT32, N_ADC, NULL},
{"TDC0", TID_UINT32, N_TDC, NULL},
{"CADC", TID_FLOAT, N_ADC, NULL},
{"ASUM", TID_STRUCT, sizeof(ASUM_BANK), (char **)asum_bank_str},
{""},
}
#define N_TDC
Definition deferredfe.c:50
#define TID_STRUCT
Definition midas.h:348
#define TID_FLOAT
Definition midas.h:341

Definition at line 75 of file analyzer.cxx.

75 {
76
77 /* online banks */
78 {"ADC0", TID_UINT32, N_ADC, NULL},
79 {"TDC0", TID_UINT32, N_TDC, NULL},
80
81 /* calculated banks */
82 {"CADC", TID_FLOAT, N_ADC, NULL},
83 {"ASUM", TID_STRUCT, sizeof(ASUM_BANK), (char **)asum_bank_str},
84
85 {""},
86};

◆ analyze_request

ANALYZE_REQUEST analyze_request[]

Definition at line 99 of file analyzer.cxx.

99 {
100 {"Trigger", /* equipment name */
101 {1, /* event ID */
102 TRIGGER_ALL, /* trigger mask */
103 GET_NONBLOCKING, /* get events without blocking producer */
104 "SYSTEM", /* event buffer */
105 TRUE, /* enabled */
106 "", "",}
107 ,
108 NULL, /* analyzer routine */
109 trigger_module, /* module list */
110 ana_trigger_bank_list, /* bank list */
111 1000, /* RWNT buffer size */
112 TRUE, /* Use tests for this event */
113 }
114 ,
115
116 {"Scaler", /* equipment name */
117 {2, /* event ID */
118 TRIGGER_ALL, /* trigger mask */
119 GET_ALL, /* get all events */
120 "SYSTEM", /* event buffer */
121 TRUE, /* enabled */
122 "", "",}
123 ,
124 NULL, /* analyzer routine */
125 scaler_module, /* module list */
126 ana_scaler_bank_list, /* bank list */
127 100, /* RWNT buffer size */
128 }
129 ,
130
131 {""}
132 ,
133};
BANK_LIST ana_scaler_bank_list[]
Definition analyzer.cxx:88
ANA_MODULE * trigger_module[]
Definition analyzer.cxx:65
ANA_MODULE * scaler_module[]
Definition analyzer.cxx:60
BANK_LIST ana_trigger_bank_list[]
Definition analyzer.cxx:75
#define GET_NONBLOCKING
Definition midas.h:322
#define GET_ALL
Definition midas.h:321
#define TRIGGER_ALL
Definition midas.h:538

◆ analyzer_loop_period

INT analyzer_loop_period = 0

Definition at line 43 of file analyzer.cxx.

◆ analyzer_name

const char* analyzer_name = "Analyzer"

Definition at line 40 of file analyzer.cxx.

◆ exp_param

EXP_PARAM exp_param

Definition at line 51 of file analyzer.cxx.

◆ global_param

GLOBAL_PARAM global_param

Definition at line 50 of file analyzer.cxx.

◆ odb_size

INT odb_size = DEFAULT_ODB_SIZE

Definition at line 46 of file analyzer.cxx.

◆ runinfo

RUNINFO runinfo

Definition at line 49 of file analyzer.cxx.

◆ scaler_accum_module

ANA_MODULE scaler_accum_module
extern

Definition at line 32 of file scaler.cxx.

32 {
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};
INT scaler_clear(INT run_number)
Definition scaler.cxx:51
INT scaler_accum(EVENT_HEADER *, void *)
Definition scaler.cxx:66
INT scaler_eor(INT run_number)
Definition scaler.cxx:59

◆ scaler_module

ANA_MODULE* scaler_module[]
Initial value:
= {
}
ANA_MODULE scaler_accum_module
Definition scaler.cxx:32

Definition at line 60 of file analyzer.cxx.

60 {
62 NULL
63};

◆ trigger_module

ANA_MODULE* trigger_module[]
Initial value:
= {
}
ANA_MODULE adc_summing_module
Definition adcsum.cxx:54
ANA_MODULE adc_calib_module
Definition adccalib.cxx:49

Definition at line 65 of file analyzer.cxx.

65 {
68 NULL
69};

◆ trigger_settings

TRIGGER_SETTINGS trigger_settings

Definition at line 52 of file analyzer.cxx.