From fd8bd08be5369a6e82adce07caf07eff46520b1d Mon Sep 17 00:00:00 2001 From: hadaq Date: Fri, 8 Oct 2010 12:30:48 +0000 Subject: [PATCH] Fixed trigger mismatch. Sergey. --- hadaq/args.h | 2 +- hadaq/debug.c | 17 +++++++------- hadaq/evtbuild.c | 58 +++++++++++++++++++++--------------------------- 3 files changed, 34 insertions(+), 43 deletions(-) diff --git a/hadaq/args.h b/hadaq/args.h index fe18018..5725b63 100644 --- a/hadaq/args.h +++ b/hadaq/args.h @@ -73,7 +73,7 @@ typedef struct TheArgsS { char fileName[PARAM_MAX_VALUE_LEN]; unsigned short multiDisks; /* Write files to diferent disks */ - unsigned long maxTrigMissmatch; + unsigned long maxTrigMismatch; char hostname[PARAM_MAX_VALUE_LEN]; } TheArgs; diff --git a/hadaq/debug.c b/hadaq/debug.c index a6e45f8..a0db7a6 100644 --- a/hadaq/debug.c +++ b/hadaq/debug.c @@ -185,14 +185,14 @@ void Debug_print(TheArgs *theArgs, TheStats *theStats, TheDebug * theDebug) } } -void Debug_printPopTrigMissmatch(TheArgs *theArgs, TheStats *theStats, TheDebug * theDebug, int qi) +void Debug_printPopTrigMismatch(TheArgs *theArgs, TheStats *theStats, TheDebug * theDebug, int qi) { int i; - storeLogInfo(theArgs, " trigger missmatch is too large. Exit."); + storeLogInfo(theArgs, " trigger mismatch is too large. Exit."); printf("\n\n"); - fprintf(stderr, " daq_evtbuild: trigger missmatch is above %d.\n", theArgs->maxTrigMissmatch); + fprintf(stderr, " daq_evtbuild: trigger mismatch is too large.\n"); printf("\n"); fputs @@ -249,18 +249,18 @@ void Debug_printPopTrigMissmatch(TheArgs *theArgs, TheStats *theStats, TheDebug } printf("\n\n"); - fprintf(stderr, " Exit.\n", theArgs->maxTrigMissmatch); + fprintf(stderr, " Exit.\n"); printf("\n"); } -void Debug_printBrokenTrigMissmatch(TheArgs *theArgs, TheStats *theStats) +void Debug_printBrokenTrigMismatch(TheArgs *theArgs, TheStats *theStats) { int i; - storeLogInfo(theArgs, " trigger missmatch is too large. Exit."); + storeLogInfo(theArgs, " trigger mismatch is too large. Exit."); printf("\n\n"); - fprintf(stderr, " daq_evtbuild: trigger missmatch is above %d.\n", theArgs->maxTrigMissmatch); + fprintf(stderr, " daq_evtbuild: trigger mismatch is too large.\n"); printf("\n"); fputs @@ -278,7 +278,6 @@ void Debug_printBrokenTrigMissmatch(TheArgs *theArgs, TheStats *theStats) } printf("\n\n"); - fprintf(stderr, " Exit.\n", theArgs->maxTrigMissmatch); + fprintf(stderr, " Exit.\n"); printf("\n"); - } diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index 2f2b69a..a34fa05 100644 --- a/hadaq/evtbuild.c +++ b/hadaq/evtbuild.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.135 2010-09-23 17:24:45 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.136 2010-10-08 12:30:52 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L #define SYSLOG_NAMES @@ -55,8 +55,6 @@ static RFILE *fRemote = NULL; #define NEVTIDS 64UL /* must be 2^n */ #define NEVTIDS_IN_FILE 0UL /* must be 2^n */ -#define CHECK_MISMATCH 0 -#define BEAM 1 #define TIMEOFFSET 1200000000 /* needed to reconstruct time from runId */ static FILE *outFile; @@ -146,7 +144,7 @@ static void usage(const char *progName) 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, " [--maxtrigmismatch 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:"); @@ -283,41 +281,35 @@ unsigned long getRunId(TheArgs *my) return myRunId; } -int is_mismatch_enough_to_stop(TheArgs *theArgs, TheStats *my) +int isMismatchCritical(TheArgs *theArgs, TheStats *my) { + int retVal = 0; + + if (theArgs->maxTrigMismatch == -1) { + return retVal; + } + /* min file size to start checking */ - unsigned long minfilesize = (theArgs->maxFileSz) * 0.1; /* 0.02 */ + unsigned long minfilesize = (theArgs->maxFileSz) * 0.2; /* max number of discarded evts allowed */ - unsigned long maxdiscarded = (*my->evtsComplete) * 0.1; /* 0.03 */ + unsigned long maxdiscarded = (*my->evtsComplete) * theArgs->maxTrigMismatch / 100; /* in % */ /* max number of evts with tag error allowed */ unsigned long maxtagerror = (*my->evtsComplete) * 0.03; if ((*my->bytesWritten) >= minfilesize && !(theArgs->ignore)) { if ((*my->evtsDiscarded) > maxdiscarded && !(theArgs->ignore)) { + retVal = 1; - syslog(LOG_ERR, " evtbuild.c: Too many events are broken!"); - syslog(LOG_ERR, " evtbuild.c: bytes written: %u, minimum file size: %u", minfilesize, (*my->bytesWritten)); - syslog(LOG_ERR, " evtbuild.c: discarded evts: %u, allowed: %u, total evts num: %u", - (*my->evtsDiscarded), maxdiscarded, (*my->evtsComplete)); -#if BEAM system("echo tagerror | netcat -w1 hadesdaq 12122"); -#endif - sleep(5); } if ((*my->evtsTagError) > maxtagerror && !(theArgs->ignore)) { + retVal = 1; - syslog(LOG_ERR, " evtbuild.c: Too many TagErrors!"); - syslog(LOG_ERR, " evtbuild.c: bytes written: %u, minimum file size: %u", minfilesize, (*my->bytesWritten)); - syslog(LOG_ERR, " evtbuild.c: tagerror evts: %u, allowed: %u, total evts num: %u", - (*my->evtsTagError), maxtagerror, (*my->evtsComplete)); - -#if BEAM system("echo tagerror | netcat -w1 hadesdaq 12122"); -#endif - sleep(5); } } - return 0; + + return retVal; } int get_file_number_in_dir(char *path) @@ -1186,8 +1178,8 @@ int main(int argc, char *argv[]) step = 0; popCnt++; - if (popCnt > theArgs->maxTrigMissmatch) { - Debug_printPopTrigMissmatch(theArgs, theStats, theDebug, i); + if (popCnt > 10000) { + Debug_printPopTrigMismatch(theArgs, theStats, theDebug, i); goto bailOut1; } } else { @@ -1225,9 +1217,12 @@ int main(int argc, char *argv[]) if (tagError) { Evt_setDataError(evt); (*theStats->evtsTagError)++; -#if CHECK_MISMATCH - is_mismatch_enough_to_stop(theArgs, theStats); -#endif + + /* Check if triggger missmatch is large enough to exit */ + if (isMismatchCritical(theArgs, theStats)) { + Debug_printBrokenTrigMismatch(theArgs, theStats); + goto bailOut1; + } } (*theStats->bytesWritten) += Evt_size(evt); writeFile(theArgs, evt); @@ -1253,13 +1248,10 @@ int main(int argc, char *argv[]) (*theStats->evtsDiscarded)++; /* Check if triggger missmatch is large enough to exit */ - if ((*theStats->evtsDiscarded) > theArgs->maxTrigMissmatch) { - Debug_printBrokenTrigMissmatch(theArgs, theStats); + if (isMismatchCritical(theArgs, theStats)) { + Debug_printBrokenTrigMismatch(theArgs, theStats); goto bailOut1; } -#if CHECK_MISMATCH - is_mismatch_enough_to_stop(theArgs, theStats); -#endif } deleteEvt(evt); -- 2.43.0