]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added code to allow sending back of EventDoneData from the DoEvent methods of AliHLTP...
authorjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 7 Sep 2008 23:11:01 +0000 (23:11 +0000)
committerjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 7 Sep 2008 23:11:01 +0000 (23:11 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h
HLT/BASE/AliHLTProcessor.cxx

index ebc966baa59618a28d7129c1e2d9b0bb2dfeaa8d..fa8be1b336afdd06e15982b14d2ec9aad6475c0a 100644 (file)
@@ -79,7 +79,9 @@ AliHLTComponent::AliHLTComponent()
   fpBenchmark(NULL),
   fRequireSteeringBlocks(false),
   fEventType(gkAliEventTypeUnknown),
-  fComponentArgs()
+  fComponentArgs(),
+  fEventDoneData(NULL),
+  fEventDoneDataSize(0)
 {
   // see header file for class documentation
   // or
@@ -118,6 +120,8 @@ AliHLTComponent::~AliHLTComponent()
     delete fpRunDesc;
     fpRunDesc=NULL;
   }
+  if (fEventDoneData)
+    delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
 }
 
 AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
@@ -515,6 +519,51 @@ int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventD
   return -ENOSYS;
 }
 
+int AliHLTComponent::ReserveEventDoneData( unsigned long size )
+{
+  // see header file for function documentation
+  int iResult=0;
+
+  
+  if (size>fEventDoneDataSize) {
+    AliHLTComponentEventDoneData* newEDD = reinterpret_cast<AliHLTComponentEventDoneData*>( new AliHLTUInt8_t[ sizeof(AliHLTComponentEventDoneData)+size ] );
+    if (!newEDD)
+      return -ENOMEM;
+    newEDD->fStructSize = sizeof(AliHLTComponentEventDoneData);
+    newEDD->fDataSize = 0;
+    newEDD->fData = reinterpret_cast<AliHLTUInt8_t*>(newEDD)+newEDD->fStructSize;
+    if (fEventDoneData) {
+      memcpy( newEDD->fData, fEventDoneData->fData, fEventDoneData->fDataSize );
+      newEDD->fDataSize = fEventDoneData->fDataSize;
+      delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
+    }
+    fEventDoneData = newEDD;
+    fEventDoneDataSize = size;
+  }
+  return iResult;
+
+}
+
+int AliHLTComponent::PushEventDoneData( AliHLTUInt32_t eddDataWord )
+{
+  if (!fEventDoneData)
+    return -ENOMEM;
+  if (fEventDoneData->fDataSize+sizeof(AliHLTUInt32_t)>fEventDoneDataSize)
+    return -ENOSPC;
+  *reinterpret_cast<AliHLTUInt32_t*>((reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize)) = eddDataWord;
+  fEventDoneData->fDataSize += sizeof(AliHLTUInt32_t);
+  return 0;
+}
+
+void AliHLTComponent::ReleaseEventDoneData()
+{
+  if (fEventDoneData)
+    delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
+  fEventDoneData = NULL;
+  fEventDoneDataSize = 0;
+}
+
+
 int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList) 
 {
   // see header file for function documentation
@@ -1235,12 +1284,39 @@ 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;
-  //#warning  function not yet implemented
-  HLTWarning("function not yet implemented");
+  int iResult=0;
+
+  AliHLTComponentEventDoneData* newEDD = NULL;
+  
+  unsigned long newSize=edd.fDataSize;
+  if (fEventDoneData)
+    newSize += fEventDoneData->fDataSize;
+
+  if (newSize>fEventDoneDataSize) {
+    newEDD = reinterpret_cast<AliHLTComponentEventDoneData*>( new AliHLTUInt8_t[ sizeof(AliHLTComponentEventDoneData)+newSize ] );
+    if (!newEDD)
+      return -ENOMEM;
+    newEDD->fStructSize = sizeof(AliHLTComponentEventDoneData);
+    newEDD->fDataSize = newSize;
+    newEDD->fData = reinterpret_cast<AliHLTUInt8_t*>(newEDD)+newEDD->fStructSize;
+    unsigned long long offset = 0;
+    if (fEventDoneData) {
+      memcpy( newEDD->fData, fEventDoneData->fData, fEventDoneData->fDataSize );
+      offset += fEventDoneData->fDataSize;
+    }
+    memcpy( reinterpret_cast<AliHLTUInt8_t*>(newEDD->fData)+offset, edd.fData, edd.fDataSize );
+    if (fEventDoneData)
+      delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
+    fEventDoneData = newEDD;
+    fEventDoneDataSize = newSize;
+  }
+  else {
+    memcpy( reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize, edd.fData, edd.fDataSize );
+    fEventDoneData->fDataSize += edd.fDataSize;
+  }
   return iResult;
 }
 
