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