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