]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/rec/AliRawReaderHLT.cxx
The description of changes:
[u/mrichter/AliRoot.git] / HLT / rec / AliRawReaderHLT.cxx
index 0f20a5560971dce646cc9f9a81e4ac203b8e83f3..d7091da132c125160333358a12df97a57c35f663 100644 (file)
@@ -34,6 +34,7 @@
 #include "AliHLTOUTHandler.h"
 #include "AliHLTOUTHandlerEquId.h"
 #include "AliHLTSystem.h"
+#include "AliHLTPluginBase.h"
 #include "AliLog.h"
 #include "AliDAQ.h"            // RAW, for detector names and equipment ids
 #include "TObjString.h"
@@ -45,7 +46,6 @@ ClassImp(AliRawReaderHLT)
 AliRawReaderHLT::AliRawReaderHLT(AliRawReader* pRawreader, const char* options)
   :
   AliRawReader(),
-  AliHLTReconstructorBase(),
   fpParentReader(pRawreader),
   fOptions(),
   fSystemOptions(),
@@ -58,7 +58,8 @@ AliRawReaderHLT::AliRawReaderHLT(AliRawReader* pRawreader, const char* options)
   fDetectors(),
   fpHLTOUT(NULL),
   fbReadFirst(true),
-  fpDataHandler(NULL)
+  fpDataHandler(NULL),
+  fpPluginBase(new AliHLTPluginBase)
 {
   // see header file for class documentation
   // or
@@ -73,6 +74,8 @@ AliRawReaderHLT::~AliRawReaderHLT()
 {
   // see header file for class documentation
   ReleaseHLTData();
+  if (fpPluginBase) delete fpPluginBase;
+  fpPluginBase=NULL;
 }
 
 UInt_t AliRawReaderHLT::GetType() const
@@ -190,13 +193,13 @@ Bool_t   AliRawReaderHLT::ReadHeader()
   // see header file for class documentation
   Bool_t result=kFALSE;
   Bool_t firstParentCycle=fbHaveHLTData;
-  while (fbHaveHLTData=(fbHaveHLTData && ReadNextHLTData())) {
+  while ((fbHaveHLTData=(fbHaveHLTData && ReadNextHLTData()))) {
     // all internal data variables set
     assert(fpData!=NULL);
     fHeader=reinterpret_cast<AliRawDataHeader*>(const_cast<AliHLTUInt8_t*>(fpData));
     fOffset=sizeof(AliRawDataHeader);
     fPosition=fOffset;
-    if (result=IsSelected()) break;
+    if ((result=IsSelected())) break;
   }
   firstParentCycle&=!fbHaveHLTData; // true if it just changed from true to false
   while (!result) {
@@ -212,15 +215,24 @@ Bool_t   AliRawReaderHLT::ReadHeader()
       break;
     }
     fHeader=const_cast<AliRawDataHeader*>(fpParentReader->GetDataHeader());
+    fDataSize=fpParentReader->GetDataSize();
+    fPosition=0;
+    fpData=NULL;
 
     // filter out all equipment ids which should be taken from the HLT stream
     int id=fpParentReader->GetEquipmentId();
-    if (result=!IsHLTInput(id)) break;
+    if ((result=!IsHLTInput(id))) break;
   }
   return result;
 }
 
 Bool_t   AliRawReaderHLT::ReadNextData(UChar_t*& data)
+{
+  // see header file for class documentation
+  return ReadNextData(data, kTRUE);
+}
+
+Bool_t   AliRawReaderHLT::ReadNextData(UChar_t*& data, Bool_t readHeader)
 {
   // see header file for class documentation
 
@@ -230,7 +242,7 @@ Bool_t   AliRawReaderHLT::ReadNextData(UChar_t*& data)
   Bool_t result=kTRUE;
 
   // read new header if data already read
-  if (fPosition<fDataSize || (result=ReadHeader())) {
+  if (fPosition<fDataSize || (result=(readHeader && ReadHeader()))) {
     if (fbHaveHLTData && fpHLTOUT!=NULL) {
       // all internal data variables set
       result=kTRUE;
@@ -271,7 +283,7 @@ Bool_t   AliRawReaderHLT::ReadNextInt(UInt_t& data)
       fOffset+=iCopy;
       return kTRUE;
     }
-  } while (ReadNextData(dummy));
+  } while (ReadNextData(dummy, kTRUE));
   return kFALSE;
 }
 
