]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponent.cxx
initialization of CDB in wrapper interface;added treatment of reconfiguration event
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.cxx
index 9da7b05e9a379adae825927415e206807e131c1e..db222bdbeece8d0228a0d405cff24bfd17d4786b 100644 (file)
     @date   
     @brief  Base class implementation for HLT components. */
 
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
 #if __GNUC__>= 3
 using namespace std;
 #endif
@@ -31,11 +37,14 @@ using namespace std;
 #include "AliHLTComponentHandler.h"
 #include "AliHLTMessage.h"
 #include "TString.h"
+#include "TMath.h"
 #include "TObjArray.h"
 #include "TObjectTable.h"
 #include "TClass.h"
 #include "TStopwatch.h"
 #include "AliHLTMemoryFile.h"
+#include "AliHLTMisc.h"
+#include <cassert>
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTComponent);
@@ -68,8 +77,9 @@ AliHLTComponent::AliHLTComponent()
   fpStopwatches(new TObjArray(kSWTypeCount)),
   fMemFiles(),
   fpRunDesc(NULL),
-  fpDDLList(NULL)
-
+  fpDDLList(NULL),
+  fCDBInitialized(false),
+  fChainId()
 {
   // see header file for class documentation
   // or
@@ -82,50 +92,19 @@ AliHLTComponent::AliHLTComponent()
   //SetLocalLoggingLevel(kHLTLogDefault);
 }
 
-AliHLTComponent::AliHLTComponent(const AliHLTComponent&)
-  :
-  AliHLTLogging(),
-  fEnvironment(),
-  fCurrentEvent(0),
-  fEventCount(-1),
-  fFailedEvents(0),
-  fCurrentEventData(),
-  fpInputBlocks(NULL),
-  fCurrentInputBlock(-1),
-  fSearchDataType(kAliHLTVoidDataType),
-  fClassName(),
-  fpInputObjects(NULL),
-  fpOutputBuffer(NULL),
-  fOutputBufferSize(0),
-  fOutputBufferFilled(0),
-  fOutputBlocks(),
-  fpStopwatches(NULL),
-  fMemFiles(),
-  fpRunDesc(NULL),
-  fpDDLList(NULL)
-{
-  // see header file for class documentation
-}
-
-AliHLTComponent& AliHLTComponent::operator=(const AliHLTComponent&)
-{ 
-  // see header file for class documentation
-  return *this;
-}
-
 AliHLTComponent::~AliHLTComponent()
 {
   // see header file for function documentation
   CleanupInputObjects();
   if (fpStopwatches!=NULL) delete fpStopwatches;
   fpStopwatches=NULL;
-  vector<AliHLTMemoryFile*>::iterator element=fMemFiles.begin();
+  AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
   while (element!=fMemFiles.end()) {
     if (*element) {
       if ((*element)->IsClosed()==0) {
        HLTWarning("memory file has not been closed, possible data loss or incomplete buffer");
        // close but do not flush as we dont know whether the buffer is still valid
-       (*element)->Close(0);
+       (*element)->CloseMemoryFile(0);
       }
       delete *element;
       *element=NULL;
@@ -220,28 +199,67 @@ int AliHLTComponent::Deinit()
     fpRunDesc=NULL;
     delete pRunDesc;
   }
+  fEventCount=0;
   return iResult;
 }
 
-int AliHLTComponent::DoInit( int argc, const char** argv )
+int AliHLTComponent::InitCDB(const char* cdbPath)
 {
-  // see header file for function documentation
-  if (argc==0 && argv==NULL) {
-    // this is currently just to get rid of the warning "unused parameter"
+  int iResult=0;
+  // we presume the library already to be loaded
+  // find the symbol
+  AliHLTComponentHandler cHandler;
+  AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB); 
+  if (pFunc) {
+    iResult=(*pFunc)(cdbPath);
+    fCDBInitialized=iResult>=0;
+  } else {
+    Message(NULL, kHLTLogError, "AliHLTComponent::InitCDB", "init CDB",
+           "can not find initialization function");
+    iResult=-ENOSYS;
   }
-  fEventCount=0;
+  return iResult;
+}
+
+int AliHLTComponent::SetCDBRunNo(int runNo)
+{
+  int iResult=0;
+  if (!fCDBInitialized) return iResult;
+  // we presume the library already to be loaded
+  // find the symbol
+  AliHLTComponentHandler cHandler;
+  AliHLTMiscSetCDBRunNo_t pFunc=(AliHLTMiscSetCDBRunNo_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO); 
+  if (pFunc) {
+    iResult=(*pFunc)(runNo);
+  } else {
+    Message(NULL, kHLTLogError, "AliHLTComponent::SetCDBRunNo", "init CDB",
+           "can not find initialization function");
+    iResult=-ENOSYS;
+  }
+  return iResult;
+}
+
+int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/)
+{
+  // default implementation, childs can overload
   return 0;
 }
 
 int AliHLTComponent::DoDeinit()
 {
-  // see header file for function documentation
-  fEventCount=0;
+  // default implementation, childs can overload
+  return 0;
+}
+
+int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
+{
+  // default implementation, childs can overload
   return 0;
 }
 
