]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderRoot.cxx
2D Centrality files
[u/mrichter/AliRoot.git] / RAW / AliRawReaderRoot.cxx
index ec519f9f186290c413c2d7832f755bf6c79f3512..1fde2b8018387b002b2f991c708449121463234b 100644 (file)
@@ -402,6 +402,10 @@ Bool_t AliRawReaderRoot::ReadHeader()
 
       // get the next equipment and raw data
       fCount = 0;
+      if (fEquipmentIndex >= fSubEvent->GetNEquipments()) {
+       fEquipment = NULL;
+       continue;
+      }
       fEquipment = fSubEvent->GetEquipment(fEquipmentIndex++);
       if (!fEquipment) continue;
       if (!IsSelected()) {
@@ -424,7 +428,7 @@ Bool_t AliRawReaderRoot::ReadHeader()
       // check that there are enough bytes left for the data header
       if (fPosition + sizeof(AliRawDataHeader) > fEnd) {
        Error("ReadHeader", "could not read data header!");
-       Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition);
+       Warning("ReadHeader", "skipping %ld bytes", fEnd - fPosition);
        fEquipment->GetEquipmentHeader()->Dump();
        fCount = 0;
        fPosition = fEnd;
@@ -441,7 +445,7 @@ Bool_t AliRawReaderRoot::ReadHeader()
       if ((fPosition + fHeader->fSize) != fEnd) {
        if (fHeader->fSize != 0xFFFFFFFF)
          Warning("ReadHeader",
-                 "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+                 "Equipment %d : raw data size found in the header is wrong (%d != %ld)! Using the equipment size instead !",
                  fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
        fHeader->fSize = fEnd - fPosition;
       }
@@ -454,7 +458,7 @@ Bool_t AliRawReaderRoot::ReadHeader()
       // check consistency of data size in the header and in the sub event
       if (fPosition + fCount > fEnd) {  
        Error("ReadHeader", "size in data header exceeds event size!");
-       Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition);
+       Warning("ReadHeader", "skipping %ld bytes", fEnd - fPosition);
        fEquipment->GetEquipmentHeader()->Dump();
        fCount = 0;
        fPosition = fEnd;
@@ -619,6 +623,10 @@ Int_t AliRawReaderRoot::CheckData() const
     }
 
     // get the next equipment and raw data
+    if (equipmentIndex >= subEvent->GetNEquipments()) {
+      equipment = NULL;
+      continue;
+    }
     equipment = subEvent->GetEquipment(equipmentIndex++);
     if (!equipment) continue;
     AliRawData* rawData = equipment->GetRawData();
@@ -641,7 +649,7 @@ Int_t AliRawReaderRoot::CheckData() const
       if ((position + header->fSize) != end) {
        if (header->fSize != 0xFFFFFFFF)
          Warning("ReadHeader",
-                 "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+                 "Equipment %d : raw data size found in the header is wrong (%d != %ld)! Using the equipment size instead !",
                  equipment->GetEquipmentHeader()->GetId(),header->fSize, end - position);
        header->fSize = end - position;
        result |= kErrSize;
@@ -652,3 +660,32 @@ Int_t AliRawReaderRoot::CheckData() const
 
   return result;
 }
+
+AliRawReader* AliRawReaderRoot::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)
+
+  if (fEvent) {
+    // Root formatted raw data
+    AliRawVEvent *gdcRootEvent = (AliRawVEvent*)fEvent->Clone();
+    for (Int_t ldcCounter=0; ldcCounter < gdcRootEvent->GetNSubEvents(); ldcCounter++) {
+      AliRawVEvent *ldcRootEvent = gdcRootEvent->GetSubEvent(ldcCounter);
+      AliRawVEvent *subEvent = fEvent->GetSubEvent(ldcCounter);
+      for (Int_t eqCounter=0; eqCounter < ldcRootEvent->GetNEquipments(); eqCounter++) {
+       AliRawVEquipment *equipment=ldcRootEvent->GetEquipment(eqCounter);
+       AliRawVEquipment *eq = subEvent->GetEquipment(eqCounter);
+       equipment->CloneRawData(eq->GetRawData());
+      }
+    }
+    // Reset original event and newly
+    // produced one
+    gdcRootEvent->GetSubEvent(-1);
+    fEvent->GetSubEvent(-1);
+    return new AliRawReaderRoot(gdcRootEvent);
+  }
+  return NULL;
+}