@@ -286,7 +298,7 @@ Bool_t   AliRawReaderHLT::ReadNextShort(UShort_t& data)
       fOffset+=iCopy;
       return kTRUE;
     }
-  } while (ReadNextData(dummy));
+  } while (ReadNextData(dummy, kTRUE));
   return kFALSE;
 }
 
@@ -301,7 +313,7 @@ Bool_t   AliRawReaderHLT::ReadNextChar(UChar_t& data)
       fOffset+=iCopy;
       return kTRUE;
     }
-  } while (ReadNextData(dummy));
+  } while (ReadNextData(dummy, kTRUE));
   return kFALSE;
 }
 
@@ -318,7 +330,10 @@ Bool_t   AliRawReaderHLT::ReadNext(UChar_t* data, Int_t size)
       fOffset+=iCopy;
       return kTRUE;
     }
-  } while (ReadNextData(dummy));
+    // By convention, the ReadNextData function stays in the
+    // current block and does not switch to the next one
+    // automatically -> kFALSE
+  } while (ReadNextData(dummy, kFALSE));
   return kFALSE;
 }
 
@@ -395,6 +410,7 @@ void AliRawReaderHLT::SkipInvalid(Bool_t skip)
   fpParentReader->SkipInvalid(skip);
 }
 
+/*
 void AliRawReaderHLT::SelectEvents(Int_t type)
 {
   // see header file for class documentation
@@ -403,6 +419,7 @@ void AliRawReaderHLT::SelectEvents(Int_t type)
   AliRawReader::SelectEvents(type);
   fpParentReader->SelectEvents(type);
 }
+*/
 
 int AliRawReaderHLT::ScanOptions(const char* options)
 {
@@ -447,12 +464,16 @@ Bool_t   AliRawReaderHLT::ReadNextHLTData()
   if (fbReadFirst || !fpHLTOUT) {
     if (!fpHLTOUT) {
     fpHLTOUT=new AliHLTOUTRawReader(fpParentReader);
-    if (result=(fpHLTOUT!=NULL)) {
-      AliHLTSystem* pSystem=GetInstance();
+    if ((result=(fpHLTOUT!=NULL))) {
+      if (!fpPluginBase) {
+       AliFatal("internal data error: can not get AliHLTSystem instance from plugin");
+       return false;
+      }
+      AliHLTSystem* pSystem=fpPluginBase->GetInstance();
       if (pSystem) {
        pSystem->ScanOptions(fSystemOptions.Data());
       }
-      if (result=(fpHLTOUT->Init()>=0)) {
+      if ((result=(fpHLTOUT->Init())>=0)) {
       }
     }
     }
@@ -474,7 +495,7 @@ Bool_t   AliRawReaderHLT::ReadNextHLTData()
     AliHLTOUTHandler* pHandler=fpHLTOUT->GetHandler();
     if (pHandler) {
       if (dynamic_cast<AliHLTOUTHandlerEquId*>(pHandler)!=NULL) {
-       AliHLTOUT::AliHLTOUTLockGuard g(fpHLTOUT);
+       AliHLTOUT::AliHLTOUTSelectionGuard g(fpHLTOUT);
        fEquipmentId=pHandler->ProcessData(fpHLTOUT);
        fpData=NULL;
        fDataSize=pHandler->GetProcessedData(fpData);
@@ -542,7 +563,7 @@ Bool_t AliRawReaderHLT::EvaluateSelection()
 {
   // see header file for class documentation
   Bool_t bHaveHLTData=kFALSE;
-  if (bHaveHLTData=(fDetectors.size()>0)) {
+  if ((bHaveHLTData=(fDetectors.size())>0)) {
     vector<int>::iterator detector=fDetectors.begin();
     for (; detector!=fDetectors.end(); detector++) {
       int ddlOffset=AliDAQ::DdlIDOffset(*detector);