-int AliHLTComponent::GetOutputDataTypes(vector<AliHLTComponentDataType>& /*tgtList*/)
+int AliHLTComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& /*tgtList*/)
 {
+  HLTLogKeyword("dummy");
   return 0;
 }
 
@@ -254,11 +272,49 @@ void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char o
   strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
 }
 
-string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type )
+string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, int mode)
 {
   // see header file for function documentation
   string out("");
-  
+
+  if (mode==2) {
+    int i=0;
+    char tmp[8];
+    for (i=0; i<kAliHLTComponentDataTypefOriginSize; i++) {
+      sprintf(tmp, "'%d", type.fOrigin[i]);
+      out+=tmp;
+    }
+    out+="':'";
+    for (i=0; i<kAliHLTComponentDataTypefIDsize; i++) {
+      sprintf(tmp, "%d'", type.fID[i]);
+      out+=tmp;
+    }
+    return out;
+  }
+
+  if (mode==1) {
+    int i=0;
+    char tmp[8];
+    for (i=0; i<kAliHLTComponentDataTypefOriginSize; i++) {
+      unsigned char* puc=(unsigned char*)type.fOrigin;
+      if ((puc[i])<32)
+       sprintf(tmp, "'\\%x", type.fOrigin[i]);
+      else
+       sprintf(tmp, "'%c", type.fOrigin[i]);
+      out+=tmp;
+    }
+    out+="':'";
+    for (i=0; i<kAliHLTComponentDataTypefIDsize; i++) {
+      unsigned char* puc=(unsigned char*)type.fID;
+      if (puc[i]<32)
+       sprintf(tmp, "\\%x'", type.fID[i]);
+      else
+       sprintf(tmp, "%c'", type.fID[i]);
+      out+=tmp;
+    }
+    return out;
+  }
+
   if (type==kAliHLTVoidDataType) {
     out="VOID:VOID";
   } else {
@@ -287,7 +343,7 @@ void* AliHLTComponent::AllocMemory( unsigned long size )
   return NULL;
 }
 
-int AliHLTComponent::MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
+int AliHLTComponent::MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount,
                                              AliHLTComponentBlockData** outputBlocks ) 
 {
   // see header file for function documentation
@@ -329,26 +385,35 @@ int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventD
   return -ENOSYS;
 }
 
