-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.123 2010-07-23 13:45:02 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.124 2010-07-30 09:18:59 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#define SYSLOG_NAMES
char fileName[PARAM_MAX_VALUE_LEN];
unsigned short multiDisks; /* Write files to diferent disks */
+
+ unsigned long maxTrigMissmatch;
} TheArgs;
typedef struct TheStatsS {
syslog(LOG_ERR, " [--lustre path_to_lustre] Output path for writing data on the Lustre cluster (if mounted).");
syslog(LOG_ERR, " [--orapath path] Path to eb_runinfo2ora.txt for writing data to Oracle.");
syslog(LOG_ERR, " [--ignore] Ignore trigger mismatch conditions.");
+ syslog(LOG_ERR, " [--maxtrigmissmatch number] Maximum number of triggers allowed for missmatch.");
syslog(LOG_ERR, " [--multidisk] Write data to a disk number provided by daq_disks via shared memory.");
syslog(LOG_ERR, "");
syslog(LOG_ERR, "Options for debugging:");
my->debugOpts[i] = my->debugOptsS[i];
}
my->debugOptsCnt = 0;
+
+ my->maxTrigMissmatch = 100000;
}
static int argsFromCL(TheArgs *my, int argc, char *argv[])
{"debug", 1, 0, 'D'},
{"trigtype", 1, 0, 'T'},
{"multidisks", 0, 0, 'k'},
+ {"maxtrigmissmatch", 1, 0, 'g'},
{0, 0, 0, 0}
};
- i = getopt_long(argc, argv, "am:f:r:o:d:q:Q:p:v:x:I:tz:e:n:h:w:Hs:l:R:A:bEL:S:B:O:iW:M:F:X:C:D:T:k", long_options,
+ i = getopt_long(argc, argv, "am:f:r:o:d:q:Q:p:v:x:I:tz:e:n:h:w:Hs:l:R:A:bEL:S:B:O:iW:M:F:X:C:D:T:kg:", long_options,
&option_index);
if (i == -1)
break;
case 'O':
sprintf(my->runinfo2ora, "%s_runinfo2ora.txt", getenv("DAQ_SETUP"));
break;
+ case 'g':
+ my->maxTrigMissmatch = strtoul(optarg, NULL, 0);
+ break;
case 'H':
return -1;
break;
}
}
+static void printPopTrigMissmatch(TheArgs *theArgs, TheStats *theStats, TheDebug * theDebug, int qi)
+{
+ int i;
+
+ printf("\n\n");
+ fprintf(stderr, "<E> daq_evtbuild: trigger missmatch is above %d.\n", theArgs->maxTrigMissmatch);
+
+ printf("\n");
+ fputs
+ ("---------------------------- error: discarded triggers ----------------------------------------------------------------\n",
+ stderr);
+ printf("%7s", "Queue");
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
+ printf("%9d", i);
+ }
+ printf("\n");
+
+ if (theArgs->debugOptsCnt) {
+ int j;
+
+ /* First print last succesfuly built event */
+ if (theArgs->debug_trignr) {
+ printf("%7s", "trigNr");
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
+ printf(" %08x", theDebug->evtsLastBuilt[i]);
+ }
+ printf("\n");
+ }
+
+ int maxEvts = 0;
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
+ if (maxEvts < theDebug->evtsBrokenCnt[i])
+ maxEvts = theDebug->evtsBrokenCnt[i];
+ }
+
+ for (j = 0; j < maxEvts; j++) {
+
+ /* Print trigger numbers */
+ if (theArgs->debug_trignr) {
+ printf("%7s", "trigNr");
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
+ if (j < theDebug->evtsBrokenCnt[i]) {
+ printf(" %08x", theDebug->evtsBroken[i][j]);
+ } else {
+ printf("%9s", "-");
+ }
+ }
+ printf("\n");
+ }
+ }
+ }
+
+ printf("%7s", "lastNr");
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
+ if (i <= qi) {
+ printf(" %08x", (*theStats->trigNr[i]));
+ } else {
+ printf("%9s", "-");
+ }
+ }
+
+ printf("\n\n");
+ fprintf(stderr, "<E> Exit.\n", theArgs->maxTrigMissmatch);
+ printf("\n");
+}
+
+static void printBrokenTrigMissmatch(TheArgs *theArgs, TheStats *theStats)
+{
+ int i;
+
+ printf("\n\n");
+ fprintf(stderr, "<E> daq_evtbuild: trigger missmatch is above %d.\n", theArgs->maxTrigMissmatch);
+ printf("\n");
+
+ fputs
+ ("---------------------------- error: discarded triggers ----------------------------------------------------------------\n",
+ stderr);
+ printf("%7s", "Queue");
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
+ printf("%9d", i);
+ }
+ printf("\n");
+
+ printf("%7s", "lastNr");
+ for (i = 0; i < theArgs->nrOfMsgs; i++) {
+ printf(" %08x", (*theStats->trigNr[i]));
+ }
+
+ printf("\n\n");
+ fprintf(stderr, "<E> Exit.\n", theArgs->maxTrigMissmatch);
+ printf("\n");
+
+}
+
static void add2Stat(TheArgs *theArgs, TheStats *my, float interval, ShmTrans **shmtr)
{
/* Add statistic for fill levels of buffers in percentage. */
return returned;
}
-static void changeData(int once, TheArgs *theArgs, TheStats *theStats)
+static void changeDisk(int once, TheArgs *theArgs, TheStats *theStats)
{
if (theArgs->multiDisks) {
theArgs->runNr = runNr;
if (once) {
- changeData(once, theArgs, theStats);
+ changeDisk(once, theArgs, theStats);
file_size = theArgs->maxFileSz;
strcpy(sec_path, theArgs->sec_path);
strcpy(outPath, theArgs->outPath);
strcpy(theArgs->outPath, outPath);
strcpy(theArgs->lustrePath, outLustrePath);
strcpy(theArgs->sec_path, sec_path);
- changeData(once, theArgs, theStats);
+ changeDisk(once, theArgs, theStats);
}
/* construct a default filename */
rfio_openConnection(theArgs, theStats);
#endif
- uint32_t trigType;
- uint32_t lastCurrTrigNr = 0;
int brokenEvtCnt = 0;
+ unsigned long popCnt = 0;
currId = 0;
+
while (setjmp(terminateJmp) == 0) {
void *evt;
void *subEvt;
}
}
-
evt = newEvt(EvtDecoding_64bitAligned, EvtId_data);
+ popCnt = 0; /* Counter of popped up subevents */
for (i = 0; i < theArgs->nrOfMsgs && !evtIsBroken; i += step) {
uint32_t trigNr;
evt = Evt_appendSubEvt(evt, subEvt);
}
+
HadTuQueue_pop(hadTuQueue[i]);
step = 1;
} else if (trigNr < currTrigNr) {
/* BUGBUG subevt discarded, not in statistic */
HadTuQueue_pop(hadTuQueue[i]);
step = 0;
+
+ popCnt++;
+ if (popCnt > theArgs->maxTrigMissmatch) {
+ fprintf(stderr, "<E> daq_evtbuild: trigger missmatch is above %d. Exit.\n", theArgs->maxTrigMissmatch);
+ printPopTrigMissmatch(theArgs, theStats, theDebug, i);
+ goto bailOut1;
+ }
} else {
if (theArgs->debugOptsCnt)
brokenEvtCnt = fillDebug(theArgs, theStats, theDebug, i, "broken");
Evt_online(evt);
} else {
(*theStats->evtsDiscarded)++;
+
+ /* Check if triggger missmatch is large enough to exit */
+ if ((*theStats->evtsDiscarded) > theArgs->maxTrigMissmatch) {
+ printBrokenTrigMissmatch(theArgs, theStats);
+ goto bailOut1;
+ }
#if CHECK_MISMATCH
is_mismatch_enough_to_stop(theArgs, theStats);
#endif
}
}
+ bailOut1:
+
ourTime = time(NULL);
closeFile();