]>
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 | ||
a8714ffa | 144 | fSolenoidBz = -5.00668; |
6edb0fb5 | 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 | } | |
24a9f989 | 278 | AliGeomManager::ApplyAlignObjsFromCDB("ITS"); |
fb015741 | 279 | |
6edb0fb5 | 280 | TString arguments = ""; |
281 | for ( int i = 0; i < argc; i++ ) { | |
282 | if ( !arguments.IsNull() ) arguments += " "; | |
283 | arguments += argv[i]; | |
284 | } | |
285 | ||
b55698e6 | 286 | int ret = Configure( NULL, NULL, arguments.Data() ); |
287 | ||
288 | // set field | |
289 | if (!TGeoGlobalMagField::Instance()->IsLocked()) { | |
290 | AliMagF* field = new AliMagF("Maps","Maps",1.,1.,AliMagF::k5kG); | |
291 | field->SetFactorSol(1); | |
292 | Double_t initialFieldStrengh=field->SolenoidField(); | |
293 | field->SetFactorSol(fSolenoidBz/initialFieldStrengh); | |
294 | TGeoGlobalMagField::Instance()->SetField(field); | |
295 | } | |
296 | ||
297 | fTracker = new AliITStrackerHLT(0); | |
298 | ||
299 | return ret; | |
6edb0fb5 | 300 | } |
301 | ||
302 | ||
303 | int AliHLTITSTrackerComponent::DoDeinit() | |
304 | { | |
305 | // see header file for class documentation | |
306 | delete fTracker; | |
307 | fTracker = 0; | |
308 | return 0; | |
309 | } | |
310 | ||
311 | ||
312 | ||
313 | int AliHLTITSTrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId ) | |
314 | { | |
315 | // Reconfigure the component from OCDB . | |
316 | ||
317 | return Configure( cdbEntry, chainId, NULL ); | |
318 | } | |
319 | ||
320 | ||
321 | ||
322 | int AliHLTITSTrackerComponent::DoEvent | |
323 | ( | |
324 | const AliHLTComponentEventData& evtData, | |
325 | const AliHLTComponentBlockData* blocks, | |
326 | AliHLTComponentTriggerData& /*trigData*/, | |
327 | AliHLTUInt8_t* outputPtr, | |
328 | AliHLTUInt32_t& size, | |
329 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
330 | { | |
331 | //* process event | |
332 | ||
333 | AliHLTUInt32_t maxBufferSize = size; | |
334 | size = 0; // output size | |
335 | ||
21de9ddd | 336 | if (!IsDataEvent()) return 0; |
6edb0fb5 | 337 | |
338 | if ( evtData.fBlockCnt <= 0 ) { | |
339 | HLTWarning( "no blocks in event" ); | |
340 | return 0; | |
341 | } | |
342 | ||
343 | ||
344 | TStopwatch timer; | |
345 | ||
346 | // Event reconstruction in ITS | |
347 | ||
348 | int iResult=0; | |
349 | ||
350 | int nBlocks = evtData.fBlockCnt; | |
351 | ||
352 | ||
353 | vector< AliExternalTrackParam > tracksTPC; | |
354 | vector< int > tracksTPCId; | |
355 | std::vector<AliITSRecPoint> clusters; | |
356 | ||
d8cddd2e | 357 | //int currentTrackID = 0; |
6edb0fb5 | 358 | |
359 | for (int ndx=0; ndx<nBlocks && iResult>=0; ndx++) { | |
360 | ||
361 | const AliHLTComponentBlockData* iter = blocks+ndx; | |
362 | ||
363 | // Read TPC tracks | |
9af5a71c | 364 | |
365 | if( iter->fDataType == ( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC ) ){ | |
366 | AliHLTTracksData* dataPtr = ( AliHLTTracksData* ) iter->fPtr; | |
367 | int nTracks = dataPtr->fCount; | |
368 | AliHLTExternalTrackParam* currOutTrack = dataPtr->fTracklets; | |
369 | for( int itr=0; itr<nTracks; itr++ ){ | |
0cd1ba6e | 370 | AliHLTGlobalBarrelTrack t(*currOutTrack); |
9af5a71c | 371 | tracksTPC.push_back( t ); |
372 | tracksTPCId.push_back( currOutTrack->fTrackID ); | |
373 | unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + currOutTrack->fNPoints * sizeof( unsigned int ); | |
374 | currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize ); | |
6edb0fb5 | 375 | } |
376 | } | |
377 | ||
9af5a71c | 378 | |
6edb0fb5 | 379 | // Read ITS clusters |
380 | ||
381 | if ( (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD) ) || | |
21de9ddd | 382 | (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD) ) || |
383 | (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD) ) | |
6edb0fb5 | 384 | ){ |
385 | ||
386 | AliHLTITSClusterData *inPtr=reinterpret_cast<AliHLTITSClusterData*>( iter->fPtr ); | |
387 | int nClusters = inPtr->fSpacePointCnt; | |
388 | for( int icl=0; icl<nClusters; icl++ ){ | |
389 | AliHLTITSSpacePointData &d = inPtr->fSpacePoints[icl]; | |
87cc43e1 | 390 | |
391 | Int_t lab[4] = { d.fTracks[0], d.fTracks[1], d.fTracks[2], d.fIndex }; | |
392 | Int_t info[3] = { d.fNy, d.fNz, d.fLayer }; | |
393 | Float_t hit[6] = { d.fY, d.fZ, d.fSigmaY2, d.fSigmaZ2, d.fQ, d.fSigmaYZ }; | |
394 | if( d.fLayer==4 ) hit[5] = -hit[5]; | |
395 | ||
396 | AliITSRecPoint p( lab, hit, info ); | |
6edb0fb5 | 397 | clusters.push_back( p ); |
398 | } | |
399 | } | |
400 | ||
401 | }// end read input blocks | |
402 | ||
403 | // set clusters to tracker | |
404 | ||
6edb0fb5 | 405 | |
9eee44f6 | 406 | fTracker->LoadClusters( clusters ); |
407 | //timer.Stop(); | |
6edb0fb5 | 408 | // Reconstruct the event |
409 | ||
410 | TStopwatch timerReco; | |
411 | ||
412 | fTracker->Reconstruct( tracksTPC ); | |
413 | ||
414 | timerReco.Stop(); | |
415 | ||
416 | // Fill output tracks | |
9eee44f6 | 417 | int nITSUpdated = 0; |
6edb0fb5 | 418 | { |
9af5a71c | 419 | unsigned int mySize = 0; |
420 | ||
421 | AliHLTTracksData* outPtr = ( AliHLTTracksData* )( outputPtr ); | |
422 | ||
423 | AliHLTExternalTrackParam* currOutTrack = outPtr->fTracklets; | |
424 | ||
425 | mySize = ( ( AliHLTUInt8_t * )currOutTrack ) - ( ( AliHLTUInt8_t * )outputPtr ); | |
426 | ||
427 | outPtr->fCount = 0; | |
6edb0fb5 | 428 | |
429 | int nTracks = fTracker->Tracks().size(); | |
9af5a71c | 430 | |
431 | for ( int itr = 0; itr < nTracks; itr++ ) { | |
432 | ||
9eee44f6 | 433 | const AliExternalTrackParam &tp = fTracker->Tracks()[itr]; |
9af5a71c | 434 | int id = tracksTPCId[fTracker->Tracks()[itr].TPCtrackId()]; |
9eee44f6 | 435 | |
9af5a71c | 436 | int nClusters = 0; |
9eee44f6 | 437 | if( fTracker->Tracks()[itr].GetNumberOfClusters()>0 ) nITSUpdated++; |
9af5a71c | 438 | |
439 | unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + nClusters * sizeof( unsigned int ); | |
440 | ||
441 | if ( mySize + dSize > maxBufferSize ) { | |
442 | HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, nTracks - itr + 1 ); | |
443 | iResult = -ENOSPC; | |
444 | break; | |
6edb0fb5 | 445 | } |
9af5a71c | 446 | |
447 | currOutTrack->fAlpha = tp.GetAlpha(); | |
448 | currOutTrack->fX = tp.GetX(); | |
449 | currOutTrack->fY = tp.GetY(); | |
450 | currOutTrack->fZ = tp.GetZ(); | |
451 | currOutTrack->fLastX = 0; | |
452 | currOutTrack->fLastY = 0; | |
453 | currOutTrack->fLastZ = 0; | |
454 | currOutTrack->fq1Pt = tp.GetSigned1Pt(); | |
455 | currOutTrack->fSinPsi = tp.GetSnp(); | |
456 | currOutTrack->fTgl = tp.GetTgl(); | |
457 | for( int i=0; i<15; i++ ) currOutTrack->fC[i] = tp.GetCovariance()[i]; | |
458 | currOutTrack->fTrackID = id; | |
459 | currOutTrack->fFlags = 0; | |
460 | currOutTrack->fNPoints = nClusters; | |
461 | currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize ); | |
462 | mySize += dSize; | |
463 | outPtr->fCount++; | |
6edb0fb5 | 464 | } |
9af5a71c | 465 | |
6edb0fb5 | 466 | |
467 | AliHLTComponentBlockData resultData; | |
468 | FillBlockData( resultData ); | |
469 | resultData.fOffset = 0; | |
470 | resultData.fSize = mySize; | |
9af5a71c | 471 | resultData.fDataType = kAliHLTDataTypeTrack|kAliHLTDataOriginITS; |
6edb0fb5 | 472 | outputBlocks.push_back( resultData ); |
9af5a71c | 473 | size = resultData.fSize; |
474 | ||
6edb0fb5 | 475 | } |
9eee44f6 | 476 | |
477 | timer.Stop(); | |
478 | fFullTime += timer.RealTime(); | |
479 | fRecoTime += timerReco.RealTime(); | |
480 | fNEvents++; | |
481 | ||
482 | // Set log level to "Warning" for on-line system monitoring | |
483 | int hz = ( int ) ( fFullTime > 1.e-10 ? fNEvents / fFullTime : 100000 ); | |
484 | int hz1 = ( int ) ( fRecoTime > 1.e-10 ? fNEvents / fRecoTime : 100000 ); | |
485 | HLTInfo( "ITS Tracker: output %d tracks; input %d clusters, %d tracks; time: full %d / reco %d Hz", | |
486 | nITSUpdated, clusters.size(), tracksTPC.size(), hz, hz1 ); | |
487 | ||
6edb0fb5 | 488 | return iResult; |
489 | } |