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