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