cf471b1e |
1 | // @(#) $Id$ |
ce565086 |
2 | // ************************************************************************** |
d54804bf |
3 | // This file is property of and copyright by the ALICE HLT Project * |
4 | // ALICE Experiment at CERN, All rights reserved. * |
5 | // * |
6 | // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> * |
7 | // Ivan Kisel <kisel@kip.uni-heidelberg.de> * |
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. * |
ce565086 |
17 | // * |
d54804bf |
18 | //*************************************************************************** |
ce565086 |
19 | |
cf471b1e |
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" |
cf471b1e |
34 | #include "AliHLTTPCCAOutTrack.h" |
d54804bf |
35 | #include "AliHLTTPCCAParam.h" |
eb30eb49 |
36 | #include "AliHLTTPCCATrackConvertor.h" |
cf471b1e |
37 | |
cf471b1e |
38 | #include "AliHLTTPCSpacePointData.h" |
cf471b1e |
39 | #include "AliHLTTPCClusterDataFormat.h" |
40 | #include "AliHLTTPCTransform.h" |
41 | #include "AliHLTTPCTrackSegmentData.h" |
42 | #include "AliHLTTPCTrackArray.h" |
43 | #include "AliHLTTPCTrackletDataFormat.h" |
44 | #include "AliHLTTPCDefinitions.h" |
d54804bf |
45 | #include "AliExternalTrackParam.h" |
dc4788ec |
46 | #include "TStopwatch.h" |
cf471b1e |
47 | #include "TMath.h" |
53a9c37c |
48 | #include "AliCDBEntry.h" |
49 | #include "AliCDBManager.h" |
50 | #include "TObjString.h" |
51 | #include "TObjArray.h" |
cf471b1e |
52 | |
00d07bcd |
53 | /** global object for registration |
54 | * Matthias 2009-01-13 temporarily using the global object approach again. |
55 | * CA cade had to be disabled because of various compilation problems, so |
56 | * the global object approach fits better for the moment. |
57 | */ |
58 | AliHLTTPCCATrackerComponent gAliHLTTPCCATrackerComponent; |
59 | |
672f8b8c |
60 | /** ROOT macro for the implementation of ROOT specific class methods */ |
cf471b1e |
61 | ClassImp(AliHLTTPCCATrackerComponent) |
62 | |
63 | AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent() |
64 | : |
65 | fTracker(NULL), |
eb30eb49 |
66 | fSolenoidBz(0), |
67 | fMinNTrackClusters(0), |
eb30eb49 |
68 | fClusterZCut(500.), |
d54804bf |
69 | fFullTime(0), |
70 | fRecoTime(0), |
71 | fNEvents(0) |
cf471b1e |
72 | { |
73 | // see header file for class documentation |
74 | // or |
75 | // refer to README to build package |
76 | // or |
77 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt |
78 | } |
79 | |
80 | AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent(const AliHLTTPCCATrackerComponent&) |
81 | : |
c61a7285 |
82 | AliHLTProcessor(), |
cf471b1e |
83 | fTracker(NULL), |
eb30eb49 |
84 | fSolenoidBz(0), |
d54804bf |
85 | fMinNTrackClusters(30), |
eb30eb49 |
86 | fClusterZCut(500.), |
53a9c37c |
87 | fFullTime(0), |
d54804bf |
88 | fRecoTime(0), |
89 | fNEvents(0) |
cf471b1e |
90 | { |
91 | // see header file for class documentation |
92 | HLTFatal("copy constructor untested"); |
93 | } |
94 | |
95 | AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=(const AliHLTTPCCATrackerComponent&) |
96 | { |
97 | // see header file for class documentation |
98 | HLTFatal("assignment operator untested"); |
99 | return *this; |
100 | } |
101 | |
102 | AliHLTTPCCATrackerComponent::~AliHLTTPCCATrackerComponent() |
4c256004 |
103 | { |
cf471b1e |
104 | // see header file for class documentation |
4c256004 |
105 | delete fTracker; |
106 | } |
cf471b1e |
107 | |
4c256004 |
108 | // |
cf471b1e |
109 | // Public functions to implement AliHLTComponent's interface. |
110 | // These functions are required for the registration process |
4c256004 |
111 | // |
cf471b1e |
112 | |
113 | const char* AliHLTTPCCATrackerComponent::GetComponentID() |
4c256004 |
114 | { |
cf471b1e |
115 | // see header file for class documentation |
4c256004 |
116 | return "TPCCATracker"; |
117 | } |
cf471b1e |
118 | |
119 | void AliHLTTPCCATrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
4c256004 |
120 | { |
cf471b1e |
121 | // see header file for class documentation |
4c256004 |
122 | list.clear(); |
123 | list.push_back( AliHLTTPCDefinitions::fgkClustersDataType ); |
124 | } |
cf471b1e |
125 | |
126 | AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType() |
4c256004 |
127 | { |
cf471b1e |
128 | // see header file for class documentation |
4c256004 |
129 | return AliHLTTPCDefinitions::fgkTrackSegmentsDataType; |
130 | } |
cf471b1e |
131 | |
132 | void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) |
4c256004 |
133 | { |
134 | // define guess for the output data size |
135 | constBase = 200; // minimum size |
136 | inputMultiplier = 0.5; // size relative to input |
137 | } |
cf471b1e |
138 | |
139 | AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn() |
4c256004 |
140 | { |
cf471b1e |
141 | // see header file for class documentation |
4c256004 |
142 | return new AliHLTTPCCATrackerComponent; |
143 | } |
cf471b1e |
144 | |
4687b8fc |
145 | Int_t AliHLTTPCCATrackerComponent::DoInit( Int_t argc, const char** argv ) |
4c256004 |
146 | { |
53a9c37c |
147 | // Configure the CA tracker component |
d54804bf |
148 | |
53a9c37c |
149 | fSolenoidBz = 5; |
150 | fMinNTrackClusters = 0; |
151 | fClusterZCut = 500.; |
d54804bf |
152 | fFullTime = 0; |
153 | fRecoTime = 0; |
00d07bcd |
154 | fNEvents = 0; |
d54804bf |
155 | |
53a9c37c |
156 | if ( fTracker ) return EINPROGRESS; |
4c256004 |
157 | fTracker = new AliHLTTPCCATracker(); |
d54804bf |
158 | |
53a9c37c |
159 | Int_t iResult = EINVAL; |
eb30eb49 |
160 | |
53a9c37c |
161 | TString arguments=""; |
162 | for (int i=0; i<argc; i++) { |
163 | TString argument=argv[i]; |
164 | if (!arguments.IsNull()) arguments+=" "; |
165 | arguments+=argument; |
4c256004 |
166 | } |
53a9c37c |
167 | if (!arguments.IsNull()) { |
168 | iResult=Configure(arguments.Data()); |
169 | } else { |
170 | iResult=Reconfigure(NULL, NULL); |
171 | } |
172 | return iResult; |
4c256004 |
173 | } |
cf471b1e |
174 | |
53a9c37c |
175 | |
4687b8fc |
176 | Int_t AliHLTTPCCATrackerComponent::DoDeinit() |
4c256004 |
177 | { |
cf471b1e |
178 | // see header file for class documentation |
4c256004 |
179 | if ( fTracker ) delete fTracker; |
180 | fTracker = NULL; |
181 | return 0; |
182 | } |
cf471b1e |
183 | |
53a9c37c |
184 | Int_t AliHLTTPCCATrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId) |
185 | { |
186 | // see header file for class documentation |
187 | |
188 | Int_t iResult=EINVAL; |
4acbee3b |
189 | const char* path="HLT/ConfigTPC/TPCCATrackerComponent"; |
53a9c37c |
190 | const char* defaultNotify=""; |
191 | if (cdbEntry) { |
192 | path=cdbEntry; |
193 | defaultNotify=" (default)"; |
194 | } |
195 | if (path) { |
196 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); |
197 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); |
198 | if (pEntry) { |
199 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); |
200 | if (pString) { |
201 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); |
202 | iResult=Configure(pString->GetString().Data()); |
203 | } else { |
204 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); |
205 | } |
206 | } else { |
207 | HLTError("cannot fetch object \"%s\" from CDB", path); |
208 | } |
209 | } |
210 | |
211 | const char* pathBField=kAliHLTCDBSolenoidBz; |
212 | |
213 | if (pathBField) { |
214 | HLTInfo("reconfigure B-Field from entry %s, chain id %s", path,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); |
215 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathBField/*,GetRunNo()*/); |
216 | if (pEntry) { |
217 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); |
218 | if (pString) { |
219 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); |
220 | iResult=Configure(pString->GetString().Data()); |
221 | } else { |
222 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); |
223 | } |
224 | } else { |
225 | HLTError("cannot fetch object \"%s\" from CDB", path); |
226 | } |
227 | } |
228 | return iResult; |
229 | } |
230 | |
231 | |
eb30eb49 |
232 | Bool_t AliHLTTPCCATrackerComponent::CompareClusters(AliHLTTPCSpacePointData *a, AliHLTTPCSpacePointData *b) |
233 | { |
234 | //* Comparison function for sorting clusters |
235 | if( a->fPadRow<b->fPadRow ) return 1; |
236 | if( a->fPadRow>b->fPadRow ) return 0; |
237 | return (a->fZ < b->fZ); |
238 | } |
239 | |
53a9c37c |
240 | |
241 | Int_t AliHLTTPCCATrackerComponent::Configure( const char* arguments ) |
242 | { |
243 | //* Set parameters |
244 | |
245 | Int_t iResult=EINVAL; |
246 | if (!arguments) return iResult; |
247 | |
248 | TString allArgs=arguments; |
249 | TString argument; |
250 | Int_t bMissingParam=0; |
251 | |
252 | TObjArray* pTokens=allArgs.Tokenize(" "); |
253 | |
254 | Int_t nArgs = pTokens ?pTokens->GetEntries() :0; |
255 | |
256 | for (int i=0; i<nArgs; i++ ){ |
257 | argument=((TObjString*)pTokens->At(i))->GetString(); |
258 | if (argument.IsNull()){ |
259 | } |
260 | else if (argument.CompareTo("-solenoidBz")==0 ){ |
261 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; |
262 | fSolenoidBz = ((TObjString*)pTokens->At(i))->GetString().Atof(); |
263 | HLTInfo("Magnetic Field set to: %f", fSolenoidBz ); |
264 | } |
265 | else if ( argument.CompareTo("-minNClustersOnTrack")==0 || |
266 | argument.CompareTo("-minNTrackClusters")==0 ){ |
267 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; |
268 | fMinNTrackClusters = ((TObjString*)pTokens->At(i))->GetString().Atoi(); |
269 | HLTInfo("minNClustersOnTrack set to: %d", fMinNTrackClusters ); |
270 | } |
271 | else if ( argument.CompareTo("-clusterZCut")==0 ){ |
272 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; |
273 | fClusterZCut = TMath::Abs( ((TObjString*)pTokens->At(i))->GetString().Atof()); |
274 | HLTInfo("ClusterZCut set to: %f", fClusterZCut ); |
275 | } |
276 | else { |
277 | HLTError("Unknown option %s ", argument.Data()); |
278 | iResult=-EINVAL; |
279 | } |
280 | } |
281 | delete pTokens; |
282 | |
283 | if (bMissingParam) { |
284 | HLTError("Specifier missed for %s", argument.Data()); |
285 | iResult=-EINVAL; |
286 | } |
287 | |
288 | return iResult; |
289 | } |
290 | |
291 | |
292 | |
293 | |
4687b8fc |
294 | Int_t AliHLTTPCCATrackerComponent::DoEvent |
4c256004 |
295 | ( |
296 | const AliHLTComponentEventData& evtData, |
297 | const AliHLTComponentBlockData* blocks, |
c61a7285 |
298 | AliHLTComponentTriggerData& /*trigData*/, |
4c256004 |
299 | AliHLTUInt8_t* outputPtr, |
300 | AliHLTUInt32_t& size, |
301 | vector<AliHLTComponentBlockData>& outputBlocks ) |
cf471b1e |
302 | { |
00d07bcd |
303 | //* process event |
304 | AliHLTUInt32_t maxBufferSize = size; |
dc4788ec |
305 | size = 0; // output size |
306 | |
eb30eb49 |
307 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){ |
308 | return 0; |
309 | } |
310 | |
dc4788ec |
311 | TStopwatch timer; |
312 | |
4c256004 |
313 | // Event reconstruction in one TPC slice with CA Tracker |
eb30eb49 |
314 | |
d54804bf |
315 | //Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA::DoEvent()" ); |
cf471b1e |
316 | if ( evtData.fBlockCnt<=0 ) |
317 | { |
318 | Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "no blocks in event" ); |
319 | return 0; |
320 | } |
4c256004 |
321 | |
cf471b1e |
322 | const AliHLTComponentBlockData* iter = NULL; |
323 | unsigned long ndx; |
4c256004 |
324 | AliHLTTPCClusterData* inPtrSP; |
cf471b1e |
325 | |
4c256004 |
326 | // Determine the slice number |
cf471b1e |
327 | |
4c256004 |
328 | Int_t slice=-1; |
329 | { |
330 | std::vector<Int_t> slices; |
331 | std::vector<Int_t>::iterator slIter; |
332 | std::vector<unsigned> sliceCnts; |
333 | std::vector<unsigned>::iterator slCntIter; |
cf471b1e |
334 | |
4c256004 |
335 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ){ |
cf471b1e |
336 | iter = blocks+ndx; |
4c256004 |
337 | if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue; |
338 | |
cf471b1e |
339 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); |
dc4788ec |
340 | |
4c256004 |
341 | Bool_t found = 0; |
cf471b1e |
342 | slCntIter = sliceCnts.begin(); |
4c256004 |
343 | for( slIter = slices.begin(); slIter!=slices.end(); slIter++, slCntIter++ ){ |
344 | if ( *slIter == slice ){ |
345 | found = kTRUE; |
346 | break; |
cf471b1e |
347 | } |
4c256004 |
348 | } |
349 | if ( !found ){ |
350 | slices.push_back( slice ); |
351 | sliceCnts.push_back( 1 ); |
352 | } else *slCntIter++; |
cf471b1e |
353 | } |
354 | |
355 | |
4c256004 |
356 | // Determine slice number to really use. |
357 | if ( slices.size()>1 ) |
358 | { |
359 | Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event", |
360 | "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...", |
361 | evtData.fEventID, evtData.fEventID ); |
362 | unsigned maxCntSlice=0; |
363 | slCntIter = sliceCnts.begin(); |
364 | for( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) |
365 | { |
366 | Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event", |
367 | "Slice %lu found %lu times.", *slIter, *slCntIter ); |
368 | if ( maxCntSlice<*slCntIter ) |
369 | { |
370 | maxCntSlice = *slCntIter; |
371 | slice = *slIter; |
372 | } |
373 | } |
374 | Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event", |
375 | "Using slice %lu.", slice ); |
376 | } |
377 | else if ( slices.size()>0 ) |
378 | { |
379 | slice = *(slices.begin()); |
380 | } |
381 | } |
382 | |
383 | if( slice<0 ){ |
d54804bf |
384 | Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA:: no slices found in event" ); |
4c256004 |
385 | return 0; |
386 | } |
cf471b1e |
387 | |
4c256004 |
388 | |
389 | // Initialize the tracker |
390 | |
4c256004 |
391 | |
cf471b1e |
392 | { |
4c256004 |
393 | if( !fTracker ) fTracker = new AliHLTTPCCATracker; |
cf471b1e |
394 | Int_t iSec = slice; |
eb30eb49 |
395 | Float_t inRmin = 83.65; |
396 | // Float_t inRmax = 133.3; |
397 | // Float_t outRmin = 133.5; |
398 | Float_t outRmax = 247.7; |
399 | Float_t plusZmin = 0.0529937; |
400 | Float_t plusZmax = 249.778; |
401 | Float_t minusZmin = -249.645; |
402 | Float_t minusZmax = -0.0799937; |
403 | Float_t dalpha = 0.349066; |
404 | Float_t alpha = 0.174533 + dalpha*iSec; |
cf471b1e |
405 | |
dc4788ec |
406 | Bool_t zPlus = (iSec<18 ); |
eb30eb49 |
407 | Float_t zMin = zPlus ?plusZmin :minusZmin; |
408 | Float_t zMax = zPlus ?plusZmax :minusZmax; |
dc4788ec |
409 | //TPCZmin = -249.645, ZMax = 249.778 |
eb30eb49 |
410 | // Float_t rMin = inRmin; |
411 | // Float_t rMax = outRmax; |
00d07bcd |
412 | Int_t nRows = AliHLTTPCTransform::GetNRows(); |
dc4788ec |
413 | |
eb30eb49 |
414 | Float_t padPitch = 0.4; |
415 | Float_t sigmaZ = 0.228808; |
cf471b1e |
416 | |
00d07bcd |
417 | Float_t *rowX = new Float_t [nRows]; |
418 | for( Int_t irow=0; irow<nRows; irow++){ |
dc4788ec |
419 | rowX[irow] = AliHLTTPCTransform::Row2X( irow ); |
420 | } |
cf471b1e |
421 | |
422 | AliHLTTPCCAParam param; |
00d07bcd |
423 | param.Initialize( iSec, nRows, rowX, alpha, dalpha, |
424 | inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz ); |
693d2443 |
425 | param.SetHitPickUpFactor( 2 ); |
eb30eb49 |
426 | param.Update(); |
dc4788ec |
427 | fTracker->Initialize( param ); |
d54804bf |
428 | delete[] rowX; |
cf471b1e |
429 | } |
430 | |
4c256004 |
431 | |
432 | // min and max patch numbers and row numbers |
433 | |
434 | Int_t row[2] = {0,0}; |
4687b8fc |
435 | Int_t minPatch=100, maxPatch = -1; |
4c256004 |
436 | |
437 | // total n Hits |
cf471b1e |
438 | |
439 | Int_t nHitsTotal = 0; |
4c256004 |
440 | |
441 | // sort patches |
442 | |
443 | std::vector<unsigned long> patchIndices; |
444 | |
445 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ){ |
446 | iter = blocks+ndx; |
447 | if( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue; |
448 | if( slice!=AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue; |
cf471b1e |
449 | inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr); |
450 | nHitsTotal+=inPtrSP->fSpacePointCnt; |
4c256004 |
451 | Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); |
452 | if ( minPatch>patch ){ |
453 | minPatch = patch; |
454 | row[0] = AliHLTTPCTransform::GetFirstRow( patch ); |
455 | } |
456 | if ( maxPatch<patch ){ |
457 | maxPatch = patch; |
458 | row[1] = AliHLTTPCTransform::GetLastRow( patch ); |
459 | } |
460 | std::vector<unsigned long>::iterator pIter = patchIndices.begin(); |
461 | while( pIter!=patchIndices.end() && AliHLTTPCDefinitions::GetMinPatchNr( blocks[*pIter] ) < patch ){ |
462 | pIter++; |
463 | } |
464 | patchIndices.insert( pIter, ndx ); |
cf471b1e |
465 | } |
4c256004 |
466 | |
467 | |
468 | // pass event to CA Tracker |
469 | |
470 | fTracker->StartEvent(); |
471 | |
4c256004 |
472 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits", |
473 | "Total %d hits to read for slice %d", nHitsTotal, slice ); |
474 | |
eb30eb49 |
475 | |
476 | AliHLTTPCSpacePointData** vOrigClusters = new AliHLTTPCSpacePointData* [ nHitsTotal]; |
477 | |
dc4788ec |
478 | Int_t nClusters=0; |
479 | |
4c256004 |
480 | for( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter!=patchIndices.end(); pIter++ ){ |
481 | ndx = *pIter; |
482 | iter = blocks+ndx; |
cf471b1e |
483 | |
4c256004 |
484 | Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); |
485 | inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr); |
cf471b1e |
486 | |
4c256004 |
487 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits", |
488 | "Reading %d hits for slice %d - patch %d", inPtrSP->fSpacePointCnt, slice, patch ); |
cf471b1e |
489 | |
eb30eb49 |
490 | for (UInt_t i=0; i<inPtrSP->fSpacePointCnt; i++ ){ |
491 | vOrigClusters[nClusters++] = &(inPtrSP->fSpacePoints[i]); |
492 | } |
493 | } |
4c256004 |
494 | |
eb30eb49 |
495 | // sort clusters since they are not sorted fore some reason |
496 | |
497 | sort( vOrigClusters, vOrigClusters+nClusters, CompareClusters ); |
498 | |
eb30eb49 |
499 | Float_t *vHitStoreX = new Float_t [nHitsTotal]; // hit X coordinates |
500 | Float_t *vHitStoreY = new Float_t [nHitsTotal]; // hit Y coordinates |
501 | Float_t *vHitStoreZ = new Float_t [nHitsTotal]; // hit Z coordinates |
00d07bcd |
502 | Int_t *vHitStoreIntID = new Int_t [nHitsTotal]; // hit ID's |
eb30eb49 |
503 | Int_t *vHitStoreID = new Int_t [nHitsTotal]; // hit ID's |
504 | Int_t *vHitRowID = new Int_t [nHitsTotal]; // hit ID's |
505 | |
506 | Int_t nHits = 0; |
00d07bcd |
507 | |
eb30eb49 |
508 | { |
00d07bcd |
509 | Int_t rowNHits[200]; |
510 | Int_t rowFirstHits[200]; |
511 | for( Int_t ir=0; ir<200; ir++ ) rowNHits[ir] = 0; |
4c256004 |
512 | Int_t oldRow = -1; |
eb30eb49 |
513 | for (Int_t i=0; i<nClusters; i++ ){ |
514 | AliHLTTPCSpacePointData* pSP = vOrigClusters[i]; |
00d07bcd |
515 | if( oldRow>=0 && pSP->fPadRow < oldRow ) |
516 | HLTError("CA: clusters from row %d are readed twice",oldRow); |
517 | |
518 | if( TMath::Abs(pSP->fZ)>fClusterZCut) continue; |
519 | |
eb30eb49 |
520 | vHitStoreX[nHits] = pSP->fX; |
00d07bcd |
521 | vHitStoreY[nHits] = pSP->fY; |
522 | vHitStoreZ[nHits] = pSP->fZ; |
523 | vHitStoreIntID[nHits] = nHits; |
4c256004 |
524 | vHitStoreID[nHits] = pSP->fID; |
dc4788ec |
525 | vHitRowID[nHits] = pSP->fPadRow; |
4c256004 |
526 | nHits++; |
00d07bcd |
527 | rowNHits[pSP->fPadRow]++; |
4c256004 |
528 | } |
00d07bcd |
529 | |
530 | Int_t firstRowHit = 0; |
531 | for( Int_t ir=0; ir<200; ir++ ){ |
532 | rowFirstHits[ir] = firstRowHit; |
533 | firstRowHit+=rowNHits[ir]; |
eb30eb49 |
534 | } |
00d07bcd |
535 | |
536 | fTracker->ReadEvent( rowFirstHits, rowNHits, vHitStoreY, vHitStoreZ, nHits ); |
4c256004 |
537 | } |
00d07bcd |
538 | |
eb30eb49 |
539 | if( vOrigClusters ) delete[] vOrigClusters; |
4c256004 |
540 | |
cf471b1e |
541 | // reconstruct the event |
542 | |
dc4788ec |
543 | TStopwatch timerReco; |
544 | |
cf471b1e |
545 | fTracker->Reconstruct(); |
546 | |
dc4788ec |
547 | timerReco.Stop(); |
548 | |
4c256004 |
549 | Int_t ret = 0; |
550 | |
551 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reconstruct", |
552 | "%d tracks found for slice %d",fTracker->NOutTracks(), slice); |
cf471b1e |
553 | |
554 | // write reconstructed tracks |
555 | |
556 | AliHLTTPCTrackletData* outPtr = (AliHLTTPCTrackletData*)(outputPtr); |
557 | |
558 | AliHLTTPCTrackSegmentData* currOutTracklet = outPtr->fTracklets; |
559 | |
4687b8fc |
560 | Int_t ntracks = *fTracker->NOutTracks(); |
4c256004 |
561 | |
562 | UInt_t mySize = ((AliHLTUInt8_t *)currOutTracklet) - ((AliHLTUInt8_t *)outputPtr); |
563 | |
564 | outPtr->fTrackletCnt = 0; |
565 | |
4687b8fc |
566 | for( Int_t itr=0; itr<ntracks; itr++ ){ |
cf471b1e |
567 | |
568 | AliHLTTPCCAOutTrack &t = fTracker->OutTracks()[itr]; |
4c256004 |
569 | |
570 | //Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Wrtite output","track %d with %d hits", itr, t.NHits()); |
571 | |
d54804bf |
572 | if( t.NHits()<fMinNTrackClusters ) continue; |
573 | |
4c256004 |
574 | // calculate output track size |
575 | |
576 | UInt_t dSize = sizeof(AliHLTTPCTrackSegmentData) + t.NHits()*sizeof(UInt_t); |
577 | |
00d07bcd |
578 | if( mySize + dSize > maxBufferSize ){ |
579 | Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "Wrtite output","Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, ntracks-itr+1); |
4c256004 |
580 | ret = -ENOSPC; |
581 | break; |
582 | } |
583 | |
584 | // convert CA track parameters to HLT Track Segment |
eb30eb49 |
585 | |
586 | Int_t iFirstRow = 1000; |
587 | Int_t iLastRow = -1; |
cf471b1e |
588 | Int_t iFirstHit = fTracker->OutTrackHits()[t.FirstHitRef()]; |
eb30eb49 |
589 | Int_t iLastHit = iFirstHit; |
590 | for( Int_t ih=0; ih<t.NHits(); ih++ ){ |
591 | Int_t hitID = fTracker->OutTrackHits()[t.FirstHitRef() + ih ]; |
592 | Int_t iRow = vHitRowID[hitID]; |
593 | if( iRow<iFirstRow ){ iFirstRow = iRow; iFirstHit = hitID; } |
594 | if( iRow>iLastRow ){ iLastRow = iRow; iLastHit = hitID; } |
595 | } |
596 | |
d54804bf |
597 | AliHLTTPCCATrackParam par = t.StartPoint(); |
598 | |
00d07bcd |
599 | par.TransportToX( vHitStoreX[iFirstHit], .99 ); |
d54804bf |
600 | |
601 | AliExternalTrackParam tp; |
eb30eb49 |
602 | AliHLTTPCCATrackConvertor::GetExtParam( par, tp, 0, fSolenoidBz ); |
d54804bf |
603 | |
604 | currOutTracklet->fX = tp.GetX(); |
605 | currOutTracklet->fY = tp.GetY(); |
606 | currOutTracklet->fZ = tp.GetZ(); |
00d07bcd |
607 | currOutTracklet->fCharge = (Int_t ) tp.GetSign(); |
d54804bf |
608 | currOutTracklet->fPt = TMath::Abs(tp.GetSignedPt()); |
eb30eb49 |
609 | Float_t snp = tp.GetSnp() ; |
d54804bf |
610 | if( snp>.999 ) snp=.999; |
5b41cd63 |
611 | if( snp<-.999 ) snp=-.999; |
d54804bf |
612 | currOutTracklet->fPsi = TMath::ASin( snp ); |
613 | currOutTracklet->fTgl = tp.GetTgl(); |
eb30eb49 |
614 | |
615 | currOutTracklet->fY0err = tp.GetSigmaY2(); |
616 | currOutTracklet->fZ0err = tp.GetSigmaZ2(); |
617 | Float_t h = -currOutTracklet->fPt*currOutTracklet->fPt; |
d54804bf |
618 | currOutTracklet->fPterr = h*h*tp.GetSigma1Pt2(); |
619 | h = 1./TMath::Sqrt(1-snp*snp); |
620 | currOutTracklet->fPsierr = h*h*tp.GetSigmaSnp2(); |
621 | currOutTracklet->fTglerr = tp.GetSigmaTgl2(); |
eb30eb49 |
622 | |
00d07bcd |
623 | if( par.TransportToX( vHitStoreX[iLastHit],.99 ) ){ |
eb30eb49 |
624 | currOutTracklet->fLastX = par.GetX(); |
625 | currOutTracklet->fLastY = par.GetY(); |
626 | currOutTracklet->fLastZ = par.GetZ(); |
627 | } else { |
628 | currOutTracklet->fLastX = vHitStoreX[iLastHit]; |
629 | currOutTracklet->fLastY = vHitStoreY[iLastHit]; |
630 | currOutTracklet->fLastZ = vHitStoreZ[iLastHit]; |
631 | } |
632 | //if( currOutTracklet->fLastX<10. ) { |
633 | //HLTError("CA last point: hitxyz=%f,%f,%f, track=%f,%f,%f, tracklet=%f,%f,%f, nhits=%d",vHitStoreX[iLastHit],vHitStoreY[iLastHit],vHitStoreZ[iLastHit], |
634 | //par.GetX(), par.GetY(),par.GetZ(),currOutTracklet->fLastX,currOutTracklet->fLastY ,currOutTracklet->fLastZ, t.NHits()); |
635 | //} |
dc4788ec |
636 | #ifdef INCLUDE_TPC_HOUGH |
637 | #ifdef ROWHOUGHPARAMS |
638 | currOutTracklet->fTrackID = 0; |
639 | currOutTracklet->fRowRange1 = vHitRowID[iFirstHit]; |
640 | currOutTracklet->fRowRange2 = vHitRowID[iLastHit]; |
641 | currOutTracklet->fSector = slice; |
642 | currOutTracklet->fPID = 211; |
643 | #endif |
644 | #endif // INCLUDE_TPC_HOUGH |
645 | |
646 | |
cf471b1e |
647 | currOutTracklet->fNPoints = t.NHits(); |
648 | |
649 | for( Int_t i=0; i<t.NHits(); i++ ){ |
4c256004 |
650 | currOutTracklet->fPointIDs[i] = vHitStoreID[fTracker->OutTrackHits()[t.FirstHitRef()+i]]; |
cf471b1e |
651 | } |
4c256004 |
652 | |
653 | currOutTracklet = (AliHLTTPCTrackSegmentData*)( (Byte_t *)currOutTracklet + dSize ); |
654 | mySize+=dSize; |
655 | outPtr->fTrackletCnt++; |
cf471b1e |
656 | } |
d54804bf |
657 | |
eb30eb49 |
658 | if( vHitStoreX ) delete[] vHitStoreX; |
659 | if( vHitStoreY ) delete[] vHitStoreY; |
660 | if( vHitStoreZ ) delete[] vHitStoreZ; |
00d07bcd |
661 | if( vHitStoreIntID ) delete[] vHitStoreIntID; |
eb30eb49 |
662 | if( vHitStoreID ) delete[] vHitStoreID; |
663 | if( vHitRowID ) delete[] vHitRowID; |
cf471b1e |
664 | |
cf471b1e |
665 | AliHLTComponentBlockData bd; |
666 | FillBlockData( bd ); |
4c256004 |
667 | bd.fOffset = 0; |
cf471b1e |
668 | bd.fSize = mySize; |
669 | bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch ); |
670 | outputBlocks.push_back( bd ); |
671 | |
cf471b1e |
672 | size = mySize; |
673 | |
d54804bf |
674 | timer.Stop(); |
675 | |
eb30eb49 |
676 | fFullTime+= timer.RealTime(); |
677 | fRecoTime+= timerReco.RealTime(); |
d54804bf |
678 | fNEvents++; |
dc4788ec |
679 | |
680 | // Set log level to "Warning" for on-line system monitoring |
eb30eb49 |
681 | Int_t hz = (Int_t) (fFullTime>1.e-10 ?fNEvents/fFullTime :100000); |
682 | Int_t hz1 = (Int_t) (fRecoTime>1.e-10 ?fNEvents/fRecoTime :100000); |
d54804bf |
683 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Tracks", |
eb30eb49 |
684 | "CATracker slice %d: output %d tracks; input %d clusters, patches %d..%d, rows %d..%d; reco time %d/%d Hz", |
685 | slice, ntracks, nClusters, minPatch, maxPatch, row[0], row[1], hz, hz1 ); |
dc4788ec |
686 | |
4c256004 |
687 | return ret; |
cf471b1e |
688 | } |
689 | |
690 | |