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