]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCCATrackerComponent.cxx
rootcint sees ALI_DATE and not DATE_ROOT
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCATrackerComponent.cxx
CommitLineData
21b6a334 1
2
3/**************************************************************************
9be2600f 4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
21b6a334 6 * *
9be2600f 7 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 * Ivan Kisel <kisel@kip.uni-heidelberg.de> *
9 * for The ALICE HLT Project. *
21b6a334 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///////////////////////////////////////////////////////////////////////////////
21// //
22// a TPC tracker processing component for the HLT based on CA by Ivan Kisel //
23// //
24///////////////////////////////////////////////////////////////////////////////
25
26#if __GNUC__>= 3
27using namespace std;
28#endif
29
30#include "AliHLTTPCCATrackerComponent.h"
31#include "AliHLTTPCTransform.h"
32#include "AliHLTTPCCATracker.h"
33#include "AliHLTTPCVertex.h"
34#include "AliHLTTPCSpacePointData.h"
35#include "AliHLTTPCVertexData.h"
36#include "AliHLTTPCClusterDataFormat.h"
37#include "AliHLTTPCTransform.h"
38#include "AliHLTTPCTrackSegmentData.h"
39#include "AliHLTTPCTrackArray.h"
40#include "AliHLTTPCTrackletDataFormat.h"
96bda103 41#include "AliHLTTPCDefinitions.h"
5994547c 42//#include "AliHLTTPC.h"
21b6a334 43#include <stdlib.h>
44#include <iostream>
45#include <errno.h>
46
47//static bool ask = true;
48static bool ask = false;
49
50// this is a global object used for automatic component registration, do not use this
51AliHLTTPCCATrackerComponent gAliHLTTPCCATrackerComponent;
52
53ClassImp(AliHLTTPCCATrackerComponent)
54
55AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent()
96bda103 56 :
57 fTracker(NULL),
e419b223 58 fVertex(NULL),
59 fBField(0)
96bda103 60{
61 // see header file for class documentation
62 // or
63 // refer to README to build package
64 // or
65 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
66}
67
68AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent(const AliHLTTPCCATrackerComponent&)
69 :
70 fTracker(NULL),
e419b223 71 fVertex(NULL),
72 fBField(0)
96bda103 73{
74 // see header file for class documentation
75 HLTFatal("copy constructor untested");
76}
77
78AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=(const AliHLTTPCCATrackerComponent&)
79{
80 // see header file for class documentation
81 HLTFatal("assignment operator untested");
82 return *this;
83}
21b6a334 84
85AliHLTTPCCATrackerComponent::~AliHLTTPCCATrackerComponent()
86 {
96bda103 87 // see header file for class documentation
21b6a334 88 }
89
90// Public functions to implement AliHLTComponent's interface.
91// These functions are required for the registration process
92
93const char* AliHLTTPCCATrackerComponent::GetComponentID()
94 {
96bda103 95 // see header file for class documentation
21b6a334 96 return "TPCCATracker";
97 }
98
96bda103 99void AliHLTTPCCATrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
21b6a334 100 {
96bda103 101 // see header file for class documentation
21b6a334 102 list.clear();
96bda103 103 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
104 list.push_back( AliHLTTPCDefinitions::fgkVertexDataType );
21b6a334 105 }
106
96bda103 107AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType()
21b6a334 108 {
96bda103 109 // see header file for class documentation
110 return AliHLTTPCDefinitions::fgkTrackSegmentsDataType;
21b6a334 111 }
112
113void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
114 {
96bda103 115 // see header file for class documentation
21b6a334 116 // XXX TODO: Find more realistic values.
117 constBase = 0;
118 inputMultiplier = 0.2;
119 }
120
121AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn()
122 {
96bda103 123 // see header file for class documentation
21b6a334 124 return new AliHLTTPCCATrackerComponent;
125 }
126
127int AliHLTTPCCATrackerComponent::DoInit( int argc, const char** argv )
128 {
96bda103 129 // see header file for class documentation
21b6a334 130 Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "DoInit", "DoInit()" );
131
132 if ( fTracker || fVertex )
133 return EINPROGRESS;
134
135 fTracker = new AliHLTTPCCATracker();
136 fTracker->CACreateHistos();
137
138 fVertex = new AliHLTTPCVertex();
139
140
141/* ---------------------------------------------------------------------------------
142 * cmdline arguments not needed so far
143
144 int i = 0;
145 char* cpErr;
146
147 while ( i < argc )
148 {
149 if ( !strcmp( argv[i], "bfield" ) )
150 {
151 if ( argc <= i+1 )
152 {
153 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing B-field", "Missing B-field specifier." );
154 return ENOTSUP;
155 }
156 fBField = strtod( argv[i+1], &cpErr );
157 if ( *cpErr )
158 {
159 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Cannot convert B-field specifier '%s'.", argv[i+1] );
160 return EINVAL;
161 }
162 i += 2;
163 continue;
164 }
165
166 Logging(kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
167 return EINVAL;
168 }
169--------------------------------------------------------------------------------- */
170
171 return 0;
172 }
173
174int AliHLTTPCCATrackerComponent::DoDeinit()
175 {
96bda103 176 // see header file for class documentation
21b6a334 177 if ( fTracker )
178 delete fTracker;
179 fTracker = NULL;
180 if ( fVertex )
181 delete fVertex;
182 fVertex = NULL;
183 return 0;
184 }
185
96bda103 186int AliHLTTPCCATrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
187 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
188 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
21b6a334 189 {
96bda103 190 // see header file for class documentation
21b6a334 191 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "DoEvent", "DoEvent()" );
192 if ( evtData.fBlockCnt<=0 )
193 {
194 Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "no blocks in event" );
195 return 0;
196 }
197
96bda103 198 const AliHLTComponentBlockData* iter = NULL;
21b6a334 199 unsigned long ndx;
200 AliHLTTPCClusterData* inPtrSP;
201 AliHLTTPCVertexData* inPtrV = NULL;
96bda103 202 const AliHLTComponentBlockData* vertexIter=NULL;
21b6a334 203 AliHLTTPCTrackletData* outPtr;
204 AliHLTUInt8_t* outBPtr;
205
206 AliHLTUInt32_t vSize = 0;
207 UInt_t offset=0, mysize, tSize = 0;
208 outBPtr = outputPtr;
209
210 outPtr = (AliHLTTPCTrackletData*)(outBPtr);
211 fTracker->SetOutPtr( outPtr->fTracklets );
212
213 // ------------------------------------------
214
215 Int_t slice=-1, patch=-1, row[2];
216 Int_t minPatch=INT_MAX, maxPatch = 0;
217 offset = 0;
218 std::vector<Int_t> slices;
219 std::vector<Int_t>::iterator slIter, slEnd;
220 std::vector<unsigned> sliceCnts;
221 std::vector<unsigned>::iterator slCntIter;
222 Int_t vertexSlice=-1;
223
224 // Find min/max rows used in total and find and read out vertex if it is present
225 // also determine correct slice number, if multiple slice numbers are present in event
226 // (which should not happen in the first place) we use the one that occurs the most times
227 row[0] = 0;
228 row[1] = 0;
229 bool found;
230
231 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
232 {
233 iter = blocks+ndx;
234
235
236 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
237 found = false;
238 slIter = slices.begin();
239 slEnd = slices.end();
240 slCntIter = sliceCnts.begin();
241 while ( slIter != slEnd )
242 {
243 if ( *slIter == slice )
244 {
245 found = true;
246 break;
247 }
248 slIter++;
249 slCntIter++;
250 }
251 if ( !found )
252 {
253 slices.insert( slices.end(), slice );
254 sliceCnts.insert( sliceCnts.end(), 1 );
255 }
256 else
257 *slCntIter++;
258
96bda103 259 if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType )
21b6a334 260 {
261 inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
262 vertexIter = iter;
263 vSize = iter->fSize;
264 fVertex->Read( inPtrV );
265 vertexSlice = slice;
266 }
96bda103 267 if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType )
21b6a334 268 {
269 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
270 if ( minPatch>patch )
271 {
272 minPatch = patch;
273 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
274 }
275 if ( maxPatch<patch )
276 {
277 maxPatch = patch;
278 row[1] = AliHLTTPCTransform::GetLastRow( patch );
279 }
280 }
281 }
282
283 // Determine slice number to really use.
284 if ( slices.size()>1 )
285 {
286 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
287 "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
288 evtData.fEventID, evtData.fEventID );
289 unsigned maxCntSlice=0;
290 slIter = slices.begin();
291 slEnd = slices.end();
292 slCntIter = sliceCnts.begin();
293 while ( slIter != slEnd )
294 {
295 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
296 "Slice %lu found %lu times.", *slIter, *slCntIter );
297 if ( maxCntSlice<*slCntIter )
298 {
299 maxCntSlice = *slCntIter;
300 slice = *slIter;
301 }
302 slIter++;
303 slCntIter++;
304 }
305 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
306 "Using slice %lu.", slice );
307 }
308 else if ( slices.size()>0 )
309 {
310 slice = *(slices.begin());
311 }
312 else
313 {
314 slice = -1;
315 }
316
317 if ( vertexSlice != slice )
318 {
319 // multiple vertex blocks in event and we used the wrong one...
320 found = false;
321 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
322 {
323 iter = blocks+ndx;
96bda103 324 if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
21b6a334 325 {
326 inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
327 vertexIter = iter;
328 vSize = iter->fSize;
329 fVertex->Read( inPtrV );
330 break;
331 }
332 }
333 }
334
335 // fTracker->InitSector( slice, row, fEta );
336 // fTracker->SetVertex(fVertex);
337
338 mysize = 0;
339 // read in all hits
340 std::vector<unsigned long> patchIndices;
341 std::vector<unsigned long>::iterator pIter, pEnd;
342 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
343 {
344 iter = blocks+ndx;
345
96bda103 346 if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
21b6a334 347 {
348 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
349 pIter = patchIndices.begin();
350 pEnd = patchIndices.end();
351 while ( pIter!=pEnd && AliHLTTPCDefinitions::GetMinSliceNr( blocks[*pIter] ) < patch )
352 pIter++;
353 patchIndices.insert( pIter, ndx );
354 }
355 }
356
357 fTracker->CAInitialize();
358
359 pIter = patchIndices.begin();
360 pEnd = patchIndices.end();
361 while ( pIter!=pEnd )
362 {
363 ndx = *pIter;
364 iter = blocks+ndx;
365
366 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
367 inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr);
368
369 Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Reading hits",
370 "Reading hits for slice %d - patch %d", slice, patch );
371
372 fTracker->CAReadPatchHits( patch, inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints );
373 fTracker->CAFindPatchTracks( patch );
374
375 pIter++;
376 }
377
378 fTracker->CAFindSliceTracks();
379
380 //#ifdef XXX
381 char symbol;
382 if (ask){
383 do{
384 std::cin.get(symbol);
385 if (symbol == 'r')
386 ask = false;
387 } while (symbol != '\n');
388 }
389 //#endif //XXX
390
391
392 UInt_t ntracks0=0;
393
394 mysize = fTracker->GetOutputSize();
395 ntracks0 = fTracker->GetOutputNTracks();
396 outPtr->fTrackletCnt = fTracker->GetOutputNTracks();
397
398 Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracks",
399 "Input: Number of tracks: %lu Slice/MinPatch/MaxPatch/RowMin/RowMax: %lu/%lu/%lu/%lu/%lu.",
400 ntracks0, slice, minPatch, maxPatch, row[0], row[1] );
401
402 tSize += mysize+sizeof(AliHLTTPCTrackletData);
403 outBPtr += mysize+sizeof(AliHLTTPCTrackletData);
404
96bda103 405 AliHLTComponentBlockData bd;
21b6a334 406 FillBlockData( bd );
407 bd.fOffset = offset;
408 bd.fSize = tSize;
409 bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
410 outputBlocks.push_back( bd );
411
412#ifdef FORWARD_VERTEX_BLOCK
413 if ( vertexIter )
414 {
415 // Copy the descriptor block for the vertex information.
416 bd = *vertexIter;
417 outputBlocks.push_back( bd );
418 }
419#endif // FORWARD_VERTEX_BLOCK
420
421 size = tSize;
422
423 fTracker->CAWriteHistos();
424
425 return 0;
426 }
427
428