]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/alimdc.cxx
create a new AliEn directory per day (like for the physical files in CASTOR),
[u/mrichter/AliRoot.git] / RAW / alimdc.cxx
index 622b468f22fd9a8b2bafde5474fa882a9e56200e..7923c23d519e7664ada5621b9015e21e17acb3dd 100644 (file)
@@ -31,9 +31,57 @@ extern "C" {
 
 #include "AliRawEvent.h"
 
+//______________________________________________________________________________
+static void AliMDCErrorHandler(int level, Bool_t abort, const char *location,
+                               const char *msg)
+{
+   // The default error handler function. It prints the message on stderr and
+   // if abort is set it aborts the application. Comapared to the default
+   // ROOT error handler this one also prints the date and time in front
+   // of each message.
+
+   if (level < gErrorIgnoreLevel)
+      return;
+
+   const char *type = 0;
+
+   if (level >= kInfo)
+      type = "Info";
+   if (level >= kWarning)
+      type = "Warning";
+   if (level >= kError)
+      type = "Error";
+   if (level >= kBreak)
+      type = "\n *** Break ***";
+   if (level >= kSysError)
+      type = "SysError";
+   if (level >= kFatal)
+      type = "Fatal";
+
+   TDatime dt;
+
+   if (level >= kBreak && level < kSysError)
+      fprintf(stderr, "%s: %s %s\n", dt.AsSQLString(), type, msg);
+   else if (!location || strlen(location) == 0)
+      fprintf(stderr, "%s: %s: %s\n", dt.AsSQLString(), type, msg);
+   else
+      fprintf(stderr, "%s: %s in <%s>: %s\n", dt.AsSQLString(), type, location,
+              msg);
+
+   fflush(stderr);
+   if (abort) {
+      fprintf(stderr, "aborting\n");
+      fflush(stderr);
+      if (gSystem) {
+         gSystem->StackTrace();
+         gSystem->Abort();
+      } else
+         ::abort();
+   }
+}
 
 #ifdef USE_SMI
-void SMI_handle_command()
+static void SMI_handle_command()
 {
    // Handle SMI commands
 
@@ -47,7 +95,7 @@ void SMI_handle_command()
       strcpy(param, "");
    }
    if (strcmp(action, "STOP") == 0) {
-      gAliMDC->StopLoop();
+      if (gAliMDC) gAliMDC->SetStopLoop();
    }
    smi_set_state("RUNNING");
 }
@@ -88,6 +136,9 @@ int main(int argc, char **argv)
    // Set ROOT in batch mode
    gROOT->SetBatch();
 
+   // Set custom error handler
+   SetErrorHandler(AliMDCErrorHandler);
+
 #ifdef USE_SMI
     // Handle command line arguments
    if ((argc == 2 && (!strcmp(argv[1], "-?") || !strcmp(argv[1], "-help"))) ||
@@ -174,5 +225,13 @@ int main(int argc, char **argv)
    mdcproc.SetDebugLevel(3);
 #endif
 
-   return mdcproc.Run();
+   Int_t result = 0;
+
+   result = mdcproc.Run();
+
+   if (result == 0)
+      Info(argv[0], "normal termination of run");
+   else
+      Error(argv[0], "error termination of run, status: %d", result);
+   return result;
 }