]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCATrackerComponent.cxx
Improvement of the magnetic field usage.
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATrackerComponent.cxx
CommitLineData
cf471b1e 1// @(#) $Id$
ce565086 2// **************************************************************************
fbb9b71b 3// This file is property of and copyright by the ALICE HLT Project *
d54804bf 4// ALICE Experiment at CERN, All rights reserved. *
5// *
6// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7// Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8// for The ALICE HLT Project. *
9// *
10// Permission to use, copy, modify and distribute this software and its *
11// documentation strictly for non-commercial purposes is hereby granted *
12// without fee, provided that the above copyright notice appears in all *
13// copies and that both the copyright notice and this permission notice *
14// appear in the supporting documentation. The authors make no claims *
15// about the suitability of this software for any purpose. It is *
16// provided "as is" without express or implied warranty. *
ce565086 17// *
d54804bf 18//***************************************************************************
ce565086 19
fbb9b71b 20
cf471b1e 21///////////////////////////////////////////////////////////////////////////////
22// //
23// a TPC tracker processing component for the HLT based on CA by Ivan Kisel //
24// //
25///////////////////////////////////////////////////////////////////////////////
26
27#if __GNUC__>= 3
28using namespace std;
29#endif
30
31#include "AliHLTTPCCATrackerComponent.h"
32#include "AliHLTTPCTransform.h"
33#include "AliHLTTPCCATracker.h"
cf471b1e 34#include "AliHLTTPCCAOutTrack.h"
d54804bf 35#include "AliHLTTPCCAParam.h"
eb30eb49 36#include "AliHLTTPCCATrackConvertor.h"
4acc2401 37#include "AliHLTArray.h"
cf471b1e 38
cf471b1e 39#include "AliHLTTPCSpacePointData.h"
cf471b1e 40#include "AliHLTTPCClusterDataFormat.h"
41#include "AliHLTTPCTransform.h"
42#include "AliHLTTPCTrackSegmentData.h"
43#include "AliHLTTPCTrackArray.h"
44#include "AliHLTTPCTrackletDataFormat.h"
45#include "AliHLTTPCDefinitions.h"
d54804bf 46#include "AliExternalTrackParam.h"
dc4788ec 47#include "TStopwatch.h"
cf471b1e 48#include "TMath.h"
53a9c37c 49#include "AliCDBEntry.h"
50#include "AliCDBManager.h"
51#include "TObjString.h"
52#include "TObjArray.h"
e1f2d1c3 53#include "AliHLTTPCCASliceOutput.h"
4acc2401 54#include "AliHLTTPCCAClusterData.h"
e1f2d1c3 55
56const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkTrackletsDataType = AliHLTComponentDataTypeInitializer( "CATRACKL", kAliHLTDataOriginTPC );
57
58/** ROOT macro for the implementation of ROOT specific class methods */
fbb9b71b 59ClassImp( AliHLTTPCCATrackerComponent )
cf471b1e 60
cf471b1e 61AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent()
fbb9b71b 62 :
63 fTracker( NULL ),
64 fSolenoidBz( 0 ),
65 fMinNTrackClusters( 0 ),
66 fClusterZCut( 500. ),
67 fFullTime( 0 ),
68 fRecoTime( 0 ),
69 fNEvents( 0 ),
768b27af 70 fOutputTRAKSEGS( 0 )
cf471b1e 71{
72 // see header file for class documentation
73 // or
74 // refer to README to build package
75 // or
76 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
77}
78
fbb9b71b 79AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent( const AliHLTTPCCATrackerComponent& )
80 :
81 AliHLTProcessor(),
82 fTracker( NULL ),
83 fSolenoidBz( 0 ),
84 fMinNTrackClusters( 30 ),
85 fClusterZCut( 500. ),
86 fFullTime( 0 ),
87 fRecoTime( 0 ),
88 fNEvents( 0 ),
768b27af 89 fOutputTRAKSEGS( 0 )
cf471b1e 90{
91 // see header file for class documentation
fbb9b71b 92 HLTFatal( "copy constructor untested" );
cf471b1e 93}
94
fbb9b71b 95AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=( const AliHLTTPCCATrackerComponent& )
cf471b1e 96{
97 // see header file for class documentation
fbb9b71b 98 HLTFatal( "assignment operator untested" );
cf471b1e 99 return *this;
100}
101
102AliHLTTPCCATrackerComponent::~AliHLTTPCCATrackerComponent()
4c256004 103{
cf471b1e 104 // see header file for class documentation
4c256004 105 delete fTracker;
106}
cf471b1e 107
4c256004 108//
cf471b1e 109// Public functions to implement AliHLTComponent's interface.
110// These functions are required for the registration process
4c256004 111//
cf471b1e 112
fbb9b71b 113const char* AliHLTTPCCATrackerComponent::GetComponentID()
4c256004 114{
cf471b1e 115 // see header file for class documentation
4c256004 116 return "TPCCATracker";
117}
cf471b1e 118
fbb9b71b 119void AliHLTTPCCATrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list )
4c256004 120{
cf471b1e 121 // see header file for class documentation
4c256004 122 list.clear();
123 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
124}
cf471b1e 125
fbb9b71b 126AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType()
4c256004 127{
cf471b1e 128 // see header file for class documentation
768b27af 129 if ( fOutputTRAKSEGS ) return AliHLTTPCDefinitions::fgkTrackSegmentsDataType;
130 else return AliHLTTPCCADefinitions::fgkTrackletsDataType;
4c256004 131}
cf471b1e 132
fbb9b71b 133void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
4c256004 134{
135 // define guess for the output data size
136 constBase = 200; // minimum size
fbb9b71b 137 inputMultiplier = 0.5; // size relative to input
4c256004 138}
cf471b1e 139
fbb9b71b 140AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn()
4c256004 141{
cf471b1e 142 // see header file for class documentation
4c256004 143 return new AliHLTTPCCATrackerComponent;
144}
cf471b1e 145
768b27af 146void AliHLTTPCCATrackerComponent::SetDefaultConfiguration()
4c256004 147{
768b27af 148 // Set default configuration for the CA tracker component
149 // Some parameters can be later overwritten from the OCDB
d54804bf 150
768b27af 151 fSolenoidBz = 5.;
53a9c37c 152 fMinNTrackClusters = 0;
153 fClusterZCut = 500.;
768b27af 154 fOutputTRAKSEGS = 0;
d54804bf 155 fFullTime = 0;
156 fRecoTime = 0;
00d07bcd 157 fNEvents = 0;
768b27af 158}
d54804bf 159
768b27af 160int AliHLTTPCCATrackerComponent::ReadConfigurationString( const char* arguments )
161{
162 // Set configuration parameters for the CA tracker component from the string
d54804bf 163
fbb9b71b 164 int iResult = 0;
768b27af 165 if ( !arguments ) return iResult;
166
167 TString allArgs = arguments;
168 TString argument;
169 int bMissingParam = 0;
eb30eb49 170
768b27af 171 TObjArray* pTokens = allArgs.Tokenize( " " );
172
173 int nArgs = pTokens ? pTokens->GetEntries() : 0;
174
175 for ( int i = 0; i < nArgs; i++ ) {
176 argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
177 if ( argument.IsNull() ) continue;
178
179 if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
180 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
181 fSolenoidBz = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
182 HLTInfo( "Magnetic Field set to: %f", fSolenoidBz );
183 continue;
184 }
185
186 if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ) {
187 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
188 fMinNTrackClusters = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
189 HLTInfo( "minNClustersOnTrack set to: %d", fMinNTrackClusters );
190 continue;
191 }
192
193 if ( argument.CompareTo( "-clusterZCut" ) == 0 ) {
194 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
195 fClusterZCut = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() );
196 HLTInfo( "ClusterZCut set to: %f", fClusterZCut );
197 continue;
198 }
199
200 if ( argument.CompareTo( "-outputTRAKSEGS" ) == 0 ) {
201 fOutputTRAKSEGS = 1;
202 HLTInfo( "The special output type \"TRAKSEGS\" is set" );
203 continue;
204 }
205
206 HLTError( "Unknown option \"%s\"", argument.Data() );
207 iResult = -EINVAL;
4c256004 208 }
768b27af 209 delete pTokens;
210
211 if ( bMissingParam ) {
212 HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
213 iResult = -EINVAL;
fbb9b71b 214 }
768b27af 215
53a9c37c 216 return iResult;
4c256004 217}
cf471b1e 218
53a9c37c 219
768b27af 220int AliHLTTPCCATrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
4c256004 221{
cf471b1e 222 // see header file for class documentation
cf471b1e 223
768b27af 224 const char* defaultNotify="";
e1f2d1c3 225
768b27af 226 if (!cdbEntry) {
227 cdbEntry="HLT/ConfigTPC/TPCCATracker";
228 defaultNotify=" (default)";
229 chainId = 0;
230 }
53a9c37c 231
768b27af 232 HLTInfo("configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
233 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(cdbEntry);//,GetRunNo());
fbb9b71b 234
768b27af 235 if( !pEntry ) {
236 HLTError("cannot fetch object \"%s\" from CDB", cdbEntry);
237 return -EINVAL;
53a9c37c 238 }
768b27af 239
240 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
241
242 if( !pString ) {
243 HLTError("configuration object \"%s\" has wrong type, required TObjString", cdbEntry);
244 return -EINVAL;
53a9c37c 245 }
fbb9b71b 246
768b27af 247 HLTInfo("received configuration object string: \"%s\"", pString->GetString().Data());
fbb9b71b 248
768b27af 249 return ReadConfigurationString( pString->GetString().Data() );
250}
251
252
17d6eada 253int AliHLTTPCCATrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
254{
255 // Configure the component
256 // There are few levels of configuration,
257 // parameters which are set on one step can be overwritten on the next step
258
259 //* read hard-coded values
260
261 SetDefaultConfiguration();
262
263 //* read the default CDB entry
264
265 int iResult1 = ReadCDBEntry( NULL, chainId );
266
267 //* read magnetic field
268
269 int iResult2 = ReadCDBEntry( kAliHLTCDBSolenoidBz, chainId );
270
271 //* read the actual CDB entry if required
272
273 int iResult3 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) :0;
274
275 //* read extra parameters from input (if they are)
276
277 int iResult4 = 0;
278
279 if( commandLine && commandLine[0]!='\0' ){
280 HLTInfo("received configuration string from HLT framework: \"%s\"", commandLine );
281 iResult4 = ReadConfigurationString( commandLine );
282 }
283
284 // Initialise the tracker here
285
286 return iResult1 ? iResult1 :(iResult2 ? iResult2 :( iResult3 ? iResult3 :iResult4 ) );
287}
288
289
290
768b27af 291int AliHLTTPCCATrackerComponent::DoInit( int argc, const char** argv )
292{
293 // Configure the CA tracker component
294
295 if ( fTracker ) return EINPROGRESS;
296
297 fTracker = new AliHLTTPCCATracker();
298
299 TString arguments = "";
300 for ( int i = 0; i < argc; i++ ) {
301 if ( !arguments.IsNull() ) arguments += " ";
302 arguments += argv[i];
fbb9b71b 303 }
768b27af 304
17d6eada 305 return Configure( NULL, NULL,arguments.Data() );
53a9c37c 306}
307
308
768b27af 309int AliHLTTPCCATrackerComponent::DoDeinit()
eb30eb49 310{
768b27af 311 // see header file for class documentation
312 delete fTracker;
313 fTracker = NULL;
314 return 0;
eb30eb49 315}
316
53a9c37c 317
768b27af 318
319int AliHLTTPCCATrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
53a9c37c 320{
17d6eada 321 // Reconfigure the component from OCDB .
fbb9b71b 322
17d6eada 323 return Configure( cdbEntry, chainId, NULL );
53a9c37c 324}
53a9c37c 325
326
768b27af 327bool AliHLTTPCCATrackerComponent::CompareClusters( AliHLTTPCSpacePointData *a, AliHLTTPCSpacePointData *b )
328{
329 //* Comparison function for sort clusters
330
331 if ( a->fPadRow < b->fPadRow ) return 1;
332 if ( a->fPadRow > b->fPadRow ) return 0;
333 return ( a->fZ < b->fZ );
334}
335
53a9c37c 336
fbb9b71b 337
338int AliHLTTPCCATrackerComponent::DoEvent
339(
340 const AliHLTComponentEventData& evtData,
341 const AliHLTComponentBlockData* blocks,
342 AliHLTComponentTriggerData& /*trigData*/,
343 AliHLTUInt8_t* outputPtr,
344 AliHLTUInt32_t& size,
345 vector<AliHLTComponentBlockData>& outputBlocks )
cf471b1e 346{
768b27af 347 //* process event
348
00d07bcd 349 AliHLTUInt32_t maxBufferSize = size;
dc4788ec 350 size = 0; // output size
351
fbb9b71b 352 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
eb30eb49 353 return 0;
354 }
355
dc4788ec 356 TStopwatch timer;
357
4c256004 358 // Event reconstruction in one TPC slice with CA Tracker
fbb9b71b 359
d54804bf 360 //Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA::DoEvent()" );
fbb9b71b 361 if ( evtData.fBlockCnt <= 0 ) {
362 HLTWarning( "no blocks in event" );
363 return 0;
364 }
365
cf471b1e 366 const AliHLTComponentBlockData* iter = NULL;
367 unsigned long ndx;
fbb9b71b 368 AliHLTTPCClusterData* inPtrSP;
369
370 // Determine the slice number
371
372 int slice = -1;
4c256004 373 {
fbb9b71b 374 std::vector<int> slices;
375 std::vector<int>::iterator slIter;
4acc2401 376 std::vector<unsigned> sliceCnts;
377 std::vector<unsigned>::iterator slCntIter;
fbb9b71b 378
379 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
380 iter = blocks + ndx;
4c256004 381 if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue;
382
cf471b1e 383 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
dc4788ec 384
fbb9b71b 385 bool found = 0;
cf471b1e 386 slCntIter = sliceCnts.begin();
fbb9b71b 387 for ( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) {
388 if ( *slIter == slice ) {
389 found = kTRUE;
390 break;
391 }
4c256004 392 }
fbb9b71b 393 if ( !found ) {
394 slices.push_back( slice );
395 sliceCnts.push_back( 1 );
396 } else *slCntIter++;
cf471b1e 397 }
fbb9b71b 398
399
4c256004 400 // Determine slice number to really use.
fbb9b71b 401 if ( slices.size() > 1 ) {
402 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
403 "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
404 evtData.fEventID, evtData.fEventID );
4acc2401 405 unsigned maxCntSlice = 0;
fbb9b71b 406 slCntIter = sliceCnts.begin();
407 for ( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) {
408 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
409 "Slice %lu found %lu times.", *slIter, *slCntIter );
410 if ( maxCntSlice < *slCntIter ) {
411 maxCntSlice = *slCntIter;
412 slice = *slIter;
413 }
4c256004 414 }
fbb9b71b 415 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
416 "Using slice %lu.", slice );
417 } else if ( slices.size() > 0 ) {
418 slice = *( slices.begin() );
419 }
4c256004 420 }
fbb9b71b 421
422 if ( slice < 0 ) {
423 HLTWarning( "no slices found in event" );
4c256004 424 return 0;
425 }
cf471b1e 426
4c256004 427
428 // Initialize the tracker
429
fbb9b71b 430
cf471b1e 431 {
fbb9b71b 432 if ( !fTracker ) fTracker = new AliHLTTPCCATracker;
433 int iSec = slice;
434 float inRmin = 83.65;
435 // float inRmax = 133.3;
436 // float outRmin = 133.5;
437 float outRmax = 247.7;
438 float plusZmin = 0.0529937;
439 float plusZmax = 249.778;
440 float minusZmin = -249.645;
441 float minusZmax = -0.0799937;
442 float dalpha = 0.349066;
443 float alpha = 0.174533 + dalpha * iSec;
444
445 bool zPlus = ( iSec < 18 );
446 float zMin = zPlus ? plusZmin : minusZmin;
447 float zMax = zPlus ? plusZmax : minusZmax;
448 //TPCZmin = -249.645, ZMax = 249.778
449 // float rMin = inRmin;
450 // float rMax = outRmax;
451 int nRows = AliHLTTPCTransform::GetNRows();
452
453 float padPitch = 0.4;
454 float sigmaZ = 0.228808;
455
456 float *rowX = new float [nRows];
457 for ( int irow = 0; irow < nRows; irow++ ) {
dc4788ec 458 rowX[irow] = AliHLTTPCTransform::Row2X( irow );
fbb9b71b 459 }
460
cf471b1e 461 AliHLTTPCCAParam param;
16b802c5 462
00d07bcd 463 param.Initialize( iSec, nRows, rowX, alpha, dalpha,
91794c67 464 inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz );
693d2443 465 param.SetHitPickUpFactor( 2 );
eb30eb49 466 param.Update();
fbb9b71b 467 fTracker->Initialize( param );
d54804bf 468 delete[] rowX;
cf471b1e 469 }
470
fbb9b71b 471
4c256004 472 // min and max patch numbers and row numbers
473
fbb9b71b 474 int row[2] = {0, 0};
475 int minPatch = 100, maxPatch = -1;
4c256004 476
477 // total n Hits
cf471b1e 478
6de2bc40 479 int nClustersTotal = 0;
4c256004 480
481 // sort patches
482
483 std::vector<unsigned long> patchIndices;
484
fbb9b71b 485 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
486 iter = blocks + ndx;
487 if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue;
488 if ( slice != AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue;
489 inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
6de2bc40 490 nClustersTotal += inPtrSP->fSpacePointCnt;
fbb9b71b 491 int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
492 if ( minPatch > patch ) {
4c256004 493 minPatch = patch;
494 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
495 }
fbb9b71b 496 if ( maxPatch < patch ) {
4c256004 497 maxPatch = patch;
498 row[1] = AliHLTTPCTransform::GetLastRow( patch );
499 }
fbb9b71b 500 std::vector<unsigned long>::iterator pIter = patchIndices.begin();
501 while ( pIter != patchIndices.end() && AliHLTTPCDefinitions::GetMinPatchNr( blocks[*pIter] ) < patch ) {
4c256004 502 pIter++;
503 }
504 patchIndices.insert( pIter, ndx );
cf471b1e 505 }
fbb9b71b 506
4c256004 507
508 // pass event to CA Tracker
fbb9b71b 509
4c256004 510
4c256004 511 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits",
6de2bc40 512 "Total %d hits to read for slice %d", nClustersTotal, slice );
4c256004 513
eb30eb49 514
6de2bc40 515 AliHLTTPCCAClusterData clusterData;
516 clusterData.StartReading( slice, nClustersTotal );
dc4788ec 517
fbb9b71b 518 for ( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter != patchIndices.end(); pIter++ ) {
4c256004 519 ndx = *pIter;
fbb9b71b 520 iter = blocks + ndx;
521
522 int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
523 inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
524
4c256004 525 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits",
fbb9b71b 526 "Reading %d hits for slice %d - patch %d", inPtrSP->fSpacePointCnt, slice, patch );
527
528 for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) {
6de2bc40 529 AliHLTTPCSpacePointData *c = &( inPtrSP->fSpacePoints[i] );
530 if ( CAMath::Abs( c->fZ ) > fClusterZCut ) continue;
17d6eada 531 if( c->fPadRow <0 || c->fPadRow>159 ){
532 HLTError("Wrong TPC cluster with row number %d received",c->fPadRow);
533 continue;
534 }
6de2bc40 535 clusterData.ReadCluster( c->fID, c->fPadRow, c->fX, c->fY, c->fZ, c->fCharge );
eb30eb49 536 }
537 }
4c256004 538
6de2bc40 539 clusterData.FinishReading();
b8139972 540
fbb9b71b 541 // reconstruct the event
cf471b1e 542
dc4788ec 543 TStopwatch timerReco;
544
6de2bc40 545 fTracker->ReadEvent( &clusterData );
546
cf471b1e 547 fTracker->Reconstruct();
548
dc4788ec 549 timerReco.Stop();
550
fbb9b71b 551 int ret = 0;
4c256004 552
553 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reconstruct",
fbb9b71b 554 "%d tracks found for slice %d", fTracker->NOutTracks(), slice );
cf471b1e 555
cf471b1e 556
e1f2d1c3 557 // write reconstructed tracks
cf471b1e 558
fbb9b71b 559 unsigned int mySize = 0;
560 int ntracks = *fTracker->NOutTracks();
561
562
768b27af 563 if ( fOutputTRAKSEGS ) {
fbb9b71b 564
565 AliHLTTPCTrackletData* outPtr = ( AliHLTTPCTrackletData* )( outputPtr );
566
567 AliHLTTPCTrackSegmentData* currOutTracklet = outPtr->fTracklets;
568
569 mySize = ( ( AliHLTUInt8_t * )currOutTracklet ) - ( ( AliHLTUInt8_t * )outputPtr );
570
571 outPtr->fTrackletCnt = 0;
572
573 for ( int itr = 0; itr < ntracks; itr++ ) {
574
575 AliHLTTPCCAOutTrack &t = fTracker->OutTracks()[itr];
576
e1f2d1c3 577 //Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Wrtite output","track %d with %d hits", itr, t.NHits());
fbb9b71b 578
579 if ( t.NHits() < fMinNTrackClusters ) continue;
580
e1f2d1c3 581 // calculate output track size
fbb9b71b 582
583 unsigned int dSize = sizeof( AliHLTTPCTrackSegmentData ) + t.NHits() * sizeof( unsigned int );
584
585 if ( mySize + dSize > maxBufferSize ) {
586 HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, ntracks - itr + 1 );
587 ret = -ENOSPC;
588 break;
e1f2d1c3 589 }
fbb9b71b 590
e1f2d1c3 591 // convert CA track parameters to HLT Track Segment
fbb9b71b 592
593 int iFirstRow = 1000;
594 int iLastRow = -1;
595 int iFirstHit = fTracker->OutTrackHits()[t.FirstHitRef()];
596 int iLastHit = iFirstHit;
597 for ( int ih = 0; ih < t.NHits(); ih++ ) {
598 int hitID = fTracker->OutTrackHits()[t.FirstHitRef() + ih ];
4acc2401 599 int iRow = clusterData.RowNumber( hitID );
fbb9b71b 600 if ( iRow < iFirstRow ) { iFirstRow = iRow; iFirstHit = hitID; }
601 if ( iRow > iLastRow ) { iLastRow = iRow; iLastHit = hitID; }
602 }
603
e1f2d1c3 604 AliHLTTPCCATrackParam par = t.StartPoint();
fbb9b71b 605
4acc2401 606 par.TransportToX( clusterData.X( iFirstHit ), .99 );
fbb9b71b 607
e1f2d1c3 608 AliExternalTrackParam tp;
15d2e9cf 609 AliHLTTPCCATrackConvertor::GetExtParam( par, tp, 0 );
fbb9b71b 610
e1f2d1c3 611 currOutTracklet->fX = tp.GetX();
612 currOutTracklet->fY = tp.GetY();
613 currOutTracklet->fZ = tp.GetZ();
fbb9b71b 614 currOutTracklet->fCharge = ( int ) tp.GetSign();
615 currOutTracklet->fPt = TMath::Abs( tp.GetSignedPt() );
616 float snp = tp.GetSnp() ;
617 if ( snp > .999 ) snp = .999;
618 if ( snp < -.999 ) snp = -.999;
e1f2d1c3 619 currOutTracklet->fPsi = TMath::ASin( snp );
620 currOutTracklet->fTgl = tp.GetTgl();
fbb9b71b 621
e1f2d1c3 622 currOutTracklet->fY0err = tp.GetSigmaY2();
623 currOutTracklet->fZ0err = tp.GetSigmaZ2();
fbb9b71b 624 float h = -currOutTracklet->fPt * currOutTracklet->fPt;
625 currOutTracklet->fPterr = h * h * tp.GetSigma1Pt2();
626 h = 1. / TMath::Sqrt( 1 - snp * snp );
627 currOutTracklet->fPsierr = h * h * tp.GetSigmaSnp2();
e1f2d1c3 628 currOutTracklet->fTglerr = tp.GetSigmaTgl2();
fbb9b71b 629
4acc2401 630 if ( par.TransportToX( clusterData.X( iLastHit ), .99 ) ) {
fbb9b71b 631 currOutTracklet->fLastX = par.GetX();
632 currOutTracklet->fLastY = par.GetY();
633 currOutTracklet->fLastZ = par.GetZ();
e1f2d1c3 634 } else {
4acc2401 635 currOutTracklet->fLastX = clusterData.X( iLastHit );
636 currOutTracklet->fLastY = clusterData.Y( iLastHit );
637 currOutTracklet->fLastZ = clusterData.Z( iLastHit );
e1f2d1c3 638 }
639 //if( currOutTracklet->fLastX<10. ) {
4acc2401 640 //HLTError("CA last point: hitxyz=%f,%f,%f, track=%f,%f,%f, tracklet=%f,%f,%f, nhits=%d",clusterData.X( iLastHit ),clusterData.Y( iLastHit],clusterData.Z( iLastHit],
e1f2d1c3 641 //par.GetX(), par.GetY(),par.GetZ(),currOutTracklet->fLastX,currOutTracklet->fLastY ,currOutTracklet->fLastZ, t.NHits());
642 //}
dc4788ec 643#ifdef INCLUDE_TPC_HOUGH
644#ifdef ROWHOUGHPARAMS
e1f2d1c3 645 currOutTracklet->fTrackID = 0;
4acc2401 646 currOutTracklet->fRowRange1 = clusterData.RowNumber( iFirstHit );
647 currOutTracklet->fRowRange2 = clusterData.RowNumber( iLastHit );
e1f2d1c3 648 currOutTracklet->fSector = slice;
649 currOutTracklet->fPID = 211;
dc4788ec 650#endif
651#endif // INCLUDE_TPC_HOUGH
fbb9b71b 652
653
e1f2d1c3 654 currOutTracklet->fNPoints = t.NHits();
fbb9b71b 655
656 for ( int i = 0; i < t.NHits(); i++ ) {
4acc2401 657 currOutTracklet->fPointIDs[i] = clusterData.Id( fTracker->OutTrackHits()[t.FirstHitRef()+i] );
e1f2d1c3 658 }
fbb9b71b 659
660 currOutTracklet = ( AliHLTTPCTrackSegmentData* )( ( Byte_t * )currOutTracklet + dSize );
661 mySize += dSize;
662 outPtr->fTrackletCnt++;
e1f2d1c3 663 }
768b27af 664
665 } else { // default output type
e1f2d1c3 666
fbb9b71b 667 mySize = fTracker->Output()->EstimateSize( fTracker->Output()->NTracks(),
b8139972 668 fTracker->Output()->NTrackClusters() );
fbb9b71b 669 if ( mySize <= maxBufferSize ) {
670 const AliHLTUInt8_t* outputevent = reinterpret_cast<const AliHLTUInt8_t*>( fTracker->Output() );
671 for ( unsigned int i = 0; i < mySize; i++ ) outputPtr[i] = outputevent[i];
672 } else {
673 HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), tracks are not stored", maxBufferSize, mySize );
e1f2d1c3 674 mySize = 0;
675 ret = -ENOSPC;
cf471b1e 676 }
cf471b1e 677 }
fbb9b71b 678
fbb9b71b 679 if ( mySize > 0 ) {
e1f2d1c3 680 AliHLTComponentBlockData bd;
681 FillBlockData( bd );
682 bd.fOffset = 0;
683 bd.fSize = mySize;
fbb9b71b 684 bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
768b27af 685 bd.fDataType = GetOutputDataType();
e1f2d1c3 686 outputBlocks.push_back( bd );
687 }
cf471b1e 688 size = mySize;
fbb9b71b 689
d54804bf 690 timer.Stop();
691
fbb9b71b 692 fFullTime += timer.RealTime();
693 fRecoTime += timerReco.RealTime();
d54804bf 694 fNEvents++;
dc4788ec 695
696 // Set log level to "Warning" for on-line system monitoring
fbb9b71b 697 int hz = ( int ) ( fFullTime > 1.e-10 ? fNEvents / fFullTime : 100000 );
698 int hz1 = ( int ) ( fRecoTime > 1.e-10 ? fNEvents / fRecoTime : 100000 );
768b27af 699 HLTInfo( "CATracker slice %d: output %d tracks; input %d clusters, patches %d..%d, rows %d..%d; time: full %d / reco %d Hz",
700 slice, ntracks, nClustersTotal, minPatch, maxPatch, row[0], row[1], hz, hz1 );
dc4788ec 701
4c256004 702 return ret;
cf471b1e 703}
704
fbb9b71b 705