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