- code version from TPC commissioning merged
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCSliceTrackerComponent.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
7  *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
8  *          for The ALICE Off-line 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 // a TPC sector tracker processing component for the HLT                     //
22 //                                                                           //
23 ///////////////////////////////////////////////////////////////////////////////
24
25 #if __GNUC__>= 3
26 using namespace std;
27 #endif
28
29 #include "AliHLTTPCSliceTrackerComponent.h"
30 #include "AliHLTTPCTransform.h"
31 #include "AliHLTTPCConfMapper.h"
32 #include "AliHLTTPCVertex.h"
33 #include "AliHLTTPCSpacePointData.h"
34 #include "AliHLTTPCVertexData.h"
35 #include "AliHLTTPCClusterDataFormat.h"
36 #include "AliHLTTPCTransform.h"
37 #include "AliHLTTPCTrackSegmentData.h"
38 #include "AliHLTTPCTrackArray.h"
39 #include "AliHLTTPCTrackletDataFormat.h"
40 #include "AliHLTTPC.h"
41 #include <stdlib.h>
42 #include <errno.h>
43
44 // this is a global object used for automatic component registration, do not use this
45 AliHLTTPCSliceTrackerComponent gAliHLTTPCSliceTrackerComponent;
46
47 ClassImp(AliHLTTPCSliceTrackerComponent)
48
49 AliHLTTPCSliceTrackerComponent::AliHLTTPCSliceTrackerComponent()
50     {
51     fTracker = NULL;
52     fVertex = NULL;
53     fEta[0] = 0.;
54     fEta[1] = 1.1;
55     fDoNonVertex = false;
56     fMultiplicity = 4000;
57     fBField = 0.4;
58     fDoPP = false;
59 // BEGINN ############################################## MODIFIY JMT
60     fnonvertextracking = kFALSE;   // enable NONVERTEX Tracking
61     fmainvertextracking = kTRUE;   // enable MAINVERTEX Tracking
62 // END ################################################# MODIFIY JMT
63     }
64
65 AliHLTTPCSliceTrackerComponent::~AliHLTTPCSliceTrackerComponent()
66     {
67     }
68
69 // Public functions to implement AliHLTComponent's interface.
70 // These functions are required for the registration process
71
72 const char* AliHLTTPCSliceTrackerComponent::GetComponentID()
73     {
74     return "TPCSliceTracker";
75     }
76
77 void AliHLTTPCSliceTrackerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
78     {
79     list.clear();
80     list.push_back( AliHLTTPCDefinitions::gkClustersDataType );
81     list.push_back( AliHLTTPCDefinitions::gkVertexDataType );
82     }
83
84 AliHLTComponent_DataType AliHLTTPCSliceTrackerComponent::GetOutputDataType()
85     {
86     return AliHLTTPCDefinitions::gkTrackSegmentsDataType;
87     }
88
89 void AliHLTTPCSliceTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
90     {
91     // XXX TODO: Find more realistic values.
92     constBase = 0;
93     inputMultiplier = 0.2;
94     }
95
96 AliHLTComponent* AliHLTTPCSliceTrackerComponent::Spawn()
97     {
98     return new AliHLTTPCSliceTrackerComponent;
99     }
100
101 void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phi_segments, Int_t eta_segments,
102                                    Int_t trackletlength, Int_t tracklength,
103                                    Int_t rowscopetracklet, Int_t rowscopetrack,
104                                    Double_t min_pt_fit, Double_t maxangle,
105                                    Double_t goodDist, Double_t hitChi2Cut,
106                                    Double_t goodHitChi2, Double_t trackChi2Cut,
107                                    Int_t maxdist, Double_t maxphi,Double_t maxeta, bool vertexConstraints )
108     {
109     //fTracker->SetClusterFinderParam( fXYClusterError, fZClusterError, kTRUE ); // ??
110     //Set parameters input to the tracker
111     //If no arguments are given, default parameters will be used
112     
113     fTracker->SetNSegments(phi_segments,eta_segments);
114     fTracker->SetMaxDca(min_pt_fit);
115     //   fTracker->MainVertexSettings(trackletlength,tracklength,rowscopetracklet,rowscopetrack);
116
117 // BEGINN ############################################## MODIFIY JMT
118 #if 1
119     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "==============================" );
120
121     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){
122         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kTRUE);
123         fTracker->SetTrackletCuts(maxangle,goodDist,kTRUE);
124
125         fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);    
126         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING" );
127     }
128     else if ( fmainvertextracking == kTRUE && fnonvertextracking == kTRUE){
129         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kTRUE);
130         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kFALSE);
131         fTracker->SetTrackletCuts(maxangle,goodDist,kTRUE);
132         fTracker->SetTrackletCuts(maxangle,goodDist,kFALSE);
133
134         fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);
135         fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);     
136         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING - NONVERTEXTRACKING" );
137     }
138     else if ( fmainvertextracking == kFALSE && fnonvertextracking == kTRUE){
139         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kFALSE);
140         fTracker->SetTrackletCuts(maxangle,goodDist,kFALSE);
141
142         fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);
143         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "NONVERTEXTRACKING" );
144     }
145 #else
146     fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,vertexConstraints);
147     fTracker->SetTrackletCuts(maxangle,goodDist,vertexConstraints);
148     
149     if( vertexConstraints )
150         fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);
151     else
152         fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);
153 #endif
154 // END ################################################# MODIFIY JMT
155
156     //fTracker->SetParamDone(true);
157     //AliHLTTPC::SetVertexFit( kFALSE );
158     
159     fTracker->InitVolumes();
160     }
161
162 void AliHLTTPCSliceTrackerComponent::SetTrackerParam( bool doPP, int multiplicity, double bField )
163     {
164     AliHLTTPCTransform::SetBField( bField );
165     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f T\n", bField );
166
167     if ( doPP )
168         {
169         //tracker->SetClusterFinderParam(xyerror,zerror,kTRUE); // ??
170         SetTrackerParam( 50, 100, 3, 10,
171                          2, 2,
172                          0, 0.1745, 5, 100,
173                          5, 50, 50, 0.1, 0.1, kTRUE);
174         }
175     else
176         {
177         int mults[] = { 1000, 2000, 4000, 8000 };
178         int multCount = 4;
179         int closestMult = 0;
180         int i;
181         int multDist, tmpMultDist;
182         if ( multiplicity>mults[closestMult] )
183             multDist = multiplicity-mults[closestMult];
184         else
185             multDist = mults[closestMult]-multiplicity;
186         for ( i = 1; i < multCount; i++ )
187             {
188             if ( multiplicity>mults[i] )
189                 tmpMultDist = multiplicity-mults[i];
190             else
191                 tmpMultDist = mults[i]-multiplicity;
192             if ( tmpMultDist < multDist )
193                 {
194                 closestMult = i;
195                 multDist = tmpMultDist;
196                 }
197             }
198         
199         double bfs[] = { 0.2, 0.4 };
200         int bfCount = 2;
201         int closestBf = 0;
202         double bfDist, tmpBFDist;
203         if ( bField>bfs[closestBf] )
204             bfDist = bField-bfs[closestBf];
205         else
206             bfDist = bfs[closestBf]-bField;
207         for ( i = 1; i < bfCount; i++ )
208             {
209             if ( bField>bfs[i] )
210                 tmpBFDist = bField-bfs[i];
211             else
212                 tmpBFDist = bfs[i]-bField;
213             if ( tmpBFDist < bfDist )
214                 {
215                 closestBf = i;
216                 bfDist = tmpBFDist;
217                 }
218             }
219
220         switch ( closestMult )
221             {
222             case 0: // 1000
223                 switch ( closestBf )
224                     {
225                     case 0: // 0.2
226                         SetTrackerParam( 50, 100, 3, 10,
227                                         2, 4,
228                                         0, 0.1745, 5, 100,
229                                         5, 50, 50, 0.1, 0.1, kTRUE );
230                         break;
231                     case 1: // 0.4
232                         SetTrackerParam( 50, 100, 3, 10,
233                                          2, 4,
234                                          0, 0.1745, 5, 100,
235                                          5, 50, 50, 0.1, 0.1, kTRUE );
236                         break;
237                     }
238                 break;
239             case 1: // 2000
240                 switch ( closestBf )
241                     {
242                     case 0: // 0.2
243                         SetTrackerParam( 50, 100, 3, 10,
244                                          2, 4,
245                                          0, 0.1745, 5, 30,
246                                          5, 20, 50, 0.1, 0.1, kTRUE );
247                         break;
248                     case 1: // 0.4
249                         SetTrackerParam( 50, 100, 3, 10,
250                                          2, 5,
251                                          0, 0.1745, 5, 30,
252                                          5, 20, 50, 0.1, 0.1, kTRUE );
253                         break;
254                     }
255                 break;
256             case 2: // 4000
257                 switch ( closestBf )
258                     {
259                     case 0: // 0.2
260                         SetTrackerParam( 50, 100, 3, 10,
261                                          2 , 10,
262                                          0, 0.1745, 5, 20,
263                                          5, 10 , 50, 0.1, 0.1, kTRUE );
264                         break;
265                     case 1: // 0.4
266                         SetTrackerParam( 50, 100, 3, 10,
267                                          2, 10,
268                                          0, 0.1745, 5, 20,
269                                          5, 10, 50, 0.1, 0.1, kTRUE );
270                         break;
271                     }
272                 break;
273             case 3: // 8000
274                 switch ( closestBf )
275                     {
276                     case 0: // 0.2
277                         SetTrackerParam( 50, 100, 3, 10,
278                                          3, 15,
279                                          0, 0.1745, 5, 10,
280                                          5, 5, 50, 0.1, 0.1, kTRUE );
281                         break;
282                     case 1: // 0.4
283                         SetTrackerParam( 50, 100, 3, 10,
284                                          2, 15,
285                                          0, 0.1745, 5, 15,
286                                          5, 5, 50, 0.1, 0.1, kTRUE );
287                         break;
288                     }
289                 break;
290             }
291 //      Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bfs[closestBf] );
292 //      AliHLTTPCTransform::SetBField( bfs[closestBf] );
293 //      AliHLTTPCTransform::SetBField( bField );
294 //      Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bField );
295         }
296     }
297
298
299         
300 int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
301     {
302     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "DoInit", "DoInit()" );
303
304     if ( fTracker || fVertex )
305         return EINPROGRESS;
306     fTracker = new AliHLTTPCConfMapper();
307     fVertex = new AliHLTTPCVertex();
308     fEta[0] = 0.;
309     fEta[1] = 1.1;
310     fDoNonVertex = false;
311     fMultiplicity = 4000;
312     fBField = 0.4;
313     fDoPP = false;
314
315     int i = 0;
316     char* cpErr;
317     while ( i < argc )
318         {
319         if ( !strcmp( argv[i], "pp-run" ) )
320             {
321             fDoPP = true;
322             i++;
323             continue;
324             }
325         if ( !strcmp( argv[i], "multiplicity" ) )
326             {
327             if ( argc <= i+1 )
328                 {
329                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Missing event multiplicity specifier." );
330                 return ENOTSUP;
331                 }
332             fMultiplicity = strtoul( argv[i+1], &cpErr, 0 );
333             if ( *cpErr )
334                 {
335                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Cannot convert event multiplicity specifier '%s'.", argv[i+1] );
336                 return EINVAL;
337                 }
338             i += 2;
339             continue;
340             }
341         if ( !strcmp( argv[i], "bfield" ) )
342             {
343             if ( argc <= i+1 )
344                 {
345                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing B-field", "Missing B-field specifier." );
346                 return ENOTSUP;
347                 }
348             fBField = strtod( argv[i+1], &cpErr );
349             if ( *cpErr )
350                 {
351                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Cannot convert B-field specifier '%s'.", argv[i+1] );
352                 return EINVAL;
353                 }
354             i += 2;
355             continue;
356             }
357
358 // BEGINN ############################################## MODIFIY JMT
359         if ( !strcmp( argv[i], "nonvertextracking" ) ){
360             fnonvertextracking = kTRUE;
361             i++;
362             continue;       
363         }
364         
365         if ( !strcmp( argv[i], "mainvertextrackingoff" ) ){     
366             fmainvertextracking = kFALSE;
367             i++;
368             continue;       
369         }
370
371         if ( !strcmp( argv[i], "etarange" ) ){  
372             if ( argc <= i+1 ){
373                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing Eta range", "Missing Eta-range specifiers." );
374                 return ENOTSUP;
375             }
376             fEta[1] = strtod( argv[i+1], &cpErr );
377             if ( *cpErr ){
378                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing Eta range", "Cannot convert Eta-range specifier '%s'.", argv[i+1] );
379                 return EINVAL;
380             }
381    
382             i += 2;
383             continue;
384         }
385 // END ################################################# MODIFIY JMT
386         Logging(kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
387         return EINVAL;
388         }
389 // #### -B0-CHANGE-START == JMT
390     if (fBField == 0.){
391         // parameter for B=0 T 
392         fDoPP = kTRUE;
393         fnonvertextracking = kTRUE;
394         fmainvertextracking = kFALSE;
395     }
396 // #### -B0-CHANGE-END == JMT
397
398     SetTrackerParam( fDoPP, fMultiplicity, fBField );
399     return 0;
400     }
401
402 int AliHLTTPCSliceTrackerComponent::DoDeinit()
403     {
404     if ( fTracker )
405         delete fTracker;
406     fTracker = NULL;
407     if ( fVertex )
408         delete fVertex;
409     fVertex = NULL;
410     return 0;
411     }
412
413 int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
414                                               AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
415                                               AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
416     {
417     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "DoEvent()" );
418     const AliHLTComponent_BlockData* iter = NULL;
419     unsigned long ndx;
420     AliHLTTPCClusterData* inPtrSP;
421     AliHLTTPCVertexData* inPtrV = NULL;
422     const AliHLTComponent_BlockData* vertexIter=NULL;
423     AliHLTTPCTrackletData* outPtr;
424     AliHLTUInt8_t* outBPtr;
425     AliHLTUInt32_t vSize = 0;
426     UInt_t offset=0, mysize, tSize = 0;
427     outBPtr = outputPtr;
428     Int_t slice, patch, row[2];
429     Int_t minPatch=INT_MAX, maxPatch = 0;
430     offset = 0;
431     std::vector<Int_t> slices;
432     std::vector<Int_t>::iterator slIter, slEnd;
433     std::vector<unsigned> sliceCnts;
434     std::vector<unsigned>::iterator slCntIter;
435     Int_t vertexSlice=0;
436
437     // Find min/max rows used in total and find and read out vertex if it is present
438     // also determine correct slice number, if multiple slice numbers are present in event
439     // (which should not happen in the first place) we use the one that occurs the most times
440     row[0] = 0;
441     row[1] = 0;
442     bool found;
443     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
444         {
445         iter = blocks+ndx;
446
447         slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
448         found = false;
449         slIter = slices.begin();
450         slEnd = slices.end();
451         slCntIter = sliceCnts.begin();
452         while ( slIter != slEnd )
453             {
454             if ( *slIter == slice )
455                 {
456                 found = true;
457                 break;
458                 }
459             slIter++;
460             slCntIter++;
461             }
462         if ( !found )
463             {
464             slices.insert( slices.end(), slice );
465             sliceCnts.insert( sliceCnts.end(), 1 );
466             }
467         else
468             *slCntIter++;
469
470         if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType )
471             {
472             inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
473             vertexIter = iter;
474             vSize = iter->fSize;
475             fVertex->Read( inPtrV );
476             vertexSlice = slice;
477             }
478         if ( iter->fDataType == AliHLTTPCDefinitions::gkClustersDataType )
479             {
480             patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
481             if ( minPatch>patch )
482                 {
483                 minPatch = patch;
484                 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
485                 }
486             if ( maxPatch<patch )
487                 {
488                 maxPatch = patch;
489                 row[1] = AliHLTTPCTransform::GetLastRow( patch );
490                 }
491             }
492         }
493
494     // Determine slice number to really use.
495     if ( slices.size()>1 )
496         {
497         Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
498                  "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
499                  evtData.fEventID, evtData.fEventID );
500         unsigned maxCntSlice=0;
501         slIter = slices.begin();
502         slEnd = slices.end();
503         slCntIter = sliceCnts.begin();
504         while ( slIter != slEnd )
505             {
506             Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
507                      "Slice %lu found %lu times.", *slIter, *slCntIter );
508             if ( maxCntSlice<*slCntIter )
509                 {
510                 maxCntSlice = *slCntIter;
511                 slice = *slIter;
512                 }
513             slIter++;
514             slCntIter++;
515             }
516         Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
517                  "Using slice %lu.", slice );
518         }
519     else
520         slice = *(slices.begin());
521     
522     if ( vertexSlice != slice )
523         {
524         // multiple vertex blocks in event and we used the wrong one...
525         found = false;
526         for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
527             {
528             iter = blocks+ndx;
529             if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
530                 {
531                 inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
532                 vertexIter = iter;
533                 vSize = iter->fSize;
534                 fVertex->Read( inPtrV );
535                 break;
536                 }
537             }
538         }
539
540     fTracker->InitSector( slice, row, fEta );
541     fTracker->SetVertex(fVertex);
542     mysize = 0;
543     // read in all hits
544     std::vector<unsigned long> patchIndices;
545     std::vector<unsigned long>::iterator pIter, pEnd;
546     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
547         {
548         iter = blocks+ndx;
549
550         if ( iter->fDataType == AliHLTTPCDefinitions::gkClustersDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
551             {
552             patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
553             pIter = patchIndices.begin();
554             pEnd = patchIndices.end();
555             while ( pIter!=pEnd && AliHLTTPCDefinitions::GetMinSliceNr( blocks[*pIter] ) < patch )
556                 pIter++;
557             patchIndices.insert( pIter, ndx );
558             }
559         }
560     pIter = patchIndices.begin();
561     pEnd = patchIndices.end();
562     while ( pIter!=pEnd )
563         {
564         ndx = *pIter;
565         iter = blocks+ndx;
566
567         patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
568         inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr);
569             
570         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Reading hits",
571                  "Reading hits for slice %d - patch %d", slice, patch );
572         fTracker->ReadHits( inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints );
573         pIter++;
574         }
575
576     outPtr = (AliHLTTPCTrackletData*)(outBPtr);
577 // BEGINN ############################################## MODIFIY JMT
578 #if 1
579     fTracker->SetPointers();
580     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){ 
581         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
582         fTracker->MainVertexTracking_a();
583         fTracker->MainVertexTracking_b();
584         fTracker->FillTracks();
585     }
586     else if ( fmainvertextracking == kTRUE && fnonvertextracking == kTRUE){     
587         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
588         fTracker->MainVertexTracking_a();
589         fTracker->MainVertexTracking_b();
590         fTracker->FillTracks(); 
591         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---NONVERTEXTRACKING---");
592         fTracker->NonVertexTracking();
593     }
594     else if ( fmainvertextracking == kFALSE && fnonvertextracking == kTRUE){
595         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---NONVERTEXTRACKING---");
596         fTracker->NonVertexTracking();  
597         fTracker->FillTracks(); 
598     }
599 #else
600     fTracker->MainVertexTracking_a();
601     fTracker->MainVertexTracking_b();
602     fTracker->FillTracks();
603     
604     if ( fDoNonVertex )
605         fTracker->NonVertexTracking();//Do a second pass for nonvertex tracks
606 #endif
607 // END ################################################# MODIFIY JMT
608     // XXX Do track merging??
609     
610     UInt_t ntracks0=0;
611     mysize = fTracker->GetTracks()->WriteTracks( ntracks0, outPtr->fTracklets );
612     outPtr->fTrackletCnt = ntracks0;
613     
614     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracks",
615              "Input: Number of tracks: %lu Slice/MinPatch/MaxPatch/RowMin/RowMax: %lu/%lu/%lu/%lu/%lu.", 
616              ntracks0, slice, minPatch, maxPatch, row[0], row[1] );
617
618     tSize += mysize+sizeof(AliHLTTPCTrackletData);
619     outBPtr += mysize+sizeof(AliHLTTPCTrackletData);
620     
621     AliHLTComponent_BlockData bd;
622     FillBlockData( bd );
623     bd.fOffset = offset;
624     bd.fSize = tSize;
625     bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
626     outputBlocks.push_back( bd );
627
628 #ifdef FORWARD_VERTEX_BLOCK
629     if ( vertexIter )
630         {
631         // Copy the descriptor block for the vertex information.
632         bd = *vertexIter;
633         outputBlocks.push_back( bd );
634         }
635 #endif // FORWARD_VERTEX_BLOCK
636
637     size = tSize;
638     return 0;
639     }
640
641