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