#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef SOLARIS #include #include #endif #ifdef LINUX #include #endif #include "gdecomp.h" #include "ctk.h" #define DEBUGGETEVENT 1 off_t inData; /* input file */ /*-----------------------------------------------------------------------------*/ int main (int argc, char **argv) { /* declarations */ int st, i, nn = 0, siz1, siz2, nprint = 100000; TRACK_STRUCT track; long long int type_count[100]; PAYLOAD *ptinp; GEBDATA *ptgd; double d1, lsum; GEBDATA *gd; char *payload; char str[128]; int j, checksum, *iptr; int mode, ncoin, next, nc = 1; int nbytes = 0; // int getEvent (TRACK_STRUCT *);dataCheck /* help */ if (argc != 4) { printf ("use: %s file mode nprint\n", argv[0]); printf ("\n"); printf ("mode: 1 or 2\n"); printf ("\n"); printf ("\n"); }; mode = atol (argv[2]); assert (mode == 1 || mode == 2); nprint = atol (argv[3]); /* init */ gd = (GEBDATA *) calloc (1, sizeof (GEBDATA)); payload = (char *) calloc (1, MAXDATASIZE); for (i = 0; i < 100; i++) type_count[i] = 0; /* open input file */ inData = 0; /* + name of data file */ /* | */ inData = open ((char *) argv[1], O_RDONLY); if (inData == 0) { printf ("could not open input data file \"%s\", quit!\n", argv[1]); exit (1); }; printf ("input data file \"%s\" is open\n", argv[1]); printf ("if this program crashes, it might be because it is not mode2/mode1 data\n"); printf ("the program does not check that yet\n"); fflush (stdout); /* read until we drop */ lsum = 0; st = 0; siz2 = 1; siz1 = 1; next = 0; while (siz2 > 0 && siz1 > 0) { if (mode == 1) { if (next == 0) { siz1 = read (inData, (char *) &ncoin, sizeof (int)); nbytes += siz1; next = ncoin; if (nn < nprint) if (ncoin == 1) printf ("\n---COINCIDENCE # %6i, %i member\n", nc, ncoin); else printf ("\n---COINCIDENCE# %6i, %i members\n", nc, ncoin); nc++; }; next--; }; siz1 = read (inData, (char *) gd, sizeof (GEBDATA)); if (siz1 <= 0) break; nbytes += siz1; siz2 = read (inData, (char *) payload, gd->length); if (siz2 <= 0) break; nbytes += siz2; type_count[gd->type]++; lsum++; if ((nn < nprint) || (gd->timestamp == 5411216)) { checksum = 0; iptr = (int *) payload; for (j = 0; j < (gd->length / sizeof (int)); j++) { checksum += *iptr; // printf ("%4i> %15i\n", j, *iptr); iptr++; }; printf ("%6i> ", nn); printf ("%10i ", nbytes); printf ("%4i/", siz1); printf ("%4i; ", siz2); get_GEB_Type_str (gd->type, str); printf ("%s", str); printf ("TS=%20lli ", gd->timestamp); printf ("checksum=%15i, ", checksum); printf ("\n"); fflush (stdout); }; nn++; }; printf ("\n"); printf ("%s done reading\n", argv[0]); printf ("\n"); printf ("type statistics \n"); // lsum = 0; // for (i = 0; i < 100; i++) // lsum += (double) type_count[i]; for (i = 0; i < 100; i++) if (type_count[i] > 0) { d1 = (double) type_count[i] / lsum; d1 *= 100; get_GEB_Type_str (i, str); printf ("%s, %10lli %9.2f%%\n", str, type_count[i], (float) d1); nn += type_count[i]; }; printf ("\n"); printf ("%s done, read %i header/payloads and %i bytes\n", argv[0], nn, nbytes); printf ("\n"); exit (0); }