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