/* Analyze L1 Specific Trigger Overlap Revision: 24-AUG-1994 by Daniel Edmunds */ #include /* I/O definitions */ #define MAXLINE 80 #define CHAROFFSET 19 int counter[40][40]; main () { int fndx, sndx, charndx, sptrgndx, count_events, physics_events; int fired, kndx, lndx; extern int counter[40][40]; char line[135]; char outstr[135]; FILE *fp, *fopen(); FILE *fpout, *fopen(); fp = fopen("SpTrg_Fired_List_2215_2NOV94.txt", "r"); fpout = fopen("Temp.txt", "w"); for (fndx = 0; fndx <= 32; ++fndx) { for (sndx = 0; sndx <= 32; ++sndx) counter[fndx][sndx] = 0; } count_events = 0; fgets(line, MAXLINE, fp); while (line[0] != NULL) { ++count_events; first_scan(line); fgets(line, MAXLINE, fp); } physics_events = count_events - counter[31][31]; sprintf(outstr, "\n Number of Events Processed = %d \n", count_events); fputs(outstr, fpout); sprintf(outstr, " Number of Monitor Data Only Events = %d \n", counter[31][31]); fputs(outstr, fpout); sprintf(outstr, " Number of Physics Events = %d \n", physics_events ); fputs(outstr, fpout); for (sptrgndx = 31; sptrgndx >= 0; --sptrgndx) { fired = counter[sptrgndx][sptrgndx]; sprintf(outstr, "\n\n\n Specific Trigger = %d", sptrgndx); fputs(outstr, fpout); sprintf(outstr, " This Spec Trig Fired %d times. \n", fired); fputs(outstr, fpout); sprintf(outstr, "\n Overlap Counts with Spec Trig's 31:0 \n"); fputs(outstr, fpout); for (lndx = 0; lndx <= 3; ++lndx){ for (kndx = 0; kndx <= 7; ++kndx){ sprintf(outstr, "%6d%c", counter[sptrgndx][31 - kndx - (8 * lndx)], (kndx == 7) ? '\n' : ' '); fputs(outstr, fpout); } } sprintf(outstr, "\n Percentage Overlap with Spec Trig's 31:0 \n"); fputs(outstr, fpout); if (fired == 0) fired = 100000000; for (lndx = 0; lndx <= 3; ++lndx){ for (kndx = 0; kndx <= 7; ++kndx){ sprintf(outstr, "%6d%c", ((100 * counter[sptrgndx] [31 - kndx - (8 * lndx)]) / fired), (kndx == 7) ? '\n' : ' '); fputs(outstr, fpout); } } } fclose(fp); fclose(fpout); } /* First Scan Routine */ first_scan(myline) char myline[135]; { extern int counter[40][40]; int charndx, bndx; unsigned thischar; for (charndx = 0; charndx <= 7; ++charndx) { thischar = myline[charndx + CHAROFFSET]; for (bndx = 0; bndx <= 3; ++bndx) { if (thischar & 01) search(28 + bndx - (4 * charndx), myline); thischar >>= 1; } } } /* Second Scan and Counter Increment Routine */ search(ndxf, myline) int ndxf; char myline[135]; { extern int counter[40][40]; int charndx, bndx; unsigned thischar; for (charndx = 0; charndx <= 7; ++charndx) { thischar = myline[charndx + CHAROFFSET]; for (bndx = 0; bndx <= 3; ++bndx) { if (thischar & 01) ++counter[ndxf][28 + bndx - (4 * charndx)]; thischar >>= 1; } } }