]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCATrackerComponent.cxx
Comment debugging lines
[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"
b22af1bf 33#include "AliHLTTPCCATrackerFramework.h"
d54804bf 34#include "AliHLTTPCCAParam.h"
eb30eb49 35#include "AliHLTTPCCATrackConvertor.h"
4acc2401 36#include "AliHLTArray.h"
cf471b1e 37
cf471b1e 38#include "AliHLTTPCSpacePointData.h"
cf471b1e 39#include "AliHLTTPCClusterDataFormat.h"
751d16ac 40#include "AliHLTTPCCACompressedInputData.h"
cf471b1e 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"
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"
4acc2401 53#include "AliHLTTPCCAClusterData.h"
e1f2d1c3 54
55const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkTrackletsDataType = AliHLTComponentDataTypeInitializer( "CATRACKL", kAliHLTDataOriginTPC );
56
57/** ROOT macro for the implementation of ROOT specific class methods */
fbb9b71b 58ClassImp( AliHLTTPCCATrackerComponent )
cf471b1e 59
cf471b1e 60AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent()
fbb9b71b 61 :
62 fTracker( NULL ),
63 fSolenoidBz( 0 ),
36e3690e 64 fMinNTrackClusters( 30 ),
65 fMinTrackPt(0.2),
fbb9b71b 66 fClusterZCut( 500. ),
f0fb467d 67 fNeighboursSearchArea( 0 ),
68 fClusterErrorCorrectionY(0),
69 fClusterErrorCorrectionZ(0),
57a4102f 70 fBenchmark("CATracker"),
fd6816cd 71 fAllowGPU( 0)
cf471b1e 72{
73 // see header file for class documentation
74 // or
75 // refer to README to build package
76 // or
77 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
78}
79
fbb9b71b 80AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent( const AliHLTTPCCATrackerComponent& )
81 :
82 AliHLTProcessor(),
83 fTracker( NULL ),
84 fSolenoidBz( 0 ),
85 fMinNTrackClusters( 30 ),
36e3690e 86 fMinTrackPt( 0.2 ),
fbb9b71b 87 fClusterZCut( 500. ),
f0fb467d 88 fNeighboursSearchArea(0),
89 fClusterErrorCorrectionY(0),
90 fClusterErrorCorrectionZ(0),
57a4102f 91 fBenchmark("CATracker"),
fd6816cd 92 fAllowGPU( 0)
cf471b1e 93{
94 // see header file for class documentation
fbb9b71b 95 HLTFatal( "copy constructor untested" );
cf471b1e 96}
97
fbb9b71b 98AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=( const AliHLTTPCCATrackerComponent& )
cf471b1e 99{
100 // see header file for class documentation
fbb9b71b 101 HLTFatal( "assignment operator untested" );
cf471b1e 102 return *this;
103}
104
105AliHLTTPCCATrackerComponent::~AliHLTTPCCATrackerComponent()
4c256004 106{
cf471b1e 107 // see header file for class documentation
3a4ab1ca 108 if (fTracker) delete fTracker;
4c256004 109}
cf471b1e 110
4c256004 111//
cf471b1e 112// Public functions to implement AliHLTComponent's interface.
113// These functions are required for the registration process
4c256004 114//
cf471b1e 115
fbb9b71b 116const char* AliHLTTPCCATrackerComponent::GetComponentID()
4c256004 117{
cf471b1e 118 // see header file for class documentation
4c256004 119 return "TPCCATracker";
120}
cf471b1e 121
fbb9b71b 122void AliHLTTPCCATrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list )
4c256004 123{
cf471b1e 124 // see header file for class documentation
4c256004 125 list.clear();
64fc3975 126 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
751d16ac 127 list.push_back( AliHLTTPCCADefinitions::fgkCompressedInputDataType );
4c256004 128}
cf471b1e 129
fbb9b71b 130AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType()
4c256004 131{
cf471b1e 132 // see header file for class documentation
5cb6ddd4 133 return AliHLTTPCCADefinitions::fgkTrackletsDataType;
4c256004 134}
cf471b1e 135
fbb9b71b 136void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
4c256004 137{
138 // define guess for the output data size
139 constBase = 200; // minimum size
ebf92187 140 inputMultiplier = 0.6; // size relative to input
4c256004 141}
cf471b1e 142
fbb9b71b 143AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn()
4c256004 144{
cf471b1e 145 // see header file for class documentation
4c256004 146 return new AliHLTTPCCATrackerComponent;
147}
cf471b1e 148
768b27af 149void AliHLTTPCCATrackerComponent::SetDefaultConfiguration()
4c256004 150{
c26cae51 151 // Set default configuration for the CA tracker component
768b27af 152 // Some parameters can be later overwritten from the OCDB
d54804bf 153
a8714ffa 154 fSolenoidBz = -5.00668;
36e3690e 155 fMinNTrackClusters = 30;
156 fMinTrackPt = 0.2;
53a9c37c 157 fClusterZCut = 500.;
f0fb467d 158 fNeighboursSearchArea = 0;
159 fClusterErrorCorrectionY = 0;
160 fClusterErrorCorrectionZ = 0;
57a4102f 161 fBenchmark.Reset();
162 fBenchmark.SetTimer(0,"total");
163 fBenchmark.SetTimer(1,"reco");
768b27af 164}
d54804bf 165
768b27af 166int AliHLTTPCCATrackerComponent::ReadConfigurationString( const char* arguments )
167{
168 // Set configuration parameters for the CA tracker component from the string
d54804bf 169
fbb9b71b 170 int iResult = 0;
768b27af 171 if ( !arguments ) return iResult;
c26cae51 172
768b27af 173 TString allArgs = arguments;
174 TString argument;
175 int bMissingParam = 0;
eb30eb49 176
768b27af 177 TObjArray* pTokens = allArgs.Tokenize( " " );
178
179 int nArgs = pTokens ? pTokens->GetEntries() : 0;
c26cae51 180
768b27af 181 for ( int i = 0; i < nArgs; i++ ) {
182 argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
183 if ( argument.IsNull() ) continue;
c26cae51 184
768b27af 185 if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
186 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
75970b8d 187 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
768b27af 188 continue;
c26cae51 189 }
768b27af 190
191 if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ) {
192 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
193 fMinNTrackClusters = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
194 HLTInfo( "minNClustersOnTrack set to: %d", fMinNTrackClusters );
195 continue;
196 }
c26cae51 197
36e3690e 198 if ( argument.CompareTo( "-minTrackPt" ) == 0 ) {
199 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
200 fMinTrackPt = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
201 HLTInfo( "minTrackPt set to: %f", fMinTrackPt );
202 continue;
203 }
204
768b27af 205 if ( argument.CompareTo( "-clusterZCut" ) == 0 ) {
206 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
207 fClusterZCut = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() );
208 HLTInfo( "ClusterZCut set to: %f", fClusterZCut );
209 continue;
210 }
f0fb467d 211
212 if ( argument.CompareTo( "-neighboursSearchArea" ) == 0 ) {
213 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
214 fNeighboursSearchArea = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() );
215 HLTInfo( "NeighboursSearchArea set to: %f", fNeighboursSearchArea );
216 continue;
217 }
c26cae51 218
f0fb467d 219 if ( argument.CompareTo( "-errorCorrectionY" ) == 0 ) {
220 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
221 fClusterErrorCorrectionY = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
222 HLTInfo( "Cluster Y error correction factor set to: %f", fClusterErrorCorrectionY );
223 continue;
224 }
225
226 if ( argument.CompareTo( "-errorCorrectionZ" ) == 0 ) {
227 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
228 fClusterErrorCorrectionZ = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
229 HLTInfo( "Cluster Z error correction factor set to: %f", fClusterErrorCorrectionZ );
230 continue;
231 }
232
fd6816cd 233 if (argument.CompareTo( "-allowGPU" ) == 0) {
234 fAllowGPU = 1;
235 HLTImportant( "Will try to run tracker on GPU" );
236 continue;
237 }
c26cae51 238
768b27af 239 HLTError( "Unknown option \"%s\"", argument.Data() );
240 iResult = -EINVAL;
4c256004 241 }
768b27af 242 delete pTokens;
243
244 if ( bMissingParam ) {
245 HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
246 iResult = -EINVAL;
fbb9b71b 247 }
c26cae51 248
53a9c37c 249 return iResult;
4c256004 250}
cf471b1e 251
53a9c37c 252
768b27af 253int AliHLTTPCCATrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
4c256004 254{
cf471b1e 255 // see header file for class documentation
cf471b1e 256
c26cae51 257 const char* defaultNotify = "";
e1f2d1c3 258
c26cae51 259 if ( !cdbEntry ) {
260 cdbEntry = "HLT/ConfigTPC/TPCCATracker";
261 defaultNotify = " (default)";
768b27af 262 chainId = 0;
263 }
53a9c37c 264
c26cae51 265 HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
266 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
fbb9b71b 267
c26cae51 268 if ( !pEntry ) {
269 HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
270 return -EINVAL;
53a9c37c 271 }
768b27af 272
c26cae51 273 TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
768b27af 274
c26cae51 275 if ( !pString ) {
276 HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
277 return -EINVAL;
53a9c37c 278 }
fbb9b71b 279
c26cae51 280 HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
fbb9b71b 281
768b27af 282 return ReadConfigurationString( pString->GetString().Data() );
283}
284
285
17d6eada 286int AliHLTTPCCATrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
287{
c26cae51 288 // Configure the component
289 // There are few levels of configuration,
17d6eada 290 // parameters which are set on one step can be overwritten on the next step
c26cae51 291
17d6eada 292 //* read hard-coded values
293
c26cae51 294 SetDefaultConfiguration();
17d6eada 295
296 //* read the default CDB entry
c26cae51 297
17d6eada 298 int iResult1 = ReadCDBEntry( NULL, chainId );
c26cae51 299
17d6eada 300 //* read magnetic field
3208d33f 301
75970b8d 302 fSolenoidBz = GetBz();
c26cae51 303
17d6eada 304 //* read the actual CDB entry if required
c26cae51 305
3208d33f 306 int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
c26cae51 307
17d6eada 308 //* read extra parameters from input (if they are)
309
3208d33f 310 int iResult3 = 0;
c26cae51 311
312 if ( commandLine && commandLine[0] != '\0' ) {
313 HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
3208d33f 314 iResult3 = ReadConfigurationString( commandLine );
17d6eada 315 }
316
317 // Initialise the tracker here
c26cae51 318
3208d33f 319 return iResult1 ? iResult1 : ( iResult2 ? iResult2 : iResult3 );
17d6eada 320}
321
768b27af 322int AliHLTTPCCATrackerComponent::DoInit( int argc, const char** argv )
323{
324 // Configure the CA tracker component
325
d4594e7d 326 if ( fTracker ) return EINPROGRESS;
c26cae51 327
768b27af 328 TString arguments = "";
329 for ( int i = 0; i < argc; i++ ) {
330 if ( !arguments.IsNull() ) arguments += " ";
331 arguments += argv[i];
fbb9b71b 332 }
c26cae51 333
1e63725a 334 int retVal = Configure( NULL, NULL, arguments.Data() );
335 if (retVal == 0) fTracker = new AliHLTTPCCATrackerFramework(fAllowGPU);
336 return(retVal);
53a9c37c 337}
338
768b27af 339int AliHLTTPCCATrackerComponent::DoDeinit()
eb30eb49 340{
768b27af 341 // see header file for class documentation
3a4ab1ca 342 if (fTracker) delete fTracker;
768b27af 343 fTracker = NULL;
344 return 0;
eb30eb49 345}
346
768b27af 347int AliHLTTPCCATrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
53a9c37c 348{
17d6eada 349 // Reconfigure the component from OCDB .
fbb9b71b 350
17d6eada 351 return Configure( cdbEntry, chainId, NULL );
53a9c37c 352}
53a9c37c 353
768b27af 354bool AliHLTTPCCATrackerComponent::CompareClusters( AliHLTTPCSpacePointData *a, AliHLTTPCSpacePointData *b )
355{
356 //* Comparison function for sort clusters
357
358 if ( a->fPadRow < b->fPadRow ) return 1;
359 if ( a->fPadRow > b->fPadRow ) return 0;
360 return ( a->fZ < b->fZ );
361}
362
53a9c37c 363
fbb9b71b 364
365int AliHLTTPCCATrackerComponent::DoEvent
366(
367 const AliHLTComponentEventData& evtData,
368 const AliHLTComponentBlockData* blocks,
369 AliHLTComponentTriggerData& /*trigData*/,
370 AliHLTUInt8_t* outputPtr,
371 AliHLTUInt32_t& size,
372 vector<AliHLTComponentBlockData>& outputBlocks )
cf471b1e 373{
768b27af 374 //* process event
375
00d07bcd 376 AliHLTUInt32_t maxBufferSize = size;
dc4788ec 377 size = 0; // output size
378
fbb9b71b 379 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
eb30eb49 380 return 0;
381 }
382
57a4102f 383 fBenchmark.StartNewEvent();
384 fBenchmark.Start(0);
dc4788ec 385
4c256004 386 // Event reconstruction in one TPC slice with CA Tracker
fbb9b71b 387
d54804bf 388 //Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA::DoEvent()" );
fbb9b71b 389 if ( evtData.fBlockCnt <= 0 ) {
390 HLTWarning( "no blocks in event" );
391 return 0;
392 }
393
cf471b1e 394 const AliHLTComponentBlockData* iter = NULL;
395 unsigned long ndx;
fbb9b71b 396
397 // Determine the slice number
398
d4594e7d 399 //Find min and max slice number with now slice missing in between (for default output)
400 int minslice = -1, maxslice = -1;
fbb9b71b 401 int slice = -1;
4c256004 402 {
fbb9b71b 403 std::vector<int> slices;
404 std::vector<int>::iterator slIter;
4acc2401 405 std::vector<unsigned> sliceCnts;
406 std::vector<unsigned>::iterator slCntIter;
fbb9b71b 407
408 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
409 iter = blocks + ndx;
64fc3975 410 if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType &&
2f516e61 411 iter->fDataType != AliHLTTPCCADefinitions::fgkCompressedInputDataType
751d16ac 412 ) continue;
4c256004 413
cf471b1e 414 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
d4594e7d 415 if (slice < minslice || minslice == -1) minslice = slice;
416 if (slice > maxslice) maxslice = slice;
dc4788ec 417
fbb9b71b 418 bool found = 0;
cf471b1e 419 slCntIter = sliceCnts.begin();
fbb9b71b 420 for ( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) {
421 if ( *slIter == slice ) {
422 found = kTRUE;
423 break;
424 }
4c256004 425 }
fbb9b71b 426 if ( !found ) {
427 slices.push_back( slice );
428 sliceCnts.push_back( 1 );
90da1ad5 429 } else (*slCntIter)++;
cf471b1e 430 }
fbb9b71b 431
d4594e7d 432 if ( slices.size() == 0 ) {
433 HLTWarning( "no slices found in event" );
434 return 0;
435 }
fbb9b71b 436
d4594e7d 437
438 // Determine slice number to really use. (for obsolete output)
fbb9b71b 439 if ( slices.size() > 1 ) {
5cb6ddd4 440 Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
fbb9b71b 441 "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
442 evtData.fEventID, evtData.fEventID );
fbb9b71b 443 slCntIter = sliceCnts.begin();
444 for ( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) {
5cb6ddd4 445 Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
fbb9b71b 446 "Slice %lu found %lu times.", *slIter, *slCntIter );
4c256004 447 }
fbb9b71b 448 } else if ( slices.size() > 0 ) {
449 slice = *( slices.begin() );
450 }
4c256004 451
4c256004 452
5cb6ddd4 453 for (int islice = minslice;islice <= maxslice;islice++)
454 {
455 bool found = false;
456 for(slIter = slices.begin(); slIter != slices.end();slIter++)
d4594e7d 457 {
5cb6ddd4 458 if (*slIter == islice)
459 {
460 found = true;
461 break;
462 }
d4594e7d 463 }
5cb6ddd4 464 if (!found)
d4594e7d 465 {
5cb6ddd4 466 maxslice = islice - 1;
467 break;
468 }
469 }
d4594e7d 470 }
fbb9b71b 471
fd6816cd 472 if ( !fTracker ) fTracker = new AliHLTTPCCATrackerFramework(fAllowGPU);
3a4ab1ca 473
d4594e7d 474 int slicecount = maxslice + 1 - minslice;
475 if (slicecount > fTracker->MaxSliceCount())
cf471b1e 476 {
90da1ad5 477 maxslice = minslice + (slicecount = fTracker->MaxSliceCount()) - 1;
cf471b1e 478 }
d4594e7d 479 int nClustersTotalSum = 0;
480 AliHLTTPCCAClusterData* clusterData = new AliHLTTPCCAClusterData[slicecount];
cf471b1e 481
fbb9b71b 482
4c256004 483 // min and max patch numbers and row numbers
d4594e7d 484 int* slicerow = new int[slicecount * 2];
485 int* sliceminPatch = new int[slicecount];
486 int* slicemaxPatch = new int[slicecount];
487 memset(slicerow, 0, slicecount * 2 * sizeof(int));
488 for (int i = 0;i < slicecount;i++)
489 {
490 sliceminPatch[i] = 100;
491 slicemaxPatch[i] = -1;
cf471b1e 492 }
fbb9b71b 493
d4594e7d 494 //Prepare everything for all slices
4c256004 495
d4594e7d 496 for (int islice = 0;islice < slicecount;islice++)
497 {
498 slice = minslice + islice;
499
500 // Initialize the tracker slice
501 {
502 int iSec = slice;
503 float inRmin = 83.65;
504 // float inRmax = 133.3;
505 // float outRmin = 133.5;
506 float outRmax = 247.7;
507 float plusZmin = 0.0529937;
508 float plusZmax = 249.778;
509 float minusZmin = -249.645;
510 float minusZmax = -0.0799937;
511 float dalpha = 0.349066;
512 float alpha = 0.174533 + dalpha * iSec;
513
514 bool zPlus = ( iSec < 18 );
515 float zMin = zPlus ? plusZmin : minusZmin;
516 float zMax = zPlus ? plusZmax : minusZmax;
517 //TPCZmin = -249.645, ZMax = 249.778
518 // float rMin = inRmin;
519 // float rMax = outRmax;
520 int nRows = AliHLTTPCTransform::GetNRows();
521
522 float padPitch = 0.4;
523 float sigmaZ = 0.228808;
524
525 float *rowX = new float [nRows];
526 for ( int irow = 0; irow < nRows; irow++ ) {
527 rowX[irow] = AliHLTTPCTransform::Row2X( irow );
528 }
529
530 AliHLTTPCCAParam param;
531
532 param.Initialize( iSec, nRows, rowX, alpha, dalpha,
533 inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz );
534 param.SetHitPickUpFactor( 2 );
535 if( fNeighboursSearchArea>0 ) param.SetNeighboursSearchArea( fNeighboursSearchArea );
536 if( fClusterErrorCorrectionY>1.e-4 ) param.SetClusterError2CorrectionY( fClusterErrorCorrectionY*fClusterErrorCorrectionY );
537 if( fClusterErrorCorrectionZ>1.e-4 ) param.SetClusterError2CorrectionZ( fClusterErrorCorrectionZ*fClusterErrorCorrectionZ );
36e3690e 538 param.SetMinNTrackClusters( fMinNTrackClusters );
539 param.SetMinTrackPt( fMinTrackPt );
540
d4594e7d 541 param.Update();
542 fTracker->InitializeSliceParam( slice, param );
543 delete[] rowX;
544 }
545
546 // total n Hits
547 int nClustersTotal = 0;
548
549 // sort patches
550 std::vector<unsigned long> patchIndices;
551
552 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
553 iter = blocks + ndx;
d4594e7d 554 if ( slice != AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue;
64fc3975 555 if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ){
556 AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
557 nClustersTotal += inPtrSP->fSpacePointCnt;
57a4102f 558 fBenchmark.AddInput(iter->fSize);
64fc3975 559 } else
2f516e61 560 if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){
57a4102f 561 fBenchmark.AddInput(iter->fSize);
751d16ac 562 const AliHLTUInt8_t * inPtr = (const AliHLTUInt8_t *)iter->fPtr;
563 while( inPtr< ((const AliHLTUInt8_t *) iter->fPtr) + iter->fSize ){
564 AliHLTTPCCACompressedClusterRow *row = (AliHLTTPCCACompressedClusterRow*)inPtr;
565 nClustersTotal+= row->fNClusters;
566 inPtr = (const AliHLTUInt8_t *)(row->fClusters+row->fNClusters);
567 }
568 }
569 else continue;
570
d4594e7d 571 int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
572 if ( sliceminPatch[islice] > patch ) {
573 sliceminPatch[islice] = patch;
574 slicerow[2 * islice + 0] = AliHLTTPCTransform::GetFirstRow( patch );
575 }
576 if ( slicemaxPatch[islice] < patch ) {
577 slicemaxPatch[islice] = patch;
578 slicerow[2 * islice + 1] = AliHLTTPCTransform::GetLastRow( patch );
579 }
580 std::vector<unsigned long>::iterator pIter = patchIndices.begin();
581 while ( pIter != patchIndices.end() && AliHLTTPCDefinitions::GetMinPatchNr( blocks[*pIter] ) < patch ) {
582 pIter++;
583 }
584 patchIndices.insert( pIter, ndx );
585 }
586
587
588 // pass event to CA Tracker
589
590
591 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits",
592 "Total %d hits to read for slice %d", nClustersTotal, slice );
593
594
595 clusterData[islice].StartReading( slice, nClustersTotal );
596
597 for ( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter != patchIndices.end(); pIter++ ) {
598 ndx = *pIter;
599 iter = blocks + ndx;
d4594e7d 600 int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
751d16ac 601 int nPatchClust = 0;
64fc3975 602
751d16ac 603 if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ){
604 AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
605 nPatchClust = inPtrSP->fSpacePointCnt;
606 for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) {
607 AliHLTTPCSpacePointData *c = &( inPtrSP->fSpacePoints[i] );
608 if ( CAMath::Abs( c->fZ ) > fClusterZCut ) continue;
609 if ( c->fPadRow > 159 ) {
610 HLTError( "Wrong TPC cluster with row number %d received", c->fPadRow );
611 continue;
612 }
613 clusterData[islice].ReadCluster( c->fID, c->fPadRow, c->fX, c->fY, c->fZ, c->fCharge );
614 }
64fc3975 615 } else
2f516e61 616 if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){
751d16ac 617 const AliHLTUInt8_t * inPtr = (const AliHLTUInt8_t *)iter->fPtr;
618 nPatchClust=0;
619 while( inPtr< ((const AliHLTUInt8_t *)iter->fPtr) + iter->fSize ){
620 AliHLTTPCCACompressedClusterRow *row = (AliHLTTPCCACompressedClusterRow*)inPtr;
621 UInt_t id = row->fSlicePatchRowID;
622 UInt_t jslice = id>>10;
623 UInt_t jpatch = (id>>6) & 0x7;
624 UInt_t jrow = id & 0x3F;
625 jrow+= AliHLTTPCTransform::GetFirstRow( jpatch );
626 Double_t rowX = AliHLTTPCTransform::Row2X( jrow );
627 //cout<<"Read row: s "<<jslice<<" p "<<jpatch<<" r "<<jrow<<" x "<<row->fX<<" nclu "<<row->fNClusters<<" :"<<endl;
628 if( jrow > 159 ) {
629 HLTError( "Wrong TPC cluster with row number %d received", jrow );
630 continue;
631 }
632 for ( unsigned int i = 0; i < row->fNClusters; i++ ) {
633 AliHLTTPCCACompressedCluster *c = &( row->fClusters[i] );
634
635 UInt_t ix0 = c->fP0 >>24;
636 UInt_t ix1 = c->fP1 >>24;
637 Double_t x = (ix1<<8) + ix0;
638 Double_t y = c->fP0 & 0x00FFFFFF;
639 Double_t z = c->fP1 & 0x00FFFFFF;
640 x = (x - 32768.)*1.e-4 + rowX;
641 y = (y - 8388608.)*1.e-4;
642 z = (z - 8388608.)*1.e-4;
643
a371a266 644 UInt_t cluId = AliHLTTPCSpacePointData::GetID( jslice, jpatch, nPatchClust );
751d16ac 645 //cout<<"clu "<<i<<": "<<x<<" "<<y<<" "<<z<<" "<<cluId<<endl;
646 if ( CAMath::Abs( z ) <= fClusterZCut ){
647 clusterData[islice].ReadCluster( cluId, jrow, x, y, z, 0 );
648 }
649 nPatchClust++;
650 }
651 inPtr = (const AliHLTUInt8_t *)(row->fClusters+row->fNClusters);
d4594e7d 652 }
d4594e7d 653 }
751d16ac 654 Logging( kHLTLogInfo, "HLT::TPCCATracker::DoEvent", "Reading hits",
655 "Read %d hits for slice %d - patch %d", nPatchClust, slice, patch );
d4594e7d 656 }
657
658 clusterData[islice].FinishReading();
659 nClustersTotalSum += nClustersTotal;
660 }
fbb9b71b 661
d4594e7d 662 //Prepare Output
663 AliHLTTPCCASliceOutput::outputControlStruct outputControl;
664 //Set tracker output so tracker does not have to output both formats!
90da1ad5 665 outputControl.fEndOfSpace = 0;
fbb9b71b 666
d4594e7d 667 //For new output we can write directly to output buffer
5cb6ddd4 668 outputControl.fOutputPtr = (char*) outputPtr;
d4594e7d 669 outputControl.fOutputMaxSize = maxBufferSize;
4c256004 670
d4594e7d 671 AliHLTTPCCASliceOutput** sliceOutput = new AliHLTTPCCASliceOutput*[slicecount];
672 memset(sliceOutput, 0, slicecount * sizeof(AliHLTTPCCASliceOutput*));
b8139972 673
fbb9b71b 674 // reconstruct the event
57a4102f 675
676 fBenchmark.Start(1);
d4594e7d 677 fTracker->SetOutputControl(&outputControl);
678 fTracker->ProcessSlices(minslice, slicecount, clusterData, sliceOutput);
57a4102f 679 fBenchmark.Stop(1);
d4594e7d 680
fbb9b71b 681 int ret = 0;
fbb9b71b 682 unsigned int mySize = 0;
a59a784e 683 int ntracks = 0;
d4594e7d 684 int error = 0;
fbb9b71b 685
d4594e7d 686 for (int islice = 0;islice < slicecount;islice++)
687 {
90da1ad5 688 if( outputControl.fEndOfSpace ){
689 HLTWarning( "Output buffer size exceed, tracks are not stored" );
690 ret = -ENOSPC;
691 error = 1;
692 break;
693 }
5cb6ddd4 694 slice = minslice + islice;
695
696 if (sliceOutput[islice])
697 {
698 // write reconstructed tracks
699 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reconstruct",
700 "%d tracks found for slice %d", sliceOutput[islice]->NTracks(), slice );
701
0f1f07c3 702 mySize += sliceOutput[islice]->Size();
5cb6ddd4 703 ntracks += sliceOutput[islice]->NTracks();
704 }
705 else
706 {
707 HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), tracks are not stored", maxBufferSize, mySize );
708 mySize = 0;
709 ret = -ENOSPC;
710 ntracks = 0;
711 error = 1;
712 break;
713 }
cf471b1e 714 }
5cb6ddd4 715
d4594e7d 716 size = 0;
717 if (error == 0)
718 {
5cb6ddd4 719 for (int islice = 0;islice < slicecount;islice++)
720 {
721 slice = minslice + islice;
0f1f07c3 722 mySize = sliceOutput[islice]->Size();
5cb6ddd4 723 if (mySize > 0)
d4594e7d 724 {
5cb6ddd4 725 AliHLTComponentBlockData bd;
726 FillBlockData( bd );
727 bd.fOffset = ((char*) sliceOutput[islice] - (char*) outputPtr);
728 bd.fSize = mySize;
729 bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, sliceminPatch[islice], slicemaxPatch[islice] );
730 bd.fDataType = GetOutputDataType();
731 outputBlocks.push_back( bd );
732 size += mySize;
57a4102f 733 fBenchmark.AddOutput(bd.fSize);
d4594e7d 734 }
5cb6ddd4 735 }
e1f2d1c3 736 }
d4594e7d 737
57a4102f 738
d4594e7d 739 //No longer needed
44ec922a 740
d4594e7d 741 delete[] clusterData;
d4594e7d 742 delete[] sliceOutput;
fbb9b71b 743
57a4102f 744 fBenchmark.Stop(0);
dc4788ec 745
746 // Set log level to "Warning" for on-line system monitoring
57a4102f 747
d4594e7d 748 //Min and Max Patch are taken for first slice processed...
dc4788ec 749
57a4102f 750 if( minslice==maxslice ) fBenchmark.SetName(Form("CATracker slice %d",minslice));
751 else fBenchmark.SetName(Form("CATracker slices %d-%d",minslice,maxslice));
752
753 HLTInfo(fBenchmark.GetStatistics());
c24ec5c8 754 //No longer needed
755
756 delete[] slicerow;
757 delete[] sliceminPatch;
758 delete[] slicemaxPatch;
759
4c256004 760 return ret;
cf471b1e 761}
762
fbb9b71b 763