New raw-reader class which deals with events taken from shared memory via the DATE...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 Apr 2008 13:22:01 +0000 (13:22 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 Apr 2008 13:22:01 +0000 (13:22 +0000)
RAW/AliRawReaderDateOnline.cxx
RAW/AliRawReaderDateOnline.h
RAW/RAWrecOnlineLinkDef.h [new file with mode: 0644]
RAW/libRAWDatarecOnline.pkg [new file with mode: 0644]
build/module.dep

index c77039c..39091c8 100644 (file)
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "AliRawReaderDateOnline.h"
+#include "AliLog.h"
+#ifdef ALI_DATE
+#include "event.h"
+#include "monitor.h"
+#endif
 
 ClassImp(AliRawReaderDateOnline)
 
-AliRawReaderDate::AliRawReaderDate(
+AliRawReaderDateOnline::AliRawReaderDateOnline(
 #ifdef ALI_DATE
                                   const char* filename
 #else
                                   const char* /* filename */
 #endif
                                   ) :
-  AliRawReaderDate()
+  AliRawReaderDate((void*)NULL)
 {
 
 // Constructor
@@ -50,7 +55,7 @@ AliRawReaderDate::AliRawReaderDate(
   int status;
 
   /* define data source : this is argument 1 */  
-  status=monitorSetDataSource( filename );
+  status=monitorSetDataSource( (char* )filename );
   if (status!=0) {
     AliFatal(Form("monitorSetDataSource() failed : %s",monitorDecodeError(status)));
   }
@@ -70,60 +75,83 @@ AliRawReaderDate::AliRawReaderDate(
 #endif
 }
 
-Bool_t AliRawReaderDate::NextEvent()
+Bool_t AliRawReaderDateOnline::NextEvent()
 {
 // wait and get the next event
 // from shared memory
 
 #ifdef ALI_DATE
 
+  // Event already loaded no need take a new one
+  if (AliRawReaderDate::NextEvent()) return kTRUE;
+
   if (fEvent) free(fEvent);
+  fEvent = NULL;
 
   while (1) {
     /* get next event (blocking call until timeout) */
-    int status=monitorGetEventDynamic(&fEvent);
-    struct eventHeaderStruct *event=(eventHeaderStruct*)eventPtr;
+    int status=monitorGetEventDynamic((void**)&fEvent);
 
-    if (status==MON_ERR_EOF) {
+    if ((unsigned int)status==MON_ERR_EOF) {
       AliInfo("End of File detected");
+      Reset();
+      fEvent = NULL;
       return kFALSE; /* end of monitoring file has been reached */
     }
     
     if (status!=0) {
       AliError(Form("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)));
+      Reset();
+      fEvent = NULL;
       return kFALSE;
     }
     
     /* retry if got no event */
-    if (event==NULL) {
+    if (fEvent==NULL) {
       continue;
     }
-
-    eventTypeType eventT=event->eventType;
+    
+    eventTypeType eventT=fEvent->eventType;
     /* exit when last event received, no need to wait for TERM signal */
     if (eventT==END_OF_RUN) {
       AliInfo("EOR event detected");
+      Reset();
+      fEvent = NULL;
       return kFALSE;
     }
+    
     if (eventT!=PHYSICS_EVENT) {
       continue;
     }
 
     AliInfo(Form("Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u",
-                (unsigned long)event->eventRunNb,
-                (unsigned long)event->eventSize,
-                EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
-                EVENT_ID_GET_ORBIT(event->eventId),
-                EVENT_ID_GET_PERIOD(event->eventId)
+                (unsigned long)fEvent->eventRunNb,
+                (unsigned long)fEvent->eventSize,
+                EVENT_ID_GET_BUNCH_CROSSING(fEvent->eventId),
+                EVENT_ID_GET_ORBIT(fEvent->eventId),
+                EVENT_ID_GET_PERIOD(fEvent->eventId)
                 ));
+    break;
   }
 
-  return AliRawRederDate::NextEvent();
-}
+  fEventNumber++;
+  Reset();
 
-#endif
+  return kTRUE;
 
+}
+
+#else
   return kFALSE;
 }
+#endif
 
+AliRawReaderDateOnline::~AliRawReaderDateOnline()
+{
+// Destructor
+// Free the last event in shared memory
 
+#ifdef ALI_DATE
+  if (fEvent) free(fEvent);
+#endif
+}
index 0bca8ee..e33678b 100644 (file)
@@ -26,7 +26,7 @@ class AliRawReaderDateOnline: public AliRawReaderDate {
     virtual ~AliRawReaderDateOnline();
 
     virtual Bool_t   NextEvent();
-    virtual Bool_t   RewindEvents();
+    //    virtual Bool_t   RewindEvents();
 
   private:
     AliRawReaderDateOnline(const AliRawReaderDateOnline& rawReader);
diff --git a/RAW/RAWrecOnlineLinkDef.h b/RAW/RAWrecOnlineLinkDef.h
new file mode 100644 (file)
index 0000000..5cf07ae
--- /dev/null
@@ -0,0 +1,9 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliRawReaderDateOnline+;
+
+#endif
diff --git a/RAW/libRAWDatarecOnline.pkg b/RAW/libRAWDatarecOnline.pkg
new file mode 100644 (file)
index 0000000..8e2ecee
--- /dev/null
@@ -0,0 +1,20 @@
+#-*- Mode: Makefile -*-
+
+SRCS:=  AliRawReaderDateOnline.cxx
+
+HDRS:= $(SRCS:.cxx=.h)
+
+HDRS +=
+
+DHDR:= RAWrecOnlineLinkDef.h 
+
+ifdef DATE_ROOT
+EINCLUDE+= ${DATE_COMMON_DEFS}
+TEMPDATELIBS:=$(shell date-config --monitorlibs)
+ELIBS+=$(patsubst lib%,%,$(basename $(notdir $(filter %.a,$(TEMPDATELIBS)))))
+ELIBSDIR+=$(dir $(filter %.a,$(TEMPDATELIBS)))
+ELIBS+=$(patsubst -l%,%,$(filter -l%,$(TEMPDATELIBS)))
+ELIBSDIR+=$(patsubst -L%,%,$(filter -L%,$(TEMPDATELIBS)))
+endif
+
+EXPORT:=AliRawReaderDateOnline.h
index 5c3b46e..b25a910 100644 (file)
@@ -25,7 +25,7 @@ PHOS/module.mk:               PHOS/libPHOSbase.pkg PHOS/libPHOSsim.pkg PHOS/libPHOSrec.pkg PH
 PMD/module.mk:         PMD/libPMDbase.pkg PMD/libPMDsim.pkg PMD/libPMDrec.pkg
 PYTHIA6/module.mk:     PYTHIA6/libpythia6.pkg PYTHIA6/libAliPythia6.pkg
 RALICE/module.mk:      RALICE/libRALICE.pkg
-RAW/module.mk:         RAW/libRAWDatabase.pkg RAW/libRAWDatasim.pkg RAW/libRAWDatarec.pkg RAW/binalimdc.pkg RAW/bindateStream.pkg RAW/binalirawdump.pkg RAW/libMDC.pkg RAW/libMDCFilter.pkg
+RAW/module.mk:         RAW/libRAWDatabase.pkg RAW/libRAWDatasim.pkg RAW/libRAWDatarec.pkg RAW/binalimdc.pkg RAW/bindateStream.pkg RAW/binalirawdump.pkg RAW/libMDC.pkg RAW/libMDCFilter.pkg RAW/libRAWDatarecOnline.pkg
 HMPID/module.mk:       HMPID/libHMPIDbase.pkg HMPID/libHMPIDrec.pkg HMPID/libHMPIDsim.pkg
 SHUTTLE/module.mk:     SHUTTLE/libSHUTTLE.pkg SHUTTLE/TestShuttle/TestShuttle.pkg
 T0/module.mk:          T0/libT0base.pkg T0/libT0sim.pkg T0/libT0rec.pkg T0/libT0shuttle.pkg