]>
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" |
6edb0fb5 | 53 | |
54 | ||
55 | ||
56 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
57 | ClassImp( AliHLTITSTrackerComponent ) | |
58 | AliHLTITSTrackerComponent::AliHLTITSTrackerComponent() | |
59 | : | |
60 | fSolenoidBz( 0 ), | |
61 | fFullTime( 0 ), | |
62 | fRecoTime( 0 ), | |
63 | fNEvents( 0 ), | |
64 | fTracker(0) | |
65 | { | |
66 | // see header file for class documentation | |
67 | // or | |
68 | // refer to README to build package | |
69 | // or | |
70 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
71 | } | |
72 | ||
73 | AliHLTITSTrackerComponent::AliHLTITSTrackerComponent( const AliHLTITSTrackerComponent& ) | |
74 | : | |
75 | AliHLTProcessor(), | |
76 | fSolenoidBz( 0 ), | |
77 | fFullTime( 0 ), | |
78 | fRecoTime( 0 ), | |
79 | fNEvents( 0 ), | |
80 | fTracker(0) | |
81 | { | |
82 | // see header file for class documentation | |
83 | HLTFatal( "copy constructor untested" ); | |
84 | } | |
85 | ||
86 | AliHLTITSTrackerComponent& AliHLTITSTrackerComponent::operator=( const AliHLTITSTrackerComponent& ) | |
87 | { | |
88 | // see header file for class documentation | |
89 | HLTFatal( "assignment operator untested" ); | |
90 | return *this; | |
91 | } | |
92 | ||
93 | AliHLTITSTrackerComponent::~AliHLTITSTrackerComponent() | |
94 | { | |
95 | // see header file for class documentation | |
96 | delete fTracker; | |
97 | } | |
98 | ||
99 | // | |
100 | // Public functions to implement AliHLTComponent's interface. | |
101 | // These functions are required for the registration process | |
102 | // | |
103 | ||
104 | const char* AliHLTITSTrackerComponent::GetComponentID() | |
105 | { | |
106 | // see header file for class documentation | |
107 | return "ITSTracker"; | |
108 | } | |
109 | ||
110 | void AliHLTITSTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list ) | |
111 | { | |
112 | // see header file for class documentation | |
113 | list.clear(); | |
9af5a71c | 114 | list.push_back( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC ); |
6edb0fb5 | 115 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD ); |
116 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD ); | |
21de9ddd | 117 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD ); |
6edb0fb5 | 118 | } |
119 | ||
120 | AliHLTComponentDataType AliHLTITSTrackerComponent::GetOutputDataType() | |
121 | { | |
122 | // see header file for class documentation | |
9af5a71c | 123 | return kAliHLTDataTypeTrack|kAliHLTDataOriginITS; |
6edb0fb5 | 124 | } |
125 | ||
126 | void AliHLTITSTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
127 | { | |
128 | // define guess for the output data size | |
129 | constBase = 200; // minimum size | |
130 | inputMultiplier = 0.5; // size relative to input | |
131 | } | |
132 | ||
133 | AliHLTComponent* AliHLTITSTrackerComponent::Spawn() | |
134 | { | |
135 | // see header file for class documentation | |
136 | return new AliHLTITSTrackerComponent; | |
137 | } | |
138 | ||
139 | void AliHLTITSTrackerComponent::SetDefaultConfiguration() | |
140 | { | |
141 | // Set default configuration for the CA tracker component | |
142 | // Some parameters can be later overwritten from the OCDB | |
143 | ||
144 | fSolenoidBz = 5.; | |
145 | fFullTime = 0; | |
146 | fRecoTime = 0; | |
147 | fNEvents = 0; | |
6edb0fb5 | 148 | } |
149 | ||
150 | int AliHLTITSTrackerComponent::ReadConfigurationString( const char* arguments ) | |
151 | { | |
152 | // Set configuration parameters for the CA tracker component from the string | |
153 | ||
154 | int iResult = 0; | |
155 | if ( !arguments ) return iResult; | |
156 | ||
157 | TString allArgs = arguments; | |
158 | TString argument; | |
159 | int bMissingParam = 0; | |
160 | ||
161 | TObjArray* pTokens = allArgs.Tokenize( " " ); | |
162 | ||
163 | int nArgs = pTokens ? pTokens->GetEntries() : 0; | |
164 | ||
165 | for ( int i = 0; i < nArgs; i++ ) { | |
166 | argument = ( ( TObjString* )pTokens->At( i ) )->GetString(); | |
167 | if ( argument.IsNull() ) continue; | |
168 | ||
169 | if ( argument.CompareTo( "-solenoidBz" ) == 0 ) { | |
170 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
171 | fSolenoidBz = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof(); | |
172 | HLTInfo( "Magnetic Field set to: %f", fSolenoidBz ); | |
173 | continue; | |
174 | } | |
175 | ||
176 | //if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ) { | |
177 | //if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
178 | //fMinNTrackClusters = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi(); | |
179 | //HLTInfo( "minNClustersOnTrack set to: %d", fMinNTrackClusters ); | |
180 | //continue; | |
181 | //} | |
182 | ||
183 | HLTError( "Unknown option \"%s\"", argument.Data() ); | |
184 | iResult = -EINVAL; | |
185 | } | |
186 | delete pTokens; | |
187 | ||
188 | if ( bMissingParam ) { | |
189 | HLTError( "Specifier missed for parameter \"%s\"", argument.Data() ); | |
190 | iResult = -EINVAL; | |
191 | } | |
192 | ||
193 | return iResult; | |
194 | } | |
195 | ||
196 | ||
197 | int AliHLTITSTrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId ) | |
198 | { | |
199 | // see header file for class documentation | |
200 | ||
201 | const char* defaultNotify = ""; | |
202 | ||
203 | if ( !cdbEntry ) { | |
9eee44f6 | 204 | return 0;// need to add the HLT/ConfigITS/ITSTracker directory to cdb SG!!! |
6edb0fb5 | 205 | cdbEntry = "HLT/ConfigITS/ITSTracker"; |
206 | defaultNotify = " (default)"; | |
207 | chainId = 0; | |
208 | } | |
209 | ||
210 | HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" ); | |
211 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo()); | |
212 | ||
213 | if ( !pEntry ) { | |
214 | HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry ); | |
215 | return -EINVAL; | |
216 | } | |
217 | ||
218 | TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() ); | |
219 | ||
220 | if ( !pString ) { | |
221 | HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry ); | |
222 | return -EINVAL; | |
223 | } | |
224 | ||
225 | HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() ); | |
226 | ||
227 | return ReadConfigurationString( pString->GetString().Data() ); | |
228 | } | |
229 | ||
230 | ||
231 | int AliHLTITSTrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine ) | |
232 | { | |
233 | // Configure the component | |
234 | // There are few levels of configuration, | |
235 | // parameters which are set on one step can be overwritten on the next step | |
236 | ||
237 | //* read hard-coded values | |
238 | ||
239 | SetDefaultConfiguration(); | |
240 | ||
241 | //* read the default CDB entry | |
242 | ||
243 | int iResult1 = ReadCDBEntry( NULL, chainId ); | |
244 | ||
245 | //* read magnetic field | |
246 | ||
247 | int iResult2 = ReadCDBEntry( kAliHLTCDBSolenoidBz, chainId ); | |
248 | ||
249 | //* read the actual CDB entry if required | |
250 | ||
251 | int iResult3 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0; | |
252 | ||
253 | //* read extra parameters from input (if they are) | |
254 | ||
255 | int iResult4 = 0; | |
256 | ||
257 | if ( commandLine && commandLine[0] != '\0' ) { | |
258 | HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine ); | |
259 | iResult4 = ReadConfigurationString( commandLine ); | |
260 | } | |
261 | ||
262 | // Initialise the tracker here | |
263 | ||
264 | return iResult1 ? iResult1 : ( iResult2 ? iResult2 : ( iResult3 ? iResult3 : iResult4 ) ); | |
265 | } | |
266 | ||
267 | ||
268 | ||
269 | int AliHLTITSTrackerComponent::DoInit( int argc, const char** argv ) | |
270 | { | |
271 | // Configure the ITS tracker component | |
272 | ||
273 | if ( fTracker ) return EINPROGRESS; | |
fb015741 | 274 | |
275 | if(AliGeomManager::GetGeometry()==NULL){ | |
276 | AliGeomManager::LoadGeometry(); | |
277 | } | |
278 | ||
e86c406c | 279 | fTracker = new AliITStrackerHLT(0); |
6edb0fb5 | 280 | |
281 | TString arguments = ""; | |
282 | for ( int i = 0; i < argc; i++ ) { | |
283 | if ( !arguments.IsNull() ) arguments += " "; | |
284 | arguments += argv[i]; | |
285 | } | |
286 | ||
287 | return Configure( NULL, NULL, arguments.Data() ); | |
288 | } | |
289 | ||
290 | ||
291 | int AliHLTITSTrackerComponent::DoDeinit() | |
292 | { | |
293 | // see header file for class documentation | |
294 | delete fTracker; | |
295 | fTracker = 0; | |
296 | return 0; | |
297 | } | |
298 | ||
299 | ||
300 | ||
301 | int AliHLTITSTrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId ) | |
302 | { | |
303 | // Reconfigure the component from OCDB . | |
304 | ||
305 | return Configure( cdbEntry, chainId, NULL ); | |
306 | } | |
307 | ||
308 | ||
309 | ||
310 | int AliHLTITSTrackerComponent::DoEvent | |
311 | ( | |
312 | const AliHLTComponentEventData& evtData, | |
313 | const AliHLTComponentBlockData* blocks, | |
314 | AliHLTComponentTriggerData& /*trigData*/, | |
315 | AliHLTUInt8_t* outputPtr, | |
316 | AliHLTUInt32_t& size, | |
317 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
318 | { | |
319 | //* process event | |
320 | ||
321 | AliHLTUInt32_t maxBufferSize = size; | |
322 | size = 0; // output size | |
323 | ||
21de9ddd | 324 | if (!IsDataEvent()) return 0; |
6edb0fb5 | 325 | |
326 | if ( evtData.fBlockCnt <= 0 ) { | |
327 | HLTWarning( "no blocks in event" ); | |
328 | return 0; | |
329 | } | |
330 | ||
331 | ||
332 | TStopwatch timer; | |
333 | ||
334 | // Event reconstruction in ITS | |
335 | ||
336 | int iResult=0; | |
337 | ||
338 | int nBlocks = evtData.fBlockCnt; | |
339 | ||
340 | ||
341 | vector< AliExternalTrackParam > tracksTPC; | |
342 | vector< int > tracksTPCId; | |
343 | std::vector<AliITSRecPoint> clusters; | |
344 | ||
d8cddd2e | 345 | //int currentTrackID = 0; |
6edb0fb5 | 346 | |
347 | for (int ndx=0; ndx<nBlocks && iResult>=0; ndx++) { | |
348 | ||
349 | const AliHLTComponentBlockData* iter = blocks+ndx; | |
350 | ||
351 | // Read TPC tracks | |
9af5a71c | 352 | |
353 | if( iter->fDataType == ( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC ) ){ | |
354 | AliHLTTracksData* dataPtr = ( AliHLTTracksData* ) iter->fPtr; | |
355 | int nTracks = dataPtr->fCount; | |
356 | AliHLTExternalTrackParam* currOutTrack = dataPtr->fTracklets; | |
357 | for( int itr=0; itr<nTracks; itr++ ){ | |
0cd1ba6e | 358 | AliHLTGlobalBarrelTrack t(*currOutTrack); |
9af5a71c | 359 | tracksTPC.push_back( t ); |
360 | tracksTPCId.push_back( currOutTrack->fTrackID ); | |
361 | unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + currOutTrack->fNPoints * sizeof( unsigned int ); | |
362 | currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize ); | |
6edb0fb5 | 363 | } |
364 | } | |
365 | ||
9af5a71c | 366 | |
6edb0fb5 | 367 | // Read ITS clusters |
368 | ||
369 | if ( (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD) ) || | |
21de9ddd | 370 | (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD) ) || |
371 | (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD) ) | |
6edb0fb5 | 372 | ){ |
373 | ||
374 | AliHLTITSClusterData *inPtr=reinterpret_cast<AliHLTITSClusterData*>( iter->fPtr ); | |
375 | int nClusters = inPtr->fSpacePointCnt; | |
376 | for( int icl=0; icl<nClusters; icl++ ){ | |
377 | AliHLTITSSpacePointData &d = inPtr->fSpacePoints[icl]; | |
87cc43e1 | 378 | |
379 | Int_t lab[4] = { d.fTracks[0], d.fTracks[1], d.fTracks[2], d.fIndex }; | |
380 | Int_t info[3] = { d.fNy, d.fNz, d.fLayer }; | |
381 | Float_t hit[6] = { d.fY, d.fZ, d.fSigmaY2, d.fSigmaZ2, d.fQ, d.fSigmaYZ }; | |
382 | if( d.fLayer==4 ) hit[5] = -hit[5]; | |
383 | ||
384 | AliITSRecPoint p( lab, hit, info ); | |
6edb0fb5 | 385 | clusters.push_back( p ); |
386 | } | |
387 | } | |
388 | ||
389 | }// end read input blocks | |
390 | ||
391 | // set clusters to tracker | |
392 | ||
6edb0fb5 | 393 | |
9eee44f6 | 394 | fTracker->LoadClusters( clusters ); |
395 | //timer.Stop(); | |
6edb0fb5 | 396 | // Reconstruct the event |
397 | ||
398 | TStopwatch timerReco; | |
399 | ||
400 | fTracker->Reconstruct( tracksTPC ); | |
401 | ||
402 | timerReco.Stop(); | |
403 | ||
404 | // Fill output tracks | |
9eee44f6 | 405 | int nITSUpdated = 0; |
6edb0fb5 | 406 | { |
9af5a71c | 407 | unsigned int mySize = 0; |
408 | ||
409 | AliHLTTracksData* outPtr = ( AliHLTTracksData* )( outputPtr ); | |
410 | ||
411 | AliHLTExternalTrackParam* currOutTrack = outPtr->fTracklets; | |
412 | ||
413 | mySize = ( ( AliHLTUInt8_t * )currOutTrack ) - ( ( AliHLTUInt8_t * )outputPtr ); | |
414 | ||
415 | outPtr->fCount = 0; | |
6edb0fb5 | 416 | |
417 | int nTracks = fTracker->Tracks().size(); | |
9af5a71c | 418 | |
419 | for ( int itr = 0; itr < nTracks; itr++ ) { | |
420 | ||
9eee44f6 | 421 | const AliExternalTrackParam &tp = fTracker->Tracks()[itr]; |
9af5a71c | 422 | int id = tracksTPCId[fTracker->Tracks()[itr].TPCtrackId()]; |
9eee44f6 | 423 | |
9af5a71c | 424 | int nClusters = 0; |
9eee44f6 | 425 | if( fTracker->Tracks()[itr].GetNumberOfClusters()>0 ) nITSUpdated++; |
9af5a71c | 426 | |
427 | unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + nClusters * sizeof( unsigned int ); | |
428 | ||
429 | if ( mySize + dSize > maxBufferSize ) { | |
430 | HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, nTracks - itr + 1 ); | |
431 | iResult = -ENOSPC; | |
432 | break; | |
6edb0fb5 | 433 | } |
9af5a71c | 434 | |
435 | currOutTrack->fAlpha = tp.GetAlpha(); | |
436 | currOutTrack->fX = tp.GetX(); | |
437 | currOutTrack->fY = tp.GetY(); | |
438 | currOutTrack->fZ = tp.GetZ(); | |
439 | currOutTrack->fLastX = 0; | |
440 | currOutTrack->fLastY = 0; | |
441 | currOutTrack->fLastZ = 0; | |
442 | currOutTrack->fq1Pt = tp.GetSigned1Pt(); | |
443 | currOutTrack->fSinPsi = tp.GetSnp(); | |
444 | currOutTrack->fTgl = tp.GetTgl(); | |
445 | for( int i=0; i<15; i++ ) currOutTrack->fC[i] = tp.GetCovariance()[i]; | |
446 | currOutTrack->fTrackID = id; | |
447 | currOutTrack->fFlags = 0; | |
448 | currOutTrack->fNPoints = nClusters; | |
449 | currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize ); | |
450 | mySize += dSize; | |
451 | outPtr->fCount++; | |
6edb0fb5 | 452 | } |
9af5a71c | 453 | |
6edb0fb5 | 454 | |
455 | AliHLTComponentBlockData resultData; | |
456 | FillBlockData( resultData ); | |
457 | resultData.fOffset = 0; | |
458 | resultData.fSize = mySize; | |
9af5a71c | 459 | resultData.fDataType = kAliHLTDataTypeTrack|kAliHLTDataOriginITS; |
6edb0fb5 | 460 | outputBlocks.push_back( resultData ); |
9af5a71c | 461 | size = resultData.fSize; |
462 | ||
6edb0fb5 | 463 | } |
9eee44f6 | 464 | |
465 | timer.Stop(); | |
466 | fFullTime += timer.RealTime(); | |
467 | fRecoTime += timerReco.RealTime(); | |
468 | fNEvents++; | |
469 | ||
470 | // Set log level to "Warning" for on-line system monitoring | |
471 | int hz = ( int ) ( fFullTime > 1.e-10 ? fNEvents / fFullTime : 100000 ); | |
472 | int hz1 = ( int ) ( fRecoTime > 1.e-10 ? fNEvents / fRecoTime : 100000 ); | |
473 | HLTInfo( "ITS Tracker: output %d tracks; input %d clusters, %d tracks; time: full %d / reco %d Hz", | |
474 | nITSUpdated, clusters.size(), tracksTPC.size(), hz, hz1 ); | |
475 | ||
6edb0fb5 | 476 | return iResult; |
477 | } |