-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.157 2011-11-28 11:52:08 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.158 2012-02-22 13:54:48 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#define SYSLOG_NAMES
#define QUEUE_FLUSH_FAST 1
/*define this to get log output of first 10 triggernumbers*/
-#define TRIGNO_DEBUG 1
+/*#define TRIGNO_DEBUG 1*/
#define NEVTIDS 64UL /* must be 2^n */
#define NEVTIDS_IN_FILE 0UL /* must be 2^n */
uint32_t currTrigTag;
uint32_t currId;
- uint32_t failTrigNr = 0;
+ uint32_t lastTrigNr = 0;
+
+
+
signal(SIGINT, sigHandler);
signal(SIGTERM, sigHandler);
}
(*theStats->evtsComplete)++;
+ lastTrigNr = currTrigNr; /* note last complete event id for loss stats JAM */
(*theStats->evtId[currId & (NEVTIDS - 1)])++;
Evt_setId(evt, currId & (NEVTIDS_IN_FILE - 1));
if (theArgs->online)
Evt_online(evt);
} else {
- (*theStats->evtsDiscarded)++;
-
+ if (lastTrigNr) {
+ /* check how many events we did lose since last complete one: */
+ (*theStats->evtsDiscarded) += currTrigNr - lastTrigNr;
+ sprintf(msglog, "<I> Discarded %d events at TrigNr: 0x%06x", currTrigNr - lastTrigNr, currTrigNr);
+ storeLogInfo(theArgs, msglog);
+ lastTrigNr = 0;
+ } else {
+ sprintf(msglog, "<W> Found No valid last trigger nr at TrigNr: 0x%06x", currTrigNr);
+ storeLogInfo(theArgs, msglog);
+ (*theStats->evtsDiscarded)++;
+ }
/* Check if triger mismatch is large enough to exit */
if (isMismatchCritical(theArgs, theStats)) {
Debug_printBrokenTrigMismatch(theArgs, theStats);