a14540ab457697d20150fd9255cd4b522b7e7078
[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( kHLTLogError, "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( kHLTLogError, "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( kHLTLogError, "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( kHLTLogError, "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\n", bField );
166     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "B field is  %f\n",AliHLTTPCTransform::GetBFieldValue());  
167
168     if ( doPP )
169         {
170         //tracker->SetClusterFinderParam(xyerror,zerror,kTRUE); // ??
171         SetTrackerParam( 50, 100, 3, 10,
172                          2, 2,
173                          0, 0.1745, 5, 100,
174                          5, 50, 50, 0.1, 0.1, kTRUE);
175         }
176     else
177         {
178         int mults[] = { 1000, 2000, 4000, 8000 };
179         int multCount = 4;
180         int closestMult = 0;
181         int i;
182         int multDist, tmpMultDist;
183         if ( multiplicity>mults[closestMult] )
184             multDist = multiplicity-mults[closestMult];
185         else
186             multDist = mults[closestMult]-multiplicity;
187         for ( i = 1; i < multCount; i++ )
188             {
189             if ( multiplicity>mults[i] )
190                 tmpMultDist = multiplicity-mults[i];
191             else
192                 tmpMultDist = mults[i]-multiplicity;
193             if ( tmpMultDist < multDist )
194                 {
195                 closestMult = i;
196                 multDist = tmpMultDist;
197                 }
198             }
199         
200         double bfs[] = { 0.2, 0.4 };
201         int bfCount = 2;
202         int closestBf = 0;
203         double bfDist, tmpBFDist;
204         if ( bField>bfs[closestBf] )
205             bfDist = bField-bfs[closestBf];
206         else
207             bfDist = bfs[closestBf]-bField;
208         for ( i = 1; i < bfCount; i++ )
209             {
210             if ( bField>bfs[i] )
211                 tmpBFDist = bField-bfs[i];
212             else
213                 tmpBFDist = bfs[i]-bField;
214             if ( tmpBFDist < bfDist )
215                 {
216                 closestBf = i;
217                 bfDist = tmpBFDist;
218                 }
219             }
220
221         switch ( closestMult )
222             {
223             case 0: // 1000
224                 switch ( closestBf )
225                     {
226                     case 0: // 0.2
227                         SetTrackerParam( 50, 100, 3, 10,
228                                         2, 4,
229                                         0, 0.1745, 5, 100,
230                                         5, 50, 50, 0.1, 0.1, kTRUE );
231                         break;
232                     case 1: // 0.4
233                         SetTrackerParam( 50, 100, 3, 10,
234                                          2, 4,
235                                          0, 0.1745, 5, 100,
236                                          5, 50, 50, 0.1, 0.1, kTRUE );
237                         break;
238                     }
239                 break;
240             case 1: // 2000
241                 switch ( closestBf )
242                     {
243                     case 0: // 0.2
244                         SetTrackerParam( 50, 100, 3, 10,
245                                          2, 4,
246                                          0, 0.1745, 5, 30,
247                                          5, 20, 50, 0.1, 0.1, kTRUE );
248                         break;
249                     case 1: // 0.4
250                         SetTrackerParam( 50, 100, 3, 10,
251                                          2, 5,
252                                          0, 0.1745, 5, 30,
253                                          5, 20, 50, 0.1, 0.1, kTRUE );
254                         break;
255                     }
256                 break;
257             case 2: // 4000
258                 switch ( closestBf )
259                     {
260                     case 0: // 0.2
261                         SetTrackerParam( 50, 100, 3, 10,
262                                          2 , 10,
263                                          0, 0.1745, 5, 20,
264                                          5, 10 , 50, 0.1, 0.1, kTRUE );
265                         break;
266                     case 1: // 0.4
267                         SetTrackerParam( 50, 100, 3, 10,
268                                          2, 10,
269                                          0, 0.1745, 5, 20,
270                                          5, 10, 50, 0.1, 0.1, kTRUE );
271                         break;
272                     }
273                 break;
274             case 3: // 8000
275                 switch ( closestBf )
276                     {
277                     case 0: // 0.2
278                         SetTrackerParam( 50, 100, 3, 10,
279                                          3, 15,
280                                          0, 0.1745, 5, 10,
281                                          5, 5, 50, 0.1, 0.1, kTRUE );
282                         break;
283                     case 1: // 0.4
284                         SetTrackerParam( 50, 100, 3, 10,
285                                          2, 15,
286                                          0, 0.1745, 5, 15,
287                                          5, 5, 50, 0.1, 0.1, kTRUE );
288                         break;
289                     }
290                 break;
291             }
292 //      Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bfs[closestBf] );
293 //      AliHLTTPCTransform::SetBField( bfs[closestBf] );
294 //      AliHLTTPCTransform::SetBField( bField );
295 //      Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bField );
296         }
297     }
298
299
300         
301 int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
302     {
303     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "DoInit", "DoInit()" );
304     fprintf( stderr, "sizeof(AliHLTTPCTrackSegmentData): %d\n", sizeof(AliHLTTPCTrackSegmentData) );
305
306     if ( fTracker || fVertex )
307         return EINPROGRESS;
308     fTracker = new AliHLTTPCConfMapper();
309     fVertex = new AliHLTTPCVertex();
310     fEta[0] = 0.;
311     fEta[1] = 1.1;
312     fDoNonVertex = false;
313     fMultiplicity = 4000;
314     fBField = 0.4;
315     fDoPP = false;
316
317     int i = 0;
318     char* cpErr;
319     while ( i < argc )
320         {
321         if ( !strcmp( argv[i], "pp-run" ) )
322             {
323             fDoPP = true;
324             i++;
325             continue;
326             }
327         if ( !strcmp( argv[i], "multiplicity" ) )
328             {
329             if ( argc <= i+1 )
330                 {
331                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Missing event multiplicity specifier." );
332                 return ENOTSUP;
333                 }
334             fMultiplicity = strtoul( argv[i+1], &cpErr, 0 );
335             if ( *cpErr )
336                 {
337                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Cannot convert event multiplicity specifier '%s'.", argv[i+1] );
338                 return EINVAL;
339                 }
340             i += 2;
341             continue;
342             }
343         if ( !strcmp( argv[i], "bfield" ) )
344             {
345             if ( argc <= i+1 )
346                 {
347                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing B-field", "Missing B-field specifier." );
348                 return ENOTSUP;
349                 }
350             fBField = strtod( argv[i+1], &cpErr );
351             if ( *cpErr )
352                 {
353                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Cannot convert B-field specifier '%s'.", argv[i+1] );
354                 return EINVAL;
355                 }
356             i += 2;
357             continue;
358             }
359
360 // BEGINN ############################################## MODIFIY JMT
361         if ( !strcmp( argv[i], "nonvertextracking" ) ){
362             fnonvertextracking = kTRUE;
363             i++;
364             continue;       
365         }
366         
367         if ( !strcmp( argv[i], "mainvertextrackingoff" ) ){     
368             fmainvertextracking = kFALSE;
369             i++;
370             continue;       
371         }
372
373         if ( !strcmp( argv[i], "etarange" ) ){  
374             if ( argc <= i+1 ){
375                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing Eta range", "Missing Eta-range specifiers." );
376                 return ENOTSUP;
377             }
378             fEta[1] = strtod( argv[i+1], &cpErr );
379             if ( *cpErr ){
380                 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing Eta range", "Cannot convert Eta-range specifier '%s'.", argv[i+1] );
381                 return EINVAL;
382             }
383    
384             i += 2;
385             continue;
386         }
387 // END ################################################# MODIFIY JMT
388         Logging(kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
389         return EINVAL;
390         }
391     SetTrackerParam( fDoPP, fMultiplicity, fBField );
392     return 0;
393     }
394
395 int AliHLTTPCSliceTrackerComponent::DoDeinit()
396     {
397     if ( fTracker )
398         delete fTracker;
399     fTracker = NULL;
400     if ( fVertex )
401         delete fVertex;
402     fVertex = NULL;
403     return 0;
404     }
405
406 int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
407                                               AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
408                                               AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
409     {
410     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "DoEvent()" );
411     const AliHLTComponent_BlockData* iter = NULL;
412     unsigned long ndx;
413     AliHLTTPCClusterData* inPtrSP;
414     AliHLTTPCVertexData* inPtrV = NULL;
415     const AliHLTComponent_BlockData* vertexIter=NULL;
416     AliHLTTPCTrackletData* outPtr;
417     AliHLTUInt8_t* outBPtr;
418     AliHLTUInt32_t vSize = 0;
419     UInt_t offset=0, mysize, tSize = 0;
420     outBPtr = outputPtr;
421     Int_t slice, patch, row[2];
422     Int_t minPatch=INT_MAX, maxPatch = 0;
423     offset = 0;
424     std::vector<Int_t> slices;
425     std::vector<Int_t>::iterator slIter, slEnd;
426     std::vector<unsigned> sliceCnts;
427     std::vector<unsigned>::iterator slCntIter;
428     Int_t vertexSlice=0;
429
430     // Find min/max rows used in total and find and read out vertex if it is present
431     // also determine correct slice number, if multiple slice numbers are present in event
432     // (which should not happen in the first place) we use the one that occurs the most times
433     row[0] = 0;
434     row[1] = 0;
435     bool found;
436     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
437         {
438         iter = blocks+ndx;
439
440         slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
441         found = false;
442         slIter = slices.begin();
443         slEnd = slices.end();
444         slCntIter = sliceCnts.begin();
445         while ( slIter != slEnd )
446             {
447             if ( *slIter == slice )
448                 {
449                 found = true;
450                 break;
451                 }
452             slIter++;
453             slCntIter++;
454             }
455         if ( !found )
456             {
457             slices.insert( slices.end(), slice );
458             sliceCnts.insert( sliceCnts.end(), 1 );
459             }
460         else
461             *slCntIter++;
462
463         if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType )
464             {
465             inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
466             vertexIter = iter;
467             vSize = iter->fSize;
468             fVertex->Read( inPtrV );
469             vertexSlice = slice;
470             }
471         if ( iter->fDataType == AliHLTTPCDefinitions::gkClustersDataType )
472             {
473             patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
474             if ( minPatch>patch )
475                 {
476                 minPatch = patch;
477                 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
478                 }
479             if ( maxPatch<patch )
480                 {
481                 maxPatch = patch;
482                 row[1] = AliHLTTPCTransform::GetLastRow( patch );
483                 }
484             }
485         }
486
487     // Determine slice number to really use.
488     if ( slices.size()>1 )
489         {
490         Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
491                  "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
492                  evtData.fEventID, evtData.fEventID );
493         unsigned maxCntSlice=0;
494         slIter = slices.begin();
495         slEnd = slices.end();
496         slCntIter = sliceCnts.begin();
497         while ( slIter != slEnd )
498             {
499             Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
500                      "Slice %lu found %lu times.", *slIter, *slCntIter );
501             if ( maxCntSlice<*slCntIter )
502                 {
503                 maxCntSlice = *slCntIter;
504                 slice = *slIter;
505                 }
506             slIter++;
507             slCntIter++;
508             }
509         Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
510                  "Using slice %lu.", slice );
511         }
512     else
513         slice = *(slices.begin());
514     
515     if ( vertexSlice != slice )
516         {
517         // multiple vertex blocks in event and we used the wrong one...
518         found = false;
519         for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
520             {
521             iter = blocks+ndx;
522             if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
523                 {
524                 inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
525                 vertexIter = iter;
526                 vSize = iter->fSize;
527                 fVertex->Read( inPtrV );
528                 break;
529                 }
530             }
531         }
532
533     fTracker->InitSector( slice, row, fEta );
534     fTracker->SetVertex(fVertex);
535     mysize = 0;
536     // read in all hits
537     std::vector<unsigned long> patchIndices;
538     std::vector<unsigned long>::iterator pIter, pEnd;
539     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
540         {
541         iter = blocks+ndx;
542
543         if ( iter->fDataType == AliHLTTPCDefinitions::gkClustersDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
544             {
545             patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
546             pIter = patchIndices.begin();
547             pEnd = patchIndices.end();
548             while ( pIter!=pEnd && AliHLTTPCDefinitions::GetMinSliceNr( blocks[*pIter] ) < patch )
549                 pIter++;
550             patchIndices.insert( pIter, ndx );
551             }
552         }
553     pIter = patchIndices.begin();
554     pEnd = patchIndices.end();
555     while ( pIter!=pEnd )
556         {
557         ndx = *pIter;
558         iter = blocks+ndx;
559
560         patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
561         inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr);
562             
563         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Reading hits",
564                  "Reading hits for slice %d - patch %d", slice, patch );
565         fTracker->ReadHits( inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints );
566         pIter++;
567         }
568
569     outPtr = (AliHLTTPCTrackletData*)(outBPtr);
570 // BEGINN ############################################## MODIFIY JMT
571 #if 1
572     fTracker->SetPointers();
573     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){ 
574         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
575         fTracker->MainVertexTracking_a();
576         fTracker->MainVertexTracking_b();
577         fTracker->FillTracks();
578     }
579     else if ( fmainvertextracking == kTRUE && fnonvertextracking == kTRUE){     
580         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
581         fTracker->MainVertexTracking_a();
582         fTracker->MainVertexTracking_b();
583         fTracker->FillTracks(); 
584         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---NONVERTEXTRACKING---");
585         fTracker->NonVertexTracking();
586     }
587     else if ( fmainvertextracking == kFALSE && fnonvertextracking == kTRUE){
588         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---NONVERTEXTRACKING---");
589         fTracker->NonVertexTracking();  
590         fTracker->FillTracks(); 
591     }
592 #else
593     fTracker->MainVertexTracking_a();
594     fTracker->MainVertexTracking_b();
595     fTracker->FillTracks();
596     
597     if ( fDoNonVertex )
598         fTracker->NonVertexTracking();//Do a second pass for nonvertex tracks
599 #endif
600 // END ################################################# MODIFIY JMT
601     // XXX Do track merging??
602     
603     UInt_t ntracks0=0;
604     mysize = fTracker->GetTracks()->WriteTracks( ntracks0, outPtr->fTracklets );
605     outPtr->fTrackletCnt = ntracks0;
606     
607     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracks",
608              "Input: Number of tracks: %lu Slice/MinPatch/MaxPatch/RowMin/RowMax: %lu/%lu/%lu/%lu/%lu.", 
609              ntracks0, slice, minPatch, maxPatch, row[0], row[1] );
610
611     tSize += mysize+sizeof(AliHLTTPCTrackletData);
612     outBPtr += mysize+sizeof(AliHLTTPCTrackletData);
613     
614     AliHLTComponent_BlockData bd;
615     FillBlockData( bd );
616     bd.fOffset = offset;
617     bd.fSize = tSize;
618     bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
619     outputBlocks.push_back( bd );
620
621 #ifdef FORWARD_VERTEX_BLOCK
622     if ( vertexIter )
623         {
624         // Copy the descriptor block for the vertex information.
625         bd = *vertexIter;
626         outputBlocks.push_back( bd );
627         }
628 #endif // FORWARD_VERTEX_BLOCK
629
630     size = tSize;
631     return 0;
632     }
633
634