Line data Source code
1 : // $Id: AliHLTITSTrackerComponent.cxx 32659 2009-06-02 16:08:40Z sgorbuno $
2 : // **************************************************************************
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. *
17 : // *
18 : //***************************************************************************
19 :
20 : /// @file AliHLTITSTrackerComponent.cxx
21 : /// @author Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de>
22 : /// @date June 2009
23 : /// @brief An ITS tracker processing component for the HLT
24 :
25 :
26 : /////////////////////////////////////////////////////
27 : // //
28 : // a ITS tracker processing component for the HLT //
29 : // //
30 : /////////////////////////////////////////////////////
31 :
32 : #include "AliHLTITSTrackerComponent.h"
33 : #include "AliHLTArray.h"
34 : #include "AliExternalTrackParam.h"
35 : #include "TStopwatch.h"
36 : #include "TMath.h"
37 : #include "AliCDBEntry.h"
38 : #include "AliCDBManager.h"
39 : #include "AliGeomManager.h"
40 : #include "TObjString.h"
41 : #include "TObjArray.h"
42 : #include "AliITStrackerHLT.h"
43 : #include "AliHLTITSSpacePointData.h"
44 : #include "AliHLTITSClusterDataFormat.h"
45 : #include "AliHLTDataTypes.h"
46 : #include "AliHLTExternalTrackParam.h"
47 : #include "AliHLTGlobalBarrelTrack.h"
48 : #include "AliGeomManager.h"
49 : #include "AliHLTTrackMCLabel.h"
50 : #include <map>
51 :
52 : using namespace std;
53 :
54 : /** ROOT macro for the implementation of ROOT specific class methods */
55 6 : ClassImp( AliHLTITSTrackerComponent )
56 3 : AliHLTITSTrackerComponent::AliHLTITSTrackerComponent()
57 : :
58 3 : fSolenoidBz( 0 ),
59 3 : fBenchmark("ITSTracker"),
60 3 : fTracker(0)
61 15 : {
62 : // see header file for class documentation
63 : // or
64 : // refer to README to build package
65 : // or
66 : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
67 6 : }
68 :
69 : AliHLTITSTrackerComponent::AliHLTITSTrackerComponent( const AliHLTITSTrackerComponent& )
70 : :
71 0 : AliHLTProcessor(),
72 0 : fSolenoidBz( 0 ),
73 0 : fBenchmark("ITSTracker"),
74 0 : fTracker(0)
75 0 : {
76 : // see header file for class documentation
77 0 : HLTFatal( "copy constructor untested" );
78 0 : }
79 :
80 : AliHLTITSTrackerComponent& AliHLTITSTrackerComponent::operator=( const AliHLTITSTrackerComponent& )
81 : {
82 : // see header file for class documentation
83 0 : HLTFatal( "assignment operator untested" );
84 0 : return *this;
85 : }
86 :
87 : AliHLTITSTrackerComponent::~AliHLTITSTrackerComponent()
88 18 : {
89 : // see header file for class documentation
90 3 : delete fTracker;
91 9 : }
92 :
93 : //
94 : // Public functions to implement AliHLTComponent's interface.
95 : // These functions are required for the registration process
96 : //
97 :
98 : const char* AliHLTITSTrackerComponent::GetComponentID()
99 : {
100 : // see header file for class documentation
101 36 : return "ITSTracker";
102 : }
103 :
104 : void AliHLTITSTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list )
105 : {
106 : // see header file for class documentation
107 0 : list.clear();
108 0 : list.push_back( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC );
109 0 : list.push_back( kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC );
110 0 : list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD );
111 0 : list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD );
112 0 : list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD );
113 0 : list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITS );
114 0 : }
115 :
116 : AliHLTComponentDataType AliHLTITSTrackerComponent::GetOutputDataType()
117 : {
118 : // see header file for class documentation
119 0 : return kAliHLTMultipleDataType;
120 : }
121 :
122 : int AliHLTITSTrackerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
123 : {
124 : // see header file for class documentation
125 0 : tgtList.clear();
126 0 : tgtList.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
127 0 : tgtList.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
128 0 : tgtList.push_back( kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS );
129 0 : return tgtList.size();
130 : }
131 :
132 : void AliHLTITSTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
133 : {
134 : // define guess for the output data size
135 0 : constBase = 200; // minimum size
136 0 : inputMultiplier = 2.; // size relative to input
137 0 : }
138 :
139 : AliHLTComponent* AliHLTITSTrackerComponent::Spawn()
140 : {
141 : // see header file for class documentation
142 0 : return new AliHLTITSTrackerComponent;
143 0 : }
144 :
145 : void AliHLTITSTrackerComponent::SetDefaultConfiguration()
146 : {
147 : // Set default configuration for the CA tracker component
148 : // Some parameters can be later overwritten from the OCDB
149 :
150 0 : fSolenoidBz = -5.00668;
151 :
152 0 : }
153 :
154 : int AliHLTITSTrackerComponent::ReadConfigurationString( const char* arguments )
155 : {
156 : // Set configuration parameters for the CA tracker component from the string
157 :
158 : int iResult = 0;
159 0 : if ( !arguments ) return iResult;
160 :
161 0 : TString allArgs = arguments;
162 0 : TString argument;
163 : int bMissingParam = 0;
164 :
165 0 : TObjArray* pTokens = allArgs.Tokenize( " " );
166 :
167 0 : int nArgs = pTokens ? pTokens->GetEntries() : 0;
168 :
169 0 : for ( int i = 0; i < nArgs; i++ ) {
170 0 : argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
171 0 : if ( argument.IsNull() ) continue;
172 :
173 0 : if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
174 0 : if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
175 0 : HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
176 : continue;
177 : }
178 :
179 : //if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ) {
180 : //if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
181 : //fMinNTrackClusters = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi();
182 : //HLTInfo( "minNClustersOnTrack set to: %d", fMinNTrackClusters );
183 : //continue;
184 : //}
185 :
186 0 : HLTError( "Unknown option \"%s\"", argument.Data() );
187 : iResult = -EINVAL;
188 0 : }
189 0 : delete pTokens;
190 :
191 0 : if ( bMissingParam ) {
192 0 : HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
193 : iResult = -EINVAL;
194 0 : }
195 :
196 : return iResult;
197 0 : }
198 :
199 :
200 : int AliHLTITSTrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
201 : {
202 : // see header file for class documentation
203 :
204 : const char* defaultNotify = "";
205 :
206 0 : if ( !cdbEntry ) {
207 0 : return 0;// need to add the HLT/ConfigITS/ITSTracker directory to cdb SG!!!
208 : //cdbEntry = "HLT/ConfigITS/ITSTracker";
209 : //defaultNotify = " (default)";
210 : //chainId = 0;
211 : }
212 :
213 0 : HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
214 0 : AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
215 :
216 0 : if ( !pEntry ) {
217 0 : HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
218 0 : return -EINVAL;
219 : }
220 :
221 0 : TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
222 :
223 0 : if ( !pString ) {
224 0 : HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
225 0 : return -EINVAL;
226 : }
227 :
228 0 : HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
229 :
230 0 : return ReadConfigurationString( pString->GetString().Data() );
231 0 : }
232 :
233 :
234 : int AliHLTITSTrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
235 : {
236 : // Configure the component
237 : // There are few levels of configuration,
238 : // parameters which are set on one step can be overwritten on the next step
239 :
240 : //* read hard-coded values
241 :
242 0 : SetDefaultConfiguration();
243 :
244 : //* read the default CDB entry
245 :
246 0 : int iResult1 = ReadCDBEntry( NULL, chainId );
247 :
248 : //* read magnetic field
249 :
250 0 : fSolenoidBz = GetBz();
251 :
252 : //* read the actual CDB entry if required
253 :
254 0 : int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
255 :
256 : //* read extra parameters from input (if they are)
257 :
258 : int iResult3 = 0;
259 :
260 0 : if ( commandLine && commandLine[0] != '\0' ) {
261 0 : HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
262 0 : iResult3 = ReadConfigurationString( commandLine );
263 0 : }
264 :
265 : // Initialise the tracker here
266 :
267 0 : return iResult1 ? iResult1 : ( iResult2 ? iResult2 : iResult3 );
268 : }
269 :
270 :
271 :
272 : int AliHLTITSTrackerComponent::DoInit( int argc, const char** argv )
273 : {
274 : // Configure the ITS tracker component
275 :
276 0 : if ( fTracker ) return -EINPROGRESS;
277 :
278 0 : if(AliGeomManager::GetGeometry()==NULL){
279 0 : AliGeomManager::LoadGeometry();
280 0 : }
281 0 : AliGeomManager::ApplyAlignObjsFromCDB("ITS");
282 :
283 0 : TString arguments = "";
284 0 : for ( int i = 0; i < argc; i++ ) {
285 0 : if ( !arguments.IsNull() ) arguments += " ";
286 0 : arguments += argv[i];
287 : }
288 :
289 0 : int ret = Configure( NULL, NULL, arguments.Data() );
290 :
291 : // Check field
292 0 : if (!TGeoGlobalMagField::Instance()) {
293 0 : HLTError("magnetic field not initialized, please set up TGeoGlobalMagField and AliMagF");
294 0 : return -ENODEV;
295 : }
296 0 : fSolenoidBz=GetBz();
297 :
298 0 : fTracker = new AliITStrackerHLT(0);
299 0 : fBenchmark.Reset();
300 0 : fBenchmark.SetTimer(0,"total");
301 0 : fBenchmark.SetTimer(1,"reco");
302 0 : return ret;
303 0 : }
304 :
305 :
306 : int AliHLTITSTrackerComponent::DoDeinit()
307 : {
308 : // see header file for class documentation
309 0 : delete fTracker;
310 0 : fTracker = 0;
311 0 : return 0;
312 : }
313 :
314 :
315 :
316 : int AliHLTITSTrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
317 : {
318 : // Reconfigure the component from OCDB .
319 :
320 0 : return Configure( cdbEntry, chainId, NULL );
321 : }
322 :
323 :
324 :
325 : int AliHLTITSTrackerComponent::DoEvent
326 : (
327 : const AliHLTComponentEventData& evtData,
328 : const AliHLTComponentBlockData* blocks,
329 : AliHLTComponentTriggerData& /*trigData*/,
330 : AliHLTUInt8_t* outputPtr,
331 : AliHLTUInt32_t& size,
332 : vector<AliHLTComponentBlockData>& outputBlocks )
333 : {
334 : //* process event
335 :
336 0 : AliHLTUInt32_t maxBufferSize = size;
337 0 : size = 0; // output size
338 :
339 0 : if (!IsDataEvent()) return 0;
340 :
341 0 : if ( evtData.fBlockCnt <= 0 ) {
342 0 : HLTWarning( "no blocks in event" );
343 0 : return 0;
344 : }
345 :
346 0 : fBenchmark.StartNewEvent();
347 0 : fBenchmark.Start(0);
348 :
349 : // Event reconstruction in ITS
350 :
351 : int iResult=0;
352 :
353 0 : int nBlocks = evtData.fBlockCnt;
354 :
355 :
356 0 : vector< AliExternalTrackParam > tracksTPC;
357 0 : vector< int > tracksTPCLab;
358 0 : vector< int > tracksTPCId;
359 :
360 : int nClustersTotal = 0;
361 :
362 0 : for (int ndx=0; ndx<nBlocks && iResult>=0; ndx++) {
363 :
364 0 : const AliHLTComponentBlockData* iter = blocks+ndx;
365 :
366 0 : if ( (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD) ) ||
367 0 : (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD) ) ||
368 0 : (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD) ) ||
369 0 : (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITS) )
370 : ){
371 0 : AliHLTITSClusterData *inPtr=reinterpret_cast<AliHLTITSClusterData*>( iter->fPtr );
372 0 : nClustersTotal+=inPtr->fSpacePointCnt;
373 0 : }
374 : }
375 :
376 :
377 0 : fTracker->StartLoadClusters(nClustersTotal);
378 :
379 : // first read MC information (if present)
380 :
381 0 : std::map<int,int> mcLabels;
382 :
383 0 : for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
384 0 : pBlock!=NULL; pBlock=GetNextInputBlock()) {
385 :
386 0 : fBenchmark.AddInput(pBlock->fSize);
387 :
388 0 : AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
389 0 : if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
390 0 : for( unsigned int il=0; il<dataPtr->fCount; il++ ){
391 0 : AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
392 0 : mcLabels[lab.fTrackID] = lab.fMCLabel;
393 : }
394 0 : } else {
395 0 : HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
396 : DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
397 : dataPtr->fCount, pBlock->fSize);
398 : }
399 : }
400 :
401 :
402 :
403 0 : for (int ndx=0; ndx<nBlocks && iResult>=0; ndx++) {
404 :
405 0 : const AliHLTComponentBlockData* iter = blocks+ndx;
406 :
407 : // Read TPC tracks
408 :
409 0 : if( iter->fDataType == ( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC ) ){
410 0 : fBenchmark.AddInput(iter->fSize);
411 0 : AliHLTTracksData* dataPtr = ( AliHLTTracksData* ) iter->fPtr;
412 0 : int nTracks = dataPtr->fCount;
413 0 : AliHLTExternalTrackParam* currOutTrack = dataPtr->fTracklets;
414 0 : for( int itr=0; itr<nTracks; itr++ ){
415 0 : AliHLTGlobalBarrelTrack t(*currOutTrack);
416 0 : Int_t mcLabel = -1;
417 0 : if( mcLabels.find(currOutTrack->fTrackID)!=mcLabels.end() )
418 0 : mcLabel = mcLabels[currOutTrack->fTrackID];
419 :
420 0 : tracksTPC.push_back( t );
421 0 : tracksTPCLab.push_back(mcLabel);
422 0 : tracksTPCId.push_back( currOutTrack->fTrackID );
423 0 : unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + currOutTrack->fNPoints * sizeof( unsigned int );
424 0 : currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize );
425 0 : }
426 0 : }
427 :
428 :
429 : // Read ITS clusters
430 :
431 0 : if ( (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD) ) ||
432 0 : (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD) ) ||
433 0 : (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD) ) ||
434 0 : (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITS) )
435 : ){
436 :
437 0 : fBenchmark.AddInput(iter->fSize);
438 :
439 0 : AliHLTITSClusterData *inPtr=reinterpret_cast<AliHLTITSClusterData*>( iter->fPtr );
440 0 : int nClusters = inPtr->fSpacePointCnt;
441 0 : for( int icl=0; icl<nClusters; icl++ ){
442 0 : AliHLTITSSpacePointData &d = inPtr->fSpacePoints[icl];
443 :
444 0 : Int_t lab[4] = { d.fTracks[0], d.fTracks[1], d.fTracks[2], d.fIndex };
445 0 : Int_t info[3] = { d.fNy, d.fNz, d.fLayer };
446 0 : Float_t hit[6] = { d.fY, d.fZ, d.fSigmaY2, d.fSigmaZ2, d.fQ, d.fSigmaYZ };
447 0 : if( d.fLayer==4 ) hit[5] = -hit[5];
448 0 : fTracker->LoadCluster( AliITSRecPoint( lab, hit, info ) );
449 : //cout<<"SG "<<d.fLayer<<" "<<d.fTracks[0]<<endl;
450 0 : }
451 0 : }
452 :
453 : }// end read input blocks
454 :
455 : // Reconstruct the event
456 :
457 0 : fBenchmark.Start(1);
458 0 : fTracker->Reconstruct( &(tracksTPC[0]), &(tracksTPCLab[0]), tracksTPC.size() );
459 0 : fBenchmark.Stop(1);
460 :
461 :
462 : // Fill output tracks
463 : int nITSUpdated = 0;
464 : {
465 :
466 0 : for( int iOut=0; iOut<=1; iOut++ ){
467 :
468 : unsigned int blockSize = 0;
469 :
470 0 : AliHLTTracksData* outPtr = ( AliHLTTracksData* )( outputPtr + size );
471 0 : AliHLTExternalTrackParam* currOutTrack = outPtr->fTracklets;
472 :
473 0 : blockSize = ( ( AliHLTUInt8_t * )currOutTrack ) - ( ( AliHLTUInt8_t * )outPtr );
474 :
475 0 : if ( size + blockSize > maxBufferSize ) {
476 0 : HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), tracks are not stored", maxBufferSize, size + blockSize );
477 : iResult = -ENOSPC;
478 0 : break;
479 : }
480 :
481 0 : outPtr->fCount = 0;
482 : AliHLTITSTrack *tracks=0;
483 : int nTracks = 0;
484 0 : if( iOut==0 ){
485 0 : tracks = fTracker->Tracks();
486 0 : nTracks = fTracker->NTracks();
487 0 : } else{
488 0 : tracks = fTracker->ITSOutTracks();
489 0 : nTracks = fTracker->NITSOutTracks();
490 : }
491 :
492 0 : for ( int itr = 0; itr < nTracks; itr++ ) {
493 0 : AliHLTITSTrack &t = tracks[itr];
494 0 : int id = tracksTPCId[t.TPCtrackId()];
495 0 : int nClusters = t.GetNumberOfClusters();
496 0 : if( iOut==0 && nClusters>0 ) nITSUpdated++;
497 :
498 0 : unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + nClusters * sizeof( unsigned int );
499 :
500 0 : if ( size + blockSize + dSize > maxBufferSize ) {
501 0 : HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, size + blockSize + dSize, nTracks - itr + 1 );
502 : iResult = -ENOSPC;
503 0 : break;
504 : }
505 :
506 0 : currOutTrack->fAlpha = t.GetAlpha();
507 0 : currOutTrack->fX = t.GetX();
508 0 : currOutTrack->fY = t.GetY();
509 0 : currOutTrack->fZ = t.GetZ();
510 0 : currOutTrack->fLastX = 0;
511 0 : currOutTrack->fLastY = 0;
512 0 : currOutTrack->fLastZ = 0;
513 0 : currOutTrack->fq1Pt = t.GetSigned1Pt();
514 0 : currOutTrack->fSinPsi = t.GetSnp();
515 0 : currOutTrack->fTgl = t.GetTgl();
516 0 : for( int i=0; i<15; i++ ) currOutTrack->fC[i] = t.GetCovariance()[i];
517 0 : currOutTrack->fTrackID = id;
518 0 : currOutTrack->fFlags = 0;
519 0 : currOutTrack->fNPoints = nClusters;
520 0 : for ( int i = 0; i < nClusters; i++ ) currOutTrack->fPointIDs[i] = t.GetClusterIndex( i );
521 0 : currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize );
522 0 : blockSize += dSize;
523 0 : outPtr->fCount++;
524 0 : }
525 :
526 :
527 0 : AliHLTComponentBlockData resultData;
528 0 : FillBlockData( resultData );
529 0 : resultData.fOffset = size;
530 0 : resultData.fSize = blockSize;
531 0 : if( iOut==0 ){
532 0 : resultData.fDataType = kAliHLTDataTypeTrack|kAliHLTDataOriginITS;
533 0 : } else {
534 0 : resultData.fDataType = kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut;
535 : }
536 0 : fBenchmark.AddOutput(resultData.fSize);
537 0 : outputBlocks.push_back( resultData );
538 0 : size += resultData.fSize;
539 0 : }
540 : }
541 :
542 : {// fill MC labels
543 :
544 : unsigned int blockSize = 0;
545 :
546 0 : AliHLTTrackMCData* outPtr = ( AliHLTTrackMCData* )( outputPtr +size );
547 0 : AliHLTTrackMCLabel* currOutLabel = outPtr->fLabels;
548 :
549 0 : blockSize = ( ( AliHLTUInt8_t * )currOutLabel ) - ( ( AliHLTUInt8_t * )outPtr );
550 :
551 0 : AliHLTITSTrack *tracks= fTracker->Tracks();
552 0 : int nTracks = fTracker->NTracks();
553 0 : if (size + blockSize > maxBufferSize)
554 : {
555 0 : HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d mc labels are not stored", maxBufferSize, blockSize, nTracks );
556 : iResult = -ENOSPC;
557 0 : }
558 : else
559 : {
560 0 : outPtr->fCount = 0;
561 0 : for ( int itr = 0; itr < nTracks; itr++ ) {
562 0 : AliHLTITSTrack &t = tracks[itr];
563 : //cout<<"SG out:"<<tracksTPCId[t.TPCtrackId()]<<" "<<t.GetLabel()<<endl;
564 0 : if( t.GetLabel()<0 ) continue;
565 0 : int id = tracksTPCId[t.TPCtrackId()];
566 :
567 0 : if ( size + blockSize + sizeof(AliHLTTrackMCLabel) > maxBufferSize ) {
568 0 : HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d mc labels are not stored", maxBufferSize, blockSize, nTracks - itr + 1 );
569 : iResult = -ENOSPC;
570 0 : break;
571 : }
572 0 : currOutLabel->fTrackID = id;
573 0 : currOutLabel->fMCLabel = t.GetLabel();
574 0 : blockSize += sizeof(AliHLTTrackMCLabel);
575 0 : currOutLabel++;
576 0 : outPtr->fCount++;
577 0 : }
578 : }
579 0 : if( iResult>=0 && outPtr->fCount>0 ){
580 0 : AliHLTComponentBlockData resultData;
581 0 : FillBlockData( resultData );
582 0 : resultData.fOffset = size;
583 0 : resultData.fSize = blockSize;
584 0 : resultData.fDataType = kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS;
585 0 : outputBlocks.push_back( resultData );
586 0 : size+= resultData.fSize;
587 0 : }
588 : }
589 :
590 0 : fBenchmark.Stop(0);
591 :
592 : // Set log level to "Warning" for on-line system monitoring
593 0 : HLTInfo( "ITS Tracker: output %d tracks; input %d clusters, %d tracks",
594 : nITSUpdated, nClustersTotal, tracksTPC.size() );
595 :
596 0 : HLTInfo(fBenchmark.GetStatistics());
597 : return iResult;
598 0 : }
|