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