index 1b1d3028da505c11b89041130189df5ca57da230..2e3e20e2ef5cb33b2d2af1c7825cb6811992891a 100644 (file)
@@ -791,6 +791,35 @@ class AliHLTComponent : public AliHLTLogging {
    */
   int GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd );
 
+  /**
+   * Allocate an EventDoneData structure for the current event .
+   * The method allocates the memory internally and does not interact with the current Framework.
+   * The allocated data structure is empty initially and can be filled by calls to the 
+   * @ref PushEventDoneData method. The memory will be automatically released after the event has been processed.
+   * 
+   */
+  int ReserveEventDoneData( unsigned long size );
+
+  /**
+   * Push a 32 bit word of data into event done data for the current event which
+   * has previously been allocated by the @ref ReserveEventDoneData method.
+   */
+  int PushEventDoneData( AliHLTUInt32_t eddDataWord );
+
+  /**
+   * Release event done data previously reserved by @ref ReserveEventDoneData
+   */
+   void ReleaseEventDoneData();
+
+  /**
+   * Get the pointer to the event done data available/built so far for the current event via
+   * @ref ReserveEventDoneData and @ref PushEventDoneData
+   */
+  AliHLTComponentEventDoneData* GetCurrentEventDoneData()
+    {
+    return fEventDoneData;
+    }
+
   /**
    * Helper function to convert the data type to a string.
    */
@@ -1412,6 +1441,13 @@ class AliHLTComponent : public AliHLTLogging {
   /** component arguments */
   string fComponentArgs;                                           //! transient
 
+
+  /** event done data */
+  AliHLTComponentEventDoneData* fEventDoneData;                    //! transient
+
+  /** Reserved size of the memory stored at fEventDoneData */
+  unsigned long fEventDoneDataSize;                                //! transient
+
   ClassDef(AliHLTComponent, 8)
 };
 #endif
index bcb22ac7fd1fe709c979262d7b5ed839644d5a7e..619e0df8d9bd038aa11b9a0f748add27d1b1ca4e 100644 (file)
@@ -54,8 +54,24 @@ int AliHLTProcessor::DoProcessing( const AliHLTComponentEventData& evtData, cons
 {
   // see header file for class documentation
   int iResult=0;
+  ReleaseEventDoneData();
+
   iResult=DoEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
+
   edd = NULL;
+  AliHLTComponentEventDoneData* eddTmp = GetCurrentEventDoneData();
+  if (eddTmp) {
+    int ret = GetEventDoneData(eddTmp->fDataSize, &edd);
+    if (ret) {
+      HLTError( "Cannot get event done data of %u bytes for event %lu: %s (%d)", 
+               eddTmp->fDataSize, evtData.fEventID, strerror(ret), ret );
+      return -ENOMEM;
+    }
+    edd->fStructSize = sizeof(AliHLTComponentEventDoneData);
+    edd->fDataSize = eddTmp->fDataSize;
+    edd->fData = reinterpret_cast<AliHLTUInt8_t*>(edd)+edd->fStructSize;
+    memcpy( edd->fData, eddTmp->fData, eddTmp->fDataSize );
+  }
   return iResult;
 }