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