]>
Commit | Line | Data |
---|---|---|
cf471b1e | 1 | // @(#) $Id$ |
ce565086 | 2 | // ************************************************************************** |
fbb9b71b | 3 | // This file is property of and copyright by the ALICE HLT Project * |
d54804bf | 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. * | |
ce565086 | 17 | // * |
d54804bf | 18 | //*************************************************************************** |
ce565086 | 19 | |
fbb9b71b | 20 | |
cf471b1e | 21 | /////////////////////////////////////////////////////////////////////////////// |
22 | // // | |
23 | // a TPC tracker processing component for the HLT based on CA by Ivan Kisel // | |
24 | // // | |
25 | /////////////////////////////////////////////////////////////////////////////// | |
26 | ||
27 | #if __GNUC__>= 3 | |
28 | using namespace std; | |
29 | #endif | |
30 | ||
31 | #include "AliHLTTPCCATrackerComponent.h" | |
32 | #include "AliHLTTPCTransform.h" | |
b22af1bf | 33 | #include "AliHLTTPCCATrackerFramework.h" |
d54804bf | 34 | #include "AliHLTTPCCAParam.h" |
eb30eb49 | 35 | #include "AliHLTTPCCATrackConvertor.h" |
4acc2401 | 36 | #include "AliHLTArray.h" |
cf471b1e | 37 | |
cf471b1e | 38 | #include "AliHLTTPCSpacePointData.h" |
cf471b1e | 39 | #include "AliHLTTPCClusterDataFormat.h" |
751d16ac | 40 | #include "AliHLTTPCCACompressedInputData.h" |
cf471b1e | 41 | #include "AliHLTTPCTransform.h" |
cf471b1e | 42 | #include "AliHLTTPCDefinitions.h" |
d54804bf | 43 | #include "AliExternalTrackParam.h" |
cf471b1e | 44 | #include "TMath.h" |
53a9c37c | 45 | #include "AliCDBEntry.h" |
46 | #include "AliCDBManager.h" | |
47 | #include "TObjString.h" | |
48 | #include "TObjArray.h" | |
e1f2d1c3 | 49 | #include "AliHLTTPCCASliceOutput.h" |
4acc2401 | 50 | #include "AliHLTTPCCAClusterData.h" |
e1f2d1c3 | 51 | |
52 | const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkTrackletsDataType = AliHLTComponentDataTypeInitializer( "CATRACKL", kAliHLTDataOriginTPC ); | |
53 | ||
54 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
fbb9b71b | 55 | ClassImp( AliHLTTPCCATrackerComponent ) |
cf471b1e | 56 | |
e01a1f52 | 57 | AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent() |
58 | : | |
59 | fTracker( NULL ), | |
60 | fClusterData( NULL ), | |
61 | fMinSlice( 0 ), | |
62 | fSliceCount( fgkNSlices ), | |
63 | fSolenoidBz( 0 ), | |
64 | fMinNTrackClusters( 30 ), | |
65 | fMinTrackPt(0.2), | |
66 | fClusterZCut( 500. ), | |
67 | fNeighboursSearchArea( 0 ), | |
68 | fClusterErrorCorrectionY(0), | |
69 | fClusterErrorCorrectionZ(0), | |
70 | fBenchmark("CATracker"), | |
71 | fAllowGPU( 0), | |
72 | fGPUHelperThreads(-1), | |
73 | fCPUTrackers(0), | |
dedda6bb | 74 | fGlobalTracking(0), |
10dd8017 | 75 | fGPUDeviceNum(-1), |
dedda6bb | 76 | fGPULibrary("") |
cf471b1e | 77 | { |
78 | // see header file for class documentation | |
79 | // or | |
80 | // refer to README to build package | |
81 | // or | |
82 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
14faadd5 | 83 | for( int i=0; i<fgkNSlices; i++ ){ |
84 | fSliceOutput[i] = NULL; | |
85 | } | |
cf471b1e | 86 | } |
87 | ||
fbb9b71b | 88 | AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent( const AliHLTTPCCATrackerComponent& ) |
e01a1f52 | 89 | : |
90 | AliHLTProcessor(), | |
91 | fTracker( NULL ), | |
92 | fClusterData( NULL ), | |
93 | fMinSlice( 0 ), | |
94 | fSliceCount( fgkNSlices ), | |
95 | fSolenoidBz( 0 ), | |
96 | fMinNTrackClusters( 30 ), | |
97 | fMinTrackPt( 0.2 ), | |
98 | fClusterZCut( 500. ), | |
99 | fNeighboursSearchArea(0), | |
100 | fClusterErrorCorrectionY(0), | |
101 | fClusterErrorCorrectionZ(0), | |
102 | fBenchmark("CATracker"), | |
103 | fAllowGPU( 0), | |
104 | fGPUHelperThreads(-1), | |
105 | fCPUTrackers(0), | |
dedda6bb | 106 | fGlobalTracking(0), |
10dd8017 | 107 | fGPUDeviceNum(-1), |
dedda6bb | 108 | fGPULibrary("") |
cf471b1e | 109 | { |
110 | // see header file for class documentation | |
14faadd5 | 111 | for( int i=0; i<fgkNSlices; i++ ){ |
112 | fSliceOutput[i] = NULL; | |
113 | } | |
fbb9b71b | 114 | HLTFatal( "copy constructor untested" ); |
cf471b1e | 115 | } |
116 | ||
fbb9b71b | 117 | AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=( const AliHLTTPCCATrackerComponent& ) |
cf471b1e | 118 | { |
119 | // see header file for class documentation | |
14faadd5 | 120 | for( int i=0; i<fgkNSlices; i++ ){ |
121 | fSliceOutput[i] = NULL; | |
122 | } | |
fbb9b71b | 123 | HLTFatal( "assignment operator untested" ); |
cf471b1e | 124 | return *this; |
125 | } | |
126 | ||
127 | AliHLTTPCCATrackerComponent::~AliHLTTPCCATrackerComponent() | |
4c256004 | 128 | { |
cf471b1e | 129 | // see header file for class documentation |
3a4ab1ca | 130 | if (fTracker) delete fTracker; |
e01a1f52 | 131 | if (fClusterData) delete[] fClusterData; |
4c256004 | 132 | } |
cf471b1e | 133 | |
4c256004 | 134 | // |
cf471b1e | 135 | // Public functions to implement AliHLTComponent's interface. |
136 | // These functions are required for the registration process | |
4c256004 | 137 | // |
cf471b1e | 138 | |
fbb9b71b | 139 | const char* AliHLTTPCCATrackerComponent::GetComponentID() |
4c256004 | 140 | { |
cf471b1e | 141 | // see header file for class documentation |
4c256004 | 142 | return "TPCCATracker"; |
143 | } | |
cf471b1e | 144 | |
fbb9b71b | 145 | void AliHLTTPCCATrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list ) |
4c256004 | 146 | { |
cf471b1e | 147 | // see header file for class documentation |
4c256004 | 148 | list.clear(); |
64fc3975 | 149 | list.push_back( AliHLTTPCDefinitions::fgkClustersDataType ); |
751d16ac | 150 | list.push_back( AliHLTTPCCADefinitions::fgkCompressedInputDataType ); |
4c256004 | 151 | } |
cf471b1e | 152 | |
fbb9b71b | 153 | AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType() |
4c256004 | 154 | { |
cf471b1e | 155 | // see header file for class documentation |
5cb6ddd4 | 156 | return AliHLTTPCCADefinitions::fgkTrackletsDataType; |
4c256004 | 157 | } |
cf471b1e | 158 | |
fbb9b71b | 159 | void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) |
4c256004 | 160 | { |
161 | // define guess for the output data size | |
ec58a12e | 162 | constBase = 1200; // minimum size |
ebf92187 | 163 | inputMultiplier = 0.6; // size relative to input |
4c256004 | 164 | } |
cf471b1e | 165 | |
fbb9b71b | 166 | AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn() |
4c256004 | 167 | { |
cf471b1e | 168 | // see header file for class documentation |
4c256004 | 169 | return new AliHLTTPCCATrackerComponent; |
170 | } | |
cf471b1e | 171 | |
768b27af | 172 | void AliHLTTPCCATrackerComponent::SetDefaultConfiguration() |
4c256004 | 173 | { |
c26cae51 | 174 | // Set default configuration for the CA tracker component |
768b27af | 175 | // Some parameters can be later overwritten from the OCDB |
d54804bf | 176 | |
a8714ffa | 177 | fSolenoidBz = -5.00668; |
36e3690e | 178 | fMinNTrackClusters = 30; |
179 | fMinTrackPt = 0.2; | |
53a9c37c | 180 | fClusterZCut = 500.; |
f0fb467d | 181 | fNeighboursSearchArea = 0; |
182 | fClusterErrorCorrectionY = 0; | |
183 | fClusterErrorCorrectionZ = 0; | |
57a4102f | 184 | fBenchmark.Reset(); |
185 | fBenchmark.SetTimer(0,"total"); | |
186 | fBenchmark.SetTimer(1,"reco"); | |
768b27af | 187 | } |
d54804bf | 188 | |
768b27af | 189 | int AliHLTTPCCATrackerComponent::ReadConfigurationString( const char* arguments ) |
190 | { | |
191 | // Set configuration parameters for the CA tracker component from the string | |
d54804bf | 192 | |
fbb9b71b | 193 | int iResult = 0; |
768b27af | 194 | if ( !arguments ) return iResult; |
c26cae51 | 195 | |
768b27af | 196 | TString allArgs = arguments; |
197 | TString argument; | |
198 | int bMissingParam = 0; | |
eb30eb49 | 199 | |
768b27af | 200 | TObjArray* pTokens = allArgs.Tokenize( " " ); |
201 | ||
202 | int nArgs = pTokens ? pTokens->GetEntries() : 0; | |
c26cae51 | 203 | |
768b27af | 204 | for ( int i = 0; i < nArgs; i++ ) { |
205 | argument = ( ( TObjString* )pTokens->At( i ) )->GetString(); | |
206 | if ( argument.IsNull() ) continue; | |
c26cae51 | 207 | |
768b27af | 208 | if ( argument.CompareTo( "-solenoidBz" ) == 0 ) { |
209 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
75970b8d | 210 | HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz()); |
768b27af | 211 | continue; |
c26cae51 | 212 | } |
768b27af | 213 | |
214 | if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ) { | |
215 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
216 | fMinNTrackClusters = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi(); | |
217 | HLTInfo( "minNClustersOnTrack set to: %d", fMinNTrackClusters ); | |
218 | continue; | |
219 | } | |
c26cae51 | 220 | |
36e3690e | 221 | if ( argument.CompareTo( "-minTrackPt" ) == 0 ) { |
222 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
223 | fMinTrackPt = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof(); | |
224 | HLTInfo( "minTrackPt set to: %f", fMinTrackPt ); | |
225 | continue; | |
226 | } | |
227 | ||
768b27af | 228 | if ( argument.CompareTo( "-clusterZCut" ) == 0 ) { |
229 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
230 | fClusterZCut = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() ); | |
231 | HLTInfo( "ClusterZCut set to: %f", fClusterZCut ); | |
232 | continue; | |
233 | } | |
e01a1f52 | 234 | |
235 | if ( argument.CompareTo( "-neighboursSearchArea" ) == 0 ) { | |
f0fb467d | 236 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; |
237 | fNeighboursSearchArea = TMath::Abs( ( ( TObjString* )pTokens->At( i ) )->GetString().Atof() ); | |
238 | HLTInfo( "NeighboursSearchArea set to: %f", fNeighboursSearchArea ); | |
239 | continue; | |
240 | } | |
c26cae51 | 241 | |
e01a1f52 | 242 | if ( argument.CompareTo( "-errorCorrectionY" ) == 0 ) { |
243 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
244 | fClusterErrorCorrectionY = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof(); | |
245 | HLTInfo( "Cluster Y error correction factor set to: %f", fClusterErrorCorrectionY ); | |
246 | continue; | |
247 | } | |
248 | ||
249 | if ( argument.CompareTo( "-errorCorrectionZ" ) == 0 ) { | |
250 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
251 | fClusterErrorCorrectionZ = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof(); | |
252 | HLTInfo( "Cluster Z error correction factor set to: %f", fClusterErrorCorrectionZ ); | |
253 | continue; | |
254 | } | |
f0fb467d | 255 | |
fd6816cd | 256 | if (argument.CompareTo( "-allowGPU" ) == 0) { |
257 | fAllowGPU = 1; | |
258 | HLTImportant( "Will try to run tracker on GPU" ); | |
259 | continue; | |
260 | } | |
c26cae51 | 261 | |
e4818148 | 262 | if (argument.CompareTo( "-GlobalTracking" ) == 0) { |
263 | fGlobalTracking = 1; | |
264 | HLTImportant( "Global Tracking Activated" ); | |
265 | continue; | |
266 | } | |
e01a1f52 | 267 | |
268 | if ( argument.CompareTo( "-GPUHelperThreads" ) == 0 ) { | |
cf9f6481 | 269 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; |
270 | fGPUHelperThreads = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi(); | |
271 | HLTInfo( "Number of GPU Helper Threads set to: %d", fGPUHelperThreads ); | |
272 | continue; | |
273 | } | |
274 | ||
e4818148 | 275 | if ( argument.CompareTo( "-CPUTrackers" ) == 0 ) { |
276 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
277 | fCPUTrackers = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi(); | |
278 | HLTInfo( "Number of CPU Trackers set to: %d", fCPUTrackers ); | |
279 | continue; | |
280 | } | |
281 | ||
10dd8017 | 282 | if ( argument.CompareTo( "-GPUDeviceNum" ) == 0 ) { |
283 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
284 | fGPUDeviceNum = ( ( TObjString* )pTokens->At( i ) )->GetString().Atoi(); | |
285 | HLTInfo( "Using GPU Device Number %d", fGPUDeviceNum ); | |
286 | continue; | |
287 | } | |
288 | ||
dedda6bb | 289 | if ( argument.CompareTo( "-GPULibrary" ) == 0 ) { |
290 | if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break; | |
291 | fGPULibrary = ( ( TObjString* )pTokens->At( i ) )->GetString(); | |
292 | continue; | |
293 | } | |
294 | ||
295 | HLTError( "Unknown option \"%s\"", argument.Data() ); | |
768b27af | 296 | iResult = -EINVAL; |
4c256004 | 297 | } |
768b27af | 298 | delete pTokens; |
299 | ||
300 | if ( bMissingParam ) { | |
301 | HLTError( "Specifier missed for parameter \"%s\"", argument.Data() ); | |
302 | iResult = -EINVAL; | |
fbb9b71b | 303 | } |
c26cae51 | 304 | |
53a9c37c | 305 | return iResult; |
4c256004 | 306 | } |
cf471b1e | 307 | |
53a9c37c | 308 | |
768b27af | 309 | int AliHLTTPCCATrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId ) |
4c256004 | 310 | { |
cf471b1e | 311 | // see header file for class documentation |
cf471b1e | 312 | |
c26cae51 | 313 | const char* defaultNotify = ""; |
e1f2d1c3 | 314 | |
c26cae51 | 315 | if ( !cdbEntry ) { |
316 | cdbEntry = "HLT/ConfigTPC/TPCCATracker"; | |
317 | defaultNotify = " (default)"; | |
768b27af | 318 | chainId = 0; |
319 | } | |
53a9c37c | 320 | |
c26cae51 | 321 | HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" ); |
322 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo()); | |
fbb9b71b | 323 | |
c26cae51 | 324 | if ( !pEntry ) { |
325 | HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry ); | |
326 | return -EINVAL; | |
53a9c37c | 327 | } |
768b27af | 328 | |
c26cae51 | 329 | TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() ); |
768b27af | 330 | |
c26cae51 | 331 | if ( !pString ) { |
332 | HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry ); | |
333 | return -EINVAL; | |
53a9c37c | 334 | } |
fbb9b71b | 335 | |
c26cae51 | 336 | HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() ); |
fbb9b71b | 337 | |
768b27af | 338 | return ReadConfigurationString( pString->GetString().Data() ); |
339 | } | |
340 | ||
341 | ||
17d6eada | 342 | int AliHLTTPCCATrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine ) |
343 | { | |
c26cae51 | 344 | // Configure the component |
345 | // There are few levels of configuration, | |
17d6eada | 346 | // parameters which are set on one step can be overwritten on the next step |
c26cae51 | 347 | |
17d6eada | 348 | //* read hard-coded values |
c26cae51 | 349 | SetDefaultConfiguration(); |
17d6eada | 350 | |
351 | //* read the default CDB entry | |
17d6eada | 352 | int iResult1 = ReadCDBEntry( NULL, chainId ); |
c26cae51 | 353 | |
17d6eada | 354 | //* read magnetic field |
75970b8d | 355 | fSolenoidBz = GetBz(); |
c26cae51 | 356 | |
17d6eada | 357 | //* read the actual CDB entry if required |
3208d33f | 358 | int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0; |
c26cae51 | 359 | |
17d6eada | 360 | //* read extra parameters from input (if they are) |
3208d33f | 361 | int iResult3 = 0; |
c26cae51 | 362 | |
363 | if ( commandLine && commandLine[0] != '\0' ) { | |
364 | HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine ); | |
3208d33f | 365 | iResult3 = ReadConfigurationString( commandLine ); |
17d6eada | 366 | } |
367 | ||
e01a1f52 | 368 | if (fTracker) ConfigureSlices(); |
c26cae51 | 369 | |
3208d33f | 370 | return iResult1 ? iResult1 : ( iResult2 ? iResult2 : iResult3 ); |
17d6eada | 371 | } |
372 | ||
e01a1f52 | 373 | void AliHLTTPCCATrackerComponent::ConfigureSlices() |
768b27af | 374 | { |
e01a1f52 | 375 | // Initialize the tracker slices |
376 | for (int slice = 0;slice < fgkNSlices;slice++) | |
377 | { | |
378 | int iSec = slice; | |
379 | float inRmin = 83.65; | |
380 | // float inRmax = 133.3; | |
381 | // float outRmin = 133.5; | |
382 | float outRmax = 247.7; | |
383 | float plusZmin = 0.0529937; | |
384 | float plusZmax = 249.778; | |
385 | float minusZmin = -249.645; | |
386 | float minusZmax = -0.0799937; | |
387 | float dalpha = 0.349066; | |
388 | float alpha = 0.174533 + dalpha * iSec; | |
389 | ||
390 | bool zPlus = ( iSec < 18 ); | |
391 | float zMin = zPlus ? plusZmin : minusZmin; | |
392 | float zMax = zPlus ? plusZmax : minusZmax; | |
393 | //TPCZmin = -249.645, ZMax = 249.778 | |
394 | // float rMin = inRmin; | |
395 | // float rMax = outRmax; | |
396 | int nRows = AliHLTTPCTransform::GetNRows(); | |
397 | ||
398 | float padPitch = 0.4; | |
399 | float sigmaZ = 0.228808; | |
400 | ||
401 | float *rowX = new float [nRows]; | |
402 | for ( int irow = 0; irow < nRows; irow++ ) { | |
403 | rowX[irow] = AliHLTTPCTransform::Row2X( irow ); | |
404 | } | |
405 | ||
406 | AliHLTTPCCAParam param; | |
407 | ||
408 | param.Initialize( iSec, nRows, rowX, alpha, dalpha, | |
409 | inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz ); | |
410 | param.SetHitPickUpFactor( 2 ); | |
411 | if( fNeighboursSearchArea>0 ) param.SetNeighboursSearchArea( fNeighboursSearchArea ); | |
412 | if( fClusterErrorCorrectionY>1.e-4 ) param.SetClusterError2CorrectionY( fClusterErrorCorrectionY*fClusterErrorCorrectionY ); | |
413 | if( fClusterErrorCorrectionZ>1.e-4 ) param.SetClusterError2CorrectionZ( fClusterErrorCorrectionZ*fClusterErrorCorrectionZ ); | |
414 | param.SetMinNTrackClusters( fMinNTrackClusters ); | |
415 | param.SetMinTrackPt( fMinTrackPt ); | |
768b27af | 416 | |
e01a1f52 | 417 | param.Update(); |
418 | fTracker->InitializeSliceParam( slice, param ); | |
419 | delete[] rowX; | |
420 | } | |
421 | } | |
422 | ||
423 | int AliHLTTPCCATrackerComponent::DoInit( int argc, const char** argv ) | |
424 | { | |
d4594e7d | 425 | if ( fTracker ) return EINPROGRESS; |
c26cae51 | 426 | |
e01a1f52 | 427 | // Configure the CA tracker component |
768b27af | 428 | TString arguments = ""; |
429 | for ( int i = 0; i < argc; i++ ) { | |
430 | if ( !arguments.IsNull() ) arguments += " "; | |
431 | arguments += argv[i]; | |
fbb9b71b | 432 | } |
c26cae51 | 433 | |
1e63725a | 434 | int retVal = Configure( NULL, NULL, arguments.Data() ); |
e01a1f52 | 435 | if (retVal == 0) |
cf9f6481 | 436 | { |
e01a1f52 | 437 | fMinSlice = 0; |
438 | fSliceCount = fgkNSlices; | |
439 | //Create tracker instance and set parameters | |
10dd8017 | 440 | fTracker = new AliHLTTPCCATrackerFramework(fAllowGPU, fGPULibrary, fGPUDeviceNum); |
75ac9be6 | 441 | if ( fAllowGPU && fTracker->GetGPUStatus() < 2 ) { |
442 | HLTError("GPU Tracker requested but unavailable, aborting."); | |
443 | return -ENODEV; | |
444 | } | |
e01a1f52 | 445 | fClusterData = new AliHLTTPCCAClusterData[fgkNSlices]; |
446 | if (fGPUHelperThreads != -1) | |
447 | { | |
448 | char cc[256] = "HelperThreads"; | |
449 | fTracker->SetGPUTrackerOption(cc, fGPUHelperThreads); | |
450 | } | |
451 | { | |
452 | char cc[256] = "CPUTrackers"; | |
453 | fTracker->SetGPUTrackerOption(cc, fCPUTrackers); | |
454 | char cc2[256] = "SlicesPerCPUTracker"; | |
455 | fTracker->SetGPUTrackerOption(cc2, 1); | |
456 | } | |
457 | if (fGlobalTracking) | |
458 | { | |
459 | char cc[256] = "GlobalTracking"; | |
460 | fTracker->SetGPUTrackerOption(cc, 1); | |
461 | } | |
462 | ||
463 | ConfigureSlices(); | |
e4818148 | 464 | } |
465 | ||
1e63725a | 466 | return(retVal); |
53a9c37c | 467 | } |
468 | ||
768b27af | 469 | int AliHLTTPCCATrackerComponent::DoDeinit() |
eb30eb49 | 470 | { |
768b27af | 471 | // see header file for class documentation |
3a4ab1ca | 472 | if (fTracker) delete fTracker; |
768b27af | 473 | fTracker = NULL; |
e01a1f52 | 474 | if (fClusterData) delete[] fClusterData; |
475 | fClusterData = NULL; | |
768b27af | 476 | return 0; |
eb30eb49 | 477 | } |
478 | ||
768b27af | 479 | int AliHLTTPCCATrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId ) |
53a9c37c | 480 | { |
17d6eada | 481 | // Reconfigure the component from OCDB . |
17d6eada | 482 | return Configure( cdbEntry, chainId, NULL ); |
53a9c37c | 483 | } |
53a9c37c | 484 | |
fbb9b71b | 485 | int AliHLTTPCCATrackerComponent::DoEvent |
e01a1f52 | 486 | ( |
fbb9b71b | 487 | const AliHLTComponentEventData& evtData, |
488 | const AliHLTComponentBlockData* blocks, | |
489 | AliHLTComponentTriggerData& /*trigData*/, | |
490 | AliHLTUInt8_t* outputPtr, | |
491 | AliHLTUInt32_t& size, | |
492 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
cf471b1e | 493 | { |
768b27af | 494 | //* process event |
e01a1f52 | 495 | if (!fTracker) |
496 | { | |
497 | HLTError( "CATracker not initialized properly" ); | |
498 | return -ENOENT; | |
499 | } | |
768b27af | 500 | |
00d07bcd | 501 | AliHLTUInt32_t maxBufferSize = size; |
dc4788ec | 502 | size = 0; // output size |
503 | ||
fbb9b71b | 504 | if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) { |
eb30eb49 | 505 | return 0; |
506 | } | |
507 | ||
57a4102f | 508 | fBenchmark.StartNewEvent(); |
509 | fBenchmark.Start(0); | |
dc4788ec | 510 | |
d54804bf | 511 | //Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA::DoEvent()" ); |
fbb9b71b | 512 | if ( evtData.fBlockCnt <= 0 ) { |
513 | HLTWarning( "no blocks in event" ); | |
514 | return 0; | |
515 | } | |
516 | ||
cf471b1e | 517 | const AliHLTComponentBlockData* iter = NULL; |
518 | unsigned long ndx; | |
fbb9b71b | 519 | |
e01a1f52 | 520 | // min and max patch numbers and row numbers |
521 | int sliceminPatch[fgkNSlices]; | |
522 | int slicemaxPatch[fgkNSlices]; | |
523 | for (int i = 0;i < fSliceCount;i++) | |
524 | { | |
525 | sliceminPatch[i] = 100; | |
526 | slicemaxPatch[i] = -1; | |
527 | } | |
fbb9b71b | 528 | |
e01a1f52 | 529 | //Prepare everything for all slices |
530 | ||
531 | for (int islice = 0;islice < fSliceCount;islice++) | |
4c256004 | 532 | { |
e01a1f52 | 533 | int slice = fMinSlice + islice; |
534 | ||
535 | // total n Hits | |
536 | int nClustersTotal = 0; | |
537 | ||
538 | // sort patches | |
539 | std::vector<unsigned long> patchIndices; | |
fbb9b71b | 540 | |
541 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) { | |
542 | iter = blocks + ndx; | |
e01a1f52 | 543 | if ( slice != AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue; |
544 | if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ){ | |
545 | AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); | |
546 | nClustersTotal += inPtrSP->fSpacePointCnt; | |
547 | fBenchmark.AddInput(iter->fSize); | |
548 | } else | |
549 | if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){ | |
550 | fBenchmark.AddInput(iter->fSize); | |
551 | const AliHLTUInt8_t * inPtr = (const AliHLTUInt8_t *)iter->fPtr; | |
552 | while( inPtr< ((const AliHLTUInt8_t *) iter->fPtr) + iter->fSize ){ | |
553 | AliHLTTPCCACompressedClusterRow *row = (AliHLTTPCCACompressedClusterRow*)inPtr; | |
554 | nClustersTotal+= row->fNClusters; | |
555 | inPtr = (const AliHLTUInt8_t *)(row->fClusters+row->fNClusters); | |
556 | } | |
fbb9b71b | 557 | } |
e01a1f52 | 558 | else continue; |
fbb9b71b | 559 | |
e01a1f52 | 560 | int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); |
561 | if ( sliceminPatch[islice] > patch ) { | |
562 | sliceminPatch[islice] = patch; | |
563 | } | |
564 | if ( slicemaxPatch[islice] < patch ) { | |
565 | slicemaxPatch[islice] = patch; | |
566 | } | |
567 | std::vector<unsigned long>::iterator pIter = patchIndices.begin(); | |
568 | while ( pIter != patchIndices.end() && AliHLTTPCDefinitions::GetMinPatchNr( blocks[*pIter] ) < patch ) { | |
569 | pIter++; | |
570 | } | |
571 | patchIndices.insert( pIter, ndx ); | |
fbb9b71b | 572 | } |
4c256004 | 573 | |
4c256004 | 574 | |
e01a1f52 | 575 | // pass event to CA Tracker |
fbb9b71b | 576 | |
fbb9b71b | 577 | |
e01a1f52 | 578 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits", |
579 | "Total %d hits to read for slice %d", nClustersTotal, slice ); | |
4c256004 | 580 | |
e01a1f52 | 581 | if (nClustersTotal > 500000) |
582 | { | |
583 | HLTWarning( "Too many clusters in tracker input: Slice %d, Number of Clusters %d, slice not included in tracking", slice, nClustersTotal ); | |
584 | fClusterData[islice].StartReading( slice, 0 ); | |
585 | } | |
586 | else | |
587 | { | |
588 | fClusterData[islice].StartReading( slice, nClustersTotal ); | |
589 | ||
590 | for ( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter != patchIndices.end(); pIter++ ) { | |
591 | ndx = *pIter; | |
592 | iter = blocks + ndx; | |
593 | int patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
594 | int nPatchClust = 0; | |
595 | ||
596 | if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType ) { | |
597 | AliHLTTPCCAClusterData::Data* pCluster = &fClusterData[islice].Clusters()[fClusterData[islice].NumberOfClusters()]; | |
598 | AliHLTTPCClusterData* inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr ); | |
599 | nPatchClust = inPtrSP->fSpacePointCnt; | |
600 | const AliHLTTPCSpacePointData* pLastSpacePoint = &inPtrSP->fSpacePoints[inPtrSP->fSpacePointCnt]; | |
601 | for ( const AliHLTTPCSpacePointData* pSpacePoint = inPtrSP->fSpacePoints; pSpacePoint < pLastSpacePoint; pSpacePoint++ ) { | |
602 | if ( pSpacePoint->fZ > fClusterZCut || pSpacePoint->fZ < -fClusterZCut) continue; | |
603 | pCluster->fId = pSpacePoint->fID; | |
604 | pCluster->fRow = pSpacePoint->fPadRow; | |
605 | pCluster->fX = pSpacePoint->fX; | |
606 | pCluster->fY = pSpacePoint->fY; | |
607 | pCluster->fZ = pSpacePoint->fZ; | |
608 | pCluster->fAmp = pSpacePoint->fCharge; | |
609 | pCluster++; | |
610 | } | |
611 | fClusterData[islice].SetNumberOfClusters(pCluster - fClusterData[islice].Clusters()); | |
612 | } | |
613 | else if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType) | |
614 | { | |
615 | const AliHLTUInt8_t * inPtr = (const AliHLTUInt8_t *)iter->fPtr; | |
616 | nPatchClust=0; | |
617 | while( inPtr< ((const AliHLTUInt8_t *)iter->fPtr) + iter->fSize ){ | |
618 | AliHLTTPCCACompressedClusterRow *row = (AliHLTTPCCACompressedClusterRow*)inPtr; | |
619 | UInt_t id = row->fSlicePatchRowID; | |
620 | UInt_t jslice = id>>10; | |
621 | UInt_t jpatch = (id>>6) & 0x7; | |
622 | UInt_t jrow = id & 0x3F; | |
623 | jrow+= AliHLTTPCTransform::GetFirstRow( jpatch ); | |
624 | Double_t rowX = AliHLTTPCTransform::Row2X( jrow ); | |
625 | //cout<<"Read row: s "<<jslice<<" p "<<jpatch<<" r "<<jrow<<" x "<<row->fX<<" nclu "<<row->fNClusters<<" :"<<endl; | |
626 | if( jrow > 159 ) { | |
627 | HLTError( "Wrong TPC cluster with row number %d received", jrow ); | |
628 | continue; | |
629 | } | |
630 | for ( unsigned int i = 0; i < row->fNClusters; i++ ) { | |
631 | AliHLTTPCCACompressedCluster *c = &( row->fClusters[i] ); | |
632 | ||
633 | UInt_t ix0 = c->fP0 >>24; | |
634 | UInt_t ix1 = c->fP1 >>24; | |
635 | Double_t x = (ix1<<8) + ix0; | |
636 | Double_t y = c->fP0 & 0x00FFFFFF; | |
637 | Double_t z = c->fP1 & 0x00FFFFFF; | |
638 | x = (x - 32768.)*1.e-4 + rowX; | |
639 | y = (y - 8388608.)*1.e-4; | |
640 | z = (z - 8388608.)*1.e-4; | |
641 | ||
642 | UInt_t cluId = AliHLTTPCSpacePointData::GetID( jslice, jpatch, nPatchClust ); | |
643 | //cout<<"clu "<<i<<": "<<x<<" "<<y<<" "<<z<<" "<<cluId<<endl; | |
644 | if ( CAMath::Abs( z ) <= fClusterZCut){ | |
645 | fClusterData[islice].ReadCluster( cluId, jrow, x, y, z, 0 ); | |
646 | } | |
647 | nPatchClust++; | |
648 | } | |
649 | inPtr = (const AliHLTUInt8_t *)(row->fClusters+row->fNClusters); | |
650 | } | |
651 | } | |
652 | Logging( kHLTLogInfo, "HLT::TPCCATracker::DoEvent", "Reading hits", | |
653 | "Read %d hits for slice %d - patch %d", nPatchClust, slice, patch ); | |
654 | } | |
655 | } | |
d4594e7d | 656 | } |
fbb9b71b | 657 | |
d4594e7d | 658 | //Prepare Output |
659 | AliHLTTPCCASliceOutput::outputControlStruct outputControl; | |
90da1ad5 | 660 | outputControl.fEndOfSpace = 0; |
5cb6ddd4 | 661 | outputControl.fOutputPtr = (char*) outputPtr; |
d4594e7d | 662 | outputControl.fOutputMaxSize = maxBufferSize; |
e01a1f52 | 663 | fTracker->SetOutputControl(&outputControl); |
4c256004 | 664 | |
e01a1f52 | 665 | memset(fSliceOutput, 0, fSliceCount * sizeof(AliHLTTPCCASliceOutput*)); |
b8139972 | 666 | |
fbb9b71b | 667 | // reconstruct the event |
57a4102f | 668 | fBenchmark.Start(1); |
e01a1f52 | 669 | fTracker->ProcessSlices(fMinSlice, fSliceCount, fClusterData, fSliceOutput); |
57a4102f | 670 | fBenchmark.Stop(1); |
e01a1f52 | 671 | |
fbb9b71b | 672 | int ret = 0; |
fbb9b71b | 673 | unsigned int mySize = 0; |
a59a784e | 674 | int ntracks = 0; |
d4594e7d | 675 | int error = 0; |
fbb9b71b | 676 | |
e01a1f52 | 677 | for (int islice = 0;islice < fSliceCount;islice++) |
d4594e7d | 678 | { |
e01a1f52 | 679 | if (slicemaxPatch[islice] == -1) continue; |
680 | int slice = fMinSlice + islice; | |
681 | ||
90da1ad5 | 682 | if( outputControl.fEndOfSpace ){ |
e01a1f52 | 683 | HLTWarning( "Output buffer size exceeded (buffer size %d, required size %d), tracks are not stored", maxBufferSize, mySize ); |
90da1ad5 | 684 | ret = -ENOSPC; |
685 | error = 1; | |
686 | break; | |
687 | } | |
e01a1f52 | 688 | |
689 | if (fSliceOutput[islice]) | |
690 | { | |
691 | // write reconstructed tracks | |
692 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reconstruct", "%d tracks found for slice %d", fSliceOutput[islice]->NTracks(), slice ); | |
693 | ||
694 | mySize += fSliceOutput[islice]->Size(); | |
695 | ntracks += fSliceOutput[islice]->NTracks(); | |
696 | } | |
5cb6ddd4 | 697 | else |
e01a1f52 | 698 | { |
699 | HLTWarning( "Error during Tracking, no tracks stored" ); | |
700 | mySize = 0; | |
701 | ret = -ENOSPC; | |
702 | ntracks = 0; | |
703 | error = 1; | |
704 | break; | |
705 | } | |
cf471b1e | 706 | } |
e01a1f52 | 707 | |
d4594e7d | 708 | size = 0; |
709 | if (error == 0) | |
710 | { | |
3f71076b | 711 | for (int islice = 0;islice < fSliceCount && fSliceOutput[islice];islice++) |
e01a1f52 | 712 | { |
e01a1f52 | 713 | int slice = fMinSlice + islice; |
714 | ||
715 | mySize = fSliceOutput[islice]->Size(); | |
716 | if (mySize > 0) | |
5cb6ddd4 | 717 | { |
e01a1f52 | 718 | AliHLTComponentBlockData bd; |
719 | FillBlockData( bd ); | |
720 | bd.fOffset = ((char*) fSliceOutput[islice] - (char*) outputPtr); | |
721 | bd.fSize = mySize; | |
722 | bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, sliceminPatch[islice], slicemaxPatch[islice] ); | |
723 | bd.fDataType = GetOutputDataType(); | |
724 | outputBlocks.push_back( bd ); | |
725 | size += mySize; | |
726 | fBenchmark.AddOutput(bd.fSize); | |
5cb6ddd4 | 727 | } |
e01a1f52 | 728 | } |
e1f2d1c3 | 729 | } |
d4594e7d | 730 | |
731 | //No longer needed | |
44ec922a | 732 | |
57a4102f | 733 | fBenchmark.Stop(0); |
dc4788ec | 734 | |
735 | // Set log level to "Warning" for on-line system monitoring | |
57a4102f | 736 | |
d4594e7d | 737 | //Min and Max Patch are taken for first slice processed... |
dc4788ec | 738 | |
e01a1f52 | 739 | fBenchmark.SetName(Form("CATracker")); |
57a4102f | 740 | |
741 | HLTInfo(fBenchmark.GetStatistics()); | |
c24ec5c8 | 742 | //No longer needed |
743 | ||
4c256004 | 744 | return ret; |
cf471b1e | 745 | } |
746 | ||
fbb9b71b | 747 |