AlcapDAQ  1
Functions | Variables
mucap_optimize.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <endian.h>
#include <byteswap.h>
#include "midas.h"
#include "mucap_structures.h"
#include "mucap_compress.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

HNDLE hDB
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 13 of file mucap_optimize.cpp.

References cm_get_environment(), compress_event(), compress_load_all(), compress_optimize_all(), event_id, exp_name, hDB, host_name, printf(), read_midas_event(), and SUCCESS.

14 {
15  char host_name[256], exp_name[32];
16 
17  cm_get_environment(host_name, sizeof(host_name), exp_name,
18  sizeof(exp_name));
19  cm_connect_experiment(host_name, exp_name, "Compression", NULL);
20  cm_get_experiment_database(&hDB, NULL);
21 
23 
24  if(argc != 2) {
25  printf("Usage: mucap_optimize uncompressed_input.mid\n");
26  exit(1);
27  }
28 
29  FILE *fp = fopen(argv[1], "r");
30  if (!fp) {
31  printf("Unable to open %s\n", argv[1]);
32  exit(1);
33  }
34 
35  char *input_event = new char[MAX_EVENT_SIZE];
36  char *output_event = new char[MAX_EVENT_SIZE];
37 
38  while (read_midas_event(fp, input_event) == SUCCESS) {
39  EVENT_HEADER header = *((EVENT_HEADER *) input_event);
40 
41  int event_id = header.event_id;
42 
43  if (event_id == EVENTID_BOR || event_id == EVENTID_EOR ||
44  event_id == EVENTID_MESSAGE) {
45 
46  continue;
47  }
48 
49  bk_init32(output_event);
50  compress_event(input_event + sizeof(EVENT_HEADER), output_event);
51  }
52 
54 
55  fclose(fp);
56 
57  cm_disconnect_experiment();
58 }

Variable Documentation

HNDLE hDB

Definition at line 11 of file mucap_optimize.cpp.