/* find length of skimmed event */ SkimEvLen = hdr.len_clean + 1; if (curBufPos + SkimEvLen >= SKIMBUFSIZE) { /* pad output buffer */ for (ubi = curBufPos + 1; curBufPos < SKIMBUFSIZE; curBufPos++) outbuf[ubi] = 0; /* flush current buffer to disk */ siz = write(fpDisk, (char *) outbuf, SKIMBUFSIZE); if (siz != SKIMBUFSIZE) printf("error writing skimmed buffer to tape\n"); curBufPos = 0; curFileSiz += SKIMBUFSIZE; /* open a new chunck? */ if (curFileSiz > MAXSKIMFILESIZE) { close(fpDisk); ubChunck++; /* find the new file name */ strcpy(outfn,skimFileName); outfn[strlen(outfn)-1]=95; /*underscore*/ outfn[strlen(outfn)]=0; /*term*/ sprintf(str, "%2.2i.sda", ubChunck); strcat(outfn,str); /* open the file */ fpDisk = open(outfn, O_WRONLY | O_CREAT, 0644); if (fpDisk == -1) { printf("could not open skim file [%s]\n", outfn); return (-1); } else { printf("skimfile open [%s]\n", outfn); fflush(stdout); }; curFileSiz=0; }; } else { /* store event in very simple skimmed format */ /* first multiplicity */ outbuf[curBufPos++] = hdr.len_clean; /* then just the energies of the clean germaniums */ for (ubj = 0; ubj < hdr.len_clean; ubj++) outbuf[curBufPos++] = ev[ubj].ehi; };