]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderDateOnline.cxx
write also background subtracted jets to the delta AODmacros/AnalysisTrainPWG4Jets.C
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDateOnline.cxx
index 39091c854925485ce9405ed4370b187fe5dff6ce..72662e39297bf152de5ea4762f5be625df941379 100644 (file)
@@ -27,6 +27,7 @@
 ///
 /// Cvetan Cheshkov 1/04/2008
 ///////////////////////////////////////////////////////////////////////////////
+#include <TSystem.h>
 
 #include "AliRawReaderDateOnline.h"
 #include "AliLog.h"
@@ -44,7 +45,8 @@ AliRawReaderDateOnline::AliRawReaderDateOnline(
                                   const char* /* filename */
 #endif
                                   ) :
-  AliRawReaderDate((void*)NULL)
+  AliRawReaderDate((void*)NULL),
+  fStop(kFALSE)
 {
 
 // Constructor
@@ -52,6 +54,11 @@ AliRawReaderDateOnline::AliRawReaderDateOnline(
 
 #ifdef ALI_DATE
 
+
+  //  Removal of the selection of physics events
+  //  Requested by Filimon and FMD experts
+  //  fSelectEventType = PHYSICS_EVENT;
+
   int status;
 
   /* define data source : this is argument 1 */  
@@ -69,7 +76,15 @@ AliRawReaderDateOnline::AliRawReaderDateOnline(
   /* define wait event timeout - 1s max */
   monitorSetNowait();
   monitorSetNoWaitNetworkTimeout(1000);
-  
+
+  const Char_t* table[]  = {"ALL", "few", "*", "*",
+                            "EOR", "yes","*", "*",
+                            NULL, NULL, NULL, NULL};
+  monitorDeclareTableExtended(const_cast<char**>(table));
+
+  // 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
@@ -82,6 +97,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;
 
@@ -92,7 +115,7 @@ Bool_t AliRawReaderDateOnline::NextEvent()
     /* get next event (blocking call until timeout) */
     int status=monitorGetEventDynamic((void**)&fEvent);
 
-    if ((unsigned int)status==MON_ERR_EOF) {
+    if (status==MON_ERR_EOF) {
       AliInfo("End of File detected");
       Reset();
       fEvent = NULL;
@@ -116,15 +139,18 @@ Bool_t AliRawReaderDateOnline::NextEvent()
     if (eventT==END_OF_RUN) {
       AliInfo("EOR event detected");
       Reset();
+      free(fEvent);
       fEvent = NULL;
       return kFALSE;
     }
     
-    if (eventT!=PHYSICS_EVENT) {
+    if (!IsEventSelected()) {
+      free(fEvent);
+      fEvent = NULL;
       continue;
     }
 
-    AliInfo(Form("Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u",
+    AliInfo(Form("Run #%lu, event size: %lu, BC:0x%x, Orbit:0x%x, Period:0x%x",
                 (unsigned long)fEvent->eventRunNb,
                 (unsigned long)fEvent->eventSize,
                 EVENT_ID_GET_BUNCH_CROSSING(fEvent->eventId),
@@ -155,3 +181,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; 
+}