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