]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCKryptonClusterFinderComponent.cxx
Removing extra semicolon
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCKryptonClusterFinderComponent.cxx
CommitLineData
187229ab 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: Kenneth Aamodt *
8 * Kalliopi Kanaki *
9 * for The ALICE HLT Project. *
10 * *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19
20/** @file AliHLTTPCKryptonClusterFinderComponent.cxx
21 @author Kenneth Aamodt, Kalliopi Kanaki
22 @date
23 @brief The TPC krypton cluster finder processing component
24*/
25
26// see header file for class documentation //
27// or //
28// refer to README to build package //
29// or //
30// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt //
31
32#if __GNUC__>= 3
33using namespace std;
34#endif
35#include "AliHLTTPCKryptonClusterFinderComponent.h"
36#include "AliHLTTPCDigitReaderDecoder.h"
37#include "AliHLTTPCKryptonClusterFinder.h"
38#include "AliHLTTPCSpacePointData.h"
39#include "AliHLTTPCClusterDataFormat.h"
40#include "AliHLTTPCTransform.h"
41#include "AliHLTTPCClusters.h"
42#include "AliHLTTPCDefinitions.h"
43#include "AliCDBEntry.h"
44#include "AliCDBManager.h"
45
46#include <cstdlib>
47#include <cerrno>
48#include "TString.h"
49#include "TObjString.h"
50#include <sys/time.h>
51
52AliHLTTPCKryptonClusterFinderComponent gAliHLTTPCKryptonClusterFinderComponent;
53
54/** ROOT macro for the implementation of ROOT specific class methods */
55ClassImp(AliHLTTPCKryptonClusterFinderComponent)
56
57AliHLTTPCKryptonClusterFinderComponent::AliHLTTPCKryptonClusterFinderComponent()
58 :
59 fClusterFinder(NULL),
60 fReader(NULL)
61{
62 // see header file for class documentation
63 // or
64 // refer to README to build package
65 // or
66 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
67}
68
69AliHLTTPCKryptonClusterFinderComponent::~AliHLTTPCKryptonClusterFinderComponent()
70{
71 // see header file for class documentation
72}
73
74// Public functions to implement AliHLTComponent's interface.
75// These functions are required for the registration process
76
77const char* AliHLTTPCKryptonClusterFinderComponent::GetComponentID()
78{
79 // see header file for class documentation
80 return "TPCKryptonClusterFinder";
81}
82
83void AliHLTTPCKryptonClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
84{
85 // see header file for class documentation
86 list.clear();
87 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
88}
89
90AliHLTComponentDataType AliHLTTPCKryptonClusterFinderComponent::GetOutputDataType()
91{
92 // see header file for class documentation
93 return kAliHLTDataTypeHistogram;
94}
95
96int AliHLTTPCKryptonClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
97
98{
99 // see header file for class documentation
100 tgtList.clear();
101 tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
102 return tgtList.size();
103}
104
105void AliHLTTPCKryptonClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
106{
107 // see header file for class documentation
108 // XXX TODO: Find more realistic values.
109 constBase = 0;
110 inputMultiplier = (6 * 0.4);
111}
112
113AliHLTComponent* AliHLTTPCKryptonClusterFinderComponent::Spawn()
114{
115 // see header file for class documentation
116 return new AliHLTTPCKryptonClusterFinderComponent();
117}
118
119int AliHLTTPCKryptonClusterFinderComponent::DoInit( int argc, const char** argv )
120{
121 // see header file for class documentation
122 if ( fClusterFinder )
123 return EINPROGRESS;
124
125 fClusterFinder = new AliHLTTPCKryptonClusterFinder();
126
127 Int_t i = 0;
128
129 while ( i < argc ) {
130
131 //No arguments so far
132
133 Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
134 return EINVAL;
135
136 }
137
138 fReader = new AliHLTTPCDigitReaderDecoder();
139 fClusterFinder->SetReader(fReader);
140
141 return 0;
142}
143
144int AliHLTTPCKryptonClusterFinderComponent::DoDeinit()
145{
146 // see header file for class documentation
147
148 if ( fClusterFinder )
149 delete fClusterFinder;
150 fClusterFinder = NULL;
151
152 if ( fReader )
153 delete fReader;
154 fReader = NULL;
155
156 return 0;
157}
158
159int AliHLTTPCKryptonClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData,
160 const AliHLTComponentBlockData* blocks,
161 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
162 AliHLTUInt32_t& size,
163 vector<AliHLTComponentBlockData>& outputBlocks )
164{
165 // see header file for class documentation
166
167 // == init iter (pointer to datablock)
168 const AliHLTComponentBlockData* iter = NULL;
169 unsigned long ndx;
170
171 // == OUTdatatype pointer
172 AliHLTTPCClusterData* outPtr;
173
174 AliHLTUInt8_t* outBPtr;
175 UInt_t offset, mysize, nSize, tSize = 0;
176
177 outBPtr = outputPtr;
178 outPtr = (AliHLTTPCClusterData*)outBPtr;
179
180 Int_t slice, patch, row[2];
181 unsigned long maxPoints, realPoints = 0;
182
183 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
184 {
185 iter = blocks+ndx;
186 mysize = 0;
187 offset = tSize;
188
189
190 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
191 evtData.fEventID, evtData.fEventID,
192 DataType2Text( iter->fDataType).c_str(),
193 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
194
195 if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType &&
196 GetEventCount()<2) {
197 HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!",
198 DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
199 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
200 }
201
202 if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC) &&
203 iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue;
204
205
206 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
207 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
208 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
209 row[1] = AliHLTTPCTransform::GetLastRow( patch );
210
211
212 fClusterFinder->SetPatch(patch);
213
214 outPtr = (AliHLTTPCClusterData*)outBPtr;
215
216 maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
217
218 fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
219
220 fClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize);
221
222 fClusterFinder->FindNormalClusters();
223
224 fClusterFinder->FindKryptonClusters();
225
226 realPoints = fClusterFinder->GetNumberOfClusters();
227
228
229 AliHLTComponentBlockData bd;
230 FillBlockData( bd );
231 bd.fOffset = offset;
232 bd.fSize = mysize;
233 bd.fSpecification = iter->fSpecification;
234 bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
235 //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
236 outputBlocks.push_back( bd );
237
238 tSize += mysize;
239 outBPtr += mysize;
240 outPtr = (AliHLTTPCClusterData*)outBPtr;
241
242
243 if ( tSize > size )
244 {
245 Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
246 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
247 tSize, size );
248 return EMSGSIZE;
249 }
250
251 size = tSize;
252 }
253 return 0;
254}
255
256int AliHLTTPCKryptonClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
257{
258 // see header file for class documentation
259 const char* path="HLT/ConfigTPC";
260 if (cdbEntry) path=cdbEntry;
261 if (path) {
262 HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
263 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
264 if (pEntry) {
265 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
266 if (pString) {
267 HLTInfo("received configuration object: %s", pString->GetString().Data());
268 } else {
269 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
270 }
271 } else {
272 HLTError("can not fetch object \"%s\" from CDB", path);
273 }
274 }
275 return 0;
276}