]>
Commit | Line | Data |
---|---|---|
e1f2d1c3 | 1 | // ************************************************************************** |
fbb9b71b | 2 | // This file is property of and copyright by the ALICE HLT Project * |
e1f2d1c3 | 3 | // ALICE Experiment at CERN, All rights reserved. * |
4 | // * | |
5 | // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> * | |
6 | // Ivan Kisel <kisel@kip.uni-heidelberg.de> * | |
7 | // Matthias Kretz <kretz@kde.org> * | |
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 | ||
21 | /** @file AliHLTTPCCAGlobalMergerComponent.cxx | |
22 | @author Matthias Kretz | |
23 | @date | |
24 | @brief HLT TPC CA global merger component. | |
25 | */ | |
26 | ||
27 | #if __GNUC__>= 3 | |
28 | using namespace std; | |
29 | #endif | |
30 | ||
31 | #include "AliHLTTPCCAGlobalMergerComponent.h" | |
32 | #include "AliHLTTPCCAMergerOutput.h" | |
33 | #include "AliHLTTPCTransform.h" | |
34 | #include "AliHLTTPCCAMerger.h" | |
35 | #include "AliHLTTPCVertex.h" | |
36 | #include "AliHLTTPCVertexData.h" | |
37 | #include "AliHLTTPCTrackSegmentData.h" | |
38 | #include "AliHLTTPCTrack.h" | |
39 | #include "AliHLTTPCTrackArray.h" | |
40 | #include "AliHLTTPCTrackletDataFormat.h" | |
41 | #include "AliHLTTPCCADef.h" | |
42 | #include "AliHLTTPCDefinitions.h" | |
43 | #include "AliHLTTPCCATrackConvertor.h" | |
5f8cb375 | 44 | #include "AliHLTTPCCASliceOutput.h" |
e1f2d1c3 | 45 | |
46 | #include "AliCDBEntry.h" | |
47 | #include "AliCDBManager.h" | |
48 | #include "TObjString.h" | |
49 | #include "TObjArray.h" | |
be7c7c2b | 50 | #include "AliHLTExternalTrackParam.h" |
e1f2d1c3 | 51 | |
52 | #include <climits> | |
53 | #include <cstdlib> | |
54 | #include <cerrno> | |
55 | ||
56 | ||
57 | // ROOT macro for the implementation of ROOT specific class methods | |
58 | ClassImp( AliHLTTPCCAGlobalMergerComponent ) | |
59 | ||
60 | ||
e1f2d1c3 | 61 | AliHLTTPCCAGlobalMergerComponent::AliHLTTPCCAGlobalMergerComponent() |
f0fb467d | 62 | : fGlobalMerger( 0 ), fSolenoidBz( 0 ), fClusterErrorCorrectionY(0), fClusterErrorCorrectionZ(0) |
e1f2d1c3 | 63 | { |
64 | // see header file for class documentation | |
65 | } | |
66 | ||
67 | // Public functions to implement AliHLTComponent's interface. | |
68 | // These functions are required for the registration process | |
69 | ||
70 | const char *AliHLTTPCCAGlobalMergerComponent::GetComponentID() | |
71 | { | |
72 | // see header file for class documentation | |
73 | return "TPCCAGlobalMerger"; | |
74 | } | |
75 | ||
76 | void AliHLTTPCCAGlobalMergerComponent::GetInputDataTypes( AliHLTComponentDataTypeList &list ) | |
77 | { | |
78 | // see header file for class documentation | |
79 | list.clear(); | |
80 | list.push_back( AliHLTTPCCADefinitions::fgkTrackletsDataType ); | |
81 | //list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType ); | |
82 | //list.push_back( AliHLTTPCDefinitions::fgkVertexDataType ); | |
83 | } | |
84 | ||
85 | AliHLTComponentDataType AliHLTTPCCAGlobalMergerComponent::GetOutputDataType() | |
86 | { | |
87 | // see header file for class documentation | |
be7c7c2b | 88 | //return AliHLTTPCDefinitions::fgkTracksDataType; // old |
89 | return kAliHLTDataTypeTrack|kAliHLTDataOriginTPC; | |
e1f2d1c3 | 90 | } |
91 | ||
92 | void AliHLTTPCCAGlobalMergerComponent::GetOutputDataSize( unsigned long &constBase, double &inputMultiplier ) | |
93 | { | |
94 | // see header file for class documentation | |
95 | // XXX TODO: Find more realistic values. | |
96 | constBase = 0; | |
97 | inputMultiplier = 1.0; | |
98 | } | |
99 | ||
100 | AliHLTComponent *AliHLTTPCCAGlobalMergerComponent::Spawn() | |
101 | { | |
102 | // see header file for class documentation | |
103 | return new AliHLTTPCCAGlobalMergerComponent; | |
104 | } | |
105 | ||
17d6eada | 106 | |
107 | ||
108 | ||
109 | void AliHLTTPCCAGlobalMergerComponent::SetDefaultConfiguration() | |
110 | { | |
c26cae51 | 111 | // Set default configuration for the CA merger component |
17d6eada | 112 | // Some parameters can be later overwritten from the OCDB |
113 | ||
a8714ffa | 114 | fSolenoidBz = -5.00668; |
f0fb467d | 115 | fClusterErrorCorrectionY = 0; |
116 | fClusterErrorCorrectionZ = 1.1; | |
17d6eada | 117 | } |
118 | ||
119 | int AliHLTTPCCAGlobalMergerComponent::ReadConfigurationString( const char* arguments ) | |
120 | { | |
121 | // Set configuration parameters for the CA merger component from the string | |
122 | ||
123 | int iResult = 0; | |
124 | if ( !arguments ) return iResult; | |
c26cae51 | 125 | |
17d6eada | 126 | TString allArgs = arguments; |
127 | TString argument; | |
128 | int bMissingParam = 0; | |
129 | ||
130 | TObjArray* pTokens = allArgs.Tokenize( " " ); | |
131 | ||
132 | int nArgs = pTokens ? pTokens->GetEntries() : 0; | |
c26cae51 | 133 | |
17d6eada | 134 | for ( int i = 0; i < nArgs; i++ ) { |
135 | argument = ( ( TObjString* )pTokens->At( i ) )->GetString(); | |
136 | if ( argument.IsNull() ) continue; | |
c26cae51 | 137 | |
17d6eada | 138 | if ( argument.CompareTo( "-solenoidBz" ) == 0 ) { |
139 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
140 | fSolenoidBz = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof(); | |
141 | HLTInfo( "Magnetic Field set to: %f", fSolenoidBz ); | |
142 | continue; | |
c26cae51 | 143 | } |
17d6eada | 144 | |
f0fb467d | 145 | if ( argument.CompareTo( "-errorCorrectionY" ) == 0 ) { |
146 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
147 | fClusterErrorCorrectionY = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof(); | |
148 | HLTInfo( "Cluster Y error correction factor set to: %f", fClusterErrorCorrectionY ); | |
149 | continue; | |
150 | } | |
151 | ||
152 | if ( argument.CompareTo( "-errorCorrectionZ" ) == 0 ) { | |
153 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
154 | fClusterErrorCorrectionZ = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof(); | |
155 | HLTInfo( "Cluster Z error correction factor set to: %f", fClusterErrorCorrectionZ ); | |
156 | continue; | |
157 | } | |
158 | ||
17d6eada | 159 | HLTError( "Unknown option \"%s\"", argument.Data() ); |
160 | iResult = -EINVAL; | |
161 | } | |
162 | delete pTokens; | |
163 | ||
164 | if ( bMissingParam ) { | |
165 | HLTError( "Specifier missed for parameter \"%s\"", argument.Data() ); | |
166 | iResult = -EINVAL; | |
167 | } | |
c26cae51 | 168 | |
17d6eada | 169 | return iResult; |
170 | } | |
171 | ||
172 | ||
173 | int AliHLTTPCCAGlobalMergerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId ) | |
e1f2d1c3 | 174 | { |
175 | // see header file for class documentation | |
17d6eada | 176 | |
c26cae51 | 177 | const char* defaultNotify = ""; |
17d6eada | 178 | |
c26cae51 | 179 | if ( !cdbEntry ) { |
180 | cdbEntry = "HLT/ConfigTPC/TPCCAGlobalMerger"; | |
181 | defaultNotify = " (default)"; | |
17d6eada | 182 | chainId = 0; |
e1f2d1c3 | 183 | } |
184 | ||
c26cae51 | 185 | HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" ); |
186 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo()); | |
e1f2d1c3 | 187 | |
c26cae51 | 188 | if ( !pEntry ) { |
189 | HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry ); | |
190 | return -EINVAL; | |
17d6eada | 191 | } |
192 | ||
c26cae51 | 193 | TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() ); |
17d6eada | 194 | |
c26cae51 | 195 | if ( !pString ) { |
196 | HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry ); | |
197 | return -EINVAL; | |
17d6eada | 198 | } |
199 | ||
c26cae51 | 200 | HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() ); |
17d6eada | 201 | |
202 | return ReadConfigurationString( pString->GetString().Data() ); | |
203 | } | |
204 | ||
205 | ||
206 | ||
207 | int AliHLTTPCCAGlobalMergerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine ) | |
208 | { | |
c26cae51 | 209 | // Configure the component |
210 | // There are few levels of configuration, | |
17d6eada | 211 | // parameters which are set on one step can be overwritten on the next step |
c26cae51 | 212 | |
17d6eada | 213 | //* read hard-coded values |
214 | ||
c26cae51 | 215 | SetDefaultConfiguration(); |
17d6eada | 216 | |
217 | //* read the default CDB entry | |
c26cae51 | 218 | |
17d6eada | 219 | int iResult1 = ReadCDBEntry( NULL, chainId ); |
c26cae51 | 220 | |
17d6eada | 221 | //* read magnetic field |
c26cae51 | 222 | |
223 | int iResult2 = ReadCDBEntry( kAliHLTCDBSolenoidBz, chainId ); | |
224 | ||
17d6eada | 225 | //* read the actual CDB entry if required |
c26cae51 | 226 | |
227 | int iResult3 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0; | |
228 | ||
17d6eada | 229 | //* read extra parameters from input (if they are) |
230 | ||
231 | int iResult4 = 0; | |
c26cae51 | 232 | |
233 | if ( commandLine && commandLine[0] != '\0' ) { | |
234 | HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine ); | |
235 | iResult4 = ReadConfigurationString( commandLine ); | |
17d6eada | 236 | } |
237 | ||
c26cae51 | 238 | |
17d6eada | 239 | // Initialize the merger |
e1f2d1c3 | 240 | |
241 | AliHLTTPCCAParam param; | |
fbb9b71b | 242 | |
e1f2d1c3 | 243 | { |
244 | // get gemetry | |
fbb9b71b | 245 | int iSec = 0; |
246 | float inRmin = 83.65; | |
247 | float outRmax = 247.7; | |
248 | float plusZmin = 0.0529937; | |
249 | float plusZmax = 249.778; | |
250 | float minusZmin = -249.645; | |
251 | float minusZmax = -0.0799937; | |
252 | float dalpha = 0.349066; | |
253 | float alpha = 0.174533 + dalpha * iSec; | |
254 | bool zPlus = ( iSec < 18 ); | |
255 | float zMin = zPlus ? plusZmin : minusZmin; | |
256 | float zMax = zPlus ? plusZmax : minusZmax; | |
257 | int nRows = AliHLTTPCTransform::GetNRows(); | |
258 | float padPitch = 0.4; | |
259 | float sigmaZ = 0.228808; | |
260 | float *rowX = new float [nRows]; | |
261 | for ( int irow = 0; irow < nRows; irow++ ) { | |
e1f2d1c3 | 262 | rowX[irow] = AliHLTTPCTransform::Row2X( irow ); |
263 | } | |
fbb9b71b | 264 | |
e1f2d1c3 | 265 | param.Initialize( iSec, nRows, rowX, alpha, dalpha, |
fbb9b71b | 266 | inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz ); |
f0fb467d | 267 | |
268 | if( fClusterErrorCorrectionY>1.e-4 ) param.SetClusterError2CorrectionY( fClusterErrorCorrectionY*fClusterErrorCorrectionY ); | |
269 | if( fClusterErrorCorrectionZ>1.e-4 ) param.SetClusterError2CorrectionZ( fClusterErrorCorrectionZ*fClusterErrorCorrectionZ ); | |
270 | param.Update(); | |
271 | ||
e1f2d1c3 | 272 | delete[] rowX; |
273 | } | |
c26cae51 | 274 | |
e1f2d1c3 | 275 | |
276 | fGlobalMerger->SetSliceParam( param ); | |
277 | ||
c26cae51 | 278 | return iResult1 ? iResult1 : ( iResult2 ? iResult2 : ( iResult3 ? iResult3 : iResult4 ) ); |
17d6eada | 279 | } |
280 | ||
281 | ||
282 | ||
283 | ||
284 | int AliHLTTPCCAGlobalMergerComponent::DoInit( int argc, const char** argv ) | |
285 | { | |
286 | // see header file for class documentation | |
c26cae51 | 287 | |
17d6eada | 288 | if ( fGlobalMerger ) { |
289 | return EINPROGRESS; | |
290 | } | |
291 | ||
292 | fGlobalMerger = new AliHLTTPCCAMerger(); | |
e1f2d1c3 | 293 | |
fbb9b71b | 294 | TString arguments = ""; |
295 | for ( int i = 0; i < argc; i++ ) { | |
fbb9b71b | 296 | if ( !arguments.IsNull() ) arguments += " "; |
17d6eada | 297 | arguments += argv[i]; |
e1f2d1c3 | 298 | } |
c26cae51 | 299 | |
300 | return Configure( NULL, NULL, arguments.Data() ); | |
e1f2d1c3 | 301 | } |
302 | ||
17d6eada | 303 | int AliHLTTPCCAGlobalMergerComponent::Reconfigure( const char* cdbEntry, const char* chainId ) |
c26cae51 | 304 | { |
305 | // Reconfigure the component from OCDB | |
17d6eada | 306 | |
307 | return Configure( cdbEntry, chainId, NULL ); | |
308 | } | |
309 | ||
310 | ||
311 | ||
e1f2d1c3 | 312 | int AliHLTTPCCAGlobalMergerComponent::DoDeinit() |
313 | { | |
314 | // see header file for class documentation | |
315 | delete fGlobalMerger; | |
316 | fGlobalMerger = 0; | |
317 | ||
318 | return 0; | |
319 | } | |
320 | ||
321 | int AliHLTTPCCAGlobalMergerComponent::DoEvent( const AliHLTComponentEventData &evtData, | |
fbb9b71b | 322 | const AliHLTComponentBlockData *blocks, AliHLTComponentTriggerData &/*trigData*/, |
e1f2d1c3 | 323 | AliHLTUInt8_t *outputPtr, AliHLTUInt32_t &size, AliHLTComponentBlockDataList &outputBlocks ) |
324 | { | |
325 | // see header file for class documentation | |
326 | int iResult = 0; | |
fbb9b71b | 327 | unsigned int maxBufferSize = size; |
e1f2d1c3 | 328 | |
329 | size = 0; | |
330 | ||
331 | if ( !outputPtr ) { | |
fbb9b71b | 332 | return -ENOSPC; |
e1f2d1c3 | 333 | } |
334 | if ( !IsDataEvent() ) { | |
335 | return 0; | |
336 | } | |
337 | ||
338 | fGlobalMerger->Clear(); | |
339 | ||
340 | const AliHLTComponentBlockData *const blocksEnd = blocks + evtData.fBlockCnt; | |
341 | for ( const AliHLTComponentBlockData *block = blocks; block < blocksEnd; ++block ) { | |
342 | if ( block->fDataType != AliHLTTPCCADefinitions::fgkTrackletsDataType ) { | |
343 | continue; | |
344 | } | |
345 | ||
346 | int slice = AliHLTTPCDefinitions::GetMinSliceNr( *block ); | |
347 | if ( slice < 0 || slice >= AliHLTTPCTransform::GetNSlice() ) { | |
348 | HLTError( "invalid slice number %d extracted from specification 0x%08lx, skipping block of type %s", | |
fbb9b71b | 349 | slice, block->fSpecification, DataType2Text( block->fDataType ).c_str() ); |
e1f2d1c3 | 350 | // just remember the error, if there are other valid blocks ignore the error, return code otherwise |
351 | iResult = -EBADF; | |
352 | continue; | |
353 | } | |
354 | ||
355 | if ( slice != AliHLTTPCDefinitions::GetMaxSliceNr( *block ) ) { | |
356 | // the code was not written for/ never used with multiple slices in one data block/ specification | |
fbb9b71b | 357 | HLTWarning( "specification 0x%08lx indicates multiple slices in data block %s: never used before, please audit the code", |
358 | block->fSpecification, DataType2Text( block->fDataType ).c_str() ); | |
e1f2d1c3 | 359 | } |
5f8cb375 | 360 | AliHLTTPCCASliceOutput *sliceOut = reinterpret_cast<AliHLTTPCCASliceOutput *>( block->fPtr ); |
361 | sliceOut->SetPointers(); | |
362 | fGlobalMerger->SetSliceData( slice, sliceOut ); | |
d4594e7d | 363 | |
364 | /*char filename[256]; | |
365 | sprintf(filename, "debug%d.out", slice); | |
366 | FILE* fp = fopen(filename, "w+b"); | |
367 | if (fp == NULL) printf("Error!!!\n"); | |
368 | fwrite(sliceOut, 1, sliceOut->EstimateSize(sliceOut->NTracks(), sliceOut->NTrackClusters()), fp); | |
369 | fclose(fp);*/ | |
e1f2d1c3 | 370 | } |
371 | fGlobalMerger->Reconstruct(); | |
372 | ||
373 | const AliHLTTPCCAMergerOutput *mergerOutput = fGlobalMerger->Output(); | |
374 | ||
375 | ||
376 | // Fill output tracks | |
377 | ||
fbb9b71b | 378 | unsigned int mySize = 0; |
be7c7c2b | 379 | { |
380 | AliHLTTracksData* outPtr = ( AliHLTTracksData* )( outputPtr ); | |
381 | ||
382 | AliHLTExternalTrackParam* currOutTrack = outPtr->fTracklets; | |
383 | ||
384 | mySize = ( ( AliHLTUInt8_t * )currOutTrack ) - ( ( AliHLTUInt8_t * )outputPtr ); | |
385 | ||
386 | outPtr->fCount = 0; | |
387 | ||
388 | int nTracks = mergerOutput->NTracks(); | |
389 | ||
390 | for ( int itr = 0; itr < nTracks; itr++ ) { | |
391 | ||
392 | // convert AliHLTTPCCAMergedTrack to AliHLTTrack | |
393 | ||
394 | const AliHLTTPCCAMergedTrack &track = mergerOutput->Track( itr ); | |
395 | ||
396 | unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + track.NClusters() * sizeof( unsigned int ); | |
397 | ||
398 | if ( mySize + dSize > maxBufferSize ) { | |
399 | HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, nTracks - itr + 1 ); | |
400 | iResult = -ENOSPC; | |
401 | break; | |
402 | } | |
e1f2d1c3 | 403 | |
be7c7c2b | 404 | // first convert to AliExternalTrackParam |
405 | ||
406 | AliExternalTrackParam tp, tpEnd; | |
407 | AliHLTTPCCATrackConvertor::GetExtParam( track.InnerParam(), tp, track.InnerAlpha() ); | |
408 | AliHLTTPCCATrackConvertor::GetExtParam( track.OuterParam(), tpEnd, track.OuterAlpha() ); | |
409 | ||
410 | currOutTrack->fAlpha = tp.GetAlpha(); | |
411 | currOutTrack->fX = tp.GetX(); | |
412 | currOutTrack->fY = tp.GetY(); | |
413 | currOutTrack->fZ = tp.GetZ(); | |
414 | { | |
415 | float sinA = TMath::Sin( track.OuterAlpha() - track.InnerAlpha()); | |
416 | float cosA = TMath::Cos( track.OuterAlpha() - track.InnerAlpha()); | |
417 | currOutTrack->fLastX = tpEnd.GetX()*cosA - tpEnd.GetY()*sinA; | |
418 | currOutTrack->fLastY = tpEnd.GetX()*sinA + tpEnd.GetY()*cosA; | |
419 | currOutTrack->fLastZ = tpEnd.GetZ(); | |
420 | } | |
421 | currOutTrack->fq1Pt = tp.GetSigned1Pt(); | |
422 | currOutTrack->fSinPsi = tp.GetSnp(); | |
423 | currOutTrack->fTgl = tp.GetTgl(); | |
424 | for( int i=0; i<15; i++ ) currOutTrack->fC[i] = tp.GetCovariance()[i]; | |
425 | currOutTrack->fTrackID = itr; | |
426 | currOutTrack->fFlags = 0; | |
427 | currOutTrack->fNPoints = track.NClusters(); | |
428 | for ( int i = 0; i < track.NClusters(); i++ ) currOutTrack->fPointIDs[i] = mergerOutput->ClusterId( track.FirstClusterRef() + i ); | |
429 | ||
430 | currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize ); | |
431 | mySize += dSize; | |
432 | outPtr->fCount++; | |
433 | } | |
434 | ||
435 | ||
436 | AliHLTComponentBlockData resultData; | |
437 | FillBlockData( resultData ); | |
438 | resultData.fOffset = 0; | |
439 | resultData.fSize = mySize; | |
440 | resultData.fDataType = kAliHLTDataTypeTrack|kAliHLTDataOriginTPC; | |
441 | resultData.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 ); | |
442 | outputBlocks.push_back( resultData ); | |
443 | size = resultData.fSize; | |
444 | } | |
445 | ||
446 | HLTInfo( "CAGlobalMerger:: output %d tracks", mergerOutput->NTracks() ); | |
447 | ||
448 | ||
449 | /* old format | |
e1f2d1c3 | 450 | { |
451 | // check if there was enough space in the output buffer | |
452 | ||
fbb9b71b | 453 | int nTracks = mergerOutput->NTracks(); |
e1f2d1c3 | 454 | |
455 | AliHLTTPCTrackArray array( nTracks ); | |
456 | ||
fbb9b71b | 457 | int nClusters = 0; |
458 | for ( int itr = 0; itr < nTracks; itr++ ) { | |
459 | ||
e1f2d1c3 | 460 | // convert AliHLTTPCCAMergedTrack to AliHLTTPCTrack |
461 | ||
462 | const AliHLTTPCCAMergedTrack &track = mergerOutput->Track( itr ); | |
91794c67 | 463 | |
e1f2d1c3 | 464 | AliHLTTPCTrack out; |
465 | ||
c26cae51 | 466 | // first convert to AliExternalTrackParam |
e1f2d1c3 | 467 | |
468 | AliExternalTrackParam tp, tpEnd; | |
fbb9b71b | 469 | AliHLTTPCCATrackConvertor::GetExtParam( track.InnerParam(), tp, 0 ); |
470 | AliHLTTPCCATrackConvertor::GetExtParam( track.OuterParam(), tpEnd, 0 ); | |
e1f2d1c3 | 471 | |
472 | // set parameters, with rotation to global coordinates | |
fbb9b71b | 473 | |
474 | out.SetCharge( ( int ) tp.GetSign() ); | |
475 | out.SetPt( TMath::Abs( tp.GetSignedPt() ) ); | |
476 | out.SetPsi( fmod( TMath::ASin( tp.GetSnp() ) + track.InnerAlpha() , 2*TMath::Pi() ) ); | |
e1f2d1c3 | 477 | out.SetTgl( tp.GetTgl() ); |
478 | { | |
fbb9b71b | 479 | float sinA = TMath::Sin( track.InnerAlpha() ); |
480 | float cosA = TMath::Cos( track.InnerAlpha() ); | |
481 | ||
482 | out.SetFirstPoint( tp.GetX()*cosA - tp.GetY()*sinA, | |
483 | tp.GetX()*sinA + tp.GetY()*cosA, | |
484 | tp.GetZ() ); | |
e1f2d1c3 | 485 | } |
fbb9b71b | 486 | |
e1f2d1c3 | 487 | { |
fbb9b71b | 488 | float sinA = TMath::Sin( track.OuterAlpha() ); |
489 | float cosA = TMath::Cos( track.OuterAlpha() ); | |
490 | ||
491 | out.SetLastPoint( tpEnd.GetX()*cosA - tpEnd.GetY()*sinA, | |
492 | tpEnd.GetX()*sinA + tpEnd.GetY()*cosA, | |
493 | tpEnd.GetZ() ); | |
e1f2d1c3 | 494 | } |
495 | ||
496 | // set parameter errors w/o rotation, as it is done in AliHLTTPCTrackArray | |
497 | ||
fbb9b71b | 498 | out.SetY0err( tp.GetSigmaY2() ); |
499 | out.SetZ0err( tp.GetSigmaZ2() ); | |
c26cae51 | 500 | out.SetPterr( tp.GetSigma1Pt2() ); |
061d3f2d | 501 | out.SetPsierr( tp.GetSigmaSnp2() ); |
fbb9b71b | 502 | out.SetTglerr( tp.GetSigmaTgl2() ); |
503 | ||
e1f2d1c3 | 504 | // set cluster ID's |
505 | ||
fbb9b71b | 506 | unsigned int hitID[1000]; |
6de2bc40 | 507 | for ( int i = 0; i < track.NClusters(); i++ ) hitID[i] = mergerOutput->ClusterId( track.FirstClusterRef() + i ); |
e1f2d1c3 | 508 | |
509 | out.SetNHits( track.NClusters() ); | |
510 | out.SetHits( track.NClusters(), hitID ); | |
fbb9b71b | 511 | |
512 | out.SetSector( -1 ); | |
e1f2d1c3 | 513 | out.CalculateHelix(); |
fbb9b71b | 514 | if ( !out.CheckConsistency() ) *( array.NextTrack() ) = out; |
515 | nClusters += track.NClusters(); | |
e1f2d1c3 | 516 | } |
517 | ||
fbb9b71b | 518 | |
519 | if ( sizeof( AliHLTTPCTrackletData ) + nTracks*sizeof( AliHLTTPCTrackSegmentData ) + nClusters*sizeof( unsigned int ) | |
520 | > maxBufferSize ) { | |
e1f2d1c3 | 521 | iResult = -ENOSPC; |
522 | } else { | |
fbb9b71b | 523 | AliHLTTPCTrackletData *outPtr = ( AliHLTTPCTrackletData* )( outputPtr ); |
524 | unsigned int nOutTracks = 0; | |
e1f2d1c3 | 525 | mySize = array.WriteTracks( nOutTracks, outPtr->fTracklets ); |
fbb9b71b | 526 | mySize += sizeof( AliHLTTPCTrackletData ); |
e1f2d1c3 | 527 | outPtr->fTrackletCnt = nOutTracks; |
528 | } | |
529 | } | |
fbb9b71b | 530 | |
e1f2d1c3 | 531 | AliHLTComponentBlockData resultData; |
532 | FillBlockData( resultData ); | |
533 | resultData.fOffset = 0; | |
534 | resultData.fSize = mySize; | |
535 | resultData.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 ); | |
536 | outputBlocks.push_back( resultData ); | |
537 | size = resultData.fSize; | |
e1f2d1c3 | 538 | |
7be9b0d7 | 539 | HLTInfo( "CAGlobalMerger:: output %d tracks", mergerOutput->NTracks() ); |
540 | */ | |
e1f2d1c3 | 541 | return iResult; |
542 | } | |
543 |