]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCATrackerComponent.cxx
Change of transformation of off-line clusters
[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"
cf471b1e 34#include "AliHLTTPCCAOutTrack.h"
d54804bf 35#include "AliHLTTPCCAParam.h"
eb30eb49 36#include "AliHLTTPCCATrackConvertor.h"
4acc2401 37#include "AliHLTArray.h"
cf471b1e 38
cf471b1e 39#include "AliHLTTPCSpacePointData.h"
cf471b1e 40#include "AliHLTTPCClusterDataFormat.h"
41#include "AliHLTTPCTransform.h"
42#include "AliHLTTPCTrackSegmentData.h"
43#include "AliHLTTPCTrackArray.h"
44#include "AliHLTTPCTrackletDataFormat.h"
45#include "AliHLTTPCDefinitions.h"
d54804bf 46#include "AliExternalTrackParam.h"
dc4788ec 47#include "TStopwatch.h"
cf471b1e 48#include "TMath.h"
53a9c37c 49#include "AliCDBEntry.h"
50#include "AliCDBManager.h"
51#include "TObjString.h"
52#include "TObjArray.h"
e1f2d1c3 53#include "AliHLTTPCCASliceOutput.h"
4acc2401 54#include "AliHLTTPCCAClusterData.h"
e1f2d1c3 55
56const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkTrackletsDataType = AliHLTComponentDataTypeInitializer( "CATRACKL", kAliHLTDataOriginTPC );
57
58/** ROOT macro for the implementation of ROOT specific class methods */
fbb9b71b 59ClassImp( AliHLTTPCCATrackerComponent )
cf471b1e 60
cf471b1e 61AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent()
fbb9b71b 62 :
63 fTracker( NULL ),
64 fSolenoidBz( 0 ),
65 fMinNTrackClusters( 0 ),
66 fClusterZCut( 500. ),
f0fb467d 67 fNeighboursSearchArea( 0 ),
68 fClusterErrorCorrectionY(0),
69 fClusterErrorCorrectionZ(0),
fbb9b71b 70 fFullTime( 0 ),
71 fRecoTime( 0 ),
72 fNEvents( 0 ),
768b27af 73 fOutputTRAKSEGS( 0 )
cf471b1e 74{
75 // see header file for class documentation
76 // or
77 // refer to README to build package
78 // or
79 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
80}
81
fbb9b71b 82AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent( const AliHLTTPCCATrackerComponent& )
83 :
84 AliHLTProcessor(),
85 fTracker( NULL ),
86 fSolenoidBz( 0 ),
87 fMinNTrackClusters( 30 ),
88 fClusterZCut( 500. ),
f0fb467d 89 fNeighboursSearchArea(0),
90 fClusterErrorCorrectionY(0),
91 fClusterErrorCorrectionZ(0),
fbb9b71b 92 fFullTime( 0 ),
93 fRecoTime( 0 ),
94 fNEvents( 0 ),
768b27af 95 fOutputTRAKSEGS( 0 )
cf471b1e 96{
97 // see header file for class documentation
fbb9b71b 98 HLTFatal( "copy constructor untested" );
cf471b1e 99}
100
fbb9b71b 101AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=( const AliHLTTPCCATrackerComponent& )
cf471b1e 102{
103 // see header file for class documentation
fbb9b71b 104 HLTFatal( "assignment operator untested" );
cf471b1e 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
fbb9b71b 119const char* AliHLTTPCCATrackerComponent::GetComponentID()
4c256004 120{
cf471b1e 121 // see header file for class documentation
4c256004 122 return "TPCCATracker";
123}
cf471b1e 124
fbb9b71b 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
fbb9b71b 132AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType()
4c256004 133{
cf471b1e 134 // see header file for class documentation
768b27af 135 if ( fOutputTRAKSEGS ) return AliHLTTPCDefinitions::fgkTrackSegmentsDataType;
136 else return AliHLTTPCCADefinitions::fgkTrackletsDataType;
4c256004 137}
cf471b1e 138
fbb9b71b 139void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
4c256004 140{
141 // define guess for the output data size
142 constBase = 200; // minimum size
fbb9b71b 143 inputMultiplier = 0.5; // size relative to input
4c256004 144}
cf471b1e 145
fbb9b71b 146AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn()
4c256004 147{
cf471b1e 148 // see header file for class documentation
4c256004 149 return new AliHLTTPCCATrackerComponent;
150}
cf471b1e 151
768b27af 152void AliHLTTPCCATrackerComponent::SetDefaultConfiguration()
4c256004 153{
c26cae51 154 // Set default configuration for the CA tracker component
768b27af 155 // Some parameters can be later overwritten from the OCDB
d54804bf 156
768b27af 157 fSolenoidBz = 5.;
53a9c37c 158 fMinNTrackClusters = 0;
159 fClusterZCut = 500.;
f0fb467d 160 fNeighboursSearchArea = 0;
161 fClusterErrorCorrectionY = 0;
162 fClusterErrorCorrectionZ = 0;
768b27af 163 fOutputTRAKSEGS = 0;
d54804bf 164 fFullTime = 0;
165 fRecoTime = 0;
00d07bcd 166 fNEvents = 0;
768b27af 167}
d54804bf 168
768b27af 169int AliHLTTPCCATrackerComponent::ReadConfigurationString( const char* arguments )
170{
171 // Set configuration parameters for the CA tracker component from the string
d54804bf 172
fbb9b71b 173 int iResult = 0;
768b27af 174 if ( !arguments ) return iResult;
c26cae51 175
768b27af 176 TString allArgs = arguments;
177 TString argument;
178 int bMissingParam = 0;
eb30eb49 179
768b27af 180 TObjArray* pTokens = allArgs.Tokenize( " " );
181
182 int nArgs = pTokens ? pTokens->GetEntries() : 0;
c26cae51 183
768b27af 184 for ( int i = 0; i < nArgs; i++ ) {
185 argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
186 if ( argument.IsNull() ) continue;
c26cae51 187
768b27af 188 if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
189 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
190 fSolenoidBz = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
191 HLTInfo( "Magnetic Field set to: %f", fSolenoidBz );
192 continue;
c26cae51 193 }
768b27af 194
195 if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ) {
196 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
197 fMinNTrackClusters = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
198 HLTInfo( "minNClustersOnTrack set to: %d", fMinNTrackClusters );
199 continue;
200 }
c26cae51 201
768b27af 202 if ( argument.CompareTo( "-clusterZCut" ) == 0 ) {
203 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
204 fClusterZCut = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() );
205 HLTInfo( "ClusterZCut set to: %f", fClusterZCut );
206 continue;
207 }
f0fb467d 208
209 if ( argument.CompareTo( "-neighboursSearchArea" ) == 0 ) {
210 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
211 fNeighboursSearchArea = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() );
212 HLTInfo( "NeighboursSearchArea set to: %f", fNeighboursSearchArea );
213 continue;
214 }
c26cae51 215
f0fb467d 216 if ( argument.CompareTo( "-errorCorrectionY" ) == 0 ) {
217 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
218 fClusterErrorCorrectionY = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
219 HLTInfo( "Cluster Y error correction factor set to: %f", fClusterErrorCorrectionY );
220 continue;
221 }
222
223 if ( argument.CompareTo( "-errorCorrectionZ" ) == 0 ) {
224 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
225 fClusterErrorCorrectionZ = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
226 HLTInfo( "Cluster Z error correction factor set to: %f", fClusterErrorCorrectionZ );
227 continue;
228 }
229
230 if ( argument.CompareTo( "-outputTRAKSEGS" ) == 0 ) {
768b27af 231 fOutputTRAKSEGS = 1;
232 HLTInfo( "The special output type \"TRAKSEGS\" is set" );
233 continue;
c26cae51 234 }
235
768b27af 236 HLTError( "Unknown option \"%s\"", argument.Data() );
237 iResult = -EINVAL;
4c256004 238 }
768b27af 239 delete pTokens;
240
241 if ( bMissingParam ) {
242 HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
243 iResult = -EINVAL;
fbb9b71b 244 }
c26cae51 245
53a9c37c 246 return iResult;
4c256004 247}
cf471b1e 248
53a9c37c 249
768b27af 250int AliHLTTPCCATrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
4c256004 251{
cf471b1e 252 // see header file for class documentation
cf471b1e 253
c26cae51 254 const char* defaultNotify = "";
e1f2d1c3 255
c26cae51 256 if ( !cdbEntry ) {
257 cdbEntry = "HLT/ConfigTPC/TPCCATracker";
258 defaultNotify = " (default)";
768b27af 259 chainId = 0;
260 }
53a9c37c 261
c26cae51 262 HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
263 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
fbb9b71b 264
c26cae51 265 if ( !pEntry ) {
266 HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
267 return -EINVAL;
53a9c37c 268 }
768b27af 269
c26cae51 270 TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
768b27af 271
c26cae51 272 if ( !pString ) {
273 HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
274 return -EINVAL;
53a9c37c 275 }
fbb9b71b 276
c26cae51 277 HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
fbb9b71b 278
768b27af 279 return ReadConfigurationString( pString->GetString().Data() );
280}
281
282
17d6eada 283int AliHLTTPCCATrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
284{
c26cae51 285 // Configure the component
286 // There are few levels of configuration,
17d6eada 287 // parameters which are set on one step can be overwritten on the next step
c26cae51 288
17d6eada 289 //* read hard-coded values
290
c26cae51 291 SetDefaultConfiguration();
17d6eada 292
293 //* read the default CDB entry
c26cae51 294
17d6eada 295 int iResult1 = ReadCDBEntry( NULL, chainId );
c26cae51 296
17d6eada 297 //* read magnetic field
c26cae51 298
299 int iResult2 = ReadCDBEntry( kAliHLTCDBSolenoidBz, chainId );
300
17d6eada 301 //* read the actual CDB entry if required
c26cae51 302
303 int iResult3 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
304
17d6eada 305 //* read extra parameters from input (if they are)
306
307 int iResult4 = 0;
c26cae51 308
309 if ( commandLine && commandLine[0] != '\0' ) {
310 HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
311 iResult4 = ReadConfigurationString( commandLine );
17d6eada 312 }
313
314 // Initialise the tracker here
c26cae51 315
316 return iResult1 ? iResult1 : ( iResult2 ? iResult2 : ( iResult3 ? iResult3 : iResult4 ) );
17d6eada 317}
318
319
320
768b27af 321int AliHLTTPCCATrackerComponent::DoInit( int argc, const char** argv )
322{
323 // Configure the CA tracker component
324
d4594e7d 325 if ( fTracker ) return EINPROGRESS;
c26cae51 326
b22af1bf 327
328 fTracker = new AliHLTTPCCATrackerFramework();
768b27af 329
330 TString arguments = "";
331 for ( int i = 0; i < argc; i++ ) {
332 if ( !arguments.IsNull() ) arguments += " ";
333 arguments += argv[i];
fbb9b71b 334 }
c26cae51 335
336 return Configure( NULL, NULL, arguments.Data() );
53a9c37c 337}
338
339
768b27af 340int AliHLTTPCCATrackerComponent::DoDeinit()
eb30eb49 341{
768b27af 342 // see header file for class documentation
343 delete fTracker;
344 fTracker = NULL;
345 return 0;
eb30eb49 346}
347
53a9c37c 348
768b27af 349
350int AliHLTTPCCATrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
53a9c37c 351{
17d6eada 352 // Reconfigure the component from OCDB .
fbb9b71b 353
17d6eada 354 return Configure( cdbEntry, chainId, NULL );
53a9c37c 355}
53a9c37c 356
357
768b27af 358bool AliHLTTPCCATrackerComponent::CompareClusters( AliHLTTPCSpacePointData *a, AliHLTTPCSpacePointData *b )
359{
360 //* Comparison function for sort clusters
361
362 if ( a->fPadRow < b->fPadRow ) return 1;
363 if ( a->fPadRow > b->fPadRow ) return 0;
364 return ( a->fZ < b->fZ );
365}
366
53a9c37c 367
fbb9b71b 368
369int AliHLTTPCCATrackerComponent::DoEvent
370(
371 const AliHLTComponentEventData& evtData,
372 const AliHLTComponentBlockData* blocks,
373 AliHLTComponentTriggerData& /*trigData*/,
374 AliHLTUInt8_t* outputPtr,
375 AliHLTUInt32_t& size,
376 vector<AliHLTComponentBlockData>& outputBlocks )
cf471b1e 377{
768b27af 378 //* process event
379
00d07bcd 380 AliHLTUInt32_t maxBufferSize = size;
dc4788ec 381 size = 0; // output size
382
fbb9b71b 383 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
eb30eb49 384 return 0;
385 }
386
dc4788ec 387 TStopwatch timer;
388
4c256004 389 // Event reconstruction in one TPC slice with CA Tracker
fbb9b71b 390
d54804bf 391 //Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA::DoEvent()" );
fbb9b71b 392 if ( evtData.fBlockCnt <= 0 ) {
393 HLTWarning( "no blocks in event" );
394 return 0;
395 }
396
cf471b1e 397 const AliHLTComponentBlockData* iter = NULL;
398 unsigned long ndx;
fbb9b71b 399 AliHLTTPCClusterData* inPtrSP;
400
401 // Determine the slice number
402
d4594e7d 403 //Find min and max slice number with now slice missing in between (for default output)
404 int minslice = -1, maxslice = -1;
fbb9b71b 405 int slice = -1;
4c256004 406 {
fbb9b71b 407 std::vector<int> slices;
408 std::vector<int>::iterator slIter;
4acc2401 409 std::vector<unsigned> sliceCnts;
410 std::vector<unsigned>::iterator slCntIter;
fbb9b71b 411
412 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
413 iter = blocks + ndx;
4c256004 414 if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue;
415
cf471b1e 416 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
d4594e7d 417 if (slice < minslice || minslice == -1) minslice = slice;
418 if (slice > maxslice) maxslice = slice;
dc4788ec 419
fbb9b71b 420 bool found = 0;
cf471b1e 421 slCntIter = sliceCnts.begin();
fbb9b71b 422 for ( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) {
423 if ( *slIter == slice ) {
424 found = kTRUE;
425 break;
426 }
4c256004 427 }
fbb9b71b 428 if ( !found ) {
429 slices.push_back( slice );
430 sliceCnts.push_back( 1 );
431 } else *slCntIter++;
cf471b1e 432 }
fbb9b71b 433
d4594e7d 434 if ( slices.size() == 0 ) {
435 HLTWarning( "no slices found in event" );
436 return 0;
437 }
fbb9b71b 438
d4594e7d 439
440 // Determine slice number to really use. (for obsolete output)
fbb9b71b 441 if ( slices.size() > 1 ) {
d4594e7d 442 Logging( fOutputTRAKSEGS ? kHLTLogError : kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
fbb9b71b 443 "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
444 evtData.fEventID, evtData.fEventID );
4acc2401 445 unsigned maxCntSlice = 0;
fbb9b71b 446 slCntIter = sliceCnts.begin();
447 for ( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) {
d4594e7d 448 Logging( fOutputTRAKSEGS ? kHLTLogError : kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
fbb9b71b 449 "Slice %lu found %lu times.", *slIter, *slCntIter );
d4594e7d 450 if ( fOutputTRAKSEGS && maxCntSlice < *slCntIter ) {
fbb9b71b 451 maxCntSlice = *slCntIter;
452 slice = *slIter;
453 }
4c256004 454 }
d4594e7d 455 if (fOutputTRAKSEGS)
456 {
457 Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
fbb9b71b 458 "Using slice %lu.", slice );
d4594e7d 459 }
fbb9b71b 460 } else if ( slices.size() > 0 ) {
461 slice = *( slices.begin() );
462 }
4c256004 463
4c256004 464
d4594e7d 465 if (fOutputTRAKSEGS)
466 {
467 minslice = maxslice = slice;
468 }
469 else
470 {
471 for (int islice = minslice;islice <= maxslice;islice++)
472 {
473 bool found = false;
474 for(slIter = slices.begin(); slIter != slices.end();slIter++)
475 {
476 if (*slIter == islice)
477 {
478 found = true;
479 break;
480 }
481 }
482 if (!found)
483 {
484 maxslice = islice - 1;
485 break;
486 }
487 }
488 }
489 }
fbb9b71b 490
d4594e7d 491 if ( !fTracker ) fTracker = new AliHLTTPCCATrackerFramework;
492 int slicecount = maxslice + 1 - minslice;
493 if (slicecount > fTracker->MaxSliceCount())
cf471b1e 494 {
d4594e7d 495 maxslice = minslice + (slicecount = fTracker->MaxSliceCount());
cf471b1e 496 }
d4594e7d 497 int nClustersTotalSum = 0;
498 AliHLTTPCCAClusterData* clusterData = new AliHLTTPCCAClusterData[slicecount];
cf471b1e 499
fbb9b71b 500
4c256004 501 // min and max patch numbers and row numbers
d4594e7d 502 int* slicerow = new int[slicecount * 2];
503 int* sliceminPatch = new int[slicecount];
504 int* slicemaxPatch = new int[slicecount];
505 memset(slicerow, 0, slicecount * 2 * sizeof(int));
506 for (int i = 0;i < slicecount;i++)
507 {
508 sliceminPatch[i] = 100;
509 slicemaxPatch[i] = -1;
cf471b1e 510 }
fbb9b71b 511
d4594e7d 512 //Prepare everything for all slices
4c256004 513
d4594e7d 514 for (int islice = 0;islice < slicecount;islice++)
515 {
516 slice = minslice + islice;
517
518 // Initialize the tracker slice
519 {
520 int iSec = slice;
521 float inRmin = 83.65;
522 // float inRmax = 133.3;
523 // float outRmin = 133.5;
524 float outRmax = 247.7;
525 float plusZmin = 0.0529937;
526 float plusZmax = 249.778;
527 float minusZmin = -249.645;
528 float minusZmax = -0.0799937;
529 float dalpha = 0.349066;
530 float alpha = 0.174533 + dalpha * iSec;
531
532 bool zPlus = ( iSec < 18 );
533 float zMin = zPlus ? plusZmin : minusZmin;
534 float zMax = zPlus ? plusZmax : minusZmax;
535 //TPCZmin = -249.645, ZMax = 249.778
536 // float rMin = inRmin;
537 // float rMax = outRmax;
538 int nRows = AliHLTTPCTransform::GetNRows();
539
540 float padPitch = 0.4;
541 float sigmaZ = 0.228808;
542
543 float *rowX = new float [nRows];
544 for ( int irow = 0; irow < nRows; irow++ ) {
545 rowX[irow] = AliHLTTPCTransform::Row2X( irow );
546 }
547
548 AliHLTTPCCAParam param;
549
550 param.Initialize( iSec, nRows, rowX, alpha, dalpha,
551 inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz );
552 param.SetHitPickUpFactor( 2 );
553 if( fNeighboursSearchArea>0 ) param.SetNeighboursSearchArea( fNeighboursSearchArea );
554 if( fClusterErrorCorrectionY>1.e-4 ) param.SetClusterError2CorrectionY( fClusterErrorCorrectionY*fClusterErrorCorrectionY );
555 if( fClusterErrorCorrectionZ>1.e-4 ) param.SetClusterError2CorrectionZ( fClusterErrorCorrectionZ*fClusterErrorCorrectionZ );
556 param.Update();
557 fTracker->InitializeSliceParam( slice, param );
558 delete[] rowX;
559 }
560
561 // total n Hits
562 int nClustersTotal = 0;
563
564 // sort patches
565 std::vector<unsigned long> patchIndices;
566
567 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
568 iter = blocks + ndx;
569 if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue;
570 if ( slice != AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue;
571 inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
572 nClustersTotal += inPtrSP->fSpacePointCnt;
573 int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
574 if ( sliceminPatch[islice] > patch ) {
575 sliceminPatch[islice] = patch;
576 slicerow[2 * islice + 0] = AliHLTTPCTransform::GetFirstRow( patch );
577 }
578 if ( slicemaxPatch[islice] < patch ) {
579 slicemaxPatch[islice] = patch;
580 slicerow[2 * islice + 1] = AliHLTTPCTransform::GetLastRow( patch );
581 }
582 std::vector<unsigned long>::iterator pIter = patchIndices.begin();
583 while ( pIter != patchIndices.end() && AliHLTTPCDefinitions::GetMinPatchNr( blocks[*pIter] ) < patch ) {
584 pIter++;
585 }
586 patchIndices.insert( pIter, ndx );
587 }
588
589
590 // pass event to CA Tracker
591
592
593 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits",
594 "Total %d hits to read for slice %d", nClustersTotal, slice );
595
596
597 clusterData[islice].StartReading( slice, nClustersTotal );
598
599 for ( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter != patchIndices.end(); pIter++ ) {
600 ndx = *pIter;
601 iter = blocks + ndx;
602
603 int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
604 inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
605
606 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits",
607 "Reading %d hits for slice %d - patch %d", inPtrSP->fSpacePointCnt, slice, patch );
608
609 for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) {
610 AliHLTTPCSpacePointData *c = &( inPtrSP->fSpacePoints[i] );
611 if ( CAMath::Abs( c->fZ ) > fClusterZCut ) continue;
612 if ( c->fPadRow > 159 ) {
613 HLTError( "Wrong TPC cluster with row number %d received", c->fPadRow );
614 continue;
615 }
616 clusterData[islice].ReadCluster( c->fID, c->fPadRow, c->fX, c->fY, c->fZ, c->fCharge );
617 }
618 }
619
620 clusterData[islice].FinishReading();
621 nClustersTotalSum += nClustersTotal;
622 }
fbb9b71b 623
d4594e7d 624 //Prepare Output
625 AliHLTTPCCASliceOutput::outputControlStruct outputControl;
626 //Set tracker output so tracker does not have to output both formats!
627 outputControl.fObsoleteOutput = fOutputTRAKSEGS;
628 outputControl.fDefaultOutput = !fOutputTRAKSEGS;
fbb9b71b 629
d4594e7d 630 //For new output we can write directly to output buffer
631 outputControl.fOutputPtr = fOutputTRAKSEGS ? NULL : (char*) outputPtr;
632 outputControl.fOutputMaxSize = maxBufferSize;
4c256004 633
d4594e7d 634 AliHLTTPCCASliceOutput** sliceOutput = new AliHLTTPCCASliceOutput*[slicecount];
635 memset(sliceOutput, 0, slicecount * sizeof(AliHLTTPCCASliceOutput*));
b8139972 636
fbb9b71b 637 // reconstruct the event
dc4788ec 638 TStopwatch timerReco;
d4594e7d 639 fTracker->SetOutputControl(&outputControl);
640 fTracker->ProcessSlices(minslice, slicecount, clusterData, sliceOutput);
dc4788ec 641 timerReco.Stop();
d4594e7d 642
fbb9b71b 643 int ret = 0;
fbb9b71b 644 unsigned int mySize = 0;
d4594e7d 645 int ntracks;
646 int error = 0;
fbb9b71b 647
d4594e7d 648 for (int islice = 0;islice < slicecount;islice++)
649 {
650 slice = minslice + islice;
651
652 if (sliceOutput[islice])
653 {
654 Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reconstruct",
655 "%d tracks found for slice %d", sliceOutput[islice]->NOutTracks(), slice );
fbb9b71b 656
fbb9b71b 657
d4594e7d 658 // write reconstructed tracks
fbb9b71b 659
d4594e7d 660 if ( fOutputTRAKSEGS ) {
fbb9b71b 661
d4594e7d 662 ntracks = sliceOutput[islice]->NOutTracks();
fbb9b71b 663
d4594e7d 664 AliHLTTPCTrackletData* outPtr = ( AliHLTTPCTrackletData* )( outputPtr );
fbb9b71b 665
d4594e7d 666 AliHLTTPCTrackSegmentData* currOutTracklet = outPtr->fTracklets;
fbb9b71b 667
d4594e7d 668 mySize = ( ( AliHLTUInt8_t * )currOutTracklet ) - ( ( AliHLTUInt8_t * )outputPtr );
669
670 outPtr->fTrackletCnt = 0;
671
672 for ( int itr = 0; itr < ntracks; itr++ ) {
673
674 AliHLTTPCCAOutTrack &t = sliceOutput[islice]->OutTracks()[itr];
675
676 //Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Wrtite output","track %d with %d hits", itr, t.NHits());
677
678 if ( t.NHits() < fMinNTrackClusters ) continue;
679
680 // calculate output track size
681
682 unsigned int dSize = sizeof( AliHLTTPCTrackSegmentData ) + t.NHits() * sizeof( unsigned int );
683
684 if ( mySize + dSize > maxBufferSize ) {
685 HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, ntracks - itr + 1 );
686 ret = -ENOSPC;
687 error = 1;
688 break;
689 }
690
691 // convert CA track parameters to HLT Track Segment
692
693 int iFirstRow = 1000;
694 int iLastRow = -1;
695 int iFirstHit = sliceOutput[islice]->OutTrackHit(t.FirstHitRef());
696 int iLastHit = iFirstHit;
697 for ( int ih = 0; ih < t.NHits(); ih++ ) {
698 int hitID = sliceOutput[islice]->OutTrackHit(t.FirstHitRef() + ih);
699 int iRow = clusterData[islice].RowNumber( hitID );
700 if ( iRow < iFirstRow ) { iFirstRow = iRow; iFirstHit = hitID; }
701 if ( iRow > iLastRow ) { iLastRow = iRow; iLastHit = hitID; }
702 }
703
704 AliHLTTPCCATrackParam par = t.StartPoint();
705
706 par.TransportToX( clusterData[islice].X( iFirstHit ), .99 );
707
708 AliExternalTrackParam tp;
709 AliHLTTPCCATrackConvertor::GetExtParam( par, tp, 0 );
710
711 currOutTracklet->fX = tp.GetX();
712 currOutTracklet->fY = tp.GetY();
713 currOutTracklet->fZ = tp.GetZ();
714 currOutTracklet->fCharge = ( int ) tp.GetSign();
715 currOutTracklet->fPt = TMath::Abs( tp.GetSignedPt() );
716 float snp = tp.GetSnp() ;
717 if ( snp > .999 ) snp = .999;
718 if ( snp < -.999 ) snp = -.999;
719 currOutTracklet->fPsi = TMath::ASin( snp );
720 currOutTracklet->fTgl = tp.GetTgl();
721
722 currOutTracklet->fY0err = tp.GetSigmaY2();
723 currOutTracklet->fZ0err = tp.GetSigmaZ2();
724 float h = -currOutTracklet->fPt * currOutTracklet->fPt;
725 currOutTracklet->fPterr = h * h * tp.GetSigma1Pt2();
726 h = 1. / TMath::Sqrt( 1 - snp * snp );
727 currOutTracklet->fPsierr = h * h * tp.GetSigmaSnp2();
728 currOutTracklet->fTglerr = tp.GetSigmaTgl2();
729
730 if ( par.TransportToX( clusterData[islice].X( iLastHit ), .99 ) ) {
731 currOutTracklet->fLastX = par.GetX();
732 currOutTracklet->fLastY = par.GetY();
733 currOutTracklet->fLastZ = par.GetZ();
734 } else {
735 currOutTracklet->fLastX = clusterData[islice].X( iLastHit );
736 currOutTracklet->fLastY = clusterData[islice].Y( iLastHit );
737 currOutTracklet->fLastZ = clusterData[islice].Z( iLastHit );
738 }
739 //if( currOutTracklet->fLastX<10. ) {
740 //HLTError("CA last point: hitxyz=%f,%f,%f, track=%f,%f,%f, tracklet=%f,%f,%f, nhits=%d",clusterData[islice].X( iLastHit ),clusterData[islice].Y( iLastHit],clusterData[islice].Z( iLastHit],
741 //par.GetX(), par.GetY(),par.GetZ(),currOutTracklet->fLastX,currOutTracklet->fLastY ,currOutTracklet->fLastZ, t.NHits());
742 //}
743 #ifdef INCLUDE_TPC_HOUGH
744 #ifdef ROWHOUGHPARAMS
745 currOutTracklet->fTrackID = 0;
746 currOutTracklet->fRowRange1 = clusterData[islice].RowNumber( iFirstHit );
747 currOutTracklet->fRowRange2 = clusterData[islice].RowNumber( iLastHit );
748 currOutTracklet->fSector = slice;
749 currOutTracklet->fPID = 211;
750 #endif
751 #endif // INCLUDE_TPC_HOUGH
752
753
754 currOutTracklet->fNPoints = t.NHits();
755
756 for ( int i = 0; i < t.NHits(); i++ ) {
757 currOutTracklet->fPointIDs[i] = clusterData[islice].Id( sliceOutput[islice]->OutTrackHit(t.FirstHitRef()+i) );
758 }
759
760 currOutTracklet = ( AliHLTTPCTrackSegmentData* )( ( Byte_t * )currOutTracklet + dSize );
761 mySize += dSize;
762 outPtr->fTrackletCnt++;
763 }
764
765 } else { // default output type
766 mySize += sliceOutput[islice]->OutputMemorySize();
767 ntracks += sliceOutput[islice]->NTracks();
768 }
769 }
770 else
771 {
772 HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), tracks are not stored", maxBufferSize, mySize );
773 mySize = 0;
774 ret = -ENOSPC;
775 ntracks = 0;
776 error = 1;
777 break;
778 }
cf471b1e 779 }
fbb9b71b 780
d4594e7d 781 size = 0;
782 if (error == 0)
783 {
784 for (int islice = 0;islice < slicecount;islice++)
785 {
786 slice = minslice + islice;
787 if (!fOutputTRAKSEGS) mySize = sliceOutput[islice]->OutputMemorySize();
788 if (mySize > 0)
789 {
790 AliHLTComponentBlockData bd;
791 FillBlockData( bd );
792 bd.fOffset = fOutputTRAKSEGS ? 0 : ((char*) sliceOutput[islice] - (char*) outputPtr);
793 bd.fSize = mySize;
794 bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, sliceminPatch[islice], slicemaxPatch[islice] );
795 bd.fDataType = GetOutputDataType();
796 outputBlocks.push_back( bd );
797 size += mySize;
798 }
799 }
e1f2d1c3 800 }
d4594e7d 801
802 //No longer needed
803 delete[] clusterData;
804 //These are only temporary pointers to the output and no longer needed
805 delete[] sliceOutput;
fbb9b71b 806
d54804bf 807 timer.Stop();
808
fbb9b71b 809 fFullTime += timer.RealTime();
810 fRecoTime += timerReco.RealTime();
d54804bf 811 fNEvents++;
dc4788ec 812
813 // Set log level to "Warning" for on-line system monitoring
fbb9b71b 814 int hz = ( int ) ( fFullTime > 1.e-10 ? fNEvents / fFullTime : 100000 );
815 int hz1 = ( int ) ( fRecoTime > 1.e-10 ? fNEvents / fRecoTime : 100000 );
d4594e7d 816 //Min and Max Patch are taken for first slice processed...
817 HLTInfo( "CATracker slices %d-%d: output %d tracks; input %d clusters, patches %d..%d, rows %d..%d; time: full %d / reco %d Hz",
818 minslice, maxslice, ntracks, nClustersTotalSum, sliceminPatch[0], slicemaxPatch[0], slicerow[0], slicerow[1], hz, hz1 );
dc4788ec 819
4c256004 820 return ret;
cf471b1e 821}
822
fbb9b71b 823