]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
JAM: avoid duplilcate filenames in case of old runid (epics). to be tested.
authorhadaq <hadaq>
Tue, 3 Apr 2012 09:29:08 +0000 (09:29 +0000)
committerhadaq <hadaq>
Tue, 3 Apr 2012 09:29:08 +0000 (09:29 +0000)
bugfix: do not discard res events for all new files, only on process startup.

hadaq/evtbuild.c

index 02ae8789e161e2d10dc537d287fec2d984754b18..c8f05e23ff5d586b1340a1da0cf996db71170195 100644 (file)
@@ -1,4 +1,4 @@
-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
@@ -502,8 +502,8 @@ static int openFile(TheArgs *theArgs, TheStats *theStats)
        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;
 
@@ -537,19 +537,17 @@ static int openFile(TheArgs *theArgs, TheStats *theStats)
        /* 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, 
@@ -561,6 +559,14 @@ static int openFile(TheArgs *theArgs, TheStats *theStats)
        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 */
@@ -899,6 +905,7 @@ int main(int argc, char *argv[])
        uint32_t currId;
 
        uint32_t lastTrigNr = 0;
+       int firstFile = 1;
 
 
 
@@ -1490,16 +1497,16 @@ int main(int argc, char *argv[])
                        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
@@ -1508,7 +1515,8 @@ int main(int argc, char *argv[])
                                         *   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);
                                        }