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