]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/BASE/AliHLTDumpTask.cxx
Cluster indices are published via AliKalmanTrack::GetClusterIndex()
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDumpTask.cxx
... / ...
CommitLineData
1// $Id$
2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
19/** @file AliHLTDumpTask.cxx
20 @author Matthias Richter
21 @date
22 @brief Base class for data sinks with direct buffer access.
23*/
24
25#include "AliHLTDumpTask.h"
26
27/** ROOT macro for the implementation of ROOT specific class methods */
28ClassImp(AliHLTDumpTask)
29
30AliHLTDumpTask::AliHLTDumpTask(const char* chains)
31 :
32 AliHLTTask(),
33 fpDummyTask(NULL),
34 fpDummyConfiguration(NULL),
35 fBlocks()
36{
37 // see header file for class documentation
38 // or
39 // refer to README to build package
40 // or
41 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
42 if (chains && chains[0]!=0) SetChains(chains);
43}
44
45AliHLTDumpTask::~AliHLTDumpTask()
46{
47 // see header file for class documentation
48
49 // UnsetTarget called automatically
50 if (fpDummyTask) delete fpDummyTask;
51 fpDummyTask=NULL;
52
53 if (fpDummyConfiguration) delete fpDummyConfiguration;
54 fpDummyConfiguration=NULL;
55
56 if (fpConfiguration) delete fpConfiguration;
57 fpConfiguration=NULL;
58}
59
60int AliHLTDumpTask::SetChains(const char* chains)
61{
62 // see header file for class documentation
63 if (!chains || chains[0]==0) {
64 HLTError("invalid chain id string");
65 return -EINVAL;
66 }
67 TString taskname=chains;
68 taskname.ReplaceAll(" ", "_");
69 taskname+="_hltDumpTask";
70
71 // This is just a trick to use the existing Task handling, especially the
72 // ProcessTask function.
73 // 1. The 'BlockFilter' just forwards the data blocks of all specified chains
74 // 2. A dummy task is added to the target list in order to set the data segments
75 // after forwarding. In case of an empty target list the data is just discarded.
76 // That's maybe not the most elegant solution but far less awkward as one would
77 // expect.
78 fpConfiguration=new AliHLTConfiguration(taskname.Data(), "BlockFilter", chains, NULL);
79 TString dummyname=chains;
80 dummyname.ReplaceAll(" ", "_");
81 dummyname+="_never_used_dummy_";
82 fpDummyConfiguration=new AliHLTConfiguration(dummyname.Data(), "BlockFilter", taskname.Data(), NULL);
83 if (fpDummyConfiguration) {
84 fpDummyTask=new AliHLTTask(fpDummyConfiguration);
85 SetTarget(fpDummyTask);
86 }
87 return 0;
88}
89
90int AliHLTDumpTask::CustomInit(AliHLTComponentHandler* pCH)
91{
92 // see header file for class documentation
93 if (!fpDummyTask) return -ENOENT;
94 return fpDummyTask->Init(NULL, pCH);
95}
96
97int AliHLTDumpTask::CustomCleanup()
98{
99 // see header file for class documentation
100 if (!fpDummyTask) return -ENOENT;
101 return fpDummyTask->Deinit();
102}
103
104const char* AliHLTDumpTask::GetSourceChains() const
105{
106 // see header file for class documentation
107 if (!fpConfiguration) return "";
108 return fpConfiguration->GetSourceSettings();
109}
110
111const AliHLTComponentBlockDataList& AliHLTDumpTask::GetDataBlocks()
112{
113 // see header file for class documentation
114 if (fBlocks.size()>0) return fBlocks;
115 if (fpDataBuffer) {
116 if (!fpDataBuffer->FindConsumer(fpDummyTask->GetComponent())) {
117 // in order to subscribe to the buffers the dummy consumer
118 // needs to be set. The dummy task is not in the AliHLTSystem chain
119 // and therefor not automatically set.
120 fpDataBuffer->SetConsumer(fpDummyTask->GetComponent());
121 }
122 fBlocks.clear();
123 if (fpDataBuffer->GetNofSegments()>0
124 && fpDataBuffer->FindConsumer(fpDummyTask->GetComponent(), 0 /*search only among pending consumers*/)>0) {
125 if (fpDataBuffer->Subscribe(fpDummyTask->GetComponent(), fBlocks)>=0) {
126 return fBlocks;
127 } else {
128 HLTError("failed to subscribe to data buffer");
129 }
130 }
131 } else {
132 // 2008-08-07 this is not a failure condition
133 // If the chain has not been processed because LocalReconstruction
134 // is not enabled, the task will be empty
135 //HLTWarning("no data buffer available");
136 }
137 fBlocks.clear();
138 return fBlocks;
139}
140
141int AliHLTDumpTask::ReleaseDataBlocks()
142{
143 // see header file for class documentation
144 int iResult=0;
145 if (!fpDataBuffer) return 0;
146
147 if (fBlocks.size()==0 && fpDataBuffer->GetNofPendingConsumers()>0) {
148 // There are data blocks in the parents which this task has not yet
149 // subscribed to. The subscription takes place in GetDataBlocks.
150 // However, this method is not necessarily called.
151 //
152 // In order to switch buffer states correctly, first let the dummy
153 // task as the only consumer subscribe to all those buffers and
154 // release them further down. Basically, the buffers are arranged
155 // in a different internal list, which is the only state they can be
156 // released from. This approach has been chosen to implement the
157 // DumpTask having no real consumers but at the same time has to
158 // behave like a normal task in AliHLTTask::ProcessTask
159 fpDataBuffer->Subscribe(fpDummyTask->GetComponent(), fBlocks);
160 }
161
162 for (unsigned int i=0; i<fBlocks.size(); i++) {
163 fpDataBuffer->Release(&(fBlocks[i]), fpDummyTask->GetComponent(), this);
164 }
165 fBlocks.clear();
166 return iResult;
167}