]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding the propagation of the ECS parameter data block to AliHLTSystem
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Sep 2009 21:20:32 +0000 (21:20 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Sep 2009 21:20:32 +0000 (21:20 +0000)
- AliHLTSystem initializes one dummy CTP_TRIGGER_CLASS for the moment
- extended ControlTask functionality, list of blocks to be sent is easily extensible
- filter out warnings for data flow steering blocks in the AliHLTDataSource component

HLT/BASE/AliHLTControlTask.cxx
HLT/BASE/AliHLTControlTask.h
HLT/BASE/AliHLTDataSource.cxx
HLT/BASE/AliHLTSystem.cxx
HLT/BASE/AliHLTTask.cxx

index b4559976ae58a3f0d0b795b6a474205ec8365b72..be5f1b5cb5714d0f388f12851c54831436db6c82 100644 (file)
 ClassImp(AliHLTControlTask)
 
 AliHLTControlTask::AliHLTControlTask()
-  :
-  fEvent(kAliHLTVoidDataType),
-  fSpecification(kAliHLTVoidDataSpec),
-  fpData(NULL),
-  fSize(0)
+  : AliHLTTask()
+  , fBlocks()
+  , fpData(NULL)
+  , fSize(0)
 {
   // see header file for class documentation
   // or
@@ -46,6 +45,7 @@ AliHLTControlTask::AliHLTControlTask()
 AliHLTControlTask::~AliHLTControlTask()
 {
   // see header file for class documentation
+  ResetBlocks();
 }
 
 int AliHLTControlTask::CreateComponent(AliHLTConfiguration* /*pConf*/, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const
@@ -64,6 +64,34 @@ int AliHLTControlTask::CreateComponent(AliHLTConfiguration* /*pConf*/, AliHLTCom
   return -ENOMEM;
 }
 
+void AliHLTControlTask::SetBlocks(const AliHLTComponentBlockDataList& list)
+{
+  // see header file for class documentation
+  fBlocks.assign(list.begin(), list.end());
+  AliHLTComponentBlockDataList::iterator element=fBlocks.begin();
+  for (;element!=fBlocks.end(); element++) fSize+=element->fSize;
+
+  // allocate buffer for the payload of all blocks
+  fpData=new AliHLTUInt8_t[fSize];
+  AliHLTUInt8_t offset=0;
+
+  // copy and redirect
+  for (element=fBlocks.begin();element!=fBlocks.end(); element++) {
+    memcpy(fpData+offset, element->fPtr, element->fSize);
+    element->fPtr=fpData+offset;
+    offset+=element->fSize;
+  }
+}
+
+void AliHLTControlTask::ResetBlocks()
+{
+  // see header file for class documentation
+  fBlocks.clear();
+  if (fpData) delete [] fpData;
+  fpData=NULL;
+  fSize=0;
+}
+
 AliHLTControlTask::AliHLTControlEventComponent::AliHLTControlEventComponent(const AliHLTControlTask* pParent)
   :
   fpParent(pParent)
@@ -96,7 +124,7 @@ void AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataSize( unsigned
 {
   // see header file for class documentation
   if (fpParent && fpParent->fSize>0) constBase=fpParent->fSize;
-  else constBase=sizeof(AliHLTRunDesc);
+  else constBase=0;
   inputMultiplier=0;
 }
 
@@ -109,28 +137,31 @@ int AliHLTControlTask::AliHLTControlEventComponent::GetEvent(const AliHLTCompone
   // see header file for class documentation
   if (!fpParent) return -ENODEV;
   const AliHLTControlTask* pParent=fpParent;
-  if (size<pParent->fSize) {
-    return -ENOSPC;
-  }
-
-  if (pParent->fpData && pParent->fSize) {
-    memcpy(outputPtr, pParent->fpData, pParent->fSize);
-  }
-
   // return if no event has been set
-  if (pParent->fEvent==kAliHLTVoidDataType) {
+  if (pParent->fpData==NULL ||
+      pParent->fBlocks.size()==0) {
     //HLTInfo("no control event to send");
     return 0;
   }
 
-  HLTDebug("publishing control event %s", DataType2Text(pParent->fEvent).c_str());
-  AliHLTComponentBlockData bd;
-  FillBlockData(bd);
-  bd.fOffset=0;
-  bd.fSize=pParent->fSize;
-  bd.fDataType=pParent->fEvent;
-  bd.fSpecification=pParent->fSpecification;
-  outputBlocks.push_back( bd );
+  AliHLTUInt32_t capacity=size;
+  size=0;
+  if (capacity<pParent->fSize) {
+    return -ENOSPC;
+  }
+
+  for (unsigned int i=0; i<pParent->fBlocks.size(); i++) {
+    HLTDebug("publishing control block %s", DataType2Text(pParent->fBlocks[i].fDataType).c_str());
+    memcpy(outputPtr+size, pParent->fBlocks[i].fPtr, pParent->fBlocks[i].fSize);
+    AliHLTComponentBlockData bd;
+    FillBlockData(bd);
+    bd.fOffset=size;
+    bd.fSize=pParent->fBlocks[i].fSize;
+    bd.fDataType=pParent->fBlocks[i].fDataType;
+    bd.fSpecification=pParent->fBlocks[i].fSpecification;
+    outputBlocks.push_back( bd );
+    size+=bd.fSize;
+  }
 
-  return bd.fSize;
+  return size;
 }
index a7eae0d674dbea5f4a3ab31dd8b95e34327c24ad..047fcf2de56a9e73b914c253bfbaef2314e30dde 100644 (file)
@@ -46,21 +46,15 @@ class AliHLTControlTask : public AliHLTTask {
 
   class AliHLTControlEventGuard {
   public:
-    AliHLTControlEventGuard(AliHLTControlTask* me, AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt8_t* pData, AliHLTUInt32_t size) :
+    AliHLTControlEventGuard(AliHLTControlTask* me, AliHLTComponentBlockDataList& list) :
       fTask(me) {
       if (!fTask) return;
-      fTask->fEvent=dt; 
-      fTask->fSpecification=spec; 
-      fTask->fpData=pData; 
-      fTask->fSize=size;
+      fTask->SetBlocks(list); 
+    }
+    ~AliHLTControlEventGuard() {
+      if (!fTask) return;
+      fTask->ResetBlocks();
     }
-      ~AliHLTControlEventGuard() {
-       if (!fTask) return;
-       fTask->fEvent=kAliHLTVoidDataType;
-       fTask->fSpecification=kAliHLTVoidDataSpec;
-       fTask->fpData=NULL;
-       fTask->fSize=0;
-      }
 
   private:
       /** standard constructor prohibited */
@@ -108,6 +102,10 @@ class AliHLTControlTask : public AliHLTTask {
   };
 
  protected:
+  /// to be used from the guard
+  void SetBlocks(const AliHLTComponentBlockDataList& list);
+  /// to be used from the guard
+  void ResetBlocks();
 
  private:
   /** copy constructor prohibited */
@@ -115,15 +113,13 @@ class AliHLTControlTask : public AliHLTTask {
   /** assignment operator prohibited */
   AliHLTControlTask& operator=(const AliHLTControlTask&);
 
-  /** data type of the control event */
-  AliHLTComponentDataType fEvent; //! transient
-  /** specification of the control evtent */
-  AliHLTUInt32_t fSpecification; //! transient
-  /** payload to be sent with the control event */
+  /** list of control blocks */
+  AliHLTComponentBlockDataList fBlocks; //! transient
+  /** payload buffer for all control blocks */
   AliHLTUInt8_t* fpData; //! transient
   /** payload size */
   AliHLTUInt32_t fSize; //!transient
 
   ClassDef(AliHLTControlTask, 0)
-    };
+};
 #endif
index e71908dbfc8cfcbed30fb5313906eeb008d5c450..6a375e70bfaa88bd21175d07cc1762c56aa88a4b 100644 (file)
@@ -66,7 +66,10 @@ int AliHLTDataSource::DoProcessing( const AliHLTComponentEventData& evtData,
     for (unsigned int block=0; block<evtData.fBlockCnt; block++) {
       if (blocks[block].fDataType==kAliHLTDataTypeSOR ||
          blocks[block].fDataType==kAliHLTDataTypeEOR ||
-         blocks[block].fDataType==kAliHLTDataTypeEvent) {
+         blocks[block].fDataType==kAliHLTDataTypeEvent ||
+         blocks[block].fDataType==kAliHLTDataTypeComponentStatistics ||
+         blocks[block].fDataType==kAliHLTDataTypeComponentTable ||
+         blocks[block].fDataType==kAliHLTDataTypeECSParam) {
        continue;
       }
       unknown=block;
index 926e7e3537fe9a49475478d3e44780a15748c2e0..cefef79c7887d5e80c2a7c5fe4aa379bf18260e2 100644 (file)
@@ -684,10 +684,31 @@ int AliHLTSystem::SendControlEvent(AliHLTComponentDataType dt)
   // see header file for class documentation
   int iResult=0;
 
+  AliHLTComponentBlockDataList controlBlocks;
+  AliHLTComponentBlockData bd;
+
+  // run decriptor block of type kAliHLTDataTypeSOR/kAliHLTDataTypeEOR 
+  AliHLTComponent::FillBlockData(bd);
   AliHLTRunDesc runDesc;
   memset(&runDesc, 0, sizeof(AliHLTRunDesc));
   runDesc.fStructSize=sizeof(AliHLTRunDesc);
-  AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, dt, kAliHLTVoidDataSpec, (AliHLTUInt8_t*)&runDesc, sizeof(AliHLTRunDesc));
+  bd.fPtr=&runDesc;
+  bd.fSize=sizeof(AliHLTRunDesc);
+  bd.fDataType=dt;
+  bd.fSpecification=kAliHLTVoidDataSpec;
+  controlBlocks.push_back(bd);
+
+  // ECS parameter dummy of type kAliHLTDataTypeECSParam
+  // to be filled at some point from the trigger framework
+  AliHLTComponent::FillBlockData(bd);
+  TString ecsParam="CTP_TRIGGER_CLASS=00:DUMMY_TRIGGER_ALL:00-01-02-03-04-05-06-07-08-09-10-11-12-13-14-15-16-17";
+  bd.fPtr=(void*)ecsParam.Data();
+  bd.fSize=ecsParam.Length()+1;
+  bd.fDataType=kAliHLTDataTypeECSParam;
+  bd.fSpecification=kAliHLTVoidDataSpec;
+  controlBlocks.push_back(bd);  
+
+  AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, controlBlocks);
   HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
   TObjLink *lnk=fTaskList.FirstLink();
   while (lnk && iResult>=0) {
index c6ea1d09a7c747e19640ab652edb000bfc77ed94..e3f8f2cfcedfefd2c806cb479c0e300eb3829855 100644 (file)
@@ -463,6 +463,11 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType)
     // instances of SOR and EOR events to be kept
     int iSOR=-1;
     int iEOR=-1;
+    // TODO 2009-09-30
+    // generalize handling of the special blocks to be forwarded on SOR and EOR
+    // just adding a new specific handling for the ECS parameter block as a quick
+    // solution
+    int iECS=-1;
 
     // subscribe to all source tasks
     fBlockDataArray.clear();
@@ -478,12 +483,13 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType)
          HLTDebug("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
        }
        if ((iResult=pSrcTask->Subscribe(this, fBlockDataArray))>=0) {
-         iSOR=iEOR=-1;
+         iSOR=iEOR=iECS=-1;
          AliHLTComponentBlockDataList::iterator block=fBlockDataArray.begin();
          for (int i=0; block!=fBlockDataArray.end(); i++) {
            bool bRemove=0;
            bRemove|=(*block).fDataType==kAliHLTDataTypeSOR && !(iSOR<0 && (iSOR=i)>=0);
            bRemove|=(*block).fDataType==kAliHLTDataTypeEOR && !(iEOR<0 && (iEOR=i)>=0);
+           bRemove|=(*block).fDataType==kAliHLTDataTypeECSParam && !(iECS<0 && (iECS=i)>=0);
            //HLTInfo("block %d, iSOR=%d iEOR=%d remove=%d", i, iSOR, iEOR, bRemove);
            if (i<iSourceDataBlock) {
              assert(!bRemove);
@@ -568,6 +574,11 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType)
       trigData.fDataSize=sizeof(AliHLTEventTriggerData);
       memset(&evtTrigData, 0, trigData.fDataSize);
       evtTrigData.fCommonHeaderWordCnt=gkAliHLTCommonHeaderCount;
+      // TODO 2009-09-30
+      // Whenever the trigger framework is implemented and provides more than
+      // just a dummy CT_TRIGGER_CLASS, this needs to be changed. Now for
+      // all events the first bit in the trigger mask is set
+      evtTrigData.fCommonHeader[5]=0x1;
       trigData.fData=&evtTrigData;
       iLastOutputDataSize=iOutputDataSize;
       AliHLTUInt32_t size=iOutputDataSize;
@@ -688,6 +699,11 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType)
            fpDataBuffer->Forward(subscribedTaskList[iEOR], &fBlockDataArray[iEOR]);
            subscribedTaskList[iEOR]=NULL; // not to be released in the loop further down
          }
+         if (iECS>=0 && subscribedTaskList[iECS]!=NULL) {
+           HLTDebug("forward EOR event (%s) segment %d (source task %s %p) to data buffer %p", AliHLTComponent::DataType2Text(fBlockDataArray[iECS].fDataType).c_str(), iECS, pSrcTask->GetName(), pSrcTask, fpDataBuffer);
+           fpDataBuffer->Forward(subscribedTaskList[iECS], &fBlockDataArray[iECS]);
+           subscribedTaskList[iECS]=NULL; // not to be released in the loop further down
+         }
        }
       } else {
        HLTError("no target buffer available");