-int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList) 
+int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList) 
 {
   // see header file for function documentation
   int iResult=0;
   if (pConsumer) {
-    vector<AliHLTComponentDataType> ctlist;
-    ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist);
-    vector<AliHLTComponentDataType>::iterator type=ctlist.begin();
-    //AliHLTComponentDataType ouptdt=GetOutputDataType();
-    //PrintDataTypeContent(ouptdt, "publisher \'%s\'");
-    while (type!=ctlist.end() && iResult==0) {
-      //PrintDataTypeContent((*type), "consumer \'%s\'");
-      if ((*type)==GetOutputDataType() ||
-         (*type)==kAliHLTAnyDataType) {
-       if (tgtList) tgtList->push_back(*type);
+    AliHLTComponentDataTypeList itypes;
+    AliHLTComponentDataTypeList otypes;
+    otypes.push_back(GetOutputDataType());
+    if (otypes[0]==kAliHLTMultipleDataType) {
+      otypes.clear();
+      int count=0;
+      if ((count=GetOutputDataTypes(otypes))>0) {
+      } else if (GetComponentType()!=kSink) {
+       HLTWarning("component %s indicates multiple output data types but GetOutputDataTypes returns %d", GetComponentID(), count);
+      }
+    }
+    ((AliHLTComponent*)pConsumer)->GetInputDataTypes(itypes);
+    AliHLTComponentDataTypeList::iterator itype=itypes.begin();
+    while (itype!=itypes.end()) {
+      //PrintDataTypeContent((*itype), "consumer \'%s\'");
+      AliHLTComponentDataTypeList::iterator otype=otypes.begin();
+      while (otype!=otypes.end() && (*itype)!=(*otype)) otype++;
+      //if (otype!=otypes.end()) PrintDataTypeContent(*otype, "publisher \'%s\'");
+      if (otype!=otypes.end() ||
+         (*itype)==kAliHLTAnyDataType) {
+       if (tgtList) tgtList->push_back(*itype);
        iResult++;
-       // this loop has to be changed in case of multiple output types
-       break;
       }
-      type++;
+      itype++;
     }
   } else {
     iResult=-EINVAL;
@@ -377,7 +442,7 @@ void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const ch
             dt.fOrigin[3]);
 }
 
-void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData ) const
+void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData )
 {
   // see header file for function documentation
   blockData.fStructSize = sizeof(blockData);
@@ -389,7 +454,7 @@ void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData ) const
   blockData.fSpecification = kAliHLTVoidDataSpec;
 }
 
-void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData ) const
+void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData )
 {
   // see header file for function documentation
   shmData.fStructSize = sizeof(shmData);
@@ -397,7 +462,7 @@ void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData ) const
   shmData.fShmID = gkAliHLTComponentInvalidShmID;
 }
 
-void AliHLTComponent::FillDataType( AliHLTComponentDataType& dataType ) const
+void AliHLTComponent::FillDataType( AliHLTComponentDataType& dataType )
 {
   // see header file for function documentation
   dataType=kAliHLTAnyDataType;
@@ -413,19 +478,15 @@ void AliHLTComponent::CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTC
 void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin) 
 {
   // see header file for function documentation
-  tgtdt.fStructSize = sizeof(AliHLTComponentDataType);
-  memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
-  memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
-
-  if ((int)strlen(id)>kAliHLTComponentDataTypefIDsize) {
-    HLTWarning("data type id %s is too long, truncated to %d", id, kAliHLTComponentDataTypefIDsize);
+  tgtdt.fStructSize=sizeof(AliHLTComponentDataType);
+  if (id) {
+    memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
+    strncpy(&tgtdt.fID[0], id, strlen(id)<(size_t)kAliHLTComponentDataTypefIDsize?strlen(id):kAliHLTComponentDataTypefIDsize);
   }
-  strncpy(&tgtdt.fID[0], id, kAliHLTComponentDataTypefIDsize);
-
-  if ((int)strlen(origin)>kAliHLTComponentDataTypefOriginSize) {
-    HLTWarning("data type origin %s is too long, truncated to %d", origin, kAliHLTComponentDataTypefOriginSize);
+  if (origin) {
+    memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
+    strncpy(&tgtdt.fOrigin[0], origin, strlen(origin)<(size_t)kAliHLTComponentDataTypefOriginSize?strlen(origin):kAliHLTComponentDataTypefOriginSize);
   }
-  strncpy(&tgtdt.fOrigin[0], origin, kAliHLTComponentDataTypefOriginSize);
 }
 
 void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
@@ -535,7 +596,11 @@ int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int start
        AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
        if (firstWord!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue;
       }
-      if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt) {
+      if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt ||
+         (memcmp(dt.fID, kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize)==0 &&
+          memcmp(dt.fOrigin, fpInputBlocks[idx].fDataType.fOrigin, kAliHLTComponentDataTypefOriginSize)==0) ||
+         (memcmp(dt.fID, fpInputBlocks[idx].fDataType.fID, kAliHLTComponentDataTypefIDsize)==0) &&
+          memcmp(dt.fOrigin, kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize)==0) {
        iResult=idx;
       }
     }
@@ -577,7 +642,7 @@ TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
   return pObj;
 }
 
