]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTOUT.cxx
Using fNContrubutors in AliAODVertex for SPD vertices.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUT.cxx
index bc90ff2e4d0f45013d03382c9bf48f3fb1ba113a..99fdc6fe80510e352cc352bcb05301495066c5c9 100644 (file)
@@ -25,6 +25,7 @@
 #include <cerrno>
 #include <cassert>
 #include "AliHLTOUT.h"
+#include "AliHLTMessage.h"
 #include "TSystem.h"
 #include "TClass.h"
 #include "TROOT.h"
@@ -44,6 +45,10 @@ AliHLTOUT::AliHLTOUT()
   fDataHandlers(),
   fbVerbose(true),
   fLog()
+  , fpDataObject(NULL)
+  , fpObjectBuffer(NULL)
+  , fObjectBufferSize(0)
+  , fCurrentEventId(kAliHLTVoidEventID)
 {
   // see header file for class documentation
   // or
@@ -58,6 +63,11 @@ AliHLTOUT::~AliHLTOUT()
   if (CheckStatusFlag(kIsSubCollection)) {
     fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "~AliHLTOUT" , __FILE__ , __LINE__ , "severe internal error: collection has not been released, potential crash due to invalid pointer");
   }
+
+  if (fpDataObject) {
+    fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
+  }
+  fpDataObject=NULL;
 }
 AliHLTOUT* AliHLTOUT::fgGlobalInstance=NULL;
 
@@ -576,7 +586,7 @@ AliHLTOUT* AliHLTOUT::New(const char* classname)
   ROOT::NewFunc_t pNewFunc=NULL;
   do {
     pCl=TClass::GetClass(classname);
-  } while (!pCl && (iLibResult=gSystem->Load("libHLTRec.so"))==0);
+  } while (!pCl && (iLibResult=gSystem->Load("libHLTrec.so"))==0);
   if (iLibResult>=0) {
     if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
       void* p=(*pNewFunc)(NULL);
@@ -648,22 +658,38 @@ int AliHLTOUT::SelectDataBlock()
   return iResult;
 }
 
-int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerDesc)
+int AliHLTOUT::SelectDataBlocks(const AliHLTOUTHandlerListEntry* pHandlerEntry)
 {
   // see header file for class documentation
   int iResult=0;
-  if (!pHandlerDesc) return 0;
+  if (!pHandlerEntry) return 0;
 
+  AliHLTModuleAgent* pAgent=*pHandlerEntry;
+  AliHLTLogging log;
+  log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", "selecting blocks for handler %s", pAgent->GetModuleId());
   AliHLTOUTBlockDescriptorVector::iterator element;
   for (AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin();
        block!=fBlockDescList.end();
        block++) {
-    if (block->GetHandlerDesc()==*pHandlerDesc && pHandlerDesc->HasIndex(block->GetIndex()))
+    if (block->GetHandlerDesc()==*pHandlerEntry && pHandlerEntry->HasIndex(block->GetIndex())) {
       block->Select(true);
-    else
+      log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", "   select block %s", AliHLTComponent::DataType2Text(*block).c_str());
+    } else {
+      log.Logging(kHLTLogDebug, "AliHLTOUT::SelectDataBlocks", "HLTOUT handling", "   skip block %s", AliHLTComponent::DataType2Text(*block).c_str());
       block->Select(false);
+    }
   }
   EnableBlockSelection();
+
+  // Matthias 2009-07-03 bugfix: the fCurrent position was not reset at that
+  // place. Also I think the data type and specification must be set in order
+  // to make SelectFirst/NextDataBlock working on the selected collection
+  // of data blocks
+  AliHLTModuleAgent::AliHLTOUTHandlerDesc pHandlerDesc=*pHandlerEntry; 
+  fSearchDataType=pHandlerDesc;
+  fSearchSpecification=kAliHLTVoidDataSpec;
+  fSearchHandlerType=pHandlerDesc;
+  fCurrent=0;
   
   return iResult;
 }
@@ -792,6 +818,7 @@ int AliHLTOUT::Reset()
   }
 
   ResetInput();
+  fCurrentEventId=kAliHLTVoidEventID;
 
   return iResult;
 }
@@ -816,3 +843,50 @@ const AliHLTOUT::AliHLTOUTHandlerListEntry& AliHLTOUT::AliHLTOUTBlockDescriptor:
   }
   return const_cast<AliHLTOUT::AliHLTOUTHandlerListEntry&>(AliHLTOUT::AliHLTOUTHandlerListEntry::fgkVoidHandlerListEntry);
 }
+
+TObject* AliHLTOUT::GetDataObject()
+{
+  // see header file for class documentation
+  if (fpDataObject) {
+    fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "data object has not been released, potential memory leak");
+    ReleaseDataBuffer(fpObjectBuffer);
+  }
+  fpObjectBuffer=NULL;
+  fObjectBufferSize=0;
+  fpDataObject=NULL;
+
+  if (GetDataBuffer(fpObjectBuffer, fObjectBufferSize)>=0) {
+    fpDataObject=AliHLTMessage::Extract(fpObjectBuffer, fObjectBufferSize);
+  } else {
+    fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "can not fetch data buffer");    
+  }
+
+  return fpDataObject;
+}
+
+int AliHLTOUT::ReleaseDataObject(TObject* pObject)
+{
+  // see header file for class documentation
+  if (!pObject) return -EINVAL;
+  if (pObject!=fpDataObject) {
+    fLog.LoggingVarargs(kHLTLogError, "AliHLTOUT", "GetDataObject" , __FILE__ , __LINE__ , "attempt to release wrong data object %p, expected %p", pObject, fpDataObject);
+    return -EINVAL;
+  }
+
+  delete fpDataObject;
+  fpDataObject=NULL;
+  ReleaseDataBuffer(fpObjectBuffer);
+  fpObjectBuffer=NULL;
+  fObjectBufferSize=0;
+
+  return 0;
+}
+
+void AliHLTOUT::SetEventId(AliHLTUInt64_t id)
+{
+  // see header file for class documentation
+  if (fCurrentEventId!=kAliHLTVoidEventID && fCurrentEventId!=id) {
+    fLog.LoggingVarargs(kHLTLogWarning, "AliHLTOUT", "SetEventId" , __FILE__ , __LINE__ , "event id was already set to 0x%llx, setting now to 0x%llx", fCurrentEventId, id);
+  }
+  fCurrentEventId=id;
+}