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