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