2 // Original: AliL3ConfMapper.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
18 #include "AliHLTTPCRootTypes.h"
19 #include "AliHLTTPCSpacePointData.h"
20 #include "AliHLTTPCLogging.h"
21 #include "AliHLTTPCVertex.h"
22 #include "AliHLTTPCConfMapTrack.h"
23 #include "AliHLTTPCConfMapPoint.h"
24 #include "AliHLTTPCTrackArray.h"
25 #include "AliHLTTPCTransform.h"
26 #include "AliHLTTPCConfMapper.h"
32 ClassImp(AliHLTTPCConfMapper)
34 AliHLTTPCConfMapper::AliHLTTPCConfMapper()
42 fBench = (Bool_t)true;
43 fVertexConstraint = (Bool_t)true;
49 AliHLTTPCConfMapper::~AliHLTTPCConfMapper()
66 void AliHLTTPCConfMapper::InitVolumes()
69 //Allocate volumes, set conformal coordinates and pointers.
71 //Should be done after setting the track parameters
73 fNumRowSegmentPlusOne = AliHLTTPCTransform::GetNRows();//NumRows[0]; //Maximum 32.
74 fNumPhiSegmentPlusOne = fNumPhiSegment+1;
75 fNumEtaSegmentPlusOne = fNumEtaSegment+1;
76 fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
77 fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
80 if(fVolume) delete [] fVolume;
81 if(fRow) delete [] fRow;
83 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
84 "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
85 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
86 "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
88 fVolume = new AliHLTTPCConfMapContainer[fBounds];
89 fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
91 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
92 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
94 Int_t maxnumoftracks = 2000;
95 Int_t maxnumofhits = 120000;
102 fHit = new AliHLTTPCConfMapPoint[maxnumofhits];
103 fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",maxnumoftracks);
106 void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
107 { //sector means slice here
108 //Initialize tracker for tracking in a given sector.
109 //Resets track and hit arrays.
110 //Here it is also possible to specify a subsector, by defining
111 //rowrange[0]=innermost row;
112 //rowrange[1]=outermostrow;
113 //Finally you can specify etaslices to save time (assuming a good seed from TRD...)
115 //Define tracking area:
118 fRowMin = rowrange[0];
119 fRowMax = rowrange[1];
121 else //complete sector
124 fRowMax = AliHLTTPCTransform::GetNRows() - 1;
128 fEtaMin = etarange[0];
129 fEtaMax = sector < 18 ? etarange[1] : -etarange[1];
134 fEtaMax = sector < 18 ? 0.9 : -0.9;
137 //Set the angles to sector 2:
138 fPhiMin = -10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) - 10/todeg;
139 fPhiMax = 10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) + 10/todeg;
142 fMainVertexTracks = 0;
144 fEtaHitsOutOfRange=0;
145 fPhiHitsOutOfRange=0;
147 fNumRowSegment = fRowMax - fRowMin; //number of rows to be considered by tracker
148 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitSector","B-field")
149 <<"Tracker initializing with a magnetic field of "<<AliHLTTPCTransform::GetBField()<<ENDLOG;
154 Bool_t AliHLTTPCConfMapper::ReadHits(UInt_t count, AliHLTTPCSpacePointData* hits )
157 Int_t nhit=(Int_t)count;
158 for (Int_t i=0;i<nhit;i++)
160 fHit[i+fClustersUnused].Reset();
161 fHit[i+fClustersUnused].ReadHits(&(hits[i]));
163 fClustersUnused += nhit;
165 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::ReadHits","#hits")
166 <<AliHLTTPCLog::kDec<<"hit_counter: "<<nhit<<" count: "<<count<<ENDLOG;
171 void AliHLTTPCConfMapper::SetPointers()
173 //Check if there are not enough clusters to make a track in this sector
174 //Can happen in pp events.
176 if(fClustersUnused < fMinPoints[fVertexConstraint])
179 //Reset detector volumes
180 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
181 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
183 Float_t phiSlice = (fPhiMax-fPhiMin)/fNumPhiSegment;
184 Float_t etaSlice = (fEtaMax-fEtaMin)/fNumEtaSegment;
187 Int_t localcounter=0;
188 for(Int_t j=0; j<fClustersUnused; j++)
190 //AliHLTTPCConfMapPoint *thisHit = (AliHLTTPCConfMapPoint*)fHit->At(j);
191 AliHLTTPCConfMapPoint *thisHit = &(fHit[j]);
193 thisHit->Setup(fVertex);
195 Int_t localrow = thisHit->GetPadRow();
197 if(localrow < fRowMin || localrow > fRowMax)
201 thisHit->SetPhiIndex((Int_t)((thisHit->GetPhi()-fPhiMin)/phiSlice +1));
203 if(thisHit->GetPhiIndex()<1 || thisHit->GetPhiIndex()>fNumPhiSegment)
205 //cout << "Phiindex: " << thisHit->phiIndex << " " << thisHit->GetPhi() << endl;
206 fPhiHitsOutOfRange++;
210 thisHit->SetEtaIndex((Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1));
211 if(thisHit->GetEtaIndex()<1 || thisHit->GetEtaIndex()>fNumEtaSegment)
213 //cout << "Etaindex: " << thisHit->etaIndex << " " << thisHit->GetEta() << endl;
214 fEtaHitsOutOfRange++;
219 volumeIndex = (localrow-fRowMin)*fNumPhiEtaSegmentPlusOne +
220 thisHit->GetPhiIndex()*fNumEtaSegmentPlusOne+thisHit->GetEtaIndex();
222 if(fVolume[volumeIndex].first == NULL)
223 fVolume[volumeIndex].first = (void *)thisHit;
225 ((AliHLTTPCConfMapPoint *)fVolume[volumeIndex].last)->SetNextVolumeHit(thisHit);
226 fVolume[volumeIndex].last = (void *)thisHit;
230 if(fRow[(localrow-fRowMin)].first == NULL)
231 fRow[(localrow-fRowMin)].first = (void *)thisHit;
233 ((AliHLTTPCConfMapPoint *)(fRow[(localrow-fRowMin)].last))->SetNextRowHit(thisHit);
234 fRow[(localrow-fRowMin)].last = (void *)thisHit;
237 if(fClustersUnused>0 && localcounter==0)
238 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::SetPointers","Parameters")
239 <<AliHLTTPCLog::kDec<<"No points passed to track finder, hits out of range: "
240 <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
242 Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
243 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::SetPointers","Setup")
244 <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
245 <<" hits accepted "<<hits_accepted<<ENDLOG;
248 void AliHLTTPCConfMapper::MainVertexTracking_a()
250 //Tracking with vertex constraint.
252 if(!fParamSet[(Int_t)kTRUE])
254 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
255 "Tracking parameters not set!"<<ENDLOG;
259 Double_t initCpuTime,cpuTime;
260 initCpuTime = CpuTime();
263 SetVertexConstraint(true);
264 cpuTime = CpuTime() - initCpuTime;
266 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking_a","Timing")
267 <<AliHLTTPCLog::kDec<<"Setup finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
271 void AliHLTTPCConfMapper::MainVertexTracking_b()
273 //Tracking with vertex constraint.
275 if(!fParamSet[(Int_t)kTRUE])
277 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
278 "Tracking parameters not set!"<<ENDLOG;
281 Double_t initCpuTime,cpuTime;
282 initCpuTime = CpuTime();
286 cpuTime = CpuTime() - initCpuTime;
288 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking_b","Timing")
289 <<AliHLTTPCLog::kDec<<"Main Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
292 void AliHLTTPCConfMapper::MainVertexTracking()
294 //Tracking with vertex constraint.
296 if(!fParamSet[(Int_t)kTRUE])
298 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
299 "Tracking parameters not set!"<<ENDLOG;
303 Double_t initCpuTime,cpuTime;
304 initCpuTime = CpuTime();
305 // END ################################################# MODIFIY JMT
307 SetPointers(); // moved to Component
309 // END ################################################# MODIFIY JMT
310 SetVertexConstraint(true);
314 cpuTime = CpuTime() - initCpuTime;
316 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
317 "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
322 void AliHLTTPCConfMapper::NonVertexTracking()
324 //Tracking with no vertex constraint. This should be called after doing MainVertexTracking,
325 //in order to do tracking on the remaining clusters.
326 //The conformal mapping is now done with respect to the first cluster
327 //assosciated with this track.
329 if(!fParamSet[(Int_t)kFALSE])
331 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::NonVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
332 "Tracking parameters not set!"<<ENDLOG;
336 SetVertexConstraint(false);
338 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::NonVertexTracking","ntracks")<<AliHLTTPCLog::kDec<<
339 "Number of nonvertex tracks found: "<<(fNTracks-fMainVertexTracks)<<ENDLOG;
343 void AliHLTTPCConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength,
344 Int_t rowscopetracklet, Int_t rowscopetrack,
345 Double_t maxphi,Double_t maxeta)
347 //Settings for main vertex tracking. The cuts are:
348 //TrackletLength: #hits on segment, before trying to build a track
349 //TrackLength: Minimum hits on a track
350 //RowScopeTracklet: Row search range for segments
351 //RowScopeTrack: Row search range for tracks
353 SetTrackletLength(trackletlength,(Bool_t)true);
354 SetRowScopeTracklet(rowscopetracklet, (Bool_t) true);
355 SetRowScopeTrack(rowscopetrack, (Bool_t) true);
356 SetMinPoints(tracklength,(Bool_t)true);
362 void AliHLTTPCConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
363 Int_t rowscopetracklet, Int_t rowscopetrack)
365 //set parameters for non-vertex tracking
366 SetTrackletLength(trackletlength,(Bool_t)false);
367 SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
368 SetRowScopeTrack(rowscopetrack, (Bool_t)false);
369 SetMinPoints(tracklength,(Bool_t)false);
370 SetParamDone(kFALSE);
373 void AliHLTTPCConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
375 //Settings for tracks. The cuts are:
376 //HitChi2Cut: Maximum hit chi2
377 //goodHitChi2: Chi2 to stop look for next hit
378 //trackChi2Cut: Maximum track chi2
379 //maxdist: Maximum distance between two clusters when forming segments
381 SetHitChi2Cut(hitChi2Cut,vertexconstraint);
382 SetGoodHitChi2(goodHitChi2,vertexconstraint);
383 SetTrackChi2Cut(trackChi2Cut,vertexconstraint);
384 SetMaxDist(maxdist,vertexconstraint);
387 void AliHLTTPCConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_t vc)
389 //Sets cuts of tracklets. Right now this is only:
390 //maxangle: Maximum angle when forming segments (if trackletlength > 2)
393 SetMaxAngleTracklet(maxangle, vc);
396 void AliHLTTPCConfMapper::ClusterLoop()
398 //Loop over hits, starting at outermost padrow, and trying to build segments.
400 //Check if there are not enough clusters to make a track in this sector
401 //Can happen in pp events.
402 if(fClustersUnused < fMinPoints[fVertexConstraint])
405 Int_t rowsegm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
406 AliHLTTPCConfMapPoint *hit;
408 //Loop over rows, and try to create tracks from the hits.
409 //Starts at the outermost row, and loops as long as a track can be build, due to length.
411 for(rowsegm = fRowMax; rowsegm >= lastrow; rowsegm--)
413 if(fRow[(rowsegm-fRowMin)].first && ((AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first)->GetPadRow() < fRowMin + 1)
416 for(hit = (AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first; hit!=0; hit=hit->GetNextRowHit())
418 if(hit->GetUsage() == true)
429 void AliHLTTPCConfMapper::CreateTrack(AliHLTTPCConfMapPoint *hit)
431 //Tries to create a track from the initial hit given by ClusterLoop()
433 AliHLTTPCConfMapPoint *closesthit = NULL;
434 AliHLTTPCConfMapTrack *track = NULL;
437 Int_t tracks = fNTracks;
440 track = (AliHLTTPCConfMapTrack*)fTrack->NextTrack();
442 //reset hit parameters:
445 UInt_t *trackhitnumber = track->GetHitNumbers();
447 //set conformal coordinates if we are looking for non vertex tracks
448 if(!fVertexConstraint)
450 hit->SetAllCoord(hit);
453 //fill fit parameters of initial track:
454 track->UpdateParam(hit); //here the number of hits is incremented.
455 trackhitnumber[track->GetNumberOfPoints()-1] = hit->GetHitNumber();
460 for(point=1; point<fTrackletLength[fVertexConstraint]; point++)
462 if((closesthit = GetNextNeighbor(hit)))
465 // Calculate track length in sz plane
466 dx = ((AliHLTTPCConfMapPoint*)closesthit)->GetX() - ((AliHLTTPCConfMapPoint*)hit)->GetX();
467 dy = ((AliHLTTPCConfMapPoint*)closesthit)->GetY() - ((AliHLTTPCConfMapPoint*)hit)->GetY();
468 //track->fLength += (Double_t)sqrt ( dx * dx + dy * dy ) ;
469 Double_t length = track->GetLength()+(Double_t)sqrt ( dx * dx + dy * dy );
470 track->SetLength(length);
472 //closesthit->SetS(track->fLength);
473 closesthit->SetS(track->GetLength());
475 //update fit parameters
476 track->UpdateParam(closesthit);
477 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
483 //closest hit does not exist:
484 track->DeleteCandidate();
485 fTrack->RemoveLast();
487 point = fTrackletLength[fVertexConstraint];
491 //tracklet is long enough to be extended to a track
492 if(track->GetNumberOfPoints() == fTrackletLength[fVertexConstraint])
495 track->SetProperties(true);
497 if(TrackletAngle(track) > fMaxAngleTracklet[fVertexConstraint])
498 {//proof if the first points seem to be a beginning of a track
499 track->SetProperties(false);
500 track->DeleteCandidate();
501 fTrack->RemoveLast();
505 else//good tracklet ->proceed, follow the trackfit
509 //define variables to keep the total chi:
510 Double_t xyChi2 = track->GetChiSq1();
511 Double_t szChi2 = track->GetChiSq2();
513 for(point = fTrackletLength[fVertexConstraint]; point <= fNumRowSegment; point++)
515 track->SetChiSq1(fHitChi2Cut[fVertexConstraint]);
516 closesthit = GetNextNeighbor((AliHLTTPCConfMapPoint*)track->GetLastHit(),track);
521 Double_t lxyChi2 = track->GetChiSq1()-track->GetChiSq2();
523 closesthit->SetXYChi2(lxyChi2);
525 //update track length:
526 track->SetLength(closesthit->GetS());
527 szChi2 += track->GetChiSq2();
528 closesthit->SetSZChi2(track->GetChiSq2());
530 track->UpdateParam(closesthit);
531 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
533 //add closest hit to track
534 closesthit->SetUsage(true);
535 closesthit->SetTrackNumber(tracks-1);
541 //closest hit does not exist
542 point = fNumRowSegment; //continue with next hit in segment
548 track->SetChiSq1(xyChi2);
549 track->SetChiSq2(szChi2);
550 Double_t normalizedchi2 = (track->GetChiSq1()+track->GetChiSq2())/track->GetNumberOfPoints();
552 //remove tracks with not enough points already now
553 if(track->GetNumberOfPoints() < fMinPoints[fVertexConstraint] || normalizedchi2 > fTrackChi2Cut[fVertexConstraint])
555 track->SetProperties(false);
557 track->DeleteCandidate();
558 fTrack->RemoveLast();
564 fClustersUnused -= track->GetNumberOfPoints();
565 track->ComesFromMainVertex(fVertexConstraint);
566 //mark track as main vertex track or not
567 track->SetSector(2); //only needed for testing purposes.
568 track->SetRowRange(fRowMin,fRowMax);
570 if(fVertexConstraint)
581 AliHLTTPCConfMapPoint *AliHLTTPCConfMapper::GetNextNeighbor(AliHLTTPCConfMapPoint *starthit,
582 AliHLTTPCConfMapTrack *track)
584 //When forming segments: Finds closest hit to input hit
585 //When forming tracks: Find closest hit to track fit.
587 Double_t dist,closestdist = fMaxDist[fVertexConstraint];
589 AliHLTTPCConfMapPoint *hit = NULL;
590 AliHLTTPCConfMapPoint *closesthit = NULL;
598 Int_t maxrow = starthit->GetPadRow()-1;
601 if(track) //finding hit close to trackfit
603 minrow = starthit->GetPadRow()-fRowScopeTrack[fVertexConstraint];
607 minrow = starthit->GetPadRow()-fRowScopeTracklet[fVertexConstraint];
611 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};
612 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};
617 return 0; //reached the last padrow under consideration
622 for(subrowsegm=maxrow; subrowsegm>=minrow; subrowsegm--)
624 //loop over subsegments, in the order defined above.
625 for(Int_t i=0; i<9; i++)
627 subphisegm = starthit->GetPhiIndex() + loopphi[i];
629 if(subphisegm < 0 || subphisegm >= fNumPhiSegment)
633 subphisegm += fNumPhiSegment;
635 else if(subphisegm >=fNumPhiSegment)
636 subphisegm -= fNumPhiSegment;
638 //loop over sub eta segments
640 subetasegm = starthit->GetEtaIndex() + loopeta[i];
642 if(subetasegm < 0 || subetasegm >=fNumEtaSegment)
643 continue;//segment exceeds bounds->skip it
645 //loop over hits in this sub segment:
646 volumeIndex=(subrowsegm-fRowMin)*fNumPhiEtaSegmentPlusOne +
647 subphisegm*fNumEtaSegmentPlusOne + subetasegm;
651 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::GetNextNeighbor","Memory")<<AliHLTTPCLog::kDec<<
652 "VolumeIndex error "<<volumeIndex<<ENDLOG;
655 for(hit = (AliHLTTPCConfMapPoint*)fVolume[volumeIndex].first;
656 hit!=0; hit = hit->GetNextVolumeHit())
660 {//hit was not used before
662 //set conformal mapping if looking for nonvertex tracks:
663 if(!fVertexConstraint)
665 hit->SetAllCoord(starthit);
668 if(track)//track search - look for nearest neighbor to extrapolated track
670 // BEGINN ############################################## MODIFIY JMT
672 if (fVertexConstraint) {
673 if(!VerifyRange(starthit,hit))
677 if(!VerifyRange(starthit,hit))
680 // END ################################################# MODIFIY JMT
681 testhit = EvaluateHit(starthit,hit,track);
683 if(testhit == 0)//chi2 not good enough, keep looking
685 else if(testhit==2)//chi2 good enough, return it
688 closesthit = hit;//chi2 acceptable, but keep looking
692 else //tracklet search, look for nearest neighbor
695 if((dist=CalcDistance(starthit,hit)) < closestdist)
697 // BEGINN ############################################## MODIFIY JMT
699 if (fVertexConstraint) {
700 if(!VerifyRange(starthit,hit))
704 if(!VerifyRange(starthit,hit))
707 // END ################################################# MODIFIY JMT
711 //if this hit is good enough, return it:
712 if(closestdist < fGoodDist)
716 continue;//sub hit was farther away than a hit before
720 }//hit not used before
722 else continue; //sub hit was used before
724 }//loop over hits in sub segment
726 }//loop over sub segments
733 if(closesthit)// && closestdist < mMaxDist)
739 Int_t AliHLTTPCConfMapper::EvaluateHit(AliHLTTPCConfMapPoint *starthit,AliHLTTPCConfMapPoint *hit,AliHLTTPCConfMapTrack *track)
741 //Check if space point gives a fit with acceptable chi2.
743 Double_t temp,dxy,lchi2,dx,dy,slocal,dsz,lszChi2;
744 temp = (track->GetA2Xy()*hit->GetXprime()-hit->GetYprime()+track->GetA1Xy());
745 dxy = temp*temp/(track->GetA2Xy()*track->GetA2Xy() + 1.);
748 lchi2 = (dxy*hit->GetXYWeight());
750 if(lchi2 > track->GetChiSq1())//chi2 was worse than before.
753 //calculate s and the distance hit-line
754 dx = starthit->GetX()-hit->GetX();
755 dy = starthit->GetY()-hit->GetY();
756 //slocal = track->fLength+sqrt(dx*dx+dy*dy);
757 slocal = track->GetLength()+sqrt(dx*dx+dy*dy);
759 temp = (track->GetA2Sz()*slocal-hit->GetZ()+track->GetA1Sz());
760 dsz = temp*temp/(track->GetA2Sz()*track->GetA2Sz()+1);
763 lszChi2 = dsz*hit->GetZWeight();
767 //check whether chi2 is better than previous one:
768 if(lchi2 < track->GetChiSq1())
770 track->SetChiSq1(lchi2);
771 track->SetChiSq2(lszChi2);
775 //if chi2 good enough, stop here:
776 if(lchi2 < fGoodHitChi2[fVertexConstraint])
786 Double_t AliHLTTPCConfMapper::CalcDistance(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
788 //Return distance between two clusters, defined by Pablo
790 Double_t phidiff = fabs( hit1->GetPhi() - hit2->GetPhi() );
791 if (phidiff > AliHLTTPCTransform::Pi()) phidiff = AliHLTTPCTransform::TwoPi() - phidiff;
793 return AliHLTTPCTransform::ToDeg()*fabs((Float_t)((hit1->GetPadRow() - hit2->GetPadRow()) *
794 (phidiff + fabs( hit1->GetEta() - hit2->GetEta()))));
797 Bool_t AliHLTTPCConfMapper::VerifyRange(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
799 //Check if the hit are within reasonable range in phi and eta
800 Double_t dphi,deta;//maxphi=0.1,maxeta=0.1;
801 dphi = fabs(hit1->GetPhi() - hit2->GetPhi());
802 if(dphi > AliHLTTPCTransform::Pi()) dphi = fabs(AliHLTTPCTransform::TwoPi() - dphi);
803 if(dphi > fMaxPhi) return false;
805 deta = fabs(hit1->GetEta() - hit2->GetEta());
806 if(deta > fMaxEta) return false;
812 Double_t AliHLTTPCConfMapper::TrackletAngle(AliHLTTPCConfMapTrack *track,Int_t n) const
814 // Returns the angle 'between' the last three points (started at point number n) on this track.
816 if(n > track->GetNumberOfPoints())
817 n = track->GetNumberOfPoints();
825 Double_t angle1,angle2;
827 for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
829 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)track->GetCurrentHit();
830 if( (n-1) == counter)
835 else if( (n-2) == counter)
840 else if( (n-3) == counter)
848 angle1 = atan2(x2[1]-x3[1],x2[0]-x3[0]);
849 angle2 = atan2(x1[1]-x2[1],x1[0]-x2[0]);
851 return fabs(angle1-angle2);
856 Double_t angle1,angle2;
857 TObjArray *hits = track->GetHits();
859 if (n > track->GetNumberOfPoints()) {
860 n = track->GetNumberOfPoints();
867 x1[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetX();
868 x1[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetY();
870 x2[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX();
871 x2[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY();
873 angle1 = atan2(x1[1],x1[0]);
874 angle2 = atan2(x2[1],x1[0]);
875 return fabs(angle1-angle2);
879 Int_t AliHLTTPCConfMapper::FillTracks()
881 //Fill track parameters. Which basically means do a fit of helix in real space,
882 //which should be done in order to get nice tracks.
884 Int_t numoftracks = fNTracks;
887 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
888 "No tracks found!!"<<ENDLOG;
892 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
893 "Number of found tracks: "<<fNTracks<<ENDLOG;
896 for(Int_t i=0; i<numoftracks; i++)
898 AliHLTTPCConfMapTrack *track = (AliHLTTPCConfMapTrack*)fTrack->GetTrack(i);
899 track->Fill(fVertex,fMaxDca);
904 Double_t AliHLTTPCConfMapper::CpuTime()
906 //Return the Cputime in seconds.
908 gettimeofday( &tv, NULL );
909 return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.);