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