26#define VISUAL_CPLUSPLUS
40#define HFNOV(A1,A2) CCALLSFSUB2(HFNOV,hfnov,INT,FLOATV,A1,A2)
44#define HMERGE(A1,A2,A3) CCALLSFSUB3(HMERGE,hmerge,INT,STRINGV,STRING,A1,A2,A3)
58#include <TApplication.h>
67#include <TServerSocket.h>
69#include <TObjString.h>
124 char msg[256],
str[256];
130 vsprintf(msg, (
char *) format,
argptr);
138 sprintf(cmd,
"echo > /dev/console \"%s\"",
str);
151#define PVM_BUFFER_SIZE (1024*1024)
224extern int QUEST[100];
230#define HBOOK_LREC 8190
233#ifndef EXT_EVENT_SIZE
234#define EXT_EVENT_SIZE (2*(MAX_EVENT_SIZE+sizeof(EVENT_HEADER)))
275 'c',
"<filename1> Configuration file name(s). May contain a '%05d' to be\n\
276 <filename2> replaced by the run number. Up to ten files can be\n\
277 ... specified in one \"-c\" statement",
clp.config_file_name,
TID_STRING, 10}, {
278 'd',
" Debug flag when started the analyzer fron a debugger.\n\
279 Prevents the system to kill the analyzer when the\n\
280 debugger stops at a breakpoint", &
clp.debug,
TID_BOOL, 0}, {
281 'D',
" Start analyzer as a daemon in the background (UNIX only).",
283 'e',
"<experiment> MIDAS experiment to connect to",
clp.exp_name,
TID_STRING, 1}, {
284 'f',
" Filter mode. Write original events to output file\n\
285 only if analyzer accepts them (doesn't return ANA_SKIP).\n", &
clp.filter,
TID_BOOL, 0}, {
286 'h',
"<hostname> MIDAS host to connect to when running the analyzer online",
288 'i',
"<filename1> Input file name. May contain a '%05d' to be replaced by\n\
289 <filename2> the run number. Up to ten input files can be specified\n\
290 ... in one \"-i\" statement",
clp.input_file_name,
TID_STRING, 10}, {
291 'l',
" If set, don't load histos from last histo file when\n\
293 'L',
" HBOOK LREC size. Default is 8190.", &
clp.lrec,
TID_INT, 0}, {
294 'n',
"<count> Analyze only \"count\" events.\n\
296 Analyze only events from \"first\" to \"last\".\n\
297 <first> <last> <n>\n\
298 Analyze every n-th event from \"first\" to \"last\".",
clp.n,
TID_INT, 4}, {
299 'o',
"<filename> Output file name. Extension may be .mid (MIDAS binary),\n\
300 .asc (ASCII) or .rz (HBOOK). If the name contains a '%05d',\n\
301 one output file is generated for each run. Use \"OFLN\" as\n\
302 output file name to creaate a HBOOK shared memory instead\n\
304 'p',
"<param=value> Set individual parameters to a specific value.\n\
305 Overrides any setting in configuration files",
clp.param,
TID_STRING, 10}, {
306 'P',
"<ODB tree> Protect an ODB subtree from being overwritten\n\
307 with the online data when ODB gets loaded from .mid file",
clp.protect,
TID_STRING, 10}, {
308 'q',
" Quiet flag. If set, don't display run progress in\n\
310 'r',
"<range> Range of run numbers to analyzer like \"-r 120 125\"\n\
311 to analyze runs 120 to 125 (inclusive). The \"-r\"\n\
312 flag must be used with a '%05d' in the input file name.",
clp.run_number,
TID_INT, 2},
315 't',
"<n> Parallelize analyzer using <n> tasks with PVM.", &
clp.n_task,
317 'b',
"<n> Buffer size for parallelization in kB.", &
clp.pvm_buf_size,
322 's',
"<port> Start ROOT histo server under <port>. If port==0, don't start server.", &
clp.root_port,
TID_INT, 1}, {
323 'R',
" Start ROOT interpreter after analysis has finished.",
327 'v',
" Verbose output.", &
clp.verbose,
TID_BOOL, 0}, {
328 'w',
" Produce row-wise N-tuples in outpur .rz file. By\n\
329 default, column-wise N-tuples are used.", &
clp.rwnt,
TID_BOOL, 0}, {
343#define ANALYZER_REQUEST_STR "\
345Trigger mask = INT : -1\n\
346Sampling type = INT : 1\n\
347Buffer = STRING : [32] SYSTEM\n\
349Client name = STRING : [32] \n\
350Host = STRING : [32] \n\
353#define ANALYZER_STATS_STR "\
354Events received = DOUBLE : 0\n\
355Events per sec. = DOUBLE : 0\n\
356Events written = DOUBLE : 0\n\
397 printf(
"Note more than %d options possible for flag -%c\n",
414 printf(
"usage: analyzer [options]\n\n");
415 printf(
"valid options are:\n");
441 strcpy(result,
file);
488 cm_msg(
MERROR,
"db_get_event_definition",
"cannot find /equipment entry in ODB");
496 cm_msg(
MERROR,
"db_get_event_definition",
"Cannot find event id %d under /equipment",
event_id);
530 cm_msg(
MERROR,
"db_get_event_definition",
"unknown data format");
565 strcpy(
tl[0]->
name,
"Always true");
643 for (
i = 0;
clp.config_file_name[
i][0] &&
i < 10;
i++) {
655 for (
i = 0;
clp.param[
i][0] &&
i < 10;
i++) {
657 printf(
"Error: parameter %s contains no value\n",
clp.param[
i]);
677 printf(
"Error: cannot find parameter %s in ODB\n",
str);
687 printf(
"Cannot change parameter %s\n",
str);
737 printf(
"N-tuples rebooked\n");
741 printf(
"ROOT TTree rebooked\n");
771 if (bank_list !=
NULL)
772 for (; bank_list->
name[0]; bank_list++) {
775 size =
sizeof(
DWORD);
800 strcpy(
str,
"Number");
801 strcpy(
str2,
"Run:U*4,Number:U*4,Time:U*4");
806 if (bank_list ==
NULL) {
812 cm_msg(
MERROR,
"book_ntuples",
"Cannot find definition of event %s in ODB",
827 for (
j = 0;
str[
j];
j++) {
828 if (!(
str[
j] >=
'a' &&
str[
j] <=
'z') &&
843 "Key %s in event %s is of type %s with no HBOOK correspondence",
863 for (; bank_list->
name[0]; bank_list++) {
880 "Bank %s is of type %s with no HBOOK correspondence",
887 "Bank %s is of type with unknown size", bank_list->
name);
908 for (
j = 0;
str[
j];
j++) {
909 if (!(
str[
j] >=
'a' &&
str[
j] <=
'z') &&
924 "Key %s in bank %s is of type %s with no HBOOK correspondence",
964 strcpy(
rw_tag[n_tag++],
"Run");
965 strcpy(
rw_tag[n_tag++],
"Number");
966 strcpy(
rw_tag[n_tag++],
"Time");
975 if (bank_list ==
NULL) {
987 for (
j = 0; key_name[
j];
j++) {
988 if (!(key_name[
j] >=
'a' && key_name[
j] <=
'z') &&
989 !(key_name[
j] >=
'A' && key_name[
j] <=
'Z') &&
990 !(key_name[
j] >=
'0' && key_name[
j] <=
'9'))
1005 "Too much tags for RW N-tupeles (512 maximum)");
1018 "Too much tags for RW N-tupeles (512 maximum)");
1024 for (; bank_list->
name[0]; bank_list++) {
1026 bank_list->
n_data = n_tag;
1032 for (
i = 0;
i < (
INT) bank_list->
size;
i++) {
1041 "Too much tags for RW N-tupeles (512 maximum)");
1056 for (
j = 0; key_name[
j];
j++) {
1057 if (!(key_name[
j] >=
'a' && key_name[
j] <=
'z') &&
1058 !(key_name[
j] >=
'A' && key_name[
j] <=
'Z') &&
1059 !(key_name[
j] >=
'0' && key_name[
j] <=
'9'))
1069 printf(
"NT #%d-%d: %s\n",
1074 "Too much tags for RW N-tupeles (512 maximum)");
1080 printf(
"NT #%d-%d: %s\n",
1087 "Too much tags for RW N-tupeles (512 maximum)");
1107 strcpy(
str,
"//OFFLINE");
1114 "Cannot book N-tuple #%d. Increase PAWC size via the -s flag or switch off banks",
1174 if (bank_list !=
NULL)
1175 for (; bank_list->
name[0]; bank_list++) {
1178 size =
sizeof(
DWORD);
1213#if (ROOT_VERSION_CODE >= 262401)
1220 et->branch_filled = (
int *)
malloc(
sizeof(
int));
1221 et->branch_len = (
int *)
malloc(
sizeof(
int));
1223 et->branch[
et->n_branch] =
1225 "Run/I:Number/I:Time/i");
1226 strcpy(
et->branch_name,
"Number");
1230 if (bank_list ==
NULL) {
1235 cm_msg(
MERROR,
"book_ttree",
"Cannot find definition of event %s in ODB",
1259 "Key %s in event %s is of type %s with no TTREE correspondence",
1274 (
int *)
realloc(
et->branch_filled,
sizeof(
int) * (
et->n_branch + 1));
1276 (
int *)
realloc(
et->branch_len,
sizeof(
int) * (
et->n_branch + 1));
1278 et->branch[
et->n_branch] =
1285 for (; bank_list->
name[0]; bank_list++) {
1298 "Bank %s is of type %s with no TTREE correspondence",
1304 cm_msg(
MERROR,
"book_ttree",
"Bank %s is of type with unknown size",
1311 sizeof(
TBranch *) * (
et->n_branch + 1));
1315 (
int *)
realloc(
et->branch_filled,
sizeof(
int) * (
et->n_branch + 1));
1317 (
int *)
realloc(
et->branch_len,
sizeof(
int) * (
et->n_branch + 1));
1319 et->branch[
et->n_branch] =
1344 "Key %s in bank %s is of type %s with no HBOOK correspondence",
1355 sizeof(
TBranch *) * (
et->n_branch + 1));
1359 (
int *)
realloc(
et->branch_filled,
sizeof(
int) * (
et->n_branch + 1));
1361 (
int *)
realloc(
et->branch_len,
sizeof(
int) * (
et->n_branch + 1));
1363 et->branch[
et->n_branch] =
1381 TFile *
outf =
new TFile(filename,
"RECREATE",
"Midas Analyzer Histograms");
1383 cm_msg(
MERROR,
"SaveRootHistograms",
"Cannot create output file %s", filename);
1405 const char *
name =
obj->GetName();
1407 if (
obj->InheritsFrom(
"TFolder")) {
1413 }
else if (
obj->InheritsFrom(
"TH1")) {
1417 }
else if (
obj->InheritsFrom(
"TCutG")) {
1442 TFile *
inf = TFile::Open(filename,
"READ");
1444 printf(
"Error: File \"%s\" not found\n", filename);
1465 if (
obj->InheritsFrom(
"TH1"))
1467 else if (
obj->InheritsFrom(
"TFolder"))
1532 cm_msg(
MERROR,
"bor",
"Cannot read output info record");
1541 if (bank_list ==
NULL)
1544 for (; bank_list->
name[0]; bank_list++) {
1615 module = analyze_request[i].ana_module;
1616 for (
j = 0;
module != NULL && module[j] != NULL;
j++) {
1620 module[j]->enabled = TRUE;
1621 size =
sizeof(
BOOL);
1629 module[j]->histo_folder = (TFolder *) gROOT->FindObjectAny(module[j]->name);
1631 module[j]->histo_folder =
1632 gManaHistosFolder->AddFolder(module[j]->name, str);
1636 "Fatal error: ROOT Object \"%s\" of class \"%s\" exists but it is not a TFolder, exiting!",
1662 module = analyze_request[i].ana_module;
1663 for (
j = 0;
module != NULL && module[j] != NULL;
j++)
1689 if (bank_list !=
NULL)
1690 for (; bank_list->
name[0]; bank_list++) {
1693 size =
sizeof(
DWORD);
1698 module = analyze_request[i].ana_module;
1699 for (
j = 0;
module != NULL && module[j] != NULL;
j++) {
1701 module[j]->enabled = TRUE;
1702 size =
sizeof(
BOOL);
1720 for (
i = 0;
i <
n;
i++) {
1721 for (
j = 0;
j < 10000;
j++)
1781 strcpy(error,
"Unknown output data format. Please use file extension .asc, .mid, .rz or .root.\n");
1818 strcpy(
str,
"BSIZE");
1820 strcpy(
str,
"OFFLINE");
1821 strcpy(
str2,
"NQP");
1831 cm_msg(
MERROR,
"bor",
"HBOOK support is not compiled in");
1854 cm_msg(
MERROR,
"bor",
"ROOT support is not compiled in");
1901 module = analyze_request[i].ana_module;
1902 for (
j = 0;
module != NULL && module[j] != NULL;
j++)
1904 module[j]->bor(run_number);
1923 module = analyze_request[i].ana_module;
1924 for (
j = 0;
module != NULL && module[j] != NULL;
j++)
1926 module[j]->eor(run_number);
1949 (
"Error: Due to a limitation in HBOOK, directoy names may not contain uppercase\n");
1950 printf(
" characters. Histogram saving to %s will not work.\n",
str);
1968 strcpy(
str,
"OFFLINE");
1971 cm_msg(
MERROR,
"eor",
"HBOOK support is not compiled in");
1977 cm_msg(
MERROR,
"eor",
"ROOT support is not compiled in");
1992 if (bank_list ==
NULL) {
1998 for (; bank_list->name[0]; bank_list++)
1999 if (bank_list->addr) {
2000 free(bank_list->addr);
2001 bank_list->addr =
NULL;
2050 }
while (n_bytes > 0);
2091#define STR_INC(p,base) { p+=strlen(p); \
2092 if (p > base+sizeof(base)) \
2093 cm_msg(MERROR, "STR_INC", "ASCII buffer too small"); }
2113 char buffer[100000];
2166 for (
i = 0;
par->bank_list[
i].name[0];
i++)
2183 if ((
bktype & 0xFF00) == 0)
2228 for (
i = 0;
i < size;) {
2253 for (
i = 0;
i < size;
i++) {
2254 if ((
bktype & 0xFF00) == 0)
2278 cm_msg(
MERROR,
"write_event_ascii",
"cannot find event definition");
2280 pdata = (
char *) (pevent + 1);
2336 static char *buffer =
NULL;
2402 for (
i = 0;
par->bank_list[
i].name[0];
i++)
2494 strcpy(
str,
"Number");
2532 for (
i = 0;
par->bank_list[
i].name[0];
i++)
2538 if (
par->bank_list[
i].name[0] == 0)
2539 cm_msg(
MERROR,
"write_event_hbook",
"Received unknown bank %s",
2548 if (item_size == 0) {
2550 "Received bank %s with unknown item size",
block_name);
2554 pbl->n_data = size / item_size;
2557 if (
pbl->n_data >
pbl->size) {
2559 "Bank %s has more (%d) entries than maximum value (%d)",
2565 if (item_size >= 4) {
2566 size =
MIN((
INT)
pbl->size * item_size, size);
2568 }
else if (item_size == 2)
2571 else if (item_size == 1)
2590 n = size / item_size;
2595 "Bank %s has more (%d) entries than maximum value (%d)",
2601 for (
i = 0;
i <
n;
i++) {
2690 assert(!
"YBOS not supported anymore");
2698 pdata = (
char *) (pevent + 1);
2810 cm_msg(
MERROR,
"write_event_ttree",
"Event #%d not booked by book_ttree()",
2818 for (
i = 0;
i <
et->n_branch;
i++)
2822 et->branch_filled[0] =
TRUE;
2861 for (
i = 0;
par->bank_list[
i].name[0];
i++)
2867 if (
par->bank_list[
i].name[0] == 0) {
2875 for (
i = 0;
i <
et->n_branch;
i++)
2879 if (
i ==
et->n_branch) {
2895 leaf->SetAddress(&
et->branch_len[
i]);
2908 for (
i = 0;
i <
et->n_branch;
i++)
2909 if (!
et->branch_filled[
i])
2911 "Bank %s booked but not received, tree cannot be filled",
2915#if (ROOT_VERSION_CODE < 262401)
2916 if (
clp.online &&
et->tree->GetEntries() >
par->rwnt_buffer_size)
2935 cm_msg(
MERROR,
"write_event_ttree",
"Event #%d not booked by book_ttree()",
2942 et->tree->GetBranch(
et->branch_name)->SetAddress(pevent + 1);
3092 printf(
"event %d, number %d, total size %d\n",
3110 if ((
char)
ch ==
'!')
3138 par->events_received++;
3171 if (
par->analyzer) {
3172 status =
par->analyzer(pevent, (
void *) (pevent + 1));
3180 module = par->ana_module;
3181 for (
i = 0;
module != NULL && module[i] != NULL;
i++) {
3184 status =
module[i]->analyzer(pevent, (void *) (pevent + 1));
3196 cm_msg(
MERROR,
"process_event",
"Event got too large (%d Bytes) in analyzer",
i);
3203 assert(!
"YBOS not supported anymore");
3230 cm_msg(
MERROR,
"process_event",
"Error writing to file (Disk full?)");
3234 par->events_written++;
3239 &&
par->rwnt_buffer_size > 0)
3244 if (
clp.online &&
par->rwnt_buffer_size > 0)
3251 for (
i = 0;
i < 50;
i++) {
3279 static DWORD buffer_size = 0;
3280 static char *buffer =
NULL;
3283 if (buffer ==
NULL) {
3286 if (buffer ==
NULL) {
3287 cm_msg(
MERROR,
"receive_event",
"Not enough memory to buffer event of size %d", buffer_size);
3300 for (;
par->event_name[0];
par++)
3301 if (
par->buffer_handle == buffer_handle &&
par->request_id == request_id) {
3380 printf(
"Cannot open statistics record, probably other analyzer is using it\n");
3527 for (
i = 0;
i < 10000;
i++)
3570 (
"Error: Due to a limitation in HBOOK, directoy names may not contain uppercase\n");
3571 printf(
" characters. Histogram loading from %s will not work.\n",
str);
3576 printf(
"Loading previous online histos from %s\n",
str);
3589 printf(
"Loading previous online histos from %s\n",
str);
3606 printf(
"Saving current online histos to %s\n",
str);
3619 (
"Error: Due to a limitation in HBOOK, directoy names may not contain uppercase\n");
3620 printf(
" characters. Histogram saving to %s will not work.\n",
str);
3642 printf(
"Running analyzer online. Stop with \"!\"\n");
3664 if ((
char)
ch ==
'!')
3668 if ((
char)
ch ==
'!')
3701 module = analyze_request[i].ana_module;
3702 for (
j = 0;
module != NULL && module[j] != NULL;
j++) {
3713 if (size !=
module[
j]->param_size)
3720 "Cannot create/check \"%s\" parameters in ODB",
str);
3731 "Cannot open \"%s\" parameters in ODB",
str);
3751 size =
sizeof(
flag);
3756 for (
i = 0;
i < 10;
i++)
3757 if (
clp.protect[
i][0] && !
clp.quiet)
3758 printf(
"Protect ODB tree \"%s\"\n",
clp.protect[
i]);
3796 for (
i = 0;
i < 10;
i++)
3797 if (
clp.protect[
i][0]) {
3807 if (
strncmp((
char *) (pevent + 1),
"<?xml version=\"1.0\"", 19) == 0)
3830#define MA_DEVICE_DISK 1
3831#define MA_DEVICE_TAPE 2
3832#define MA_DEVICE_FTP 3
3833#define MA_DEVICE_PVM 4
3835#define MA_FORMAT_MIDAS (1<<0)
3836#define MA_FORMAT_YBOS (1<<2)
3837#define MA_FORMAT_GZIP (1<<3)
3860 cm_msg(
MERROR,
"ma_open",
"Cannot allocate MA file structure");
3896 assert(!
"YBOS not supported anymore");
3899 (
"Unknown input data format \"%s\". Please use file extension .mid or mid.gz.\n",
3906 assert(!
"YBOS not supported anymore");
3922 assert(!
"YBOS not supported anymore");
3939 cm_msg(
MERROR,
"ma_read_event",
"Buffer size too small");
3948 printf(
"Unexpected end of file %s, last event skipped\n",
file->file_name);
3965 cm_msg(
MERROR,
"ma_read_event",
"Buffer size too small");
3970 printf(
"Unexpected end of file %s, last event skipped\n",
file->file_name);
3977 assert(!
"YBOS not supported anymore");
3981 int bufid, len, tag, tid;
3999 timeout.tv_sec = 60;
4000 timeout.tv_usec = 0;
4008 PVM_DEBUG(
"ma_read_event: timeout receiving data, aborting analyzer.\n");
4018 PVM_DEBUG(
"ma_read_event: receive tag %d, buflen %d", tag, len);
4051 char error[256],
str[256];
4088 printf(
"Not enough memeory\n");
4125 cm_msg(
MERROR,
"analyze_run",
"Error writing to file (Disk full?)");
4141 if (
clp.n[0] > 0 ||
clp.n[1] > 0) {
4142 if (
clp.n[1] == 0) {
4166 for (;
par->event_name[0];
par++)
4171 &&
par->ar_info.enabled) {
4211 printf(
"\nShutting down distributed analyzers, please wait...\n");
4227 start_time / 1000.0);
4239 start_time / 1000.0);
4267 start_time / 1000.0);
4284 start_time / 1000.0);
4308 printf(
"Running analyzer offline. Stop with \"!\"\n");
4313 ||
clp.input_file_name[1][0];
4316 if (
clp.run_number[0] > 0) {
4319 (
"Input file name must contain a wildcard like \"%%05d\" when using a range.\n");
4323 if (
clp.run_number[0] == 0) {
4324 printf(
"End of range not specified.\n");
4341 for (
i = 0;
clp.input_file_name[
i][0] &&
i < 10;
i++) {
4354 printf(
"Cannot extract run number from input file name.\n");
4374 strcpy(
str,
"OFFLINE");
4377 cm_msg(
MERROR,
"loop_runs_offline",
"HBOOK support is not compiled in");
4383 cm_msg(
MERROR,
"loop_runs_offline",
"ROOT support is not compiled in");
4396 if (bank_list ==
NULL)
4399 for (; bank_list->
name[0]; bank_list++)
4400 if (bank_list->
addr) {
4401 free(bank_list->
addr);
4459 while (p >
argv[0] && *p !=
'\\')
4470 strcpy(path,
argv[0]);
4474 if (
clp.n_task == -1)
4481 if (
clp.n_task != 0)
4497 printf(
"Not enough memory to allocate PVM structures.\n");
4509 printf(
"Not enough memory to allocate PVM buffers.\n");
4534 pvmc[
i].n_events = 0;
4547 printf(
"Trouble spawning slaves. Aborting. Error codes are:\n");
4563 PVM_DEBUG(
"pvm_main: send index to client %d",
i);
4580 strcpy(path,
argv[0]);
4590 timeout.tv_sec = 10;
4591 timeout.tv_usec = 0;
4599 PVM_DEBUG(
"pvm_main: timeout receiving index, aborting analyzer.\n");
4623 printf(
"Event too large (%d) for PVM buffer (%d), analyzer aborted\n",
4629 timeout.tv_sec = 60;
4630 timeout.tv_usec = 0;
4638 printf(
"Timeout receiving data requests from %s, aborting analyzer.\n",
4649 PVM_DEBUG(
"pvm_send_event: received request from client %d",
index);
4682 timeout.tv_sec = 60;
4683 timeout.tv_usec = 0;
4696 printf(
"Timeout receiving data requests, aborting analyzer.\n");
4708 if (
pvmc[
i].tid == tid)
4712 cm_msg(
MERROR,
"pvm_send_buffer",
"received message from unknown client %d", tid);
4716 PVM_DEBUG(
"pvm_send_buffer: received request from client %d",
i);
4723 PVM_DEBUG(
"pvm_send_buffer: send %d events (%1.1lfkB) to client %d",
4733 pvmc[
i].n_events = 0;
4767 if (
pvmc[
i].wp + size >=
clp.pvm_buf_size) {
4774 printf(
"Event too large (%d) for PVM buffer (%d), analyzer aborted\n", size,
4788 if (
pvmc[
i].wp < min) {
4801 printf(
"Event too large (%d) for PVM buffer (%d), analyzer aborted\n", size,
4824 if (
pvmc[
i].wp > max)
4826 if (
pvmc[
i].wp < min)
4831 if (max <
clp.pvm_buf_size / 2)
4835 if (min >
clp.pvm_buf_size / 2) {
4863 timeout.tv_sec = 60;
4864 timeout.tv_usec = 0;
4872 printf(
"Timeout receiving data request, aborting analyzer.\n");
4884 if (
pvmc[
j].tid == tid)
4888 cm_msg(
MERROR,
"pvm_eor",
"received message from unknown client %d", tid);
4892 PVM_DEBUG(
"pvm_eor: received request from client %d",
j);
4900 PVM_DEBUG(
"pvm_eor: send %d events (%1.1lfkB) to client %d",
4910 pvmc[
j].n_events = 0;
4917 PVM_DEBUG(
"pvm_eor: send EOR to client %d",
j);
4919 PVM_DEBUG(
"pvm_eor: send EXIT to client %d",
j);
4933 timeout.tv_sec = 60;
4934 timeout.tv_usec = 0;
4942 printf(
"Timeout receiving EOR request, aborting analyzer.\n");
4961 size =
sizeof(
DWORD);
5006 if (
strncmp(ext,
".gz", 3) == 0) {
5015 if (
strncmp(ext,
".asc", 4) == 0)
5017 else if (
strncmp(ext,
".mid", 4) == 0)
5019 else if (
strncmp(ext,
".rz", 3) == 0)
5023 "Unknown output data format. Please use file extension .asc, .mid or .rz.\n");
5062#if defined ( OS_UNIX )
5064#define THREADTYPE void
5066#if defined( OS_WINNT )
5067#define THREADRETURN 0
5068#define THREADTYPE DWORD WINAPI
5131 for (
int i = 0;
i <
names->GetLast() + 1;
i++)
5151 sock->Send(
"Error");
5168 sock->Send(
"Error");
5211 char objName[100], method[100];
5213 sock->Recv(method,
sizeof(method));
5215 if (
object &&
object->InheritsFrom(TH1::Class())
5216 &&
strcmp(method,
"Reset") == 0)
5217 static_cast < TH1 *
>(
object)->Reset();
5231 cm_msg(
MINFO,
"root server thread",
"changing cut %s",
newc->GetName());
5237 for (
int i = 0;
i <
cut->GetN(); ++
i) {
5241 cm_msg(
MERROR,
"root server thread",
"ignoring receipt of unknown cut %s",
5247 printf(
"SocketServer: Received unknown command \"%s\"\n",
request);
5262 port = *(
int *) arg;
5264 printf(
"Root server listening on port %d...\n", port);
5272#if defined ( OS_LINUX )
5276#if defined( _MSC_VER )
5289 static int pport = port;
5290#if defined ( OS_LINUX )
5294#if defined( _MSC_VER )
5345 clp.root_port = 9090;
5350 sizeof(
clp.exp_name));
5364 printf(
"Becoming a daemon...\n");
5370 if (
clp.pvm_buf_size == 0)
5371 clp.pvm_buf_size = 512 * 1024;
5373 clp.pvm_buf_size *= 1024;
5380 clp.online = (
clp.input_file_name[0][0] == 0);
5396 if (
clp.host_name[0])
5397 printf(
"Connect to experiment %s on host %s...",
clp.exp_name,
clp.host_name);
5399 printf(
"Connect to experiment %s...",
clp.exp_name);
5407 printf(
"\nError: Experiment \"%s\" not defined.\n",
clp.exp_name);
5408 if (
getenv(
"MIDAS_DIR")) {
5410 (
"Note that \"MIDAS_DIR\" is defined, which results in a single experiment\n");
5412 (
"called \"Default\". If you want to use the \"exptab\" file, undefine \"MIDAS_DIR\".\n");
5417 printf(
"\nError: %s\n", s.c_str());
5437 printf(
"An analyzer named \"%s\" is already running in this experiment.\n",
5440 (
"Please select another analyzer name in analyzer.c or stop other analyzer.\n");
5449 printf(
"Failed to start local RPC server");
5464 printf(
"Previous analyzer stopped\n");
5503 gROOT->GetRootFolder()->AddFolder(
"histos",
"MIDAS Analyzer Histograms");
5540 strcpy(
str,
"OFLN");
5542 printf(
"\nGLOBAL MEMORY NAME = %s\n",
"OFLN");
INT bk_close(void *event, void *pdata)
INT bk_iterate32a(const void *event, BANK32A **pbk32a, void *pdata)
INT bk_swap(void *event, BOOL force)
BOOL bk_is32a(const void *event)
BOOL bk_is32(const void *event)
INT bk_iterate32(const void *event, BANK32 **pbk, void *pdata)
void bk_init(void *event)
INT bk_iterate(const void *event, BANK **pbk, void *pdata)
void bk_init32(void *event)
void bk_create(void *event, const char *name, WORD type, void **pdata)
INT bk_size(const void *event)
INT bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
INT bm_delete_request(INT request_id)
INT bm_request_event(HNDLE buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, HNDLE *request_id, EVENT_HANDLER *func)
INT bm_set_cache_size(INT buffer_handle, size_t read_size, size_t write_size)
INT cm_register_transition(INT transition, INT(*func)(INT, char *), INT sequence_number)
INT cm_shutdown(const char *name, BOOL bUnique)
INT cm_yield(INT millisec)
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
INT cm_register_function(INT id, INT(*func)(INT, void **))
INT cm_connect_experiment1(const char *host_name, const char *default_exp_name, const char *client_name, void(*func)(char *), INT odb_size, DWORD watchdog_timeout)
INT cm_cleanup(const char *client_name, BOOL ignore_timeout)
INT cm_disconnect_experiment(void)
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
INT cm_set_watchdog_params(BOOL call_watchdog, DWORD timeout)
INT cm_exist(const char *name, BOOL bUnique)
#define DB_NO_MORE_SUBKEYS
#define SS_INVALID_FORMAT
#define VALIGN(adr, align)
std::string ss_gethostname()
INT ss_get_struct_align()
INT ss_getchar(BOOL reset)
INT ss_daemon_init(BOOL keep_stdout)
INT ss_sleep(INT millisec)
std::string cm_get_error(INT code)
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
BOOL equal_ustring(const char *str1, const char *str2)
INT db_delete_key(HNDLE hDB, HNDLE hKey, BOOL follow_links)
INT db_send_changed_records()
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
INT db_open_record(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
INT db_paste_xml(HNDLE hDB, HNDLE hKeyRoot, const char *buffer)
std::string strcomb1(const char **list)
INT db_get_record1(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT align, const char *rec_str)
INT db_get_record_size(HNDLE hDB, HNDLE hKey, INT align, INT *buf_size)
INT db_get_data(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
INT db_check_record(HNDLE hDB, HNDLE hKey, const char *keyname, const char *rec_str, BOOL correct)
INT db_set_mode(HNDLE hDB, HNDLE hKey, WORD mode, BOOL recurse)
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
INT db_load(HNDLE hDB, HNDLE hKeyRoot, const char *filename, BOOL bRemote)
INT db_set_data_index(HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type)
INT db_paste(HNDLE hDB, HNDLE hKeyRoot, const char *buffer)
INT db_set_data(HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
INT db_sprintf(char *string, const void *data, INT data_size, INT idx, DWORD type)
INT db_set_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type)
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
INT db_set_record(HNDLE hDB, HNDLE hKey, void *data, INT buf_size, INT align)
INT db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
INT db_close_record(HNDLE hDB, HNDLE hKey)
INT db_sscanf(const char *data_str, void *data, INT *data_size, INT i, DWORD tid)
const char * rpc_tid_name(INT id)
#define RPC_ANA_CLEAR_HISTOS
#define HRGET(A1, A2, A3)
#define HROPEN(A1, A2, A3, A4, A5, A6)
#define HBNAME(A1, A2, A3, A4)
#define HROUT(A1, A2, A3)
#define HBSET(A1, A2, A3)
#define HBOOKN(A1, A2, A3, A4, A5, A6)
#define HRPUT(A1, A2, A3)
char config_file_name[10][256]
INT write_event_odb(EVENT_HEADER *pevent)
char exp_name[NAME_LENGTH]
void register_requests(void)
char output_file_name[256]
static int sys_max_event_size
INT ana_begin_of_run(INT run_number, char *error)
static struct @2 last_time_event[50]
EVENT_DEF * db_get_event_definition(short int event_id)
INT ana_resume_run(INT run_number, char *error)
ANALYZE_REQUEST * _current_par
INT init_module_parameters(BOOL bclose)
#define ANALYZER_STATS_STR
void update_request(HNDLE hDB, HNDLE hKey, void *info)
INT write_event_ascii(FILE *file, EVENT_HEADER *pevent, ANALYZE_REQUEST *par)
INT tr_stop(INT rn, char *error)
INT tr_start(INT rn, char *error)
const char * analyzer_name
int ma_close(MA_FILE *file)
INT write_event_midas(FILE *file, EVENT_HEADER *pevent, ANALYZE_REQUEST *par)
INT tr_pause(INT rn, char *error)
BOOL debug
debug printouts
static struct @1 clp_descrip[]
int ma_read_event(MA_FILE *file, EVENT_HEADER *pevent, int size)
INT ana_pause_run(INT run_number, char *error)
INT ana_end_of_run(INT run_number, char *error)
char input_file_name[10][256]
void test_register(ANA_TEST *t)
#define ANALYZER_REQUEST_STR
void banks_changed(INT hDB, INT hKey, void *info)
void correct_num_events(INT i)
INT bor(INT run_number, char *error)
ANALYZE_REQUEST analyze_request[]
INT analyze_run(INT run_number, char *input_file_name, char *output_file_name)
void odb_load(EVENT_HEADER *pevent)
INT tr_resume(INT rn, char *error)
INT getparam(int argc, char **argv)
INT eor(INT run_number, char *error)
INT process_event(ANALYZE_REQUEST *par, EVENT_HEADER *pevent)
MA_FILE * ma_open(char *file_name)
INT load_parameters(INT run_number)
void receive_event(HNDLE buffer_handle, HNDLE request_id, EVENT_HEADER *pheader, void *pevent)
void test_write(int delta_time)
char host_name[HOST_NAME_LENGTH]
void add_data_dir(char *result, char *file)
INT bm_get_buffer_level(INT buffer_handle, INT *n_bytes)
#define DIR_SEPARATOR_STR
#define DEFAULT_WATCHDOG_TIMEOUT
void EXPRT close_subfolder(void)
#define ANA_OUTPUT_INFO_STR
#define DEFAULT_RPC_TIMEOUT
void EXPRT open_subfolder(const char *name)
#define DEFAULT_MAX_EVENT_SIZE
#define DEFAULT_BUFFER_SIZE
#define message(type, str)
static char * skip(char **buf, const char *delimiters)
TObjArray * gHistoFolderStack
TFolder * gManaHistosFolder
TCutG * cut_book(const char *name)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
char global_memory_name[8]
char histo_dump_filename[256]
char last_histo_filename[256]
char event_name[NAME_LENGTH]
char client_name[NAME_LENGTH]