]>
Commit | Line | Data |
---|---|---|
cf471b1e | 1 | // @(#) $Id$ |
d54804bf | 2 | //*************************************************************************** |
3 | // This file is property of and copyright by the ALICE HLT Project * | |
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. * | |
17 | //*************************************************************************** | |
cf471b1e | 18 | |
19 | /////////////////////////////////////////////////////////////////////////////// | |
20 | // // | |
21 | // a TPC tracker processing component for the HLT based on CA by Ivan Kisel // | |
22 | // // | |
23 | /////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #if __GNUC__>= 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | ||
00d07bcd | 29 | //#include <climits> |
cf471b1e | 30 | #include "AliHLTTPCCATrackerComponent.h" |
31 | #include "AliHLTTPCTransform.h" | |
32 | #include "AliHLTTPCCATracker.h" | |
cf471b1e | 33 | #include "AliHLTTPCCAOutTrack.h" |
d54804bf | 34 | #include "AliHLTTPCCAParam.h" |
eb30eb49 | 35 | #include "AliHLTTPCCATrackConvertor.h" |
cf471b1e | 36 | |
cf471b1e | 37 | #include "AliHLTTPCSpacePointData.h" |
cf471b1e | 38 | #include "AliHLTTPCClusterDataFormat.h" |
39 | #include "AliHLTTPCTransform.h" | |
40 | #include "AliHLTTPCTrackSegmentData.h" | |
41 | #include "AliHLTTPCTrackArray.h" | |
42 | #include "AliHLTTPCTrackletDataFormat.h" | |
43 | #include "AliHLTTPCDefinitions.h" | |
d54804bf | 44 | #include "AliExternalTrackParam.h" |
dc4788ec | 45 | #include "TStopwatch.h" |
cf471b1e | 46 | #include "TMath.h" |
cf471b1e | 47 | |
00d07bcd | 48 | /** global object for registration |
49 | * Matthias 2009-01-13 temporarily using the global object approach again. | |
50 | * CA cade had to be disabled because of various compilation problems, so | |
51 | * the global object approach fits better for the moment. | |
52 | */ | |
53 | AliHLTTPCCATrackerComponent gAliHLTTPCCATrackerComponent; | |
54 | ||
672f8b8c | 55 | /** ROOT macro for the implementation of ROOT specific class methods */ |
cf471b1e | 56 | ClassImp(AliHLTTPCCATrackerComponent) |
57 | ||
58 | AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent() | |
59 | : | |
60 | fTracker(NULL), | |
eb30eb49 | 61 | fSolenoidBz(0), |
62 | fMinNTrackClusters(0), | |
63 | fCellConnectionAngleXY(45), | |
64 | fCellConnectionAngleXZ(45), | |
65 | fClusterZCut(500.), | |
d54804bf | 66 | fFullTime(0), |
67 | fRecoTime(0), | |
68 | fNEvents(0) | |
cf471b1e | 69 | { |
70 | // see header file for class documentation | |
71 | // or | |
72 | // refer to README to build package | |
73 | // or | |
74 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
75 | } | |
76 | ||
77 | AliHLTTPCCATrackerComponent::AliHLTTPCCATrackerComponent(const AliHLTTPCCATrackerComponent&) | |
78 | : | |
c61a7285 | 79 | AliHLTProcessor(), |
cf471b1e | 80 | fTracker(NULL), |
eb30eb49 | 81 | fSolenoidBz(0), |
d54804bf | 82 | fMinNTrackClusters(30), |
eb30eb49 | 83 | fCellConnectionAngleXY(35), |
84 | fCellConnectionAngleXZ(35), | |
85 | fClusterZCut(500.), | |
86 | fFullTime(0), | |
d54804bf | 87 | fRecoTime(0), |
88 | fNEvents(0) | |
cf471b1e | 89 | { |
90 | // see header file for class documentation | |
91 | HLTFatal("copy constructor untested"); | |
92 | } | |
93 | ||
94 | AliHLTTPCCATrackerComponent& AliHLTTPCCATrackerComponent::operator=(const AliHLTTPCCATrackerComponent&) | |
95 | { | |
96 | // see header file for class documentation | |
97 | HLTFatal("assignment operator untested"); | |
98 | return *this; | |
99 | } | |
100 | ||
101 | AliHLTTPCCATrackerComponent::~AliHLTTPCCATrackerComponent() | |
4c256004 | 102 | { |
cf471b1e | 103 | // see header file for class documentation |
4c256004 | 104 | delete fTracker; |
105 | } | |
cf471b1e | 106 | |
4c256004 | 107 | // |
cf471b1e | 108 | // Public functions to implement AliHLTComponent's interface. |
109 | // These functions are required for the registration process | |
4c256004 | 110 | // |
cf471b1e | 111 | |
112 | const char* AliHLTTPCCATrackerComponent::GetComponentID() | |
4c256004 | 113 | { |
cf471b1e | 114 | // see header file for class documentation |
4c256004 | 115 | return "TPCCATracker"; |
116 | } | |
cf471b1e | 117 | |
118 | void AliHLTTPCCATrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
4c256004 | 119 | { |
cf471b1e | 120 | // see header file for class documentation |
4c256004 | 121 | list.clear(); |
122 | list.push_back( AliHLTTPCDefinitions::fgkClustersDataType ); | |
123 | } | |
cf471b1e | 124 | |
125 | AliHLTComponentDataType AliHLTTPCCATrackerComponent::GetOutputDataType() | |
4c256004 | 126 | { |
cf471b1e | 127 | // see header file for class documentation |
4c256004 | 128 | return AliHLTTPCDefinitions::fgkTrackSegmentsDataType; |
129 | } | |
cf471b1e | 130 | |
131 | void AliHLTTPCCATrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
4c256004 | 132 | { |
133 | // define guess for the output data size | |
134 | constBase = 200; // minimum size | |
135 | inputMultiplier = 0.5; // size relative to input | |
136 | } | |
cf471b1e | 137 | |
138 | AliHLTComponent* AliHLTTPCCATrackerComponent::Spawn() | |
4c256004 | 139 | { |
cf471b1e | 140 | // see header file for class documentation |
4c256004 | 141 | return new AliHLTTPCCATrackerComponent; |
142 | } | |
cf471b1e | 143 | |
144 | int AliHLTTPCCATrackerComponent::DoInit( int argc, const char** argv ) | |
4c256004 | 145 | { |
146 | // Initialize the CA tracker component | |
147 | // | |
148 | // arguments could be: | |
eb30eb49 | 149 | // solenoidBz - the magnetic field value |
150 | // minNTrackClusters - required minimum of clusters on the track | |
4c256004 | 151 | // |
cf471b1e | 152 | |
4c256004 | 153 | if ( fTracker ) return EINPROGRESS; |
d54804bf | 154 | |
155 | fFullTime = 0; | |
156 | fRecoTime = 0; | |
00d07bcd | 157 | fNEvents = 0; |
d54804bf | 158 | |
4c256004 | 159 | fTracker = new AliHLTTPCCATracker(); |
00d07bcd | 160 | |
4c256004 | 161 | // read command line |
cf471b1e | 162 | |
4c256004 | 163 | int i = 0; |
164 | char* cpErr; | |
165 | while ( i < argc ){ | |
eb30eb49 | 166 | if ( !strcmp( argv[i], "solenoidBz" ) || !strcmp( argv[i], "-solenoidBz" ) ){ |
4c256004 | 167 | if ( i+1 >= argc ) |
cf471b1e | 168 | { |
eb30eb49 | 169 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing solenoidBz", "Missing solenoidBz specifier." ); |
4c256004 | 170 | return ENOTSUP; |
171 | } | |
eb30eb49 | 172 | fSolenoidBz = strtod( argv[i+1], &cpErr ); |
4c256004 | 173 | if ( *cpErr ) |
174 | { | |
eb30eb49 | 175 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing multiplicity", "Cannot convert solenoidBz specifier '%s'.", argv[i+1] ); |
4c256004 | 176 | return EINVAL; |
cf471b1e | 177 | } |
cf471b1e | 178 | |
d54804bf | 179 | Logging( kHLTLogInfo, "HLT::TPCCATracker::DoInit", "Reading command line", |
eb30eb49 | 180 | "Magnetic field value is set to %f kG", fSolenoidBz ); |
4c256004 | 181 | |
182 | i += 2; | |
183 | continue; | |
cf471b1e | 184 | } |
d54804bf | 185 | |
eb30eb49 | 186 | if ( !strcmp( argv[i], "minNTrackClusters" ) || !strcmp( argv[i], "-minNTrackClusters" ) ){ |
d54804bf | 187 | if ( i+1 >= argc ) |
188 | { | |
eb30eb49 | 189 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing minNTrackClusters", "Missing minNTrackClusters specifier." ); |
d54804bf | 190 | return ENOTSUP; |
191 | } | |
192 | fMinNTrackClusters = (Int_t ) strtod( argv[i+1], &cpErr ); | |
193 | if ( *cpErr ) | |
194 | { | |
eb30eb49 | 195 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing multiplicity", "Cannot convert minNTrackClusters '%s'.", argv[i+1] ); |
d54804bf | 196 | return EINVAL; |
197 | } | |
198 | ||
199 | Logging( kHLTLogInfo, "HLT::TPCCATracker::DoInit", "Reading command line", | |
eb30eb49 | 200 | "minNTrackClusters is set to %i ", fMinNTrackClusters ); |
d54804bf | 201 | |
202 | i += 2; | |
203 | continue; | |
204 | } | |
eb30eb49 | 205 | |
206 | if ( !strcmp( argv[i], "cellConnectionAngleXY" ) || !strcmp( argv[i], "-cellConnectionAngleXY" ) ){ | |
207 | if ( i+1 >= argc ) | |
208 | { | |
209 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing cellConnectionAngleXY", "Missing cellConnectionAngleXY specifier." ); | |
210 | return ENOTSUP; | |
211 | } | |
212 | fCellConnectionAngleXY = strtod( argv[i+1], &cpErr ); | |
213 | if ( *cpErr ) | |
214 | { | |
215 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing multiplicity", "Cannot convert cellConnectionAngleXY '%s'.", argv[i+1] ); | |
216 | return EINVAL; | |
217 | } | |
218 | ||
219 | Logging( kHLTLogInfo, "HLT::TPCCATracker::DoInit", "Reading command line", | |
220 | "cellConnectionAngleXY is set to %f ", fCellConnectionAngleXY ); | |
221 | ||
222 | i += 2; | |
223 | continue; | |
224 | } | |
225 | if ( !strcmp( argv[i], "cellConnectionAngleXZ" ) || !strcmp( argv[i], "-cellConnectionAngleXZ" ) ){ | |
226 | if ( i+1 >= argc ) | |
227 | { | |
228 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing cellConnectionAngleXZ", "Missing cellConnectionAngleXZ specifier." ); | |
229 | return ENOTSUP; | |
230 | } | |
231 | fCellConnectionAngleXZ = strtod( argv[i+1], &cpErr ); | |
232 | if ( *cpErr ) | |
233 | { | |
234 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing multiplicity", "Cannot convert cellConnectionAngleXZ '%s'.", argv[i+1] ); | |
235 | return EINVAL; | |
236 | } | |
237 | ||
238 | Logging( kHLTLogInfo, "HLT::TPCCATracker::DoInit", "Reading command line", | |
239 | "cellConnectionAngleXZ is set to %f ", fCellConnectionAngleXZ ); | |
240 | ||
241 | i += 2; | |
242 | continue; | |
243 | } | |
244 | if ( !strcmp( argv[i], "clusterZCut" ) || !strcmp( argv[i], "-clusterZCut" ) ){ | |
245 | if ( i+1 >= argc ) | |
246 | { | |
247 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing clusterZCut", "Missing clusterZCut specifier." ); | |
248 | return ENOTSUP; | |
249 | } | |
250 | fClusterZCut = TMath::Abs(strtod( argv[i+1], &cpErr )); | |
251 | if ( *cpErr ) | |
252 | { | |
253 | Logging( kHLTLogError, "HLT::TPCCATracker::DoInit", "Missing multiplicity", "Cannot convert clusterZCut '%s'.", argv[i+1] ); | |
254 | return EINVAL; | |
255 | } | |
256 | ||
257 | Logging( kHLTLogInfo, "HLT::TPCCATracker::DoInit", "Reading command line", | |
258 | "clusterZCut is set to %f ", fClusterZCut ); | |
259 | ||
260 | i += 2; | |
261 | continue; | |
262 | } | |
263 | ||
4c256004 | 264 | Logging(kHLTLogError, "HLT::TPCCATracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); |
265 | return EINVAL; | |
266 | } | |
267 | ||
268 | return 0; | |
269 | } | |
cf471b1e | 270 | |
271 | int AliHLTTPCCATrackerComponent::DoDeinit() | |
4c256004 | 272 | { |
cf471b1e | 273 | // see header file for class documentation |
4c256004 | 274 | if ( fTracker ) delete fTracker; |
275 | fTracker = NULL; | |
276 | return 0; | |
277 | } | |
cf471b1e | 278 | |
eb30eb49 | 279 | Bool_t AliHLTTPCCATrackerComponent::CompareClusters(AliHLTTPCSpacePointData *a, AliHLTTPCSpacePointData *b) |
280 | { | |
281 | //* Comparison function for sorting clusters | |
282 | if( a->fPadRow<b->fPadRow ) return 1; | |
283 | if( a->fPadRow>b->fPadRow ) return 0; | |
284 | return (a->fZ < b->fZ); | |
285 | } | |
286 | ||
4c256004 | 287 | int AliHLTTPCCATrackerComponent::DoEvent |
288 | ( | |
289 | const AliHLTComponentEventData& evtData, | |
290 | const AliHLTComponentBlockData* blocks, | |
c61a7285 | 291 | AliHLTComponentTriggerData& /*trigData*/, |
4c256004 | 292 | AliHLTUInt8_t* outputPtr, |
293 | AliHLTUInt32_t& size, | |
294 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
cf471b1e | 295 | { |
00d07bcd | 296 | //* process event |
297 | AliHLTUInt32_t maxBufferSize = size; | |
dc4788ec | 298 | size = 0; // output size |
299 | ||
eb30eb49 | 300 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){ |
301 | return 0; | |
302 | } | |
303 | ||
dc4788ec | 304 | TStopwatch timer; |
305 | ||
4c256004 | 306 | // Event reconstruction in one TPC slice with CA Tracker |
eb30eb49 | 307 | |
d54804bf | 308 | //Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA::DoEvent()" ); |
cf471b1e | 309 | if ( evtData.fBlockCnt<=0 ) |
310 | { | |
311 | Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "no blocks in event" ); | |
312 | return 0; | |
313 | } | |
4c256004 | 314 | |
cf471b1e | 315 | const AliHLTComponentBlockData* iter = NULL; |
316 | unsigned long ndx; | |
4c256004 | 317 | AliHLTTPCClusterData* inPtrSP; |
cf471b1e | 318 | |
4c256004 | 319 | // Determine the slice number |
cf471b1e | 320 | |
4c256004 | 321 | Int_t slice=-1; |
322 | { | |
323 | std::vector<Int_t> slices; | |
324 | std::vector<Int_t>::iterator slIter; | |
325 | std::vector<unsigned> sliceCnts; | |
326 | std::vector<unsigned>::iterator slCntIter; | |
cf471b1e | 327 | |
4c256004 | 328 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ){ |
cf471b1e | 329 | iter = blocks+ndx; |
4c256004 | 330 | if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue; |
331 | ||
cf471b1e | 332 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); |
dc4788ec | 333 | |
4c256004 | 334 | Bool_t found = 0; |
cf471b1e | 335 | slCntIter = sliceCnts.begin(); |
4c256004 | 336 | for( slIter = slices.begin(); slIter!=slices.end(); slIter++, slCntIter++ ){ |
337 | if ( *slIter == slice ){ | |
338 | found = kTRUE; | |
339 | break; | |
cf471b1e | 340 | } |
4c256004 | 341 | } |
342 | if ( !found ){ | |
343 | slices.push_back( slice ); | |
344 | sliceCnts.push_back( 1 ); | |
345 | } else *slCntIter++; | |
cf471b1e | 346 | } |
347 | ||
348 | ||
4c256004 | 349 | // Determine slice number to really use. |
350 | if ( slices.size()>1 ) | |
351 | { | |
352 | Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event", | |
353 | "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...", | |
354 | evtData.fEventID, evtData.fEventID ); | |
355 | unsigned maxCntSlice=0; | |
356 | slCntIter = sliceCnts.begin(); | |
357 | for( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) | |
358 | { | |
359 | Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event", | |
360 | "Slice %lu found %lu times.", *slIter, *slCntIter ); | |
361 | if ( maxCntSlice<*slCntIter ) | |
362 | { | |
363 | maxCntSlice = *slCntIter; | |
364 | slice = *slIter; | |
365 | } | |
366 | } | |
367 | Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event", | |
368 | "Using slice %lu.", slice ); | |
369 | } | |
370 | else if ( slices.size()>0 ) | |
371 | { | |
372 | slice = *(slices.begin()); | |
373 | } | |
374 | } | |
375 | ||
376 | if( slice<0 ){ | |
d54804bf | 377 | Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "DoEvent", "CA:: no slices found in event" ); |
4c256004 | 378 | return 0; |
379 | } | |
cf471b1e | 380 | |
4c256004 | 381 | |
382 | // Initialize the tracker | |
383 | ||
4c256004 | 384 | |
cf471b1e | 385 | { |
4c256004 | 386 | if( !fTracker ) fTracker = new AliHLTTPCCATracker; |
cf471b1e | 387 | Int_t iSec = slice; |
eb30eb49 | 388 | Float_t inRmin = 83.65; |
389 | // Float_t inRmax = 133.3; | |
390 | // Float_t outRmin = 133.5; | |
391 | Float_t outRmax = 247.7; | |
392 | Float_t plusZmin = 0.0529937; | |
393 | Float_t plusZmax = 249.778; | |
394 | Float_t minusZmin = -249.645; | |
395 | Float_t minusZmax = -0.0799937; | |
396 | Float_t dalpha = 0.349066; | |
397 | Float_t alpha = 0.174533 + dalpha*iSec; | |
cf471b1e | 398 | |
dc4788ec | 399 | Bool_t zPlus = (iSec<18 ); |
eb30eb49 | 400 | Float_t zMin = zPlus ?plusZmin :minusZmin; |
401 | Float_t zMax = zPlus ?plusZmax :minusZmax; | |
dc4788ec | 402 | //TPCZmin = -249.645, ZMax = 249.778 |
eb30eb49 | 403 | // Float_t rMin = inRmin; |
404 | // Float_t rMax = outRmax; | |
00d07bcd | 405 | Int_t nRows = AliHLTTPCTransform::GetNRows(); |
dc4788ec | 406 | |
eb30eb49 | 407 | Float_t padPitch = 0.4; |
408 | Float_t sigmaZ = 0.228808; | |
cf471b1e | 409 | |
00d07bcd | 410 | Float_t *rowX = new Float_t [nRows]; |
411 | for( Int_t irow=0; irow<nRows; irow++){ | |
dc4788ec | 412 | rowX[irow] = AliHLTTPCTransform::Row2X( irow ); |
413 | } | |
cf471b1e | 414 | |
415 | AliHLTTPCCAParam param; | |
00d07bcd | 416 | param.Initialize( iSec, nRows, rowX, alpha, dalpha, |
417 | inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, fSolenoidBz ); | |
dc4788ec | 418 | param.YErrorCorrection() = 1; |
419 | param.ZErrorCorrection() = 2; | |
eb30eb49 | 420 | param.CellConnectionAngleXY() = fCellConnectionAngleXY/180.*TMath::Pi(); |
421 | param.CellConnectionAngleXZ() = fCellConnectionAngleXZ/180.*TMath::Pi(); | |
422 | param.Update(); | |
dc4788ec | 423 | fTracker->Initialize( param ); |
d54804bf | 424 | delete[] rowX; |
cf471b1e | 425 | } |
426 | ||
4c256004 | 427 | |
428 | // min and max patch numbers and row numbers | |
429 | ||
430 | Int_t row[2] = {0,0}; | |
dc4788ec | 431 | Int_t minPatch=INT_MAX, maxPatch = -1; |
4c256004 | 432 | |
433 | // total n Hits | |
cf471b1e | 434 | |
435 | Int_t nHitsTotal = 0; | |
4c256004 | 436 | |
437 | // sort patches | |
438 | ||
439 | std::vector<unsigned long> patchIndices; | |
440 | ||
441 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ){ | |
442 | iter = blocks+ndx; | |
443 | if( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue; | |
444 | if( slice!=AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) continue; | |
cf471b1e | 445 | inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr); |
446 | nHitsTotal+=inPtrSP->fSpacePointCnt; | |
4c256004 | 447 | Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); |
448 | if ( minPatch>patch ){ | |
449 | minPatch = patch; | |
450 | row[0] = AliHLTTPCTransform::GetFirstRow( patch ); | |
451 | } | |
452 | if ( maxPatch<patch ){ | |
453 | maxPatch = patch; | |
454 | row[1] = AliHLTTPCTransform::GetLastRow( patch ); | |
455 | } | |
456 | std::vector<unsigned long>::iterator pIter = patchIndices.begin(); | |
457 | while( pIter!=patchIndices.end() && AliHLTTPCDefinitions::GetMinPatchNr( blocks[*pIter] ) < patch ){ | |
458 | pIter++; | |
459 | } | |
460 | patchIndices.insert( pIter, ndx ); | |
cf471b1e | 461 | } |
4c256004 | 462 | |
463 | ||
464 | // pass event to CA Tracker | |
465 | ||
466 | fTracker->StartEvent(); | |
467 | ||
4c256004 | 468 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits", |
469 | "Total %d hits to read for slice %d", nHitsTotal, slice ); | |
470 | ||
eb30eb49 | 471 | |
472 | AliHLTTPCSpacePointData** vOrigClusters = new AliHLTTPCSpacePointData* [ nHitsTotal]; | |
473 | ||
dc4788ec | 474 | Int_t nClusters=0; |
475 | ||
4c256004 | 476 | for( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter!=patchIndices.end(); pIter++ ){ |
477 | ndx = *pIter; | |
478 | iter = blocks+ndx; | |
cf471b1e | 479 | |
4c256004 | 480 | Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); |
481 | inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr); | |
cf471b1e | 482 | |
4c256004 | 483 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits", |
484 | "Reading %d hits for slice %d - patch %d", inPtrSP->fSpacePointCnt, slice, patch ); | |
cf471b1e | 485 | |
eb30eb49 | 486 | for (UInt_t i=0; i<inPtrSP->fSpacePointCnt; i++ ){ |
487 | vOrigClusters[nClusters++] = &(inPtrSP->fSpacePoints[i]); | |
488 | } | |
489 | } | |
4c256004 | 490 | |
eb30eb49 | 491 | // sort clusters since they are not sorted fore some reason |
492 | ||
493 | sort( vOrigClusters, vOrigClusters+nClusters, CompareClusters ); | |
494 | ||
eb30eb49 | 495 | Float_t *vHitStoreX = new Float_t [nHitsTotal]; // hit X coordinates |
496 | Float_t *vHitStoreY = new Float_t [nHitsTotal]; // hit Y coordinates | |
497 | Float_t *vHitStoreZ = new Float_t [nHitsTotal]; // hit Z coordinates | |
00d07bcd | 498 | Int_t *vHitStoreIntID = new Int_t [nHitsTotal]; // hit ID's |
eb30eb49 | 499 | Int_t *vHitStoreID = new Int_t [nHitsTotal]; // hit ID's |
500 | Int_t *vHitRowID = new Int_t [nHitsTotal]; // hit ID's | |
501 | ||
502 | Int_t nHits = 0; | |
00d07bcd | 503 | |
eb30eb49 | 504 | { |
00d07bcd | 505 | Int_t rowNHits[200]; |
506 | Int_t rowFirstHits[200]; | |
507 | for( Int_t ir=0; ir<200; ir++ ) rowNHits[ir] = 0; | |
4c256004 | 508 | Int_t oldRow = -1; |
eb30eb49 | 509 | for (Int_t i=0; i<nClusters; i++ ){ |
510 | AliHLTTPCSpacePointData* pSP = vOrigClusters[i]; | |
00d07bcd | 511 | if( oldRow>=0 && pSP->fPadRow < oldRow ) |
512 | HLTError("CA: clusters from row %d are readed twice",oldRow); | |
513 | ||
514 | if( TMath::Abs(pSP->fZ)>fClusterZCut) continue; | |
515 | ||
eb30eb49 | 516 | vHitStoreX[nHits] = pSP->fX; |
00d07bcd | 517 | vHitStoreY[nHits] = pSP->fY; |
518 | vHitStoreZ[nHits] = pSP->fZ; | |
519 | vHitStoreIntID[nHits] = nHits; | |
4c256004 | 520 | vHitStoreID[nHits] = pSP->fID; |
dc4788ec | 521 | vHitRowID[nHits] = pSP->fPadRow; |
4c256004 | 522 | nHits++; |
00d07bcd | 523 | rowNHits[pSP->fPadRow]++; |
4c256004 | 524 | } |
00d07bcd | 525 | |
526 | Int_t firstRowHit = 0; | |
527 | for( Int_t ir=0; ir<200; ir++ ){ | |
528 | rowFirstHits[ir] = firstRowHit; | |
529 | firstRowHit+=rowNHits[ir]; | |
eb30eb49 | 530 | } |
00d07bcd | 531 | |
532 | fTracker->ReadEvent( rowFirstHits, rowNHits, vHitStoreY, vHitStoreZ, nHits ); | |
4c256004 | 533 | } |
00d07bcd | 534 | |
eb30eb49 | 535 | if( vOrigClusters ) delete[] vOrigClusters; |
4c256004 | 536 | |
cf471b1e | 537 | // reconstruct the event |
538 | ||
dc4788ec | 539 | TStopwatch timerReco; |
540 | ||
cf471b1e | 541 | fTracker->Reconstruct(); |
542 | ||
dc4788ec | 543 | timerReco.Stop(); |
544 | ||
4c256004 | 545 | Int_t ret = 0; |
546 | ||
547 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reconstruct", | |
548 | "%d tracks found for slice %d",fTracker->NOutTracks(), slice); | |
cf471b1e | 549 | |
550 | // write reconstructed tracks | |
551 | ||
552 | AliHLTTPCTrackletData* outPtr = (AliHLTTPCTrackletData*)(outputPtr); | |
553 | ||
554 | AliHLTTPCTrackSegmentData* currOutTracklet = outPtr->fTracklets; | |
555 | ||
556 | Int_t ntracks = fTracker->NOutTracks(); | |
4c256004 | 557 | |
558 | UInt_t mySize = ((AliHLTUInt8_t *)currOutTracklet) - ((AliHLTUInt8_t *)outputPtr); | |
559 | ||
560 | outPtr->fTrackletCnt = 0; | |
561 | ||
cf471b1e | 562 | for( int itr=0; itr<ntracks; itr++ ){ |
563 | ||
564 | AliHLTTPCCAOutTrack &t = fTracker->OutTracks()[itr]; | |
4c256004 | 565 | |
566 | //Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Wrtite output","track %d with %d hits", itr, t.NHits()); | |
567 | ||
d54804bf | 568 | if( t.NHits()<fMinNTrackClusters ) continue; |
569 | ||
4c256004 | 570 | // calculate output track size |
571 | ||
572 | UInt_t dSize = sizeof(AliHLTTPCTrackSegmentData) + t.NHits()*sizeof(UInt_t); | |
573 | ||
00d07bcd | 574 | if( mySize + dSize > maxBufferSize ){ |
575 | Logging( kHLTLogWarning, "HLT::TPCCATracker::DoEvent", "Wrtite output","Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", maxBufferSize, mySize, ntracks-itr+1); | |
4c256004 | 576 | ret = -ENOSPC; |
577 | break; | |
578 | } | |
579 | ||
580 | // convert CA track parameters to HLT Track Segment | |
eb30eb49 | 581 | |
582 | Int_t iFirstRow = 1000; | |
583 | Int_t iLastRow = -1; | |
cf471b1e | 584 | Int_t iFirstHit = fTracker->OutTrackHits()[t.FirstHitRef()]; |
eb30eb49 | 585 | Int_t iLastHit = iFirstHit; |
586 | for( Int_t ih=0; ih<t.NHits(); ih++ ){ | |
587 | Int_t hitID = fTracker->OutTrackHits()[t.FirstHitRef() + ih ]; | |
588 | Int_t iRow = vHitRowID[hitID]; | |
589 | if( iRow<iFirstRow ){ iFirstRow = iRow; iFirstHit = hitID; } | |
590 | if( iRow>iLastRow ){ iLastRow = iRow; iLastHit = hitID; } | |
591 | } | |
592 | ||
d54804bf | 593 | AliHLTTPCCATrackParam par = t.StartPoint(); |
594 | ||
00d07bcd | 595 | par.TransportToX( vHitStoreX[iFirstHit], .99 ); |
d54804bf | 596 | |
597 | AliExternalTrackParam tp; | |
eb30eb49 | 598 | AliHLTTPCCATrackConvertor::GetExtParam( par, tp, 0, fSolenoidBz ); |
d54804bf | 599 | |
600 | currOutTracklet->fX = tp.GetX(); | |
601 | currOutTracklet->fY = tp.GetY(); | |
602 | currOutTracklet->fZ = tp.GetZ(); | |
00d07bcd | 603 | currOutTracklet->fCharge = (Int_t ) tp.GetSign(); |
d54804bf | 604 | currOutTracklet->fPt = TMath::Abs(tp.GetSignedPt()); |
eb30eb49 | 605 | Float_t snp = tp.GetSnp() ; |
d54804bf | 606 | if( snp>.999 ) snp=.999; |
5b41cd63 | 607 | if( snp<-.999 ) snp=-.999; |
d54804bf | 608 | currOutTracklet->fPsi = TMath::ASin( snp ); |
609 | currOutTracklet->fTgl = tp.GetTgl(); | |
eb30eb49 | 610 | |
611 | currOutTracklet->fY0err = tp.GetSigmaY2(); | |
612 | currOutTracklet->fZ0err = tp.GetSigmaZ2(); | |
613 | Float_t h = -currOutTracklet->fPt*currOutTracklet->fPt; | |
d54804bf | 614 | currOutTracklet->fPterr = h*h*tp.GetSigma1Pt2(); |
615 | h = 1./TMath::Sqrt(1-snp*snp); | |
616 | currOutTracklet->fPsierr = h*h*tp.GetSigmaSnp2(); | |
617 | currOutTracklet->fTglerr = tp.GetSigmaTgl2(); | |
eb30eb49 | 618 | |
00d07bcd | 619 | if( par.TransportToX( vHitStoreX[iLastHit],.99 ) ){ |
eb30eb49 | 620 | currOutTracklet->fLastX = par.GetX(); |
621 | currOutTracklet->fLastY = par.GetY(); | |
622 | currOutTracklet->fLastZ = par.GetZ(); | |
623 | } else { | |
624 | currOutTracklet->fLastX = vHitStoreX[iLastHit]; | |
625 | currOutTracklet->fLastY = vHitStoreY[iLastHit]; | |
626 | currOutTracklet->fLastZ = vHitStoreZ[iLastHit]; | |
627 | } | |
628 | //if( currOutTracklet->fLastX<10. ) { | |
629 | //HLTError("CA last point: hitxyz=%f,%f,%f, track=%f,%f,%f, tracklet=%f,%f,%f, nhits=%d",vHitStoreX[iLastHit],vHitStoreY[iLastHit],vHitStoreZ[iLastHit], | |
630 | //par.GetX(), par.GetY(),par.GetZ(),currOutTracklet->fLastX,currOutTracklet->fLastY ,currOutTracklet->fLastZ, t.NHits()); | |
631 | //} | |
dc4788ec | 632 | #ifdef INCLUDE_TPC_HOUGH |
633 | #ifdef ROWHOUGHPARAMS | |
634 | currOutTracklet->fTrackID = 0; | |
635 | currOutTracklet->fRowRange1 = vHitRowID[iFirstHit]; | |
636 | currOutTracklet->fRowRange2 = vHitRowID[iLastHit]; | |
637 | currOutTracklet->fSector = slice; | |
638 | currOutTracklet->fPID = 211; | |
639 | #endif | |
640 | #endif // INCLUDE_TPC_HOUGH | |
641 | ||
642 | ||
cf471b1e | 643 | currOutTracklet->fNPoints = t.NHits(); |
644 | ||
645 | for( Int_t i=0; i<t.NHits(); i++ ){ | |
4c256004 | 646 | currOutTracklet->fPointIDs[i] = vHitStoreID[fTracker->OutTrackHits()[t.FirstHitRef()+i]]; |
cf471b1e | 647 | } |
4c256004 | 648 | |
649 | currOutTracklet = (AliHLTTPCTrackSegmentData*)( (Byte_t *)currOutTracklet + dSize ); | |
650 | mySize+=dSize; | |
651 | outPtr->fTrackletCnt++; | |
cf471b1e | 652 | } |
d54804bf | 653 | |
eb30eb49 | 654 | if( vHitStoreX ) delete[] vHitStoreX; |
655 | if( vHitStoreY ) delete[] vHitStoreY; | |
656 | if( vHitStoreZ ) delete[] vHitStoreZ; | |
00d07bcd | 657 | if( vHitStoreIntID ) delete[] vHitStoreIntID; |
eb30eb49 | 658 | if( vHitStoreID ) delete[] vHitStoreID; |
659 | if( vHitRowID ) delete[] vHitRowID; | |
cf471b1e | 660 | |
cf471b1e | 661 | AliHLTComponentBlockData bd; |
662 | FillBlockData( bd ); | |
4c256004 | 663 | bd.fOffset = 0; |
cf471b1e | 664 | bd.fSize = mySize; |
665 | bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch ); | |
666 | outputBlocks.push_back( bd ); | |
667 | ||
cf471b1e | 668 | size = mySize; |
669 | ||
d54804bf | 670 | timer.Stop(); |
671 | ||
eb30eb49 | 672 | fFullTime+= timer.RealTime(); |
673 | fRecoTime+= timerReco.RealTime(); | |
d54804bf | 674 | fNEvents++; |
dc4788ec | 675 | |
676 | // Set log level to "Warning" for on-line system monitoring | |
eb30eb49 | 677 | Int_t hz = (Int_t) (fFullTime>1.e-10 ?fNEvents/fFullTime :100000); |
678 | Int_t hz1 = (Int_t) (fRecoTime>1.e-10 ?fNEvents/fRecoTime :100000); | |
d54804bf | 679 | Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Tracks", |
eb30eb49 | 680 | "CATracker slice %d: output %d tracks; input %d clusters, patches %d..%d, rows %d..%d; reco time %d/%d Hz", |
681 | slice, ntracks, nClusters, minPatch, maxPatch, row[0], row[1], hz, hz1 ); | |
dc4788ec | 682 | |
4c256004 | 683 | return ret; |
cf471b1e | 684 | } |
685 | ||
686 |