-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.163 2012-04-02 10:34:08 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.164 2012-04-03 09:29:08 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#define SYSLOG_NAMES
static char outLustrePath[_POSIX_PATH_MAX];
static char sec_path[_POSIX_PATH_MAX];
static once = 1;
- /*static unsigned long old_runNr=0;
- static unsigned open_count=0; */
+ static unsigned long old_runNr = 0;
+ static unsigned open_count = 0;
seqNr = 0;
/* JAM: check here if new run id from epics is our old run id
* this means we closed our file because of reaching file size limit
* before master ioc assigned new run id. In this case, we need to modify file name!
- * Still disabled to ensure old naming convention for analysis scripts...
* */
- /*if(old_runNr!=0 && (theArgs->runNr > old_runNr))
- {
- open_count=0; we have a real new run nr, reset file count for this run nr
- }
- else if(old_runNr!=0 && (theArgs->runNr ==old_runNr))
- {
- sprintf(msglog, "<I> openFile: begin next file %d for run id: %s", open_count,fileName);
- storeLogInfo(theArgs, msglog);
- }
- sprintf(fileName, "%s_%02d_", fileName, open_count++); file name is always run id + file count
- */
+
+ if ((theArgs->runNr == old_runNr)) {
+ open_count++;
+ sprintf(msglog, "<W> openFile: duplicate runid: Open additional file version %d for run id: %s", open_count, fileName);
+ storeLogInfo(theArgs, msglog);
+ } else {
+ open_count = 0; /*we have a real new run nr, reset file count for this run nr */
+ }
+ old_runNr = theArgs->runNr;
+
/* if ebnum == 0 then we assume that there is only 1 EB,
else
sprintf(fileName, "%s.hld", fileName);
+
+ if (open_count) {
+ sprintf(fileName, "%s-%02d", fileName, open_count); /* add cycle number to file */
+ sprintf(msglog, "<W> openFile: Using filename %s", fileName);
+ storeLogInfo(theArgs, msglog);
+ }
+
+
/* Copy file name to theArgs */
/* if( strcmp(theArgs->outDev, "file") == 0 || */
/* #ifdef RFIO */
uint32_t currId;
uint32_t lastTrigNr = 0;
+ int firstFile = 1;
if (theArgs->resdownscale) {
/* my->resstartevent */
- if (*theStats->evtsComplete < theArgs->resfirstevent) {
+ if ((firstFile != 0) && (*theStats->evtsComplete < theArgs->resfirstevent)) {
/*JAM skip first n events workaround to avoid QA crashes */
} else {
- if (*theStats->evtsComplete == theArgs->resfirstevent) {
+ if ((firstFile != 0) && (*theStats->evtsComplete == theArgs->resfirstevent)) {
/* give some debug statement that we started writing */
sprintf(msglog, "<I> Started writing resfile after %d skipped initial events", *theStats->evtsComplete);
storeLogInfo(theArgs, msglog);
+ firstFile = 0;
}
-
/*
* If the setting are as follows:
* EVENT_NUM_OFFSET == 100
* then from each 100 events only
* first 5 events are written to refFile.
*/
- if (((*theStats->evtsComplete) % EVENT_NUM_OFFSET) < theArgs->resdown_offset) {
+ if (((*theStats->evtsComplete) % EVENT_NUM_OFFSET)
+ < theArgs->resdown_offset) {
(*theStats->evtsRes)++;
Res_writeFile(evt, runNr, seqNr);
}