2 // Original: AliHLTConfMapper.cxx,v 1.26 2005/06/14 10:55:21 cvetan Exp $
4 /** \class AliHLTTPCConfMapper
6 //_____________________________________________________________
9 // Conformal mapping base class
11 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
12 // Copyright © ALICE HLT Group
19 #include "AliHLTTPCRootTypes.h"
20 #include "AliHLTTPCSpacePointData.h"
21 #include "AliHLTTPCLogging.h"
22 #include "AliHLTTPCVertex.h"
23 #include "AliHLTTPCConfMapTrack.h"
24 #include "AliHLTTPCConfMapPoint.h"
25 #include "AliHLTTPCTrackArray.h"
26 #include "AliHLTTPCTransform.h"
27 #include "AliHLTTPCConfMapper.h"
33 ClassImp(AliHLTTPCConfMapper)
35 AliHLTTPCConfMapper::AliHLTTPCConfMapper()
40 fVertexFinder(kFALSE),
43 fMaxDca(0.0), // no clue whether this is reasonable, but at least better than without initialization
49 fNumRowSegmentPlusOne(0),
50 fNumPhiSegmentPlusOne(0),
51 fNumEtaSegmentPlusOne(0),
52 fNumPhiEtaSegmentPlusOne(0),
54 fPhiHitsOutOfRange(0),
55 fEtaHitsOutOfRange(0),
62 fVertexConstraint(kTRUE),
75 AliHLTTPCConfMapper::~AliHLTTPCConfMapper()
86 void AliHLTTPCConfMapper::InitVolumes()
89 //Allocate volumes, set conformal coordinates and pointers.
91 //Should be done after setting the track parameters
93 fNumRowSegmentPlusOne = AliHLTTPCTransform::GetNRows();//NumRows[0]; //Maximum 32.
94 fNumPhiSegmentPlusOne = fNumPhiSegment+1;
95 fNumEtaSegmentPlusOne = fNumEtaSegment+1;
96 fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
97 fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
101 fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",10);
104 void AliHLTTPCConfMapper::Reset()
106 if(fVolume) delete [] fVolume;
108 if(fRow) delete [] fRow;
115 void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
116 { //sector means slice here
117 //Initialize tracker for tracking in a given sector.
118 //Resets track and hit arrays.
119 //Here it is also possible to specify a subsector, by defining
120 //rowrange[0]=innermost row;
121 //rowrange[1]=outermostrow;
122 //Finally you can specify etaslices to save time (assuming a good seed from TRD...)
124 //Define tracking area:
127 fRowMin = rowrange[0];
128 fRowMax = rowrange[1];
130 else //complete sector
133 fRowMax = AliHLTTPCTransform::GetNRows() - 1;
137 fEtaMin = etarange[0];
138 fEtaMax = sector < 18 ? etarange[1] : -etarange[1];
143 fEtaMax = sector < 18 ? 0.9 : -0.9;
146 //Set the angles to sector 2:
147 fPhiMin = -10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) - 10/todeg;
148 fPhiMax = 10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) + 10/todeg;
151 fMainVertexTracks = 0;
153 fEtaHitsOutOfRange=0;
154 fPhiHitsOutOfRange=0;
156 fNumRowSegment = fRowMax - fRowMin; //number of rows to be considered by tracker
157 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitSector","B-field")
158 <<"Tracker initializing with a magnetic field of "<<AliHLTTPCTransform::GetBField()<<ENDLOG;
163 Bool_t AliHLTTPCConfMapper::ReadHits(UInt_t count, AliHLTTPCSpacePointData* hits )
166 if (fHit.size()<fClustersUnused+count) fHit.resize(fClustersUnused+count);
167 assert(fHit.size()>=fClustersUnused+count);
168 for (Int_t i=0;(UInt_t)i<count;i++)
170 fHit[i+fClustersUnused].Reset();
171 fHit[i+fClustersUnused].Read(hits[i]);
173 fClustersUnused += count;
175 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::ReadHits","#hits")
176 <<AliHLTTPCLog::kDec<<"#hits: "<<count<<" total: "<<fClustersUnused<<ENDLOG;
181 void AliHLTTPCConfMapper::SetPointers()
183 //Check if there are not enough clusters to make a track in this sector
184 //Can happen in pp events.
186 if(fClustersUnused < fMinPoints[fVertexConstraint])
189 //Allocate detector volumes
191 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
192 "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
193 fVolume = new AliHLTTPCConfMapContainer[fBounds];
197 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
198 "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
199 fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
202 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
203 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
205 Float_t phiSlice = (fPhiMax-fPhiMin)/fNumPhiSegment;
206 Float_t etaSlice = (fEtaMax-fEtaMin)/fNumEtaSegment;
209 Int_t localcounter=0;
210 assert((int)fHit.size()>=fClustersUnused);
211 for(Int_t j=0; j<fClustersUnused; j++)
213 AliHLTTPCConfMapPoint *thisHit = &(fHit[j]);
215 thisHit->Setup(fVertex);
217 Int_t localrow = thisHit->GetPadRow();
219 if(localrow < fRowMin || localrow > fRowMax)
223 thisHit->SetPhiIndex((Int_t)((thisHit->GetPhi()-fPhiMin)/phiSlice +1));
225 if(thisHit->GetPhiIndex()<1 || thisHit->GetPhiIndex()>fNumPhiSegment)
227 //cout << "Phiindex: " << thisHit->phiIndex << " " << thisHit->GetPhi() << endl;
228 fPhiHitsOutOfRange++;
232 thisHit->SetEtaIndex((Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1));
233 if(thisHit->GetEtaIndex()<1 || thisHit->GetEtaIndex()>fNumEtaSegment)
235 //cout << "Etaindex: " << thisHit->etaIndex << " " << thisHit->GetEta() << endl;
236 fEtaHitsOutOfRange++;
241 volumeIndex = (localrow-fRowMin)*fNumPhiEtaSegmentPlusOne +
242 thisHit->GetPhiIndex()*fNumEtaSegmentPlusOne+thisHit->GetEtaIndex();
244 if(fVolume[volumeIndex].first == NULL)
245 fVolume[volumeIndex].first = (void *)thisHit;
247 ((AliHLTTPCConfMapPoint *)fVolume[volumeIndex].last)->SetNextVolumeHit(thisHit);
248 fVolume[volumeIndex].last = (void *)thisHit;
252 if(fRow[(localrow-fRowMin)].first == NULL)
253 fRow[(localrow-fRowMin)].first = (void *)thisHit;
255 ((AliHLTTPCConfMapPoint *)(fRow[(localrow-fRowMin)].last))->SetNextRowHit(thisHit);
256 fRow[(localrow-fRowMin)].last = (void *)thisHit;
259 if(fClustersUnused>0 && localcounter==0)
260 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::SetPointers","Parameters")
261 <<AliHLTTPCLog::kDec<<"No points passed to track finder, hits out of range: "
262 <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
264 Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
265 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::SetPointers","Setup")
266 <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
267 <<" hits accepted "<<hits_accepted<<ENDLOG;
270 void AliHLTTPCConfMapper::MainVertexTrackingA()
272 //Tracking with vertex constraint.
274 if(!fParamSet[(Int_t)kTRUE])
276 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
277 "Tracking parameters not set!"<<ENDLOG;
281 Double_t initCpuTime,cpuTime;
282 initCpuTime = CpuTime();
285 SetVertexConstraint(true);
286 cpuTime = CpuTime() - initCpuTime;
288 LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTrackingA","Timing")
289 <<AliHLTTPCLog::kDec<<"Setup finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
293 void AliHLTTPCConfMapper::MainVertexTrackingB()
295 //Tracking with vertex constraint.
297 if(!fParamSet[(Int_t)kTRUE])
299 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
300 "Tracking parameters not set!"<<ENDLOG;
303 Double_t initCpuTime,cpuTime;
304 initCpuTime = CpuTime();
308 cpuTime = CpuTime() - initCpuTime;
310 LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTrackingB","Timing")
311 <<AliHLTTPCLog::kDec<<"Main Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
314 void AliHLTTPCConfMapper::MainVertexTracking()
316 //Tracking with vertex constraint.
318 if(!fParamSet[(Int_t)kTRUE])
320 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
321 "Tracking parameters not set!"<<ENDLOG;
325 Double_t initCpuTime,cpuTime;
326 initCpuTime = CpuTime();
330 SetVertexConstraint(true);
334 cpuTime = CpuTime() - initCpuTime;
336 LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
337 "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
342 void AliHLTTPCConfMapper::NonVertexTracking()
344 //Tracking with no vertex constraint. This should be called after doing MainVertexTracking,
345 //in order to do tracking on the remaining clusters.
346 //The conformal mapping is now done with respect to the first cluster
347 //assosciated with this track.
349 if(!fParamSet[(Int_t)kFALSE])
351 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::NonVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
352 "Tracking parameters not set!"<<ENDLOG;
356 SetVertexConstraint(false);
358 SetPointers(); //To be able to do only nonvertextracking (more testing)
361 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::NonVertexTracking","ntracks")<<AliHLTTPCLog::kDec<<
362 "Number of nonvertex tracks found: "<<(fNTracks-fMainVertexTracks)<<ENDLOG;
366 void AliHLTTPCConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength,
367 Int_t rowscopetracklet, Int_t rowscopetrack,
368 Double_t maxphi,Double_t maxeta)
370 //Settings for main vertex tracking. The cuts are:
371 //TrackletLength: #hits on segment, before trying to build a track
372 //TrackLength: Minimum hits on a track
373 //RowScopeTracklet: Row search range for segments
374 //RowScopeTrack: Row search range for tracks
376 SetTrackletLength(trackletlength,(Bool_t)true);
377 SetRowScopeTracklet(rowscopetracklet, (Bool_t) true);
378 SetRowScopeTrack(rowscopetrack, (Bool_t) true);
379 SetMinPoints(tracklength,(Bool_t)true);
385 void AliHLTTPCConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
386 Int_t rowscopetracklet, Int_t rowscopetrack)
388 //set parameters for non-vertex tracking
389 SetTrackletLength(trackletlength,(Bool_t)false);
390 SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
391 SetRowScopeTrack(rowscopetrack, (Bool_t)false);
392 SetMinPoints(tracklength,(Bool_t)false);
393 SetParamDone(kFALSE);
396 void AliHLTTPCConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
398 //Settings for tracks. The cuts are:
399 //HitChi2Cut: Maximum hit chi2
400 //goodHitChi2: Chi2 to stop look for next hit
401 //trackChi2Cut: Maximum track chi2
402 //maxdist: Maximum distance between two clusters when forming segments
404 SetHitChi2Cut(hitChi2Cut,vertexconstraint);
405 SetGoodHitChi2(goodHitChi2,vertexconstraint);
406 SetTrackChi2Cut(trackChi2Cut,vertexconstraint);
407 SetMaxDist(maxdist,vertexconstraint);
410 void AliHLTTPCConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_t vc)
412 //Sets cuts of tracklets. Right now this is only:
413 //maxangle: Maximum angle when forming segments (if trackletlength > 2)
416 SetMaxAngleTracklet(maxangle, vc);
419 void AliHLTTPCConfMapper::ClusterLoop()
421 //Loop over hits, starting at outermost padrow, and trying to build segments.
423 //Check if there are not enough clusters to make a track in this sector
424 //Can happen in pp events.
425 if(fClustersUnused < fMinPoints[fVertexConstraint])
428 Int_t rowsegm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
429 AliHLTTPCConfMapPoint *hit;
431 //Loop over rows, and try to create tracks from the hits.
432 //Starts at the outermost row, and loops as long as a track can be build, due to length.
434 for(rowsegm = fRowMax; rowsegm >= lastrow; rowsegm--)
436 if(fRow[(rowsegm-fRowMin)].first && ((AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first)->GetPadRow() < fRowMin + 1)
439 for(hit = (AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first; hit!=0; hit=hit->GetNextRowHit())
441 if(hit->GetUsage() == true)
452 void AliHLTTPCConfMapper::CreateTrack(AliHLTTPCConfMapPoint *hit)
454 //Tries to create a track from the initial hit given by ClusterLoop()
456 AliHLTTPCConfMapPoint *closesthit = NULL;
457 AliHLTTPCConfMapTrack *track = NULL;
460 Int_t tracks = fNTracks;
463 track = (AliHLTTPCConfMapTrack*)fTrack->NextTrack();
465 //reset hit parameters:
468 UInt_t *trackhitnumber = track->GetHitNumbers();
470 //set conformal coordinates if we are looking for non vertex tracks
471 if(!fVertexConstraint)
473 hit->SetAllCoord(hit);
476 //fill fit parameters of initial track:
477 track->UpdateParam(hit); //here the number of hits is incremented.
478 trackhitnumber[track->GetNumberOfPoints()-1] = hit->GetHitNumber();
483 for(point=1; point<fTrackletLength[fVertexConstraint]; point++)
485 if((closesthit = GetNextNeighbor(hit)))
488 // Calculate track length in sz plane
489 dx = ((AliHLTTPCConfMapPoint*)closesthit)->GetX() - ((AliHLTTPCConfMapPoint*)hit)->GetX();
490 dy = ((AliHLTTPCConfMapPoint*)closesthit)->GetY() - ((AliHLTTPCConfMapPoint*)hit)->GetY();
491 //track->fLength += (Double_t)sqrt ( dx * dx + dy * dy ) ;
492 Double_t length = track->GetLength()+(Double_t)sqrt ( dx * dx + dy * dy );
493 track->SetLength(length);
495 //closesthit->SetS(track->fLength);
496 closesthit->SetS(track->GetLength());
498 //update fit parameters
499 track->UpdateParam(closesthit);
500 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
506 //closest hit does not exist:
507 track->DeleteCandidate();
508 fTrack->RemoveLast();
510 point = fTrackletLength[fVertexConstraint];
514 //tracklet is long enough to be extended to a track
515 if(track->GetNumberOfPoints() == fTrackletLength[fVertexConstraint])
518 track->SetProperties(true);
520 if(TrackletAngle(track) > fMaxAngleTracklet[fVertexConstraint])
521 {//proof if the first points seem to be a beginning of a track
522 track->SetProperties(false);
523 track->DeleteCandidate();
524 fTrack->RemoveLast();
528 else//good tracklet ->proceed, follow the trackfit
532 //define variables to keep the total chi:
533 Double_t xyChi2 = track->GetChiSq1();
534 Double_t szChi2 = track->GetChiSq2();
536 for(point = fTrackletLength[fVertexConstraint]; point <= fNumRowSegment; point++)
538 track->SetChiSq1(fHitChi2Cut[fVertexConstraint]);
539 closesthit = GetNextNeighbor((AliHLTTPCConfMapPoint*)track->GetLastHit(),track);
544 Double_t lxyChi2 = track->GetChiSq1()-track->GetChiSq2();
546 closesthit->SetXYChi2(lxyChi2);
548 //update track length:
549 track->SetLength(closesthit->GetS());
550 szChi2 += track->GetChiSq2();
551 closesthit->SetSZChi2(track->GetChiSq2());
553 track->UpdateParam(closesthit);
554 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
556 //add closest hit to track
557 closesthit->SetUsage(true);
558 closesthit->SetTrackNumber(tracks-1);
564 //closest hit does not exist
565 point = fNumRowSegment; //continue with next hit in segment
571 track->SetChiSq1(xyChi2);
572 track->SetChiSq2(szChi2);
573 Double_t normalizedchi2 = (track->GetChiSq1()+track->GetChiSq2())/track->GetNumberOfPoints();
575 //remove tracks with not enough points already now
576 if(track->GetNumberOfPoints() < fMinPoints[fVertexConstraint] || normalizedchi2 > fTrackChi2Cut[fVertexConstraint])
578 track->SetProperties(false);
580 track->DeleteCandidate();
581 fTrack->RemoveLast();
587 fClustersUnused -= track->GetNumberOfPoints();
588 track->ComesFromMainVertex(fVertexConstraint);
589 //mark track as main vertex track or not
590 track->SetSector(2); //only needed for testing purposes.
591 track->SetRowRange(fRowMin,fRowMax);
593 if(fVertexConstraint)
604 AliHLTTPCConfMapPoint *AliHLTTPCConfMapper::GetNextNeighbor(AliHLTTPCConfMapPoint *starthit,
605 AliHLTTPCConfMapTrack *track)
607 //When forming segments: Finds closest hit to input hit
608 //When forming tracks: Find closest hit to track fit.
610 Double_t dist,closestdist = fMaxDist[fVertexConstraint];
612 AliHLTTPCConfMapPoint *hit = NULL;
613 AliHLTTPCConfMapPoint *closesthit = NULL;
621 Int_t maxrow = starthit->GetPadRow()-1;
624 if(track) //finding hit close to trackfit
626 minrow = starthit->GetPadRow()-fRowScopeTrack[fVertexConstraint];
630 minrow = starthit->GetPadRow()-fRowScopeTracklet[fVertexConstraint];
634 Int_t loopeta[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};
635 Int_t loopphi[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};
640 return 0; //reached the last padrow under consideration
645 for(subrowsegm=maxrow; subrowsegm>=minrow; subrowsegm--)
647 //loop over subsegments, in the order defined above.
648 for(Int_t i=0; i<9; i++)
650 subphisegm = starthit->GetPhiIndex() + loopphi[i];
652 if(subphisegm < 0 || subphisegm >= fNumPhiSegment)
656 subphisegm += fNumPhiSegment;
658 else if(subphisegm >=fNumPhiSegment)
659 subphisegm -= fNumPhiSegment;
661 //loop over sub eta segments
663 subetasegm = starthit->GetEtaIndex() + loopeta[i];
665 if(subetasegm < 0 || subetasegm >=fNumEtaSegment)
666 continue;//segment exceeds bounds->skip it
668 //loop over hits in this sub segment:
669 volumeIndex=(subrowsegm-fRowMin)*fNumPhiEtaSegmentPlusOne +
670 subphisegm*fNumEtaSegmentPlusOne + subetasegm;
674 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::GetNextNeighbor","Memory")<<AliHLTTPCLog::kDec<<
675 "VolumeIndex error "<<volumeIndex<<ENDLOG;
678 assert(fVolume!=NULL);
679 for(hit = (AliHLTTPCConfMapPoint*)fVolume[volumeIndex].first;
680 hit!=0; hit = hit->GetNextVolumeHit())
684 {//hit was not used before
686 //set conformal mapping if looking for nonvertex tracks:
687 if(!fVertexConstraint)
689 hit->SetAllCoord(starthit);
692 if(track)//track search - look for nearest neighbor to extrapolated track
694 if (fVertexConstraint) {
695 if(!VerifyRange(starthit,hit))
698 testhit = EvaluateHit(starthit,hit,track);
700 if(testhit == 0)//chi2 not good enough, keep looking
702 else if(testhit==2)//chi2 good enough, return it
705 closesthit = hit;//chi2 acceptable, but keep looking
709 else //tracklet search, look for nearest neighbor
712 if((dist=CalcDistance(starthit,hit)) < closestdist)
714 if (fVertexConstraint) {
715 if(!VerifyRange(starthit,hit))
721 //if this hit is good enough, return it:
722 if(closestdist < fGoodDist)
726 continue;//sub hit was farther away than a hit before
730 }//hit not used before
732 else continue; //sub hit was used before
734 }//loop over hits in sub segment
736 }//loop over sub segments
743 if(closesthit)// && closestdist < mMaxDist)
749 Int_t AliHLTTPCConfMapper::EvaluateHit(AliHLTTPCConfMapPoint *starthit,AliHLTTPCConfMapPoint *hit,AliHLTTPCConfMapTrack *track)
751 //Check if space point gives a fit with acceptable chi2.
753 Double_t temp,dxy,lchi2,dx,dy,slocal,dsz,lszChi2;
754 temp = (track->GetA2Xy()*hit->GetXprime()-hit->GetYprime()+track->GetA1Xy());
755 dxy = temp*temp/(track->GetA2Xy()*track->GetA2Xy() + 1.);
758 lchi2 = (dxy*hit->GetXYWeight());
760 if(lchi2 > track->GetChiSq1())//chi2 was worse than before.
763 //calculate s and the distance hit-line
764 dx = starthit->GetX()-hit->GetX();
765 dy = starthit->GetY()-hit->GetY();
766 //slocal = track->fLength+sqrt(dx*dx+dy*dy);
767 slocal = track->GetLength()+sqrt(dx*dx+dy*dy);
769 temp = (track->GetA2Sz()*slocal-hit->GetZ()+track->GetA1Sz());
770 dsz = temp*temp/(track->GetA2Sz()*track->GetA2Sz()+1);
773 lszChi2 = dsz*hit->GetZWeight();
777 //check whether chi2 is better than previous one:
778 if(lchi2 < track->GetChiSq1())
780 track->SetChiSq1(lchi2);
781 track->SetChiSq2(lszChi2);
785 //if chi2 good enough, stop here:
786 if(lchi2 < fGoodHitChi2[fVertexConstraint])
796 Double_t AliHLTTPCConfMapper::CalcDistance(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
798 //Return distance between two clusters, defined by Pablo
800 Double_t phidiff = fabs( hit1->GetPhi() - hit2->GetPhi() );
801 if (phidiff > AliHLTTPCTransform::Pi()) phidiff = AliHLTTPCTransform::TwoPi() - phidiff;
803 return AliHLTTPCTransform::ToDeg()*fabs((Float_t)((hit1->GetPadRow() - hit2->GetPadRow()) *
804 (phidiff + fabs( hit1->GetEta() - hit2->GetEta()))));
807 Bool_t AliHLTTPCConfMapper::VerifyRange(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
809 //Check if the hit are within reasonable range in phi and eta
810 Double_t dphi,deta;//maxphi=0.1,maxeta=0.1;
811 dphi = fabs(hit1->GetPhi() - hit2->GetPhi());
812 if(dphi > AliHLTTPCTransform::Pi()) dphi = fabs(AliHLTTPCTransform::TwoPi() - dphi);
813 if(dphi > fMaxPhi) return false;
815 deta = fabs(hit1->GetEta() - hit2->GetEta());
816 if(deta > fMaxEta) return false;
822 Double_t AliHLTTPCConfMapper::TrackletAngle(AliHLTTPCConfMapTrack *track,Int_t n) const
824 // Returns the angle 'between' the last three points (started at point number n) on this track.
826 if(n > track->GetNumberOfPoints())
827 n = track->GetNumberOfPoints();
835 Double_t angle1,angle2;
837 for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
839 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)track->GetCurrentHit();
840 if( (n-1) == counter)
845 else if( (n-2) == counter)
850 else if( (n-3) == counter)
858 angle1 = atan2(x2[1]-x3[1],x2[0]-x3[0]);
859 angle2 = atan2(x1[1]-x2[1],x1[0]-x2[0]);
861 return fabs(angle1-angle2);
866 Double_t angle1,angle2;
867 TObjArray *hits = track->GetHits();
869 if (n > track->GetNumberOfPoints()) {
870 n = track->GetNumberOfPoints();
877 x1[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetX();
878 x1[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetY();
880 x2[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX();
881 x2[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY();
883 angle1 = atan2(x1[1],x1[0]);
884 angle2 = atan2(x2[1],x1[0]);
885 return fabs(angle1-angle2);
889 Int_t AliHLTTPCConfMapper::FillTracks()
891 //Fill track parameters. Which basically means do a fit of helix in real space,
892 //which should be done in order to get nice tracks.
894 Int_t numoftracks = fNTracks;
897 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
898 "No tracks found!!"<<ENDLOG;
902 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
903 "Number of found tracks: "<<fNTracks<<ENDLOG;
906 for(Int_t i=0; i<numoftracks; i++)
908 AliHLTTPCConfMapTrack *track = (AliHLTTPCConfMapTrack*)fTrack->GetTrack(i);
909 track->Fill(fVertex,fMaxDca);
914 Double_t AliHLTTPCConfMapper::CpuTime()
916 //Return the Cputime in seconds.
918 gettimeofday( &tv, NULL );
919 return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.);