3 /** \class AliHLTTPCConfMapper
5 //_____________________________________________________________
8 // Conformal mapping base class
10 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
11 // Copyright © ALICE HLT Group
17 #include "AliHLTTPCRootTypes.h"
18 #include "AliHLTTPCSpacePointData.h"
19 #include "AliHLTTPCLogging.h"
20 #include "AliHLTTPCVertex.h"
21 #include "AliHLTTPCConfMapTrack.h"
22 #include "AliHLTTPCConfMapPoint.h"
23 #include "AliHLTTPCTrackArray.h"
24 #include "AliHLTTPCTransform.h"
25 #include "AliHLTTPCConfMapper.h"
31 ClassImp(AliHLTTPCConfMapper)
33 AliHLTTPCConfMapper::AliHLTTPCConfMapper()
41 fBench = (Bool_t)true;
42 fVertexConstraint = (Bool_t)true;
48 AliHLTTPCConfMapper::~AliHLTTPCConfMapper()
65 void AliHLTTPCConfMapper::InitVolumes()
68 //Allocate volumes, set conformal coordinates and pointers.
70 //Should be done after setting the track parameters
72 fNumRowSegmentPlusOne = AliHLTTPCTransform::GetNRows();//NumRows[0]; //Maximum 32.
73 fNumPhiSegmentPlusOne = fNumPhiSegment+1;
74 fNumEtaSegmentPlusOne = fNumEtaSegment+1;
75 fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
76 fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
79 if(fVolume) delete [] fVolume;
80 if(fRow) delete [] fRow;
82 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
83 "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
84 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
85 "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
87 fVolume = new AliHLTTPCConfMapContainer[fBounds];
88 fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
90 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
91 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
93 Int_t maxnumoftracks = 2000;
94 Int_t maxnumofhits = 120000;
101 fHit = new AliHLTTPCConfMapPoint[maxnumofhits];
102 fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",maxnumoftracks);
105 void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
106 { //sector means slice here
107 //Initialize tracker for tracking in a given sector.
108 //Resets track and hit arrays.
109 //Here it is also possible to specify a subsector, by defining
110 //rowrange[0]=innermost row;
111 //rowrange[1]=outermostrow;
112 //Finally you can specify etaslices to save time (assuming a good seed from TRD...)
114 //Define tracking area:
117 fRowMin = rowrange[0];
118 fRowMax = rowrange[1];
120 else //complete sector
123 fRowMax = AliHLTTPCTransform::GetNRows() - 1;
127 fEtaMin = etarange[0];
128 fEtaMax = sector < 18 ? etarange[1] : -etarange[1];
133 fEtaMax = sector < 18 ? 0.9 : -0.9;
136 //Set the angles to sector 2:
137 fPhiMin = -10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) - 10/todeg;
138 fPhiMax = 10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) + 10/todeg;
141 fMainVertexTracks = 0;
143 fEtaHitsOutOfRange=0;
144 fPhiHitsOutOfRange=0;
146 fNumRowSegment = fRowMax - fRowMin; //number of rows to be considered by tracker
147 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitSector","B-field")
148 <<"Tracker initializing with a magnetic field of "<<AliHLTTPCTransform::GetBField()<<ENDLOG;
153 Bool_t AliHLTTPCConfMapper::ReadHits(UInt_t count, AliHLTTPCSpacePointData* hits )
156 Int_t nhit=(Int_t)count;
157 for (Int_t i=0;i<nhit;i++)
159 fHit[i+fClustersUnused].Reset();
160 fHit[i+fClustersUnused].ReadHits(&(hits[i]));
162 fClustersUnused += nhit;
164 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::ReadHits","#hits")
165 <<AliHLTTPCLog::kDec<<"hit_counter: "<<nhit<<" count: "<<count<<ENDLOG;
170 void AliHLTTPCConfMapper::SetPointers()
172 //Check if there are not enough clusters to make a track in this sector
173 //Can happen in pp events.
175 if(fClustersUnused < fMinPoints[fVertexConstraint])
178 //Reset detector volumes
179 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
180 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
182 Float_t phiSlice = (fPhiMax-fPhiMin)/fNumPhiSegment;
183 Float_t etaSlice = (fEtaMax-fEtaMin)/fNumEtaSegment;
186 Int_t localcounter=0;
187 for(Int_t j=0; j<fClustersUnused; j++)
189 //AliHLTTPCConfMapPoint *thisHit = (AliHLTTPCConfMapPoint*)fHit->At(j);
190 AliHLTTPCConfMapPoint *thisHit = &(fHit[j]);
192 thisHit->Setup(fVertex);
194 Int_t localrow = thisHit->GetPadRow();
196 if(localrow < fRowMin || localrow > fRowMax)
200 thisHit->SetPhiIndex((Int_t)((thisHit->GetPhi()-fPhiMin)/phiSlice +1));
202 if(thisHit->GetPhiIndex()<1 || thisHit->GetPhiIndex()>fNumPhiSegment)
204 //cout << "Phiindex: " << thisHit->phiIndex << " " << thisHit->GetPhi() << endl;
205 fPhiHitsOutOfRange++;
209 thisHit->SetEtaIndex((Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1));
210 if(thisHit->GetEtaIndex()<1 || thisHit->GetEtaIndex()>fNumEtaSegment)
212 //cout << "Etaindex: " << thisHit->etaIndex << " " << thisHit->GetEta() << endl;
213 fEtaHitsOutOfRange++;
218 volumeIndex = (localrow-fRowMin)*fNumPhiEtaSegmentPlusOne +
219 thisHit->GetPhiIndex()*fNumEtaSegmentPlusOne+thisHit->GetEtaIndex();
221 if(fVolume[volumeIndex].first == NULL)
222 fVolume[volumeIndex].first = (void *)thisHit;
224 ((AliHLTTPCConfMapPoint *)fVolume[volumeIndex].last)->SetNextVolumeHit(thisHit);
225 fVolume[volumeIndex].last = (void *)thisHit;
229 if(fRow[(localrow-fRowMin)].first == NULL)
230 fRow[(localrow-fRowMin)].first = (void *)thisHit;
232 ((AliHLTTPCConfMapPoint *)(fRow[(localrow-fRowMin)].last))->SetNextRowHit(thisHit);
233 fRow[(localrow-fRowMin)].last = (void *)thisHit;
236 if(fClustersUnused>0 && localcounter==0)
237 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::SetPointers","Parameters")
238 <<AliHLTTPCLog::kDec<<"No points passed to track finder, hits out of range: "
239 <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
241 Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
242 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::SetPointers","Setup")
243 <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
244 <<" hits accepted "<<hits_accepted<<ENDLOG;
247 void AliHLTTPCConfMapper::MainVertexTracking_a()
249 //Tracking with vertex constraint.
251 if(!fParamSet[(Int_t)kTRUE])
253 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
254 "Tracking parameters not set!"<<ENDLOG;
258 Double_t initCpuTime,cpuTime;
259 initCpuTime = CpuTime();
262 SetVertexConstraint(true);
263 cpuTime = CpuTime() - initCpuTime;
265 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking_a","Timing")
266 <<AliHLTTPCLog::kDec<<"Setup finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
270 void AliHLTTPCConfMapper::MainVertexTracking_b()
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;
280 Double_t initCpuTime,cpuTime;
281 initCpuTime = CpuTime();
285 cpuTime = CpuTime() - initCpuTime;
287 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking_b","Timing")
288 <<AliHLTTPCLog::kDec<<"Main Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
291 void AliHLTTPCConfMapper::MainVertexTracking()
293 //Tracking with vertex constraint.
295 if(!fParamSet[(Int_t)kTRUE])
297 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
298 "Tracking parameters not set!"<<ENDLOG;
302 Double_t initCpuTime,cpuTime;
303 initCpuTime = CpuTime();
304 // END ################################################# MODIFIY JMT
306 SetPointers(); // moved to Component
308 // END ################################################# MODIFIY JMT
309 SetVertexConstraint(true);
313 cpuTime = CpuTime() - initCpuTime;
315 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
316 "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
321 void AliHLTTPCConfMapper::NonVertexTracking()
323 //Tracking with no vertex constraint. This should be called after doing MainVertexTracking,
324 //in order to do tracking on the remaining clusters.
325 //The conformal mapping is now done with respect to the first cluster
326 //assosciated with this track.
328 if(!fParamSet[(Int_t)kFALSE])
330 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::NonVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
331 "Tracking parameters not set!"<<ENDLOG;
335 SetVertexConstraint(false);
337 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::NonVertexTracking","ntracks")<<AliHLTTPCLog::kDec<<
338 "Number of nonvertex tracks found: "<<(fNTracks-fMainVertexTracks)<<ENDLOG;
342 void AliHLTTPCConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength,
343 Int_t rowscopetracklet, Int_t rowscopetrack,
344 Double_t maxphi,Double_t maxeta)
346 //Settings for main vertex tracking. The cuts are:
347 //TrackletLength: #hits on segment, before trying to build a track
348 //TrackLength: Minimum hits on a track
349 //RowScopeTracklet: Row search range for segments
350 //RowScopeTrack: Row search range for tracks
352 SetTrackletLength(trackletlength,(Bool_t)true);
353 SetRowScopeTracklet(rowscopetracklet, (Bool_t) true);
354 SetRowScopeTrack(rowscopetrack, (Bool_t) true);
355 SetMinPoints(tracklength,(Bool_t)true);
361 void AliHLTTPCConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
362 Int_t rowscopetracklet, Int_t rowscopetrack)
364 //set parameters for non-vertex tracking
365 SetTrackletLength(trackletlength,(Bool_t)false);
366 SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
367 SetRowScopeTrack(rowscopetrack, (Bool_t)false);
368 SetMinPoints(tracklength,(Bool_t)false);
369 SetParamDone(kFALSE);
372 void AliHLTTPCConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
374 //Settings for tracks. The cuts are:
375 //HitChi2Cut: Maximum hit chi2
376 //goodHitChi2: Chi2 to stop look for next hit
377 //trackChi2Cut: Maximum track chi2
378 //maxdist: Maximum distance between two clusters when forming segments
380 SetHitChi2Cut(hitChi2Cut,vertexconstraint);
381 SetGoodHitChi2(goodHitChi2,vertexconstraint);
382 SetTrackChi2Cut(trackChi2Cut,vertexconstraint);
383 SetMaxDist(maxdist,vertexconstraint);
386 void AliHLTTPCConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_t vc)
388 //Sets cuts of tracklets. Right now this is only:
389 //maxangle: Maximum angle when forming segments (if trackletlength > 2)
392 SetMaxAngleTracklet(maxangle, vc);
395 void AliHLTTPCConfMapper::ClusterLoop()
397 //Loop over hits, starting at outermost padrow, and trying to build segments.
399 //Check if there are not enough clusters to make a track in this sector
400 //Can happen in pp events.
401 if(fClustersUnused < fMinPoints[fVertexConstraint])
404 Int_t rowsegm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
405 AliHLTTPCConfMapPoint *hit;
407 //Loop over rows, and try to create tracks from the hits.
408 //Starts at the outermost row, and loops as long as a track can be build, due to length.
410 for(rowsegm = fRowMax; rowsegm >= lastrow; rowsegm--)
412 if(fRow[(rowsegm-fRowMin)].first && ((AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first)->GetPadRow() < fRowMin + 1)
415 for(hit = (AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first; hit!=0; hit=hit->GetNextRowHit())
417 if(hit->GetUsage() == true)
428 void AliHLTTPCConfMapper::CreateTrack(AliHLTTPCConfMapPoint *hit)
430 //Tries to create a track from the initial hit given by ClusterLoop()
432 AliHLTTPCConfMapPoint *closesthit = NULL;
433 AliHLTTPCConfMapTrack *track = NULL;
436 Int_t tracks = fNTracks;
439 track = (AliHLTTPCConfMapTrack*)fTrack->NextTrack();
441 //reset hit parameters:
444 UInt_t *trackhitnumber = track->GetHitNumbers();
446 //set conformal coordinates if we are looking for non vertex tracks
447 if(!fVertexConstraint)
449 hit->SetAllCoord(hit);
452 //fill fit parameters of initial track:
453 track->UpdateParam(hit); //here the number of hits is incremented.
454 trackhitnumber[track->GetNumberOfPoints()-1] = hit->GetHitNumber();
459 for(point=1; point<fTrackletLength[fVertexConstraint]; point++)
461 if((closesthit = GetNextNeighbor(hit)))
464 // Calculate track length in sz plane
465 dx = ((AliHLTTPCConfMapPoint*)closesthit)->GetX() - ((AliHLTTPCConfMapPoint*)hit)->GetX();
466 dy = ((AliHLTTPCConfMapPoint*)closesthit)->GetY() - ((AliHLTTPCConfMapPoint*)hit)->GetY();
467 //track->fLength += (Double_t)sqrt ( dx * dx + dy * dy ) ;
468 Double_t length = track->GetLength()+(Double_t)sqrt ( dx * dx + dy * dy );
469 track->SetLength(length);
471 //closesthit->SetS(track->fLength);
472 closesthit->SetS(track->GetLength());
474 //update fit parameters
475 track->UpdateParam(closesthit);
476 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
482 //closest hit does not exist:
483 track->DeleteCandidate();
484 fTrack->RemoveLast();
486 point = fTrackletLength[fVertexConstraint];
490 //tracklet is long enough to be extended to a track
491 if(track->GetNumberOfPoints() == fTrackletLength[fVertexConstraint])
494 track->SetProperties(true);
496 if(TrackletAngle(track) > fMaxAngleTracklet[fVertexConstraint])
497 {//proof if the first points seem to be a beginning of a track
498 track->SetProperties(false);
499 track->DeleteCandidate();
500 fTrack->RemoveLast();
504 else//good tracklet ->proceed, follow the trackfit
508 //define variables to keep the total chi:
509 Double_t xyChi2 = track->GetChiSq1();
510 Double_t szChi2 = track->GetChiSq2();
512 for(point = fTrackletLength[fVertexConstraint]; point <= fNumRowSegment; point++)
514 track->SetChiSq1(fHitChi2Cut[fVertexConstraint]);
515 closesthit = GetNextNeighbor((AliHLTTPCConfMapPoint*)track->GetLastHit(),track);
520 Double_t lxyChi2 = track->GetChiSq1()-track->GetChiSq2();
522 closesthit->SetXYChi2(lxyChi2);
524 //update track length:
525 track->SetLength(closesthit->GetS());
526 szChi2 += track->GetChiSq2();
527 closesthit->SetSZChi2(track->GetChiSq2());
529 track->UpdateParam(closesthit);
530 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
532 //add closest hit to track
533 closesthit->SetUsage(true);
534 closesthit->SetTrackNumber(tracks-1);
540 //closest hit does not exist
541 point = fNumRowSegment; //continue with next hit in segment
547 track->SetChiSq1(xyChi2);
548 track->SetChiSq2(szChi2);
549 Double_t normalizedchi2 = (track->GetChiSq1()+track->GetChiSq2())/track->GetNumberOfPoints();
551 //remove tracks with not enough points already now
552 if(track->GetNumberOfPoints() < fMinPoints[fVertexConstraint] || normalizedchi2 > fTrackChi2Cut[fVertexConstraint])
554 track->SetProperties(false);
556 track->DeleteCandidate();
557 fTrack->RemoveLast();
563 fClustersUnused -= track->GetNumberOfPoints();
564 track->ComesFromMainVertex(fVertexConstraint);
565 //mark track as main vertex track or not
566 track->SetSector(2); //only needed for testing purposes.
567 track->SetRowRange(fRowMin,fRowMax);
569 if(fVertexConstraint)
580 AliHLTTPCConfMapPoint *AliHLTTPCConfMapper::GetNextNeighbor(AliHLTTPCConfMapPoint *starthit,
581 AliHLTTPCConfMapTrack *track)
583 //When forming segments: Finds closest hit to input hit
584 //When forming tracks: Find closest hit to track fit.
586 Double_t dist,closestdist = fMaxDist[fVertexConstraint];
588 AliHLTTPCConfMapPoint *hit = NULL;
589 AliHLTTPCConfMapPoint *closesthit = NULL;
597 Int_t maxrow = starthit->GetPadRow()-1;
600 if(track) //finding hit close to trackfit
602 minrow = starthit->GetPadRow()-fRowScopeTrack[fVertexConstraint];
606 minrow = starthit->GetPadRow()-fRowScopeTracklet[fVertexConstraint];
610 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};
611 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};
616 return 0; //reached the last padrow under consideration
621 for(subrowsegm=maxrow; subrowsegm>=minrow; subrowsegm--)
623 //loop over subsegments, in the order defined above.
624 for(Int_t i=0; i<9; i++)
626 subphisegm = starthit->GetPhiIndex() + loopphi[i];
628 if(subphisegm < 0 || subphisegm >= fNumPhiSegment)
632 subphisegm += fNumPhiSegment;
634 else if(subphisegm >=fNumPhiSegment)
635 subphisegm -= fNumPhiSegment;
637 //loop over sub eta segments
639 subetasegm = starthit->GetEtaIndex() + loopeta[i];
641 if(subetasegm < 0 || subetasegm >=fNumEtaSegment)
642 continue;//segment exceeds bounds->skip it
644 //loop over hits in this sub segment:
645 volumeIndex=(subrowsegm-fRowMin)*fNumPhiEtaSegmentPlusOne +
646 subphisegm*fNumEtaSegmentPlusOne + subetasegm;
650 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::GetNextNeighbor","Memory")<<AliHLTTPCLog::kDec<<
651 "VolumeIndex error "<<volumeIndex<<ENDLOG;
654 for(hit = (AliHLTTPCConfMapPoint*)fVolume[volumeIndex].first;
655 hit!=0; hit = hit->GetNextVolumeHit())
659 {//hit was not used before
661 //set conformal mapping if looking for nonvertex tracks:
662 if(!fVertexConstraint)
664 hit->SetAllCoord(starthit);
667 if(track)//track search - look for nearest neighbor to extrapolated track
669 // BEGINN ############################################## MODIFIY JMT
671 if (fVertexConstraint) {
672 if(!VerifyRange(starthit,hit))
676 if(!VerifyRange(starthit,hit))
679 // END ################################################# MODIFIY JMT
680 testhit = EvaluateHit(starthit,hit,track);
682 if(testhit == 0)//chi2 not good enough, keep looking
684 else if(testhit==2)//chi2 good enough, return it
687 closesthit = hit;//chi2 acceptable, but keep looking
691 else //tracklet search, look for nearest neighbor
694 if((dist=CalcDistance(starthit,hit)) < closestdist)
696 // BEGINN ############################################## MODIFIY JMT
698 if (fVertexConstraint) {
699 if(!VerifyRange(starthit,hit))
703 if(!VerifyRange(starthit,hit))
706 // END ################################################# MODIFIY JMT
710 //if this hit is good enough, return it:
711 if(closestdist < fGoodDist)
715 continue;//sub hit was farther away than a hit before
719 }//hit not used before
721 else continue; //sub hit was used before
723 }//loop over hits in sub segment
725 }//loop over sub segments
732 if(closesthit)// && closestdist < mMaxDist)
738 Int_t AliHLTTPCConfMapper::EvaluateHit(AliHLTTPCConfMapPoint *starthit,AliHLTTPCConfMapPoint *hit,AliHLTTPCConfMapTrack *track)
740 //Check if space point gives a fit with acceptable chi2.
742 Double_t temp,dxy,lchi2,dx,dy,slocal,dsz,lszChi2;
743 temp = (track->GetA2Xy()*hit->GetXprime()-hit->GetYprime()+track->GetA1Xy());
744 dxy = temp*temp/(track->GetA2Xy()*track->GetA2Xy() + 1.);
747 lchi2 = (dxy*hit->GetXYWeight());
749 if(lchi2 > track->GetChiSq1())//chi2 was worse than before.
752 //calculate s and the distance hit-line
753 dx = starthit->GetX()-hit->GetX();
754 dy = starthit->GetY()-hit->GetY();
755 //slocal = track->fLength+sqrt(dx*dx+dy*dy);
756 slocal = track->GetLength()+sqrt(dx*dx+dy*dy);
758 temp = (track->GetA2Sz()*slocal-hit->GetZ()+track->GetA1Sz());
759 dsz = temp*temp/(track->GetA2Sz()*track->GetA2Sz()+1);
762 lszChi2 = dsz*hit->GetZWeight();
766 //check whether chi2 is better than previous one:
767 if(lchi2 < track->GetChiSq1())
769 track->SetChiSq1(lchi2);
770 track->SetChiSq2(lszChi2);
774 //if chi2 good enough, stop here:
775 if(lchi2 < fGoodHitChi2[fVertexConstraint])
785 Double_t AliHLTTPCConfMapper::CalcDistance(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
787 //Return distance between two clusters, defined by Pablo
789 Double_t phidiff = fabs( hit1->GetPhi() - hit2->GetPhi() );
790 if (phidiff > AliHLTTPCTransform::Pi()) phidiff = AliHLTTPCTransform::TwoPi() - phidiff;
792 return AliHLTTPCTransform::ToDeg()*fabs((Float_t)((hit1->GetPadRow() - hit2->GetPadRow()) *
793 (phidiff + fabs( hit1->GetEta() - hit2->GetEta()))));
796 Bool_t AliHLTTPCConfMapper::VerifyRange(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
798 //Check if the hit are within reasonable range in phi and eta
799 Double_t dphi,deta;//maxphi=0.1,maxeta=0.1;
800 dphi = fabs(hit1->GetPhi() - hit2->GetPhi());
801 if(dphi > AliHLTTPCTransform::Pi()) dphi = fabs(AliHLTTPCTransform::TwoPi() - dphi);
802 if(dphi > fMaxPhi) return false;
804 deta = fabs(hit1->GetEta() - hit2->GetEta());
805 if(deta > fMaxEta) return false;
811 Double_t AliHLTTPCConfMapper::TrackletAngle(AliHLTTPCConfMapTrack *track,Int_t n) const
813 // Returns the angle 'between' the last three points (started at point number n) on this track.
815 if(n > track->GetNumberOfPoints())
816 n = track->GetNumberOfPoints();
824 Double_t angle1,angle2;
826 for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
828 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)track->GetCurrentHit();
829 if( (n-1) == counter)
834 else if( (n-2) == counter)
839 else if( (n-3) == counter)
847 angle1 = atan2(x2[1]-x3[1],x2[0]-x3[0]);
848 angle2 = atan2(x1[1]-x2[1],x1[0]-x2[0]);
850 return fabs(angle1-angle2);
855 Double_t angle1,angle2;
856 TObjArray *hits = track->GetHits();
858 if (n > track->GetNumberOfPoints()) {
859 n = track->GetNumberOfPoints();
866 x1[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetX();
867 x1[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetY();
869 x2[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX();
870 x2[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY();
872 angle1 = atan2(x1[1],x1[0]);
873 angle2 = atan2(x2[1],x1[0]);
874 return fabs(angle1-angle2);
878 Int_t AliHLTTPCConfMapper::FillTracks()
880 //Fill track parameters. Which basically means do a fit of helix in real space,
881 //which should be done in order to get nice tracks.
883 Int_t numoftracks = fNTracks;
886 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
887 "No tracks found!!"<<ENDLOG;
891 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
892 "Number of found tracks: "<<fNTracks<<ENDLOG;
895 for(Int_t i=0; i<numoftracks; i++)
897 AliHLTTPCConfMapTrack *track = (AliHLTTPCConfMapTrack*)fTrack->GetTrack(i);
898 track->Fill(fVertex,fMaxDca);
903 Double_t AliHLTTPCConfMapper::CpuTime()
905 //Return the Cputime in seconds.
907 gettimeofday( &tv, NULL );
908 return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.);