]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCSliceTrackerComponent.cxx
adding AliHLTAltroGenerator including unit test for simulation of Altro data and...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCSliceTrackerComponent.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
9  *                  for The ALICE HLT Project.                            *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 /** @file   AliHLTTPCSliceTrackerComponent.cxx
21     @author Timm Steinbeck, Matthias Richter
22     @date   
23     @brief  The TPC conformal mapping tracker component.
24 */
25
26 // see header file for class documentation
27 // or
28 // refer to README to build package
29 // or
30 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31
32 #if __GNUC__>= 3
33 using namespace std;
34 #endif
35
36 #include "AliHLTTPCSliceTrackerComponent.h"
37 #include "AliHLTTPCTransform.h"
38 #include "AliHLTTPCConfMapper.h"
39 #include "AliHLTTPCVertex.h"
40 #include "AliHLTTPCVertexData.h"
41 #include "AliHLTTPCClusterDataFormat.h"
42 #include "AliHLTTPCTransform.h"
43 #include "AliHLTTPCTrackSegmentData.h"
44 #include "AliHLTTPCTrackArray.h"
45 #include "AliHLTTPCTrackletDataFormat.h"
46 #include "AliHLTTPCInterMerger.h"
47 #include "AliHLTTPCMemHandler.h"
48 #include "AliHLTTPCDefinitions.h"
49 #include "TString.h"
50 #include "TObjString.h"
51 #include "TObjArray.h"
52 #include "AliCDBEntry.h"
53 #include "AliCDBManager.h"
54 //#include "AliHLTTPC.h"
55 //#include <stdlib.h>
56 //#include <cerrno>
57
58 // this is a global object used for automatic component registration, do not use this
59 AliHLTTPCSliceTrackerComponent gAliHLTTPCSliceTrackerComponent;
60
61 /** ROOT macro for the implementation of ROOT specific class methods */
62 ClassImp(AliHLTTPCSliceTrackerComponent)
63
64 AliHLTTPCSliceTrackerComponent::AliHLTTPCSliceTrackerComponent()
65   :
66   fTracker(NULL),
67   fVertex(NULL),
68   fDoNonVertex(false),
69   fDoPP(false),
70   fDoPbPb(false),
71   fMultiplicity(4000),
72   fBField(0.4),
73   fnonvertextracking(kFALSE),
74   fmainvertextracking(kTRUE),
75   fPhisegment(50),
76   fEtasegment(100),
77   fTrackletlength(3),
78   fTracklength(60),
79   fRowscopetracklet(6),
80   fRowscopetrack(6),
81   fMinPtFit(0),
82   fMaxangle(0.1745),
83   fGoodDist(5),
84   fHitChi2Cut(100),
85   fGoodHitChi2(5),
86   fTrackChi2Cut(50),
87   fMaxdist(50),
88   fMaxphi(0.1),
89   fMaxeta(0.1),
90   fpInterMerger(NULL)
91 {
92   // see header file for class documentation
93   // or
94   // refer to README to build package
95   // or
96   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
97   fEta[0] = 0.;
98   fEta[1] = 1.1;
99 }
100
101 AliHLTTPCSliceTrackerComponent::~AliHLTTPCSliceTrackerComponent()
102 {
103   // see header file for class documentation
104 }
105
106 // Public functions to implement AliHLTComponent's interface.
107 // These functions are required for the registration process
108
109 const char* AliHLTTPCSliceTrackerComponent::GetComponentID()
110 {
111   // see header file for class documentation
112
113   return "TPCSliceTracker";
114 }
115
116 void AliHLTTPCSliceTrackerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
117 {
118   // see header file for class documentation
119   list.clear();
120   list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
121   list.push_back( AliHLTTPCDefinitions::fgkVertexDataType );
122 }
123
124 AliHLTComponentDataType AliHLTTPCSliceTrackerComponent::GetOutputDataType()
125 {
126   // see header file for class documentation
127   return AliHLTTPCDefinitions::fgkTrackSegmentsDataType;
128 }
129
130 void AliHLTTPCSliceTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
131 {
132   // see header file for class documentation
133   // XXX TODO: Find more realistic values.
134   constBase = 0;
135   inputMultiplier = 1;
136 }
137
138 AliHLTComponent* AliHLTTPCSliceTrackerComponent::Spawn()
139 {
140   // see header file for class documentation
141   return new AliHLTTPCSliceTrackerComponent;
142 }
143
144 void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phiSegments, Int_t etaSegments,
145                                    Int_t trackletlength, Int_t tracklength,
146                                    Int_t rowscopetracklet, Int_t rowscopetrack,
147                                    Double_t minPtFit, Double_t maxangle,
148                                    Double_t goodDist, Double_t hitChi2Cut,
149                                    Double_t goodHitChi2, Double_t trackChi2Cut,
150                                    Int_t maxdist, Double_t maxphi,Double_t maxeta)
151 {
152   // see header file for class documentation
153     //fTracker->SetClusterFinderParam( fXYClusterError, fZClusterError, kTRUE ); // ??
154     //Set parameters input to the tracker
155     //If no arguments are given, default parameters will be used
156     
157     fTracker->SetNSegments(phiSegments,etaSegments);
158     fTracker->SetMaxDca(minPtFit);
159     //   fTracker->MainVertexSettings(trackletlength,tracklength,rowscopetracklet,rowscopetrack);
160
161     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "==============================" );
162
163     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){
164         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kTRUE);
165         fTracker->SetTrackletCuts(maxangle,goodDist,kTRUE);
166
167         fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);    
168         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING" );
169     }
170     else if ( fmainvertextracking == kTRUE && fnonvertextracking == kTRUE){
171         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kTRUE);
172         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kFALSE);
173         fTracker->SetTrackletCuts(maxangle,goodDist,kTRUE);
174         fTracker->SetTrackletCuts(maxangle,goodDist,kFALSE);
175
176         fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);
177         fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);     
178         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING - NONVERTEXTRACKING" );
179     }
180     else if ( fmainvertextracking == kFALSE && fnonvertextracking == kTRUE){
181         fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kFALSE);
182         fTracker->SetTrackletCuts(maxangle,goodDist,kFALSE);
183
184         fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);
185         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "NONVERTEXTRACKING" );
186     }
187     
188     //fTracker->SetParamDone(true);
189     /* Matthias 13.12.2006
190      * the global variable AliHLTTPCS::fgDoVertexFit has never been used so far
191      * and has always been kTRUE.
192      * In order to remove the AliHLTTPC class (which is the old steering class for
193      * HLT (TPC) tracking) from the compilation, this function can not be activated
194      * again. We have to think about a more elegant way to specify the parameters
195      * anyway. The following line was surely for some testing, but was never active
196      * in a tested release.
197      */
198     //AliHLTTPC::SetVertexFit( kFALSE );
199     
200     fTracker->InitVolumes();
201     }
202
203
204 void AliHLTTPCSliceTrackerComponent::SetTrackerParam( Bool_t doPP, Bool_t doPbPb, Int_t multiplicity, 
205                                                       Double_t bField, Int_t etasegment, Double_t hitchi2cut, 
206                                                       Int_t rowscopetracklet, Int_t rowscopetrack, 
207                                                       Int_t trackletlength, Int_t tracklength )
208 {
209   // see header file for class documentation
210   AliHLTTPCTransform::SetBField( bField );
211   Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f T\n", bField );
212   
213   if ( doPP )
214     {
215       //tracker->SetClusterFinderParam(xyerror,zerror,kTRUE); // ??
216       
217       SetTrackerParam( 50, 100, 3, 10,
218                        2, 2,
219                        0, 0.1745, 5, 100,
220                        5, 50, 50, 0.1, 0.1);
221     }
222   else if(doPbPb)
223     {
224       int mults[] = { 1000, 2000, 4000, 8000 };
225       int multCount = 4;
226       int closestMult = 0;
227       int i;
228       int multDist, tmpMultDist;
229       if ( multiplicity>mults[closestMult] )
230         multDist = multiplicity-mults[closestMult];
231       else
232         multDist = mults[closestMult]-multiplicity;
233       for ( i = 1; i < multCount; i++ )
234         {
235           if ( multiplicity>mults[i] )
236             tmpMultDist = multiplicity-mults[i];
237           else
238             tmpMultDist = mults[i]-multiplicity;
239           if ( tmpMultDist < multDist )
240             {
241               closestMult = i;
242               multDist = tmpMultDist;
243             }
244         }
245       
246       double bfs[] = { 0.2, 0.4 };
247       int bfCount = 2;
248       int closestBf = 0;
249       double bfDist, tmpBFDist;
250       if ( bField>bfs[closestBf] )
251         bfDist = bField-bfs[closestBf];
252       else
253         bfDist = bfs[closestBf]-bField;
254       for ( i = 1; i < bfCount; i++ )
255         {
256           if ( bField>bfs[i] )
257             tmpBFDist = bField-bfs[i];
258           else
259             tmpBFDist = bfs[i]-bField;
260           if ( tmpBFDist < bfDist )
261             {
262               closestBf = i;
263               bfDist = tmpBFDist;
264             }
265         }
266       
267       switch ( closestMult )
268         {
269         case 0: // 1000
270           switch ( closestBf )
271             {
272             case 0: // 0.2
273               SetTrackerParam( 50, 100, 3, 10,
274                                2, 4,
275                                0, 0.1745, 5, 100,
276                                5, 50, 50, 0.1, 0.1);
277               break;
278             case 1: // 0.4
279               SetTrackerParam( 50, 100, 3, 10,
280                                2, 4,
281                                0, 0.1745, 5, 100,
282                                5, 50, 50, 0.1, 0.1);
283               break;
284             }
285           break;
286         case 1: // 2000
287           switch ( closestBf )
288             {
289             case 0: // 0.2
290               SetTrackerParam( 50, 100, 3, 10,
291                                2, 4,
292                                0, 0.1745, 5, 30,
293                                5, 20, 50, 0.1, 0.1);
294               break;
295             case 1: // 0.4
296               SetTrackerParam( 50, 100, 3, 10,
297                                2, 5,
298                                0, 0.1745, 5, 30,
299                                5, 20, 50, 0.1, 0.1);
300               break;
301             }
302           break;
303         case 2: // 4000
304           switch ( closestBf )
305             {
306             case 0: // 0.2
307               SetTrackerParam( 50, 100, 3, 10,
308                                2 , 10,
309                                0, 0.1745, 5, 20,
310                                5, 10 , 50, 0.1, 0.1);
311               break;
312             case 1: // 0.4
313               SetTrackerParam( 50, 100, 3, 10,
314                                2, 10,
315                                0, 0.1745, 5, 20,
316                                5, 10, 50, 0.1, 0.1);
317               break;
318             }
319           break;
320         case 3: // 8000
321           switch ( closestBf )
322             {
323             case 0: // 0.2
324               SetTrackerParam( 50, 100, 3, 10,
325                                3, 15,
326                                0, 0.1745, 5, 10,
327                                5, 5, 50, 0.1, 0.1);
328               break;
329             case 1: // 0.4
330               SetTrackerParam( 50, 100, 3, 10,
331                                2, 15,
332                                0, 0.1745, 5, 15,
333                                5, 5, 50, 0.1, 0.1);
334               break;
335             }
336           break;
337         }
338       //        Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bfs[closestBf] );
339       //        AliHLTTPCTransform::SetBField( bfs[closestBf] );
340       //        AliHLTTPCTransform::SetBField( bField );
341       //        Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bField );
342     }
343   else
344     {
345       SetTrackerParam( 50, etasegment, trackletlength, tracklength,
346                        rowscopetracklet, rowscopetrack,
347                        0, 0.1745, 5, hitchi2cut,
348                        5, 50, 50, 0.1, 0.1);
349     }
350 }
351         
352 int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
353     {
354   // see header file for class documentation
355     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "DoInit", "DoInit()" );
356
357     if ( fTracker || fVertex )
358         return EINPROGRESS;
359     fTracker = new AliHLTTPCConfMapper();
360     fVertex = new AliHLTTPCVertex();
361     fEta[0] = 0.;
362     fEta[1] = 1.1;
363     fDoNonVertex = false;
364     fMultiplicity = 4000;
365     fBField = 0.5;
366     fDoPP = false;
367     fDoPbPb = false;
368     fPhisegment=50;
369     fEtasegment=100;
370     fTrackletlength=3;
371     fTracklength=60;
372     fRowscopetracklet=6;
373     fRowscopetrack=6;
374     fMinPtFit=0;
375     fMaxangle=0.1745;
376     fGoodDist=5;
377     fHitChi2Cut=100;
378     fGoodHitChi2=5;
379     fTrackChi2Cut=50;
380     fMaxdist=50;
381     fMaxphi=0.1;
382     fMaxeta=0.1;
383     int iResult=0;
384         
385     TString configuration="";
386     TString argument="";
387     for (int i=0; i<argc && iResult>=0; i++) {
388       argument=argv[i];
389       if (!configuration.IsNull()) configuration+=" ";
390       configuration+=argument;
391     }
392
393     if (!configuration.IsNull()) {
394       iResult=Configure(configuration.Data());
395     } else {
396       iResult=Reconfigure(NULL, NULL);
397     }
398     
399     return iResult;
400     }
401
402 int AliHLTTPCSliceTrackerComponent::DoDeinit()
403 {
404   // see header file for class documentation
405   if ( fTracker )
406     delete fTracker;
407   fTracker = NULL;
408   if ( fVertex )
409     delete fVertex;
410   fVertex = NULL;
411   if (fpInterMerger) {
412     delete fpInterMerger;
413   }
414   fpInterMerger=NULL;
415   return 0;
416 }
417
418 int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
419                                               AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
420                                               AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks )
421     {
422   // see header file for class documentation
423     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "DoEvent()" );
424     if ( evtData.fBlockCnt<=0 )
425       {
426         Logging( kHLTLogWarning, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "no blocks in event" );
427         return 0;
428       }
429     const AliHLTComponentBlockData* iter = NULL;
430     unsigned long ndx;
431     AliHLTTPCClusterData* inPtrSP;
432     AliHLTTPCVertexData* inPtrV = NULL;
433     const AliHLTComponentBlockData* vertexIter=NULL;
434     AliHLTTPCTrackletData* outPtr;
435     AliHLTUInt8_t* outBPtr;
436     AliHLTUInt32_t vSize = 0;
437     UInt_t offset=0, mysize, tSize = 0;
438     outBPtr = outputPtr;
439     Int_t slice=-1, patch=-1, row[2];
440     Int_t minPatch=INT_MAX, maxPatch = 0;
441     offset = 0;
442     std::vector<Int_t> slices;
443     std::vector<Int_t>::iterator slIter, slEnd;
444     std::vector<unsigned> sliceCnts;
445     std::vector<unsigned>::iterator slCntIter;
446     Int_t vertexSlice=-1;
447
448     // Find min/max rows used in total and find and read out vertex if it is present
449     // also determine correct slice number, if multiple slice numbers are present in event
450     // (which should not happen in the first place) we use the one that occurs the most times
451     row[0] = 0;
452     row[1] = 0;
453     bool found;
454     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
455         {
456         iter = blocks+ndx;
457
458         if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){
459           HLTDebug("Data block type is not of type AliHLTTPCDefinitions::fgkClustersDataType");
460           continue;
461         }
462
463         slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
464         found = false;
465         slIter = slices.begin();
466         slEnd = slices.end();
467         slCntIter = sliceCnts.begin();
468         while ( slIter != slEnd )
469             {
470             if ( *slIter == slice )
471                 {
472                 found = true;
473                 break;
474                 }
475             slIter++;
476             slCntIter++;
477             }
478         if ( !found )
479             {
480             slices.insert( slices.end(), slice );
481             sliceCnts.insert( sliceCnts.end(), 1 );
482             }
483         else
484             *slCntIter++;
485
486         if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType )
487             {
488             inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
489             vertexIter = iter;
490             vSize = iter->fSize;
491             fVertex->Read( inPtrV );
492             vertexSlice = slice;
493             }
494         if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType )
495             {
496             patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
497             if ( minPatch>patch )
498                 {
499                 minPatch = patch;
500                 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
501                 }
502             if ( maxPatch<patch )
503                 {
504                 maxPatch = patch;
505                 row[1] = AliHLTTPCTransform::GetLastRow( patch );
506                 }
507             }
508         }
509
510     // Determine slice number to really use.
511     if ( slices.size()>1 )
512         {
513         Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
514                  "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
515                  evtData.fEventID, evtData.fEventID );
516         unsigned maxCntSlice=0;
517         slIter = slices.begin();
518         slEnd = slices.end();
519         slCntIter = sliceCnts.begin();
520         while ( slIter != slEnd )
521             {
522             Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
523                      "Slice %lu found %lu times.", *slIter, *slCntIter );
524             if ( maxCntSlice<*slCntIter )
525                 {
526                 maxCntSlice = *slCntIter;
527                 slice = *slIter;
528                 }
529             slIter++;
530             slCntIter++;
531             }
532         Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
533                  "Using slice %lu.", slice );
534         }
535     else if ( slices.size()>0 )
536       {
537         slice = *(slices.begin());
538       }
539     else
540       {
541         slice = -1;
542       }
543     
544     if ( vertexSlice != slice )
545         {
546         // multiple vertex blocks in event and we used the wrong one...
547         found = false;
548         for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
549             {
550             iter = blocks+ndx;
551             if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
552                 {
553                 inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
554                 vertexIter = iter;
555                 vSize = iter->fSize;
556                 fVertex->Read( inPtrV );
557                 break;
558                 }
559             }
560         }
561
562     fTracker->InitSector( slice, row, fEta );
563     fTracker->SetVertex(fVertex);
564     mysize = 0;
565     // read in all hits
566     std::vector<unsigned long> patchIndices;
567     std::vector<unsigned long>::iterator pIter, pEnd;
568     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
569         {
570         iter = blocks+ndx;
571
572         if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
573             {
574             patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
575             pIter = patchIndices.begin();
576             pEnd = patchIndices.end();
577             while ( pIter!=pEnd && AliHLTTPCDefinitions::GetMinSliceNr( blocks[*pIter] ) < patch )
578                 pIter++;
579             patchIndices.insert( pIter, ndx );
580             }
581         }
582     pIter = patchIndices.begin();
583     pEnd = patchIndices.end();
584     while ( pIter!=pEnd )
585         {
586         ndx = *pIter;
587         iter = blocks+ndx;
588
589         patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
590         inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr);
591             
592         Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Reading hits",
593                  "Reading hits for slice %d - patch %d", slice, patch );
594         fTracker->ReadHits( inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints );
595         pIter++;
596         }
597
598     outPtr = (AliHLTTPCTrackletData*)(outBPtr);
599
600     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){ 
601       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
602       fTracker->MainVertexTrackingA();
603       fTracker->MainVertexTrackingB();
604       fTracker->FillTracks();
605     }
606     else if ( fmainvertextracking == kTRUE && fnonvertextracking == kTRUE){     
607       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
608       fTracker->MainVertexTrackingA();
609       fTracker->MainVertexTrackingB();
610       fTracker->FillTracks();   
611       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---NONVERTEXTRACKING---");
612       fTracker->NonVertexTracking();
613     }
614     else if ( fmainvertextracking == kFALSE && fnonvertextracking == kTRUE){
615       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---NONVERTEXTRACKING---");
616       fTracker->NonVertexTracking();    
617       fTracker->FillTracks();   
618     }
619
620     UInt_t ntracks0 =0;
621     if(fpInterMerger){
622       AliHLTTPCMemHandler memory;
623       AliHLTTPCTrackSegmentData *trackdata0  = 
624         (AliHLTTPCTrackSegmentData *) memory.Allocate(fTracker->GetTracks());
625       memory.TrackArray2Memory(ntracks0,trackdata0,fTracker->GetTracks());
626       fpInterMerger->Reset();
627       fpInterMerger->Init(row,patch);
628       fpInterMerger->FillTracks(ntracks0,trackdata0);
629       fpInterMerger->Merge();
630     } 
631     ntracks0=0;
632     AliHLTTPCTrackArray* pArray=fTracker->GetTracks();
633     mysize = pArray->WriteTracks( ntracks0, outPtr->fTracklets );
634     outPtr->fTrackletCnt = ntracks0;
635
636     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracks",
637              "Input: Number of tracks: %lu Slice/MinPatch/MaxPatch/RowMin/RowMax: %lu/%lu/%lu/%lu/%lu.", 
638              ntracks0, slice, minPatch, maxPatch, row[0], row[1] );
639
640     fTracker->Reset();
641
642     tSize += mysize+sizeof(AliHLTTPCTrackletData);
643     outBPtr += mysize+sizeof(AliHLTTPCTrackletData);
644     
645     AliHLTComponentBlockData bd;
646     FillBlockData( bd );
647     bd.fOffset = offset;
648     bd.fSize = tSize;
649     bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
650     outputBlocks.push_back( bd );
651
652 #ifdef FORWARD_VERTEX_BLOCK
653     if ( vertexIter )
654         {
655         // Copy the descriptor block for the vertex information.
656         bd = *vertexIter;
657         outputBlocks.push_back( bd );
658         }
659 #endif // FORWARD_VERTEX_BLOCK
660
661     size = tSize;
662     return 0;
663     }
664
665 int AliHLTTPCSliceTrackerComponent::Configure(const char* arguments)
666 {
667   // see header file for class documentation
668   int iResult=0;
669   if (!arguments) return iResult;
670   
671   TString allArgs=arguments;
672   TString argument;
673   int bMissingParam=0;
674   Bool_t bDoMerger=kTRUE;
675
676   TObjArray* pTokens=allArgs.Tokenize(" ");
677   if (pTokens) {
678     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
679       argument=((TObjString*)pTokens->At(i))->GetString();
680       if (argument.IsNull()) continue;
681       
682       if (argument.CompareTo("-disable-merger")==0) {
683         HLTInfo("Disabled Inter Merger");
684         bDoMerger = kFALSE;
685         continue;
686       }
687       else if (argument.CompareTo("-pp-run")==0) {
688         HLTInfo("Using Trackparameters for pp-run");
689         fDoPP = true;
690         continue;
691       }
692       else if (argument.CompareTo("-PbPb-run")==0) {
693         HLTInfo("Using Trackparameters for Pb-Pb-run");
694         fDoPbPb = true;
695         continue;
696       }
697       else if (argument.CompareTo("-nonvertextracking")==0) {
698         HLTInfo("Doing Nonvertex Tracking");
699         fnonvertextracking = kTRUE;
700         continue;
701       }     
702       else if (argument.CompareTo("-mainvertextrackingoff")==0) {
703         HLTInfo("Mainvertex Tracking off");
704         fmainvertextracking = kFALSE;
705         continue;
706       }
707       else if (argument.CompareTo("-multiplicity")==0) {
708         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
709         HLTInfo("Multiplicity set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
710         fMultiplicity=((TObjString*)pTokens->At(i))->GetString().Atoi();
711         continue;
712       } 
713       else if (argument.CompareTo("-bfield")==0) {
714         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
715         HLTInfo("Magnetic Field set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
716         fBField=((TObjString*)pTokens->At(i))->GetString().Atof();
717         continue;
718       } 
719       else if (argument.CompareTo("-etarange")==0) {
720         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
721         HLTInfo("Etarange set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
722         fEta[1]=((TObjString*)pTokens->At(i))->GetString().Atof();
723         continue;
724       }
725       else if (argument.CompareTo("-etasegment")==0) {
726         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
727         HLTInfo("Number of Etasegment: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
728         fEtasegment=((TObjString*)pTokens->At(i))->GetString().Atoi();
729         continue;
730       }
731       else if (argument.CompareTo("-chi2cut")==0) {
732         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
733         HLTInfo("chi2cut set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
734         fHitChi2Cut=((TObjString*)pTokens->At(i))->GetString().Atof();
735         continue;
736       }
737       else if (argument.CompareTo("-rowscopetracklet")==0) {
738         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
739         HLTInfo("Number of row to look for next cluster for tracklet: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
740         fRowscopetracklet=((TObjString*)pTokens->At(i))->GetString().Atoi();
741         continue;
742       }
743       else if (argument.CompareTo("-rowscopetrack")==0) {
744         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
745         HLTInfo("Number of row to look for next cluster for track: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
746         fRowscopetrack=((TObjString*)pTokens->At(i))->GetString().Atoi();
747         continue;
748       }
749       else if (argument.CompareTo("-trackletlength")==0) {
750         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
751         HLTInfo("Minimum number of clusters on a Tracklet: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
752         fTrackletlength=((TObjString*)pTokens->At(i))->GetString().Atoi();
753         continue;
754       }
755       else if (argument.CompareTo("-tracklength")==0) {
756         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
757         HLTInfo("Minimum number of clusters on a Track: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
758         fTracklength=((TObjString*)pTokens->At(i))->GetString().Atoi();
759         continue;
760       }
761       else {
762         HLTError("unknown argument %s", argument.Data());
763         iResult=-EINVAL;
764         break;
765       }
766     }
767     delete pTokens;
768   }
769   if (bMissingParam) {
770     HLTError("missing parameter for argument %s", argument.Data());
771     iResult=-EINVAL;
772   }
773   if (fBField == 0.){
774     // parameter for B=0 T 
775     fDoPP = kTRUE;
776     fnonvertextracking = kTRUE;
777     fmainvertextracking = kFALSE;
778   }
779  
780   if (bDoMerger)
781     fpInterMerger = new AliHLTTPCInterMerger();
782   else
783     fpInterMerger = NULL;
784
785   SetTrackerParam(fDoPP,fDoPbPb,fMultiplicity,fBField,fEtasegment,fHitChi2Cut,fRowscopetracklet,fRowscopetrack,fTrackletlength,fTracklength);
786   
787   return iResult;
788 }
789
790 int AliHLTTPCSliceTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
791 {
792   // see header file for class documentation
793   int iResult=0;
794   const char* path="HLT/ConfigTPC/SliceTrackerComponent";
795   const char* defaultNotify="";
796   if (cdbEntry) {
797     path=cdbEntry;
798     defaultNotify=" (default)";
799   }
800   if (path) {
801     HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
802     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
803     if (pEntry) {
804       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
805       if (pString) {
806         HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
807         iResult=Configure(pString->GetString().Data());
808       } else {
809         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
810       }
811     } else {
812       HLTError("can not fetch object \"%s\" from CDB", path);
813     }
814   }
815
816   const char* pathBField="TPC/Config/BField";
817
818   if (pathBField) {
819     HLTInfo("reconfigure B-Field from entry %s, chain id %s", path,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
820     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathBField/*,GetRunNo()*/);
821     if (pEntry) {
822       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
823       if (pString) {
824         HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
825         iResult=Configure(pString->GetString().Data());
826       } else {
827         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
828       }
829     } else {
830       HLTError("can not fetch object \"%s\" from CDB", path);
831     }
832   }
833   
834   return iResult;
835 }
836
837 void AliHLTTPCSliceTrackerComponent::SetTrackerParam1()
838 {
839   // see header file for class documentation
840   SetTrackerParam( 10, 20, 5, 10, 2,2,
841                    0, 1.31, 5, 100,
842                    50, 100, 50, 0.1, 0.1);
843 }
844
845