-TObject* AliHLTComponent::GetInputObject(int idx, const char* classname, int bForce)
+TObject* AliHLTComponent::GetInputObject(int idx, const char* /*classname*/, int bForce)
 {
   // see header file for function documentation
   if (fpInputObjects==NULL) {
@@ -660,6 +725,43 @@ AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject)
   return iSpec;
 }
 
+int AliHLTComponent::Forward(const TObject* pObject)
+{
+  // see header file for function documentation
+  int iResult=0;
+  int idx=fCurrentInputBlock;
+  if (pObject) {
+    if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
+    } else {
+      HLTError("unknown object %p", pObject);
+      iResult=-ENOENT;
+    }
+  }
+  if (idx>=0) {
+    fOutputBlocks.push_back(fpInputBlocks[idx]);
+  }
+  return iResult;
+}
+
+int AliHLTComponent::Forward(const AliHLTComponentBlockData* pBlock)
+{
+  // see header file for function documentation
+  int iResult=0;
+  int idx=fCurrentInputBlock;
+  if (pBlock) {
+    if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
+    } else {
+      HLTError("unknown Block %p", pBlock);
+      iResult=-ENOENT;      
+    }
+  }
+  if (idx>=0) {
+    // check for fpInputBlocks pointer done in FindInputBlock
+    fOutputBlocks.push_back(fpInputBlocks[idx]);
+  }
+  return iResult;
+}
+
 const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt)
 {
   // see header file for function documentation
@@ -686,6 +788,14 @@ const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char*
   return GetFirstInputBlock(dt);
 }
 
