]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderDateOnline.cxx
ATO-58 digitization and hit creation in anohter loop (to take into account properly...
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDateOnline.cxx
index 6a6c247e130fcea757ef43f73d1348d1722cf892..c0eaf534f0eef59a0a6a76aad668765d460af1c4 100644 (file)
@@ -27,7 +27,8 @@
 ///
 /// Cvetan Cheshkov 1/04/2008
 ///////////////////////////////////////////////////////////////////////////////
-
+#include <TSystem.h>
+#include <cstdlib>
 #include "AliRawReaderDateOnline.h"
 #include "AliLog.h"
 #ifdef ALI_DATE
 
 ClassImp(AliRawReaderDateOnline)
 
+Bool_t AliRawReaderDateOnline::fgNoSleep = kTRUE;
+
 AliRawReaderDateOnline::AliRawReaderDateOnline(
 #ifdef ALI_DATE
-                                  const char* filename
+                                    const char* filename
 #else
-                                  const char* /* filename */
+                                    const char* /* filename */
 #endif
-                                  ) :
-  AliRawReaderDate((void*)NULL)
+                                  , const Char_t** customTable) :
+  AliRawReaderDate((void*)NULL),
+  fTable(customTable),
+  fStop(kFALSE)
 {
 
 // Constructor
@@ -74,7 +79,25 @@ AliRawReaderDateOnline::AliRawReaderDateOnline(
   /* define wait event timeout - 1s max */
   monitorSetNowait();
   monitorSetNoWaitNetworkTimeout(1000);
-  
+
+  if (!fTable) {
+    const Char_t* table[]  = {"ALL", "few", "*", "*",
+                             "EOR", "yes","*", "*",
+                             NULL, NULL, NULL, NULL};
+    monitorDeclareTableExtended(const_cast<char**>(table));
+  }
+  else {
+    AliInfo("Custom monitoring table:");
+    Int_t index = 0;
+    while (fTable[index] != NULL) {
+      AliInfo(Form("%s %s %s %s",fTable[index],fTable[index+1],fTable[index+2],fTable[index+3]));
+      index += 4;
+    }
+    monitorDeclareTableExtended(const_cast<char**>(fTable));
+  }
+  // install SIGUSR1 handler to allow clean end-of-events loop
+  gSystem->AddSignalHandler(new AliRawReaderDateIntHandler(this));
+
 #else
   Fatal("AliRawReaderDateOnline", "this class was compiled without DATE");
 #endif
@@ -87,6 +110,14 @@ Bool_t AliRawReaderDateOnline::NextEvent()
 
 #ifdef ALI_DATE
 
+  // Stop on SIGUSR1
+  if (fStop) {
+    AliInfo("Raw-data reading stopped by SIGUSR1");
+    if (fEvent) free(fEvent);
+    fEvent = NULL;
+    return kFALSE;
+  }
+
   // Event already loaded no need take a new one
   if (AliRawReaderDate::NextEvent()) return kTRUE;
 
@@ -113,6 +144,7 @@ Bool_t AliRawReaderDateOnline::NextEvent()
     
     /* retry if got no event */
     if (fEvent==NULL) {
+      if (fgNoSleep) gSystem->ProcessEvents();
       continue;
     }
     
@@ -121,11 +153,15 @@ Bool_t AliRawReaderDateOnline::NextEvent()
     if (eventT==END_OF_RUN) {
       AliInfo("EOR event detected");
       Reset();
+      free(fEvent);
       fEvent = NULL;
       return kFALSE;
     }
     
     if (!IsEventSelected()) {
+      free(fEvent);
+      fEvent = NULL;
+      if (fgNoSleep) gSystem->ProcessEvents();
       continue;
     }
 
@@ -160,3 +196,38 @@ AliRawReaderDateOnline::~AliRawReaderDateOnline()
   if (fEvent) free(fEvent);
 #endif
 }
+
+void AliRawReaderDateOnline::SelectEvents(Int_t type,
+  ULong64_t triggerMask,
+  const char *triggerExpr)
+{
+  // Select event by using DATE monitoring
+  // library
+#ifdef ALI_DATE
+  const Char_t* table[]  = {"ALL", "no", "*", "*",
+                           "PHY", "yes","*", "*",
+                            "EOR", "yes","*", "*",
+                           NULL, NULL, NULL, NULL};
+  TString trSelection;
+  for (Int_t i = 0; i < 50; i++) {
+    if (triggerMask & (1ull << i)) {
+       if (!trSelection.IsNull()) trSelection += "&";
+       trSelection += Form("%d",i);
+    }
+  }
+  table[7] = trSelection.Data();
+
+  monitorLogout();
+  monitorDeclareTableExtended(const_cast<char**>(table));
+  
+#endif
+  AliRawReader::SelectEvents(type,triggerMask,triggerExpr);
+}
+
+//______________________________________________________________________________
+void AliRawReaderDateOnline::Stop()
+{
+  // Stop the event loop (called on SIGUSR1)
+
+  fStop = kTRUE; 
+}