]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/rec/AliHLTOUTRawReader.cxx
Bug fix: AliHLTOUTRawReader
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTOUTRawReader.cxx
index 55ba12c29be2d2c19e5a1bac8859b5ec243de067..3a28937212c0b4daffa5b15c6de3b337af59d882 100644 (file)
@@ -1,45 +1,48 @@
 // $Id$
 
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project        * 
- * ALICE Experiment at CERN, All rights reserved.                         *
- *                                                                        *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
- *                  for The ALICE HLT Project.                            *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the                          * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
 
-/** @file   AliHLTOUTRawReader.cxx
-    @author Matthias Richter
-    @date   
-    @brief  HLTOUT data wrapper for AliRawReader.                         */
-
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+/// @file   AliHLTOUTRawReader.cxx
+/// @author Matthias Richter
+/// @date   
+/// @brief  HLTOUT data wrapper for AliRawReader.
+///
 
 #include "AliHLTOUTRawReader.h"
-#include "AliHLTHOMERLibManager.h"
 #include "AliRawReader.h"
-#include "AliHLTHOMERReader.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTOUTRawReader)
 
-AliHLTOUTRawReader::AliHLTOUTRawReader(AliRawReader* pRawreader)
+AliHLTOUTRawReader::AliHLTOUTRawReader()
+  :
+  AliHLTOUTHomerCollection(),
+  fpRawreader(NULL)
+{
+  // constructor
+  //
+  // HLTOUT data wrapper for AliRawReader
+  // 
+  // see header file for class documentation
+}
+
+AliHLTOUTRawReader::AliHLTOUTRawReader(AliRawReader* pRawreader, int event, AliHLTEsdManager* pEsdManager)
   :
-  AliHLTOUTHomerBuffer(NULL, 0),
-  fpRawreader(pRawreader),
-  fpCurrent(NULL)
+  AliHLTOUTHomerCollection(event, pEsdManager),
+  fpRawreader(pRawreader)
 {
   // see header file for class documentation
   // or
@@ -48,88 +51,53 @@ AliHLTOUTRawReader::AliHLTOUTRawReader(AliRawReader* pRawreader)
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-const int AliHLTOUTRawReader::fgkIdShift=16;
-
 AliHLTOUTRawReader::~AliHLTOUTRawReader()
 {
-  // see header file for class documentation
-  if (fpManager) {
-    if (fpCurrent) fpManager->DeleteReader(fpCurrent);
-    fpCurrent=NULL;
-  }
+  // destructor
 }
 
-int AliHLTOUTRawReader::GenerateIndex()
+Bool_t AliHLTOUTRawReader::ReadNextData(UChar_t*& data)
 {
-  // see header file for class documentation
-  // step through all HLT ddls, create HOMER reader and
-  // scan data block
-  int iResult=0;
-  if (fpRawreader && fpManager) {
-    fpRawreader->Reset();
-    fpRawreader->Select("HLT");
-    UChar_t* pSrc=NULL;
-    while (fpRawreader->ReadNextData(pSrc) && pSrc!=NULL && iResult>=0) {
-      AliHLTUInt32_t id=(fpRawreader->GetEquipmentId())<<fgkIdShift;
-      int size=fpRawreader->GetDataSize();
-      int offset=sizeof(AliHLTOUT::AliHLTOUTEventHeader);
-      AliHLTHOMERReader* pReader=fpManager->OpenReaderBuffer(pSrc+offset, size-offset);
-      if (pReader) {
-       iResult=ScanReader(pReader, id);
-       fpManager->DeleteReader(pReader);
-      }
-    }
-  } else {
-    iResult=-ENODEV;
-  }
-  return iResult;
+  // overloaded from AliHLTOUTHomerCollection: switch to next DDL
+  if (!fpRawreader) return kFALSE;
+  return fpRawreader->ReadNextData(data);
 }
 
-int AliHLTOUTRawReader::GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, 
-                                     AliHLTUInt32_t& size)
+int AliHLTOUTRawReader::Reset()
 {
-  // see header file for class documentation
-  int iResult=0;
-  pBuffer=NULL;
-  size=0;
-  if (fpManager) {
-    Int_t id = Int_t(index>>fgkIdShift);
-    AliHLTUInt32_t blockNo=index&((0x1<<fgkIdShift)-1);
-
-    // block from the same ddl requested?
-    if (fpCurrent && fpRawreader->GetEquipmentId()!=id) {
-      fpManager->DeleteReader(fpCurrent);
-      fpCurrent=NULL;
-    }
+  // overloaded from AliHLTOUTHomerCollection: reset DDL position
+  if (fpRawreader) return fpRawreader->Reset();
+  return 0;
+}
 
-    // open ddl for equipment id and create HOMER reader
-    if (!fpCurrent) {
-      fpRawreader->Reset();
-      fpRawreader->SelectEquipment(-1, id, id);
-      UChar_t* pSrc=NULL;
-      if (fpRawreader->ReadNextData(pSrc) && pSrc!=NULL) {
-       int srcSize=fpRawreader->GetDataSize();
-       int offset=sizeof(AliHLTOUT::AliHLTOUTEventHeader);
-       fpCurrent=fpManager->OpenReaderBuffer(pSrc+offset, srcSize-offset);
-       if (fpCurrent && fpCurrent->ReadNextEvent()!=0) {
-         iResult=-ENODATA;
-       }
-      } else {
-       iResult=-ENOSYS;
-      }
-    }
+int AliHLTOUTRawReader::GetDataSize()
+{
+  // overloaded from AliHLTOUTHomerCollection: get size of current DDL
+  if (fpRawreader) return fpRawreader->GetDataSize();
+  return 0;
+}
 
-    // get data
-    if (fpCurrent) {
-      AliHLTMonitoringReader* pReader=fpCurrent;
-      if ((pBuffer=static_cast<const AliHLTUInt8_t*>(pReader->GetBlockData(blockNo)))!=NULL) {
-       size=pReader->GetBlockDataLength(blockNo);
-      } else {
-       iResult=-ENOENT;
-      }
-    }
-  } else {
-    iResult=-ENODEV;
+AliHLTCDHWrapper AliHLTOUTRawReader::GetDataHeader()
+{
+  // overloaded from AliHLTOUTHomerCollection: get data header of current DDL
+  if (fpRawreader) {
+    if(fpRawreader->GetDataHeader())
+      return fpRawreader->GetDataHeader();
+    if(fpRawreader->GetDataHeaderV3())
+      return fpRawreader->GetDataHeaderV3();
   }
-  return iResult;
+  return NULL;
+}
+
+void AliHLTOUTRawReader::SelectEquipment(int equipmentType, int minEquipmentId, int maxEquipmentId)
+{
+  // overloaded from AliHLTOUTHomerCollection: select equipment range
+  if (fpRawreader) fpRawreader->SelectEquipment(equipmentType, minEquipmentId, maxEquipmentId);
+}
+
+int AliHLTOUTRawReader::GetEquipmentId()
+{
+  // overloaded from AliHLTOUTHomerCollection: get id of current DDL
+  if (fpRawreader) return fpRawreader->GetEquipmentId();
+  return -1;
 }