+const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index)
+{
+  // see header file for function documentation
+  ALIHLTCOMPONENT_BASE_STOPWATCH();
+  assert( 0 <= index and index < fCurrentEventData.fBlockCnt );
+  return &fpInputBlocks[index];
+}
+
 const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock()
 {
   // see header file for function documentation
@@ -801,7 +911,6 @@ int AliHLTComponent::InsertOutputBlock(void* pBuffer, int iBufferSize, const Ali
       AliHLTComponentBlockData bd;
       FillBlockData( bd );
       bd.fOffset        = fOutputBufferFilled;
-      bd.fPtr           = pTgt;
       bd.fSize          = iBlkSize;
       bd.fDataType      = dt;
       bd.fSpecification = spec;
@@ -874,7 +983,6 @@ AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity,
        AliHLTComponentBlockData bd;
        FillBlockData( bd );
        bd.fOffset        = fOutputBufferFilled;
-       bd.fPtr           = pTgt;
        bd.fSize          = capacity;
        bd.fDataType      = dt;
        bd.fSpecification = spec;
@@ -882,7 +990,7 @@ AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity,
        fOutputBlocks.push_back( bd );
       } else {
        HLTError("can not allocate/grow object array");
-       pFile->Close(0);
+       pFile->CloseMemoryFile(0);
        delete pFile;
        pFile=NULL;
       }
@@ -929,6 +1037,7 @@ AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(const AliHLTComponentDataTyp
 int AliHLTComponent::Write(AliHLTMemoryFile* pFile, const TObject* pObject,
                           const char* key, int option)
 {
+  // see header file for function documentation
   int iResult=0;
   if (pFile && pObject) {
     pFile->cd();
@@ -949,13 +1058,14 @@ int AliHLTComponent::Write(AliHLTMemoryFile* pFile, const TObject* pObject,
 
 int AliHLTComponent::CloseMemoryFile(AliHLTMemoryFile* pFile)
 {
+  // see header file for function documentation
   int iResult=0;
   if (pFile) {
-    vector<AliHLTMemoryFile*>::iterator element=fMemFiles.begin();
+    AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
     int i=0;
     while (element!=fMemFiles.end() && iResult>=0) {
       if (*element && *element==pFile) {
-       iResult=pFile->Close();
+       iResult=pFile->CloseMemoryFile();
        
        // sync memory files and descriptors
        if (iResult>=0) {
@@ -975,7 +1085,7 @@ int AliHLTComponent::CloseMemoryFile(AliHLTMemoryFile* pFile)
   return iResult;
 }
 
-int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
+int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData /*edd*/)
 {
   // see header file for function documentation
   int iResult=-ENOSYS;
@@ -1008,47 +1118,72 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
 
   // find special events
   if (fpInputBlocks) {
+    // first look for all special events and execute in the appropriate
+    // sequence afterwords
+    int indexComConfEvent=-1;
+    int indexSOREvent=-1;
+    int indexEOREvent=-1;
     for (unsigned int i=0; i<evtData.fBlockCnt && iResult>=0; i++) {
       if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) {
-       // start of run
-       if (fpRunDesc==NULL) {
-         fpRunDesc=new AliHLTRunDesc;
-         if (fpRunDesc) {
-           if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) {
-             HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
-           }
-         } else {
-           iResult=-ENOMEM;
+       indexSOREvent=i;
+      } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
+       indexEOREvent=i;
+      } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) {
+       // DDL list
+       // this event is most likely deprecated
+      } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComConf) {
+       indexComConfEvent=i;
+      }
+    }
+    if (indexSOREvent>=0) {
+      // start of run
+      if (fpRunDesc==NULL) {
+       fpRunDesc=new AliHLTRunDesc;
+       if (fpRunDesc) {
+         if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) {
+           HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
+           SetCDBRunNo(fpRunDesc->fRunNo);
          }
        } else {
-         HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo);
+         iResult=-ENOMEM;
        }
-      } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
-       if (fpRunDesc!=NULL) {
-         if (fpRunDesc) {
-           AliHLTRunDesc rundesc;
-           if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) {
-             if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
-               HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
-             } else {
-               HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
-             }
+      } else {
+       HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo);
+      }
+    }
+    if (indexEOREvent>=0) {
+      if (fpRunDesc!=NULL) {
+       if (fpRunDesc) {
+         AliHLTRunDesc rundesc;
+         if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexEOREvent, "AliHLTRunDesc", "SOR"))>0) {
+           if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
+             HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
+           } else {
+             HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
            }
-           AliHLTRunDesc* pRunDesc=fpRunDesc;
-           fpRunDesc=NULL;
-           delete pRunDesc;
          }
-       } else {
-         HLTWarning("did not receive SOR, ignoring EOR");
+         AliHLTRunDesc* pRunDesc=fpRunDesc;
+         fpRunDesc=NULL;
+         delete pRunDesc;
        }
-       // end of run
-      } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) {
-       // DDL list
+      } else {
+       HLTWarning("did not receive SOR, ignoring EOR");
+      }
+    }
+    if (indexComConfEvent>=0) {
+      TString cdbEntry;
+      if (fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) {
+       cdbEntry.Append(reinterpret_cast<const char*>(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize);
+      }
+      HLTDebug("received component configuration command: entry %s", cdbEntry.IsNull()?"none":cdbEntry.Data());
+      int tmpResult=Reconfigure(cdbEntry[0]==0?NULL:cdbEntry.Data(), fChainId.c_str());
+      if (tmpResult<0) {
+       HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
       }
     }
   }
   
