Increasing histo clu. lay.1 upper lim.
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDate.cxx
index fa0ef4c..8553e19 100644 (file)
@@ -34,9 +34,9 @@ ClassImp(AliRawReaderDate)
 
 AliRawReaderDate::AliRawReaderDate(
 #ifdef ALI_DATE
-                                  void* event
+                                  void* event, Bool_t owner
 #else
-                                  void* /* event */
+                                  void* /* event */, Bool_t owner
 #endif
                                   ) :
   fFile(NULL),
@@ -44,7 +44,8 @@ AliRawReaderDate::AliRawReaderDate(
   fSubEvent(NULL),
   fEquipment(NULL),
   fPosition(NULL),
-  fEnd(NULL)
+  fEnd(NULL),
+  fOwner(owner)
 {
 // create an object to read digits from the given date event
 
@@ -68,7 +69,8 @@ AliRawReaderDate::AliRawReaderDate(
   fSubEvent(NULL),
   fEquipment(NULL),
   fPosition(NULL),
-  fEnd(NULL)
+  fEnd(NULL),
+  fOwner(kTRUE)
 {
 // create an object to read digits from the given date event
 
@@ -107,7 +109,8 @@ AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) :
   fSubEvent(rawReader.fSubEvent),
   fEquipment(rawReader.fEquipment),
   fPosition(rawReader.fPosition),
-  fEnd(rawReader.fEnd)
+  fEnd(rawReader.fEnd),
+  fOwner(rawReader.fOwner)
 
 {
 // copy constructor
@@ -129,8 +132,8 @@ AliRawReaderDate::~AliRawReaderDate()
 // destructor
 
 #ifdef ALI_DATE
+  if (fEvent && fOwner) delete[] fEvent;
   if (fFile) {
-    delete[] fEvent;
     fclose(fFile);
   }
 #endif
@@ -636,3 +639,26 @@ Int_t AliRawReaderDate::CheckData() const
 #endif
   return 0;
 }
+
+AliRawReader* AliRawReaderDate::CloneSingleEvent() const
+{
+  // Clones the current event and
+  // creates raw-reader for the cloned event
+  // Can be used in order to make asynchronious
+  // access to the current raw data within
+  // several threads (online event display/reco)
+
+#ifdef ALI_DATE
+  if (fEvent) {
+    UInt_t evSize = fEvent->eventSize;
+    if (evSize) {
+      UChar_t *newEvent = new UChar_t[evSize];
+      memcpy(newEvent,fEvent,evSize);
+      return new AliRawReaderDate((void *)newEvent,kTRUE);
+    }
+  }
+#else
+  Fatal("AliRawReaderDate", "this class was compiled without DATE");
+#endif
+  return NULL;
+}