]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTTask.cxx
Updated macro for K* in pA analysis
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTTask.cxx
index 4347c495a1d3d3c802fd94747e4f4089d4e510e6..f2a4e1bb9c5c5ccc38cf708a54ef630948e982fc 100644 (file)
@@ -1,6 +1,6 @@
 // $Id$
 //**************************************************************************
-//* This file is property of and copyright by the ALICE HLT Project        * 
+//* This file is property of and copyright by the                          * 
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //*                                                                        *
 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
 /// @brief  Implementation of HLT tasks.
 ///
 
-// 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
-
 #include <cerrno>
 #include <cassert>
 #include <iostream>
@@ -44,6 +34,8 @@ using namespace std;
 #include "TList.h"
 #include "AliHLTErrorGuard.h"
 
+using std::cout;
+
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTTask)
 
@@ -413,8 +405,8 @@ int AliHLTTask::StartRun()
              if ((iResult=fpDataBuffer->SetConsumer(pTgtTask->GetComponent()))>=0) {
              }
            } else {
-             break;
              iResult=-EFAULT;
+             break;
            }
            lnk=lnk->Next();
          }
@@ -573,7 +565,7 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType, AliHLTUInt6
       AliHLTComponent::FillEventData(evtData);
       if (eventNo>=0)
        evtData.fEventID=(AliHLTEventID_t)eventNo;
-      if (timestamp) evtData.fEventCreation_s=timestamp;
+      if (timestamp < kMaxUInt) evtData.fEventCreation_s=timestamp;
       else
       evtData.fEventCreation_s=static_cast<AliHLTUInt32_t>(time(NULL));
       AliHLTComponentTriggerData trigData;
@@ -784,6 +776,58 @@ int AliHLTTask::ProcessTask(Int_t eventNo, AliHLTUInt32_t eventType, AliHLTUInt6
   return iResult;
 }
 
+int AliHLTTask::SubscribeSourcesAndSkip()
+{
+  // function carries out the proper cleanup of the source components
+  // by subscribing and releasing
+  int iResult=0;  
+  AliHLTTask* pSrcTask=NULL;
+  AliHLTTaskPList subscribedTaskList;
+
+  // cleanup the data buffer
+  if (fpDataBuffer) fpDataBuffer->Reset();
+
+  // subscribe to all source tasks
+  fBlockDataArray.clear();
+  for (TObjLink* lnk=fListDependencies.FirstLink(); lnk!=NULL; lnk=lnk->Next()) {
+    if (!lnk->GetObject()) continue;
+    pSrcTask=dynamic_cast<AliHLTTask*>(lnk->GetObject());
+    if (!pSrcTask) continue;
+    unsigned iPosition=fBlockDataArray.size();
+    if ((iResult=pSrcTask->Subscribe(this, fBlockDataArray))>0) {
+      for (unsigned i=iPosition; i<fBlockDataArray.size(); i++) {
+       subscribedTaskList.push_back(pSrcTask);
+      }
+      HLTDebug("subscribed to %d blocks of task %s (%p)", iResult, pSrcTask->GetName(), pSrcTask, iResult);
+    } else if (iResult<0) {
+      HLTError("failed to subscribe to task %s (%p) with error %d", pSrcTask->GetName(), pSrcTask, iResult);
+    }
+  }
+
+  unsigned iSourceDataBlock=0;
+  AliHLTTaskPList::iterator element;
+  while ((element=subscribedTaskList.begin())!=subscribedTaskList.end()) {
+    assert(iSourceDataBlock<fBlockDataArray.size());
+    pSrcTask=*element;
+    if (pSrcTask && iSourceDataBlock<fBlockDataArray.size()) {
+      if ((iResult=pSrcTask->Release(&fBlockDataArray[iSourceDataBlock], this))>=0) {
+       HLTDebug("successfully released segment of task %s (%p)", pSrcTask->GetName(), pSrcTask);
+      } else if (iSourceDataBlock>=fBlockDataArray.size()) {
+       HLTError("mismatch between list of subscribed tasks and block list in task %s (%p), can not release task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
+      } else {
+       HLTError("realease of task %s (%p) failed with error %d", pSrcTask->GetName(), pSrcTask, iResult);
+      }
+    }
+    subscribedTaskList.erase(element);
+    iSourceDataBlock++;
+  }
+  if (iSourceDataBlock<fBlockDataArray.size()) {
+    HLTWarning("not all subscriptions released for task %s (%p)", GetName(), this);
+  }
+
+  return 0;
+}
+
 int AliHLTTask::GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const
 {
   // see header file for function documentation