-  vector<AliHLTComponentBlockData> blockData;
+  AliHLTComponentBlockDataList blockData;
   { // dont delete, sets the scope for the stopwatch guard
     ALIHLTCOMPONENT_DA_STOPWATCH();
     iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
@@ -1058,7 +1193,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
       //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
       
       // sync memory files and descriptors
-      vector<AliHLTMemoryFile*>::iterator element=fMemFiles.begin();
+      AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
       int i=0;
       while (element!=fMemFiles.end() && iResult>=0) {
        if (*element) {
@@ -1092,7 +1227,9 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
     outputBlocks=NULL;
   }
   CleanupInputObjects();
-  IncrementEventCounter();
+  if (iResult>=0) {
+    IncrementEventCounter();
+  }
   return iResult;
 }
 
@@ -1208,12 +1345,14 @@ int AliHLTComponent::SetStopwatches(TObjArray* pStopwatches)
 
 AliHLTUInt32_t AliHLTComponent::GetRunNo() const
 {
+  // see header file for function documentation
   if (fpRunDesc==NULL) return 0;
   return fpRunDesc->fRunNo;
 }
 
 AliHLTUInt32_t AliHLTComponent::GetRunType() const
 {
+  // see header file for function documentation
   if (fpRunDesc==NULL) return 0;
   return fpRunDesc->fRunType;
 }
@@ -1221,13 +1360,13 @@ AliHLTUInt32_t AliHLTComponent::GetRunType() const
 int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
                                const char* structname, const char* eventname)
 {
+  // see header file for function documentation
   int iResult=0;
   if (pStruct!=NULL && iStructSize>sizeof(AliHLTUInt32_t)) {
     if (fpInputBlocks!=NULL && iBlockNo<fCurrentEventData.fBlockCnt) {
       AliHLTUInt32_t* pTgt=(AliHLTUInt32_t*)pStruct;
       if (fpInputBlocks[iBlockNo].fPtr && fpInputBlocks[iBlockNo].fSize) {
-       AliHLTUInt8_t* pSrc=((AliHLTUInt8_t*)fpInputBlocks[iBlockNo].fPtr)+fpInputBlocks[iBlockNo].fOffset;
-       AliHLTUInt32_t copy=*((AliHLTUInt32_t*)pSrc);
+       AliHLTUInt32_t copy=*((AliHLTUInt32_t*)fpInputBlocks[iBlockNo].fPtr);
        if (fpInputBlocks[iBlockNo].fSize!=copy) {
          HLTWarning("%s event: missmatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy);
          if (copy>fpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize;
@@ -1240,7 +1379,7 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne
            memset(pTgt, 0, iStructSize);
          }
        }
-       memcpy(pTgt, pSrc, copy);
+       memcpy(pTgt, fpInputBlocks[iBlockNo].fPtr, copy);
        *pTgt=iStructSize;
        iResult=copy;
       } else {
@@ -1255,3 +1394,70 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne
   }
   return iResult;
 }
+
+void AliHLTComponent::SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const
+{
+  // see header file for function documentation
+  
+  // -- Detector offset
+  Int_t ddlIdBase =  TMath::FloorNint( (Double_t) ddlId / 256.0 );
+  
+  // -- Word Base = 1. word of detector ( TPC has 8 words, TOF 3 ) 
+  Int_t wordBase = 0;
+
+  if ( ddlIdBase <= 3 )
+    wordBase = ddlIdBase;
+  else if ( ddlIdBase > 3 && ddlIdBase < 5 )
+    wordBase = ddlIdBase + 7;
+  else 
+    wordBase = ddlIdBase + 9;
+
+  // -- Bit index in Word
+  Int_t bitIdx = ddlId % 32;
+
+  // -- Index of word
+  Int_t wordIdx = wordBase;
+
+  // -- if TPC (3) or TOD (5) add word idx
+  if ( ( ddlIdBase == 3 ) || ( ddlIdBase == 5 ) ) {
+    wordIdx += TMath::FloorNint( (Double_t) ( ddlId - ( ddlIdBase * 256 ) ) / 32.0 );
+  }
+
+  // -- Set -- 'OR' word with bit mask;
+  if ( state )
+    list.fList[wordIdx] |= ( 0x00000001 << bitIdx );
+  // -- Unset -- 'AND' word with bit mask;
+  else
+    list.fList[wordIdx] &= ( 0xFFFFFFFF ^ ( 0x00000001 << bitIdx ) );
+}
+
+Int_t AliHLTComponent::GetFirstUsedDDLWord(AliHLTEventDDL &list) const
+{
+  // see header file for function documentation
+
+  Int_t iResult = -1;
+
+  for ( Int_t wordNdx = 0 ; wordNdx < gkAliHLTDDLListSize ; wordNdx++ ) {
+
+    if ( list.fList[wordNdx] != 0 && iResult == -1 ) {
+      // check for special cases TPC and TOF
+      if ( wordNdx > 3 && wordNdx <= 10 ) {
+       wordNdx = 10;
+       iResult = 3;
+      }
+      else if ( wordNdx > 12 && wordNdx <= 14 ) {
+       wordNdx = 14;
+       iResult = 12;
+      }
+      else
+       iResult = wordNdx;
+    }
+    else if ( list.fList[wordNdx] != 0 && iResult >= 0 ) {
+      HLTError( "DDLIDs for minimum of TWO detectors ( %d, %d ) set, this function works only for ONE detector.", iResult, wordNdx );
+      iResult = -1;
+      break;
+    }
+  }
+
+  return iResult;
+}