]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTTask.cxx
Changes required to handle software triggers correctly in the global trigger component.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTTask.cxx
index c6ea1d09a7c747e19640ab652edb000bfc77ed94..9bb842d6f20eb867d79c5043818046eace81f642 100644 (file)
@@ -39,6 +39,7 @@ using namespace std;
 #include <ctime>
 #include "AliHLTTask.h"
 #include "AliHLTConfiguration.h"
+#include "AliHLTConfigurationHandler.h"
 #include "AliHLTComponent.h"
 #include "AliHLTComponentHandler.h"
 #include "TList.h"
@@ -112,10 +113,14 @@ int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH)
   return iResult;
 }
 
-int AliHLTTask::CreateComponent(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const
+int AliHLTTask::CreateComponent(AliHLTConfiguration* pConfiguration, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const
 {
   // see header file for class documentation
   int iResult=0;
+  if (!pConfiguration) return -EINVAL;
+
+  const AliHLTConfiguration* pConf=AliHLTConfigurationHandler::FindSubstitution(*pConfiguration);
+  if (!pConf) pConf=pConfiguration;
   if (pConf) {
     if (pCH) {
       int argc=0;
@@ -445,7 +450,7 @@ int AliHLTTask::EndRun()
   return iResult;
 }
 
-int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType)
+int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType, AliHLTUInt64_t trgMask, AliHLTUInt32_t timestamp)
 {
   // see header file for function documentation
   int iResult=0;
@@ -463,6 +468,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 +488,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);
@@ -561,13 +572,30 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType)
       AliHLTComponent::FillEventData(evtData);
       if (eventNo>=0)
        evtData.fEventID=(AliHLTEventID_t)eventNo;
+      if (timestamp) evtData.fEventCreation_s=timestamp;
+      else
       evtData.fEventCreation_s=static_cast<AliHLTUInt32_t>(time(NULL));
       AliHLTComponentTriggerData trigData;
       AliHLTEventTriggerData evtTrigData;
       trigData.fStructSize=sizeof(trigData);
       trigData.fDataSize=sizeof(AliHLTEventTriggerData);
       memset(&evtTrigData, 0, trigData.fDataSize);
+      // Setup the CDH in the trigger data, based on the event type and CTP trigger.
       evtTrigData.fCommonHeaderWordCnt=gkAliHLTCommonHeaderCount;
+      AliHLTUInt8_t l1msg = 0x0;
+      switch (eventType)
+      {
+      case gkAliEventTypeData:        l1msg = 0x00; break;
+      case gkAliEventTypeDataReplay:  l1msg = 0x00; break;
+      case gkAliEventTypeStartOfRun:  l1msg = (0xE << 2) | 0x01; break;
+      case gkAliEventTypeEndOfRun:    l1msg = (0xF << 2) | 0x01; break;
+      case gkAliEventTypeCalibration: l1msg = (0x1 << 6) | 0x01; break;
+      case gkAliEventTypeSoftware:    l1msg = 0x01; break;
+      }
+      evtTrigData.fCommonHeader[1] = AliHLTUInt32_t(l1msg) << 14;
+      evtTrigData.fCommonHeader[5]=trgMask&0xffffffff;
+      trgMask>>=32;
+      evtTrigData.fCommonHeader[6]=trgMask&0x3ffff;
       trigData.fData=&evtTrigData;
       iLastOutputDataSize=iOutputDataSize;
       AliHLTUInt32_t size=iOutputDataSize;
@@ -688,6 +716,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");
@@ -848,7 +881,7 @@ int AliHLTTask::LoggingVarargs(AliHLTComponentLogSeverity severity,
   va_list args;
   va_start(args, line);
 
-  AliHLTLogging::SetLogString("%s (%p): ", GetName(), this);
+  AliHLTLogging::SetLogString(this, " (%p)", "%s_pfmt_: ", GetName());
   iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, true /*append*/));
   va_end(args);