3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliHLTTPCStandardIncludes.h"
9 #include "AliHLTTPCLogging.h"
10 #include "AliHLTTPCVertex.h"
11 #include "AliHLTTPCConfMapTrack.h"
12 #include "AliHLTTPCConfMapPoint.h"
13 #include "AliHLTTPCTrackArray.h"
14 #include "AliHLTTPCTransform.h"
15 #include "AliHLTTPCConfMapper.h"
17 /** \class AliHLTTPCConfMapper
19 //_____________________________________________________________
20 // AliHLTTPCConfMapper
22 // Conformal mapping base class
27 ClassImp(AliHLTTPCConfMapper)
29 Double_t AliHLTTPCConfMapper::pi=3.14159265358979323846;
30 Double_t AliHLTTPCConfMapper::twopi=2*pi;
31 Double_t AliHLTTPCConfMapper::todeg=180./pi;
33 AliHLTTPCConfMapper::AliHLTTPCConfMapper()
41 fBench = (Bool_t)true;
42 fVertexConstraint = (Bool_t)true;
48 AliHLTTPCConfMapper::~AliHLTTPCConfMapper()
67 void AliHLTTPCConfMapper::InitVolumes()
70 //Allocate volumes, set conformal coordinates and pointers.
72 //Should be done after setting the track parameters
74 fNumRowSegmentPlusOne = AliHLTTPCTransform::GetNRows();//NumRows[0]; //Maximum 32.
75 fNumPhiSegmentPlusOne = fNumPhiSegment+1;
76 fNumEtaSegmentPlusOne = fNumEtaSegment+1;
77 fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
78 fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
81 if(fVolume) delete [] fVolume;
82 if(fRow) delete [] fRow;
84 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
85 "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
86 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
87 "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
89 fVolume = new AliHLTTPCConfMapContainer[fBounds];
90 fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
92 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
93 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
95 //Int_t max_num_of_tracks = 2000;
96 //Int_t max_num_of_hits = 120000;
97 Int_t max_num_of_tracks = 3500;
98 Int_t max_num_of_hits = 200000;
105 fHit = new AliHLTTPCConfMapPoint[max_num_of_hits];
106 fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",max_num_of_tracks);
109 void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
110 { //sector means slice here
111 //Initialize tracker for tracking in a given sector.
112 //Resets track and hit arrays.
113 //Here it is also possible to specify a subsector, by defining
114 //rowrange[0]=innermost row;
115 //rowrange[1]=outermostrow;
116 //Finally you can specify etaslices to save time (assuming a good seed from TRD...)
118 //Define tracking area:
121 fRowMin = rowrange[0];
122 fRowMax = rowrange[1];
124 else //complete sector
127 fRowMax = AliHLTTPCTransform::GetNRows() - 1;
131 fEtaMin = etarange[0];
132 fEtaMax = sector < 18 ? etarange[1] : -etarange[1];
137 fEtaMax = sector < 18 ? 0.9 : -0.9;
140 //Set the angles to sector 2:
141 fPhiMin = -1.*10/todeg;//fParam->GetAngle(sector) - 10/todeg;
142 fPhiMax = 10/todeg;//fParam->GetAngle(sector) + 10/todeg;
145 fMainVertexTracks = 0;
147 fEtaHitsOutOfRange=0;
148 fPhiHitsOutOfRange=0;
150 fNumRowSegment = fRowMax - fRowMin; //number of rows to be considered by tracker
151 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitSector","B-field")
152 <<"Tracker initializing with a magnetic field of "<<AliHLTTPCTransform::GetBField()<<ENDLOG;
157 Bool_t AliHLTTPCConfMapper::ReadHits(UInt_t count, AliHLTTPCSpacePointData* hits )
159 Int_t nhit=(Int_t)count;
160 for(Int_t i=0;i<nhit;i++)
162 fHit[fClustersUnused].Reset();
163 fHit[fClustersUnused].ReadHits(&(hits[i]));
166 // for (Int_t i=0;i<nhit;i++)
169 // fHit[i].ReadHits(&(hits[i]));
171 // fClustersUnused += nhit;
172 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::ReadHits","#hits")
173 <<AliHLTTPCLog::kDec<<"hit_counter: "<<nhit<<" count: "<<count<<ENDLOG;
178 void AliHLTTPCConfMapper::SetPointers()
180 //Check if there are not enough clusters to make a track in this sector
181 //Can happen in pp events.
183 if(fClustersUnused < fMinPoints[fVertexConstraint])
186 //Reset detector volumes
187 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
188 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
190 Float_t phiSlice = (fPhiMax-fPhiMin)/fNumPhiSegment;
191 Float_t etaSlice = (fEtaMax-fEtaMin)/fNumEtaSegment;
194 Int_t local_counter=0;
195 for(Int_t j=0; j<fClustersUnused; j++)
197 //AliHLTTPCConfMapPoint *thisHit = (AliHLTTPCConfMapPoint*)fHit->At(j);
198 AliHLTTPCConfMapPoint *thisHit = &(fHit[j]);
200 thisHit->Setup(fVertex);
202 Int_t localrow = thisHit->GetPadRow();
204 if(localrow < fRowMin || localrow > fRowMax)
208 thisHit->phiIndex=(Int_t)((thisHit->GetPhi()-fPhiMin)/phiSlice +1);
210 if(thisHit->phiIndex<1 || thisHit->phiIndex>fNumPhiSegment)
212 //cout << "Phiindex: " << thisHit->phiIndex << " " << thisHit->GetPhi() << endl;
213 fPhiHitsOutOfRange++;
217 thisHit->etaIndex=(Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1);
218 if(thisHit->etaIndex<1 || thisHit->etaIndex>fNumEtaSegment)
220 //cout << "Etaindex: " << thisHit->etaIndex << " " << thisHit->GetEta() << endl;
221 fEtaHitsOutOfRange++;
226 volumeIndex = (localrow-fRowMin)*fNumPhiEtaSegmentPlusOne+thisHit->phiIndex*fNumEtaSegmentPlusOne+thisHit->etaIndex;
228 if(fVolume[volumeIndex].first == NULL)
229 fVolume[volumeIndex].first = (void *)thisHit;
231 ((AliHLTTPCConfMapPoint *)fVolume[volumeIndex].last)->nextVolumeHit=thisHit;
232 fVolume[volumeIndex].last = (void *)thisHit;
236 if(fRow[(localrow-fRowMin)].first == NULL)
237 fRow[(localrow-fRowMin)].first = (void *)thisHit;
239 ((AliHLTTPCConfMapPoint *)(fRow[(localrow-fRowMin)].last))->nextRowHit = thisHit;
240 fRow[(localrow-fRowMin)].last = (void *)thisHit;
243 if(fClustersUnused>0 && local_counter==0)
244 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::SetPointers","Parameters")
245 <<AliHLTTPCLog::kDec<<"No points passed to track finder, hits out of range: "
246 <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
248 Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
249 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::SetPointers","Setup")
250 <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
251 <<" hits accepted "<<hits_accepted<<ENDLOG;
254 void AliHLTTPCConfMapper::MainVertexTracking_a()
256 //Tracking with vertex constraint.
258 if(!fParamSet[(Int_t)kTRUE])
260 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
261 "Tracking parameters not set!"<<ENDLOG;
265 Double_t initCpuTime,cpuTime;
266 initCpuTime = CpuTime();
269 SetVertexConstraint(true);
270 cpuTime = CpuTime() - initCpuTime;
272 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking_a","Timing")
273 <<AliHLTTPCLog::kDec<<"Setup finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
277 void AliHLTTPCConfMapper::MainVertexTracking_b()
279 //Tracking with vertex constraint.
281 if(!fParamSet[(Int_t)kTRUE])
283 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
284 "Tracking parameters not set!"<<ENDLOG;
287 Double_t initCpuTime,cpuTime;
288 initCpuTime = CpuTime();
292 cpuTime = CpuTime() - initCpuTime;
294 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking_b","Timing")
295 <<AliHLTTPCLog::kDec<<"Main Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
298 void AliHLTTPCConfMapper::MainVertexTracking()
300 //Tracking with vertex constraint.
302 if(!fParamSet[(Int_t)kTRUE])
304 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
305 "Tracking parameters not set!"<<ENDLOG;
309 Double_t initCpuTime,cpuTime;
310 initCpuTime = CpuTime();
313 SetVertexConstraint(true);
317 cpuTime = CpuTime() - initCpuTime;
319 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
320 "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
325 void AliHLTTPCConfMapper::NonVertexTracking()
327 //Tracking with no vertex constraint. This should be called after doing MainVertexTracking,
328 //in order to do tracking on the remaining clusters.
329 //The conformal mapping is now done with respect to the first cluster
330 //assosciated with this track.
332 if(!fParamSet[(Int_t)kFALSE])
334 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::NonVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
335 "Tracking parameters not set!"<<ENDLOG;
339 SetVertexConstraint(false);
341 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::NonVertexTracking","ntracks")<<AliHLTTPCLog::kDec<<
342 "Number of nonvertex tracks found: "<<(nTracks-fMainVertexTracks)<<ENDLOG;
346 void AliHLTTPCConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength,
347 Int_t rowscopetracklet, Int_t rowscopetrack,
348 Double_t maxphi,Double_t maxeta)
350 //Settings for main vertex tracking. The cuts are:
351 //TrackletLength: #hits on segment, before trying to build a track
352 //TrackLength: Minimum hits on a track
353 //RowScopeTracklet: Row search range for segments
354 //RowScopeTrack: Row search range for tracks
356 SetTrackletLength(trackletlength,(Bool_t)true);
357 SetRowScopeTracklet(rowscopetracklet, (Bool_t) true);
358 SetRowScopeTrack(rowscopetrack, (Bool_t) true);
359 SetMinPoints(tracklength,(Bool_t)true);
365 void AliHLTTPCConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
366 Int_t rowscopetracklet, Int_t rowscopetrack)
368 SetTrackletLength(trackletlength,(Bool_t)false);
369 SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
370 SetRowScopeTrack(rowscopetrack, (Bool_t)false);
371 SetMinPoints(tracklength,(Bool_t)false);
372 SetParamDone(kFALSE);
375 void AliHLTTPCConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
377 //Settings for tracks. The cuts are:
378 //HitChi2Cut: Maximum hit chi2
379 //goodHitChi2: Chi2 to stop look for next hit
380 //trackChi2Cut: Maximum track chi2
381 //maxdist: Maximum distance between two clusters when forming segments
383 SetHitChi2Cut(hitChi2Cut,vertexconstraint);
384 SetGoodHitChi2(goodHitChi2,vertexconstraint);
385 SetTrackChi2Cut(trackChi2Cut,vertexconstraint);
386 SetMaxDist(maxdist,vertexconstraint);
389 void AliHLTTPCConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_t vertex_constraint)
391 //Sets cuts of tracklets. Right now this is only:
392 //maxangle: Maximum angle when forming segments (if trackletlength > 2)
395 SetMaxAngleTracklet(maxangle, vertex_constraint);
398 void AliHLTTPCConfMapper::ClusterLoop()
400 //Loop over hits, starting at outermost padrow, and trying to build segments.
402 //Check if there are not enough clusters to make a track in this sector
403 //Can happen in pp events.
404 if(fClustersUnused < fMinPoints[fVertexConstraint])
407 Int_t row_segm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
408 AliHLTTPCConfMapPoint *hit;
410 //Loop over rows, and try to create tracks from the hits.
411 //Starts at the outermost row, and loops as long as a track can be build, due to length.
413 for(row_segm = fRowMax; row_segm >= lastrow; row_segm--)
415 if(fRow[(row_segm-fRowMin)].first && ((AliHLTTPCConfMapPoint*)fRow[(row_segm-fRowMin)].first)->GetPadRow() < fRowMin + 1)
418 for(hit = (AliHLTTPCConfMapPoint*)fRow[(row_segm-fRowMin)].first; hit!=0; hit=hit->nextRowHit)
420 if(hit->GetUsage() == true)
431 void AliHLTTPCConfMapper::CreateTrack(AliHLTTPCConfMapPoint *hit)
433 //Tries to create a track from the initial hit given by ClusterLoop()
435 AliHLTTPCConfMapPoint *closest_hit = NULL;
436 AliHLTTPCConfMapTrack *track = NULL;
439 Int_t tracks = nTracks;
442 track = (AliHLTTPCConfMapTrack*)fTrack->NextTrack();
444 //reset hit parameters:
447 UInt_t *trackhitnumber = track->GetHitNumbers();
449 //set conformal coordinates if we are looking for non vertex tracks
450 if(!fVertexConstraint)
452 hit->SetAllCoord(hit);
455 //fill fit parameters of initial track:
456 track->UpdateParam(hit); //here the number of hits is incremented.
457 trackhitnumber[track->GetNumberOfPoints()-1] = hit->GetHitNumber();
462 for(point=1; point<fTrackletLength[fVertexConstraint]; point++)
464 if((closest_hit = GetNextNeighbor(hit)))
467 // Calculate track length in sz plane
468 dx = ((AliHLTTPCConfMapPoint*)closest_hit)->GetX() - ((AliHLTTPCConfMapPoint*)hit)->GetX();
469 dy = ((AliHLTTPCConfMapPoint*)closest_hit)->GetY() - ((AliHLTTPCConfMapPoint*)hit)->GetY();
470 //track->fLength += (Double_t)sqrt ( dx * dx + dy * dy ) ;
471 Double_t length = track->GetLength()+(Double_t)sqrt ( dx * dx + dy * dy );
472 track->SetLength(length);
474 //closest_hit->SetS(track->fLength);
475 closest_hit->SetS(track->GetLength());
477 //update fit parameters
478 track->UpdateParam(closest_hit);
479 trackhitnumber[track->GetNumberOfPoints()-1] = closest_hit->GetHitNumber();
485 //closest hit does not exist:
486 track->DeleteCandidate();
487 fTrack->RemoveLast();
489 point = fTrackletLength[fVertexConstraint];
493 //tracklet is long enough to be extended to a track
494 if(track->GetNumberOfPoints() == fTrackletLength[fVertexConstraint])
497 track->SetProperties(true);
499 if(TrackletAngle(track) > fMaxAngleTracklet[fVertexConstraint])
500 {//proof if the first points seem to be a beginning of a track
501 track->SetProperties(false);
502 track->DeleteCandidate();
503 fTrack->RemoveLast();
507 else//good tracklet ->proceed, follow the trackfit
511 //define variables to keep the total chi:
512 Double_t xyChi2 = track->fChiSq[0];
513 Double_t szChi2 = track->fChiSq[1];
515 for(point = fTrackletLength[fVertexConstraint]; point <= fNumRowSegment; point++)
517 track->fChiSq[0] = fHitChi2Cut[fVertexConstraint];
518 closest_hit = GetNextNeighbor((AliHLTTPCConfMapPoint*)track->lastHit,track);
524 Double_t lxyChi2 = track->fChiSq[0]-track->fChiSq[1];
526 closest_hit->xyChi2 = lxyChi2;
528 //update track length:
529 //track->fLength = closest_hit->GetS();
530 track->SetLength(closest_hit->GetS());
531 szChi2 += track->fChiSq[1];
532 closest_hit->szChi2 = track->fChiSq[1];
534 track->UpdateParam(closest_hit);
535 trackhitnumber[track->GetNumberOfPoints()-1] = closest_hit->GetHitNumber();
537 //add closest hit to track
538 closest_hit->SetUsage(true);
539 closest_hit->SetTrackNumber(tracks-1);
545 //closest hit does not exist
546 point = fNumRowSegment; //continue with next hit in segment
552 track->fChiSq[0] = xyChi2;
553 track->fChiSq[1] = szChi2;
554 Double_t normalized_chi2 = (track->fChiSq[0]+track->fChiSq[1])/track->GetNumberOfPoints();
556 //remove tracks with not enough points already now
557 if(track->GetNumberOfPoints() < fMinPoints[fVertexConstraint] || normalized_chi2 > fTrackChi2Cut[fVertexConstraint])
559 track->SetProperties(false);
561 track->DeleteCandidate();
562 fTrack->RemoveLast();
568 fClustersUnused -= track->GetNumberOfPoints();
569 track->ComesFromMainVertex(fVertexConstraint);
570 //mark track as main vertex track or not
571 track->SetSector(2); //only needed for testing purposes.
572 track->SetRowRange(fRowMin,fRowMax);
574 if(fVertexConstraint)
585 AliHLTTPCConfMapPoint *AliHLTTPCConfMapper::GetNextNeighbor(AliHLTTPCConfMapPoint *start_hit,
586 AliHLTTPCConfMapTrack *track)
588 //When forming segments: Finds closest hit to input hit
589 //When forming tracks: Find closest hit to track fit.
591 Double_t dist,closest_dist = fMaxDist[fVertexConstraint];
593 AliHLTTPCConfMapPoint *hit = NULL;
594 AliHLTTPCConfMapPoint *closest_hit = NULL;
602 Int_t max_row = start_hit->GetPadRow()-1;
605 if(track) //finding hit close to trackfit
607 min_row = start_hit->GetPadRow()-fRowScopeTrack[fVertexConstraint];
611 min_row = start_hit->GetPadRow()-fRowScopeTracklet[fVertexConstraint];
615 Int_t loop_eta[25] = {0,0,0,-1,-1,-1,1,1,1, 0,0,-1,-1,1,1,-2,-2,-2,-2,-2,2,2,2,2,2};
616 Int_t loop_phi[25] = {0,-1,1,0,-1,1,0,-1,1, -2,2,-2,2,-2,2,-2,-1,0,1,2,-2,-1,0,1,2};
618 if(min_row < fRowMin)
620 if(max_row < fRowMin)
621 return 0; //reached the last padrow under consideration
626 for(sub_row_segm=max_row; sub_row_segm>=min_row; sub_row_segm--)
628 //loop over subsegments, in the order defined above.
629 for(Int_t i=0; i<9; i++)
631 sub_phi_segm = start_hit->phiIndex + loop_phi[i];
633 if(sub_phi_segm < 0 || sub_phi_segm >= fNumPhiSegment)
637 sub_phi_segm += fNumPhiSegment;
639 else if(sub_phi_segm >=fNumPhiSegment)
640 sub_phi_segm -= fNumPhiSegment;
642 //loop over sub eta segments
644 sub_eta_segm = start_hit->etaIndex + loop_eta[i];
646 if(sub_eta_segm < 0 || sub_eta_segm >=fNumEtaSegment)
647 continue;//segment exceeds bounds->skip it
649 //loop over hits in this sub segment:
650 volumeIndex= (sub_row_segm-fRowMin)*fNumPhiEtaSegmentPlusOne +
651 sub_phi_segm*fNumEtaSegmentPlusOne + sub_eta_segm;
655 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::GetNextNeighbor","Memory")<<AliHLTTPCLog::kDec<<
656 "VolumeIndex error "<<volumeIndex<<ENDLOG;
659 for(hit = (AliHLTTPCConfMapPoint*)fVolume[volumeIndex].first;
660 hit!=0; hit = hit->nextVolumeHit)
664 {//hit was not used before
666 //set conformal mapping if looking for nonvertex tracks:
667 if(!fVertexConstraint)
669 hit->SetAllCoord(start_hit);
672 if(track)//track search - look for nearest neighbor to extrapolated track
674 if(!VerifyRange(start_hit,hit))
677 test_hit = EvaluateHit(start_hit,hit,track);
679 if(test_hit == 0)//chi2 not good enough, keep looking
681 else if(test_hit==2)//chi2 good enough, return it
684 closest_hit = hit;//chi2 acceptable, but keep looking
688 else //tracklet search, look for nearest neighbor
691 if((dist=CalcDistance(start_hit,hit)) < closest_dist)
693 if(!VerifyRange(start_hit,hit))
698 //if this hit is good enough, return it:
699 if(closest_dist < fGoodDist)
703 continue;//sub hit was farther away than a hit before
707 }//hit not used before
709 else continue; //sub hit was used before
711 }//loop over hits in sub segment
713 }//loop over sub segments
720 if(closest_hit)// && closest_dist < mMaxDist)
726 Int_t AliHLTTPCConfMapper::EvaluateHit(AliHLTTPCConfMapPoint *start_hit,AliHLTTPCConfMapPoint *hit,AliHLTTPCConfMapTrack *track)
728 //Check if space point gives a fit with acceptable chi2.
730 Double_t temp,dxy,lchi2,dx,dy,slocal,dsz,lszChi2;
731 temp = (track->a2Xy*hit->GetXprime()-hit->GetYprime()+track->a1Xy);
732 dxy = temp*temp/(track->a2Xy*track->a2Xy + 1.);
735 lchi2 = (dxy*hit->GetXYWeight());
737 if(lchi2 > track->fChiSq[0])//chi2 was worse than before.
740 //calculate s and the distance hit-line
741 dx = start_hit->GetX()-hit->GetX();
742 dy = start_hit->GetY()-hit->GetY();
743 //slocal = track->fLength+sqrt(dx*dx+dy*dy);
744 slocal = track->GetLength()+sqrt(dx*dx+dy*dy);
746 temp = (track->a2Sz*slocal-hit->GetZ()+track->a1Sz);
747 dsz = temp*temp/(track->a2Sz*track->a2Sz+1);
750 lszChi2 = dsz*hit->GetZWeight();
754 //check whether chi2 is better than previous one:
755 if(lchi2 < track->fChiSq[0])
757 track->fChiSq[0] = lchi2;
758 track->fChiSq[1] = lszChi2;
762 //if chi2 good enough, stop here:
763 if(lchi2 < fGoodHitChi2[fVertexConstraint])
773 Double_t AliHLTTPCConfMapper::CalcDistance(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
775 //Return distance between two clusters, defined by Pablo
777 Double_t phi_diff = fabs( hit1->GetPhi() - hit2->GetPhi() );
778 if (phi_diff > pi) phi_diff = twopi - phi_diff;
780 return todeg*fabs((Float_t)((hit1->GetPadRow() - hit2->GetPadRow()) * (phi_diff + fabs( hit1->GetEta() - hit2->GetEta()))));
783 Bool_t AliHLTTPCConfMapper::VerifyRange(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
785 //Check if the hit are within reasonable range in phi and eta
786 Double_t dphi,deta;//maxphi=0.1,maxeta=0.1;
787 dphi = fabs(hit1->GetPhi() - hit2->GetPhi());
788 if(dphi > pi) dphi = fabs(twopi - dphi);
789 if(dphi > fMaxPhi) return false;
791 deta = fabs(hit1->GetEta() - hit2->GetEta());
792 if(deta > fMaxEta) return false;
798 Double_t AliHLTTPCConfMapper::TrackletAngle(AliHLTTPCConfMapTrack *track,Int_t n) const
800 // Returns the angle 'between' the last three points (started at point number n) on this track.
802 if(n > track->GetNumberOfPoints())
803 n = track->GetNumberOfPoints();
811 Double_t angle1,angle2;
813 for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
815 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)track->currentHit;
816 if( (n-1) == counter)
821 else if( (n-2) == counter)
826 else if( (n-3) == counter)
834 angle1 = atan2(x2[1]-x3[1],x2[0]-x3[0]);
835 angle2 = atan2(x1[1]-x2[1],x1[0]-x2[0]);
837 return fabs(angle1-angle2);
842 Double_t angle1,angle2;
843 TObjArray *hits = track->GetHits();
845 if (n > track->GetNumberOfPoints()) {
846 n = track->GetNumberOfPoints();
853 x1[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetX();
854 x1[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetY();
856 x2[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX();
857 x2[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY();
859 angle1 = atan2(x1[1],x1[0]);
860 angle2 = atan2(x2[1],x1[0]);
861 return fabs(angle1-angle2);
865 Int_t AliHLTTPCConfMapper::FillTracks()
867 //Fill track parameters. Which basically means do a fit of helix in real space,
868 //which should be done in order to get nice tracks.
870 Int_t num_of_tracks = nTracks;
871 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::FillTracks","nTracks")<<AliHLTTPCLog::kDec<<
872 "Number of found tracks: "<<nTracks<<ENDLOG;
876 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::FillTracks","nTracks")<<AliHLTTPCLog::kDec<<
877 "No tracks found!!"<<ENDLOG;
882 for(int i=0; i<num_of_tracks; i++)
884 AliHLTTPCConfMapTrack *track = (AliHLTTPCConfMapTrack*)fTrack->GetTrack(i);
885 track->Fill(fVertex,fMaxDca);
892 Double_t AliHLTTPCConfMapper::CpuTime()
894 //Return the Cputime in seconds.
896 gettimeofday( &tv, NULL );
897 return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.);
898 //return (Double_t)(clock()) / CLOCKS_PER_SEC;