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
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()
39 fVertexFinder(kFALSE),
42 fMaxDca(0.0), // no clue whether this is reasonable, but at least better than without initialization
48 fNumRowSegmentPlusOne(0),
49 fNumPhiSegmentPlusOne(0),
50 fNumEtaSegmentPlusOne(0),
51 fNumPhiEtaSegmentPlusOne(0),
53 fPhiHitsOutOfRange(0),
54 fEtaHitsOutOfRange(0),
61 fVertexConstraint(kTRUE)
68 AliHLTTPCConfMapper::AliHLTTPCConfMapper(const AliHLTTPCConfMapper&)
73 fVertexFinder(kFALSE),
76 fMaxDca(0.0), // no clue whether this is reasonable, but at least better than without initialization
82 fNumRowSegmentPlusOne(0),
83 fNumPhiSegmentPlusOne(0),
84 fNumEtaSegmentPlusOne(0),
85 fNumPhiEtaSegmentPlusOne(0),
87 fPhiHitsOutOfRange(0),
88 fEtaHitsOutOfRange(0),
95 fVertexConstraint(kTRUE)
97 // dummy copy constructor
98 //HLTFatal("copy constructor untested");
101 AliHLTTPCConfMapper& AliHLTTPCConfMapper::operator=(const AliHLTTPCConfMapper&)
103 // dummy assignment operator
104 //HLTFatal("assignment operator untested");
108 AliHLTTPCConfMapper::~AliHLTTPCConfMapper()
125 void AliHLTTPCConfMapper::InitVolumes()
128 //Allocate volumes, set conformal coordinates and pointers.
130 //Should be done after setting the track parameters
132 fNumRowSegmentPlusOne = AliHLTTPCTransform::GetNRows();//NumRows[0]; //Maximum 32.
133 fNumPhiSegmentPlusOne = fNumPhiSegment+1;
134 fNumEtaSegmentPlusOne = fNumEtaSegment+1;
135 fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
136 fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
139 if(fVolume) delete [] fVolume;
140 if(fRow) delete [] fRow;
142 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
143 "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
144 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
145 "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
147 fVolume = new AliHLTTPCConfMapContainer[fBounds];
148 fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
150 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
151 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
153 Int_t maxnumoftracks = 2000;
154 Int_t maxnumofhits = 120000;
161 fHit = new AliHLTTPCConfMapPoint[maxnumofhits];
162 fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",maxnumoftracks);
165 void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
166 { //sector means slice here
167 //Initialize tracker for tracking in a given sector.
168 //Resets track and hit arrays.
169 //Here it is also possible to specify a subsector, by defining
170 //rowrange[0]=innermost row;
171 //rowrange[1]=outermostrow;
172 //Finally you can specify etaslices to save time (assuming a good seed from TRD...)
174 //Define tracking area:
177 fRowMin = rowrange[0];
178 fRowMax = rowrange[1];
180 else //complete sector
183 fRowMax = AliHLTTPCTransform::GetNRows() - 1;
187 fEtaMin = etarange[0];
188 fEtaMax = sector < 18 ? etarange[1] : -etarange[1];
193 fEtaMax = sector < 18 ? 0.9 : -0.9;
196 //Set the angles to sector 2:
197 fPhiMin = -10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) - 10/todeg;
198 fPhiMax = 10*AliHLTTPCTransform::ToRad();//fParam->GetAngle(sector) + 10/todeg;
201 fMainVertexTracks = 0;
203 fEtaHitsOutOfRange=0;
204 fPhiHitsOutOfRange=0;
206 fNumRowSegment = fRowMax - fRowMin; //number of rows to be considered by tracker
207 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::InitSector","B-field")
208 <<"Tracker initializing with a magnetic field of "<<AliHLTTPCTransform::GetBField()<<ENDLOG;
213 Bool_t AliHLTTPCConfMapper::ReadHits(UInt_t count, AliHLTTPCSpacePointData* hits )
216 Int_t nhit=(Int_t)count;
217 for (Int_t i=0;i<nhit;i++)
219 fHit[i+fClustersUnused].Reset();
220 fHit[i+fClustersUnused].ReadHits(&(hits[i]));
222 fClustersUnused += nhit;
224 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::ReadHits","#hits")
225 <<AliHLTTPCLog::kDec<<"hit_counter: "<<nhit<<" count: "<<count<<ENDLOG;
230 void AliHLTTPCConfMapper::SetPointers()
232 //Check if there are not enough clusters to make a track in this sector
233 //Can happen in pp events.
235 if(fClustersUnused < fMinPoints[fVertexConstraint])
238 //Reset detector volumes
239 memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
240 memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
242 Float_t phiSlice = (fPhiMax-fPhiMin)/fNumPhiSegment;
243 Float_t etaSlice = (fEtaMax-fEtaMin)/fNumEtaSegment;
246 Int_t localcounter=0;
247 for(Int_t j=0; j<fClustersUnused; j++)
249 //AliHLTTPCConfMapPoint *thisHit = (AliHLTTPCConfMapPoint*)fHit->At(j);
250 AliHLTTPCConfMapPoint *thisHit = &(fHit[j]);
252 thisHit->Setup(fVertex);
254 Int_t localrow = thisHit->GetPadRow();
256 if(localrow < fRowMin || localrow > fRowMax)
260 thisHit->SetPhiIndex((Int_t)((thisHit->GetPhi()-fPhiMin)/phiSlice +1));
262 if(thisHit->GetPhiIndex()<1 || thisHit->GetPhiIndex()>fNumPhiSegment)
264 //cout << "Phiindex: " << thisHit->phiIndex << " " << thisHit->GetPhi() << endl;
265 fPhiHitsOutOfRange++;
269 thisHit->SetEtaIndex((Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1));
270 if(thisHit->GetEtaIndex()<1 || thisHit->GetEtaIndex()>fNumEtaSegment)
272 //cout << "Etaindex: " << thisHit->etaIndex << " " << thisHit->GetEta() << endl;
273 fEtaHitsOutOfRange++;
278 volumeIndex = (localrow-fRowMin)*fNumPhiEtaSegmentPlusOne +
279 thisHit->GetPhiIndex()*fNumEtaSegmentPlusOne+thisHit->GetEtaIndex();
281 if(fVolume[volumeIndex].first == NULL)
282 fVolume[volumeIndex].first = (void *)thisHit;
284 ((AliHLTTPCConfMapPoint *)fVolume[volumeIndex].last)->SetNextVolumeHit(thisHit);
285 fVolume[volumeIndex].last = (void *)thisHit;
289 if(fRow[(localrow-fRowMin)].first == NULL)
290 fRow[(localrow-fRowMin)].first = (void *)thisHit;
292 ((AliHLTTPCConfMapPoint *)(fRow[(localrow-fRowMin)].last))->SetNextRowHit(thisHit);
293 fRow[(localrow-fRowMin)].last = (void *)thisHit;
296 if(fClustersUnused>0 && localcounter==0)
297 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::SetPointers","Parameters")
298 <<AliHLTTPCLog::kDec<<"No points passed to track finder, hits out of range: "
299 <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
301 Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
302 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::SetPointers","Setup")
303 <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
304 <<" hits accepted "<<hits_accepted<<ENDLOG;
307 void AliHLTTPCConfMapper::MainVertexTrackingA()
309 //Tracking with vertex constraint.
311 if(!fParamSet[(Int_t)kTRUE])
313 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
314 "Tracking parameters not set!"<<ENDLOG;
318 Double_t initCpuTime,cpuTime;
319 initCpuTime = CpuTime();
322 SetVertexConstraint(true);
323 cpuTime = CpuTime() - initCpuTime;
325 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTrackingA","Timing")
326 <<AliHLTTPCLog::kDec<<"Setup finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
330 void AliHLTTPCConfMapper::MainVertexTrackingB()
332 //Tracking with vertex constraint.
334 if(!fParamSet[(Int_t)kTRUE])
336 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
337 "Tracking parameters not set!"<<ENDLOG;
340 Double_t initCpuTime,cpuTime;
341 initCpuTime = CpuTime();
345 cpuTime = CpuTime() - initCpuTime;
347 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTrackingB","Timing")
348 <<AliHLTTPCLog::kDec<<"Main Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
351 void AliHLTTPCConfMapper::MainVertexTracking()
353 //Tracking with vertex constraint.
355 if(!fParamSet[(Int_t)kTRUE])
357 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::MainVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
358 "Tracking parameters not set!"<<ENDLOG;
362 Double_t initCpuTime,cpuTime;
363 initCpuTime = CpuTime();
364 // END ################################################# MODIFIY JMT
366 SetPointers(); // moved to Component
368 // END ################################################# MODIFIY JMT
369 SetVertexConstraint(true);
373 cpuTime = CpuTime() - initCpuTime;
375 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
376 "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
381 void AliHLTTPCConfMapper::NonVertexTracking()
383 //Tracking with no vertex constraint. This should be called after doing MainVertexTracking,
384 //in order to do tracking on the remaining clusters.
385 //The conformal mapping is now done with respect to the first cluster
386 //assosciated with this track.
388 if(!fParamSet[(Int_t)kFALSE])
390 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::NonVertexTracking","Parameters")<<AliHLTTPCLog::kDec<<
391 "Tracking parameters not set!"<<ENDLOG;
395 SetVertexConstraint(false);
397 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::NonVertexTracking","ntracks")<<AliHLTTPCLog::kDec<<
398 "Number of nonvertex tracks found: "<<(fNTracks-fMainVertexTracks)<<ENDLOG;
402 void AliHLTTPCConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength,
403 Int_t rowscopetracklet, Int_t rowscopetrack,
404 Double_t maxphi,Double_t maxeta)
406 //Settings for main vertex tracking. The cuts are:
407 //TrackletLength: #hits on segment, before trying to build a track
408 //TrackLength: Minimum hits on a track
409 //RowScopeTracklet: Row search range for segments
410 //RowScopeTrack: Row search range for tracks
412 SetTrackletLength(trackletlength,(Bool_t)true);
413 SetRowScopeTracklet(rowscopetracklet, (Bool_t) true);
414 SetRowScopeTrack(rowscopetrack, (Bool_t) true);
415 SetMinPoints(tracklength,(Bool_t)true);
421 void AliHLTTPCConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
422 Int_t rowscopetracklet, Int_t rowscopetrack)
424 //set parameters for non-vertex tracking
425 SetTrackletLength(trackletlength,(Bool_t)false);
426 SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
427 SetRowScopeTrack(rowscopetrack, (Bool_t)false);
428 SetMinPoints(tracklength,(Bool_t)false);
429 SetParamDone(kFALSE);
432 void AliHLTTPCConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
434 //Settings for tracks. The cuts are:
435 //HitChi2Cut: Maximum hit chi2
436 //goodHitChi2: Chi2 to stop look for next hit
437 //trackChi2Cut: Maximum track chi2
438 //maxdist: Maximum distance between two clusters when forming segments
440 SetHitChi2Cut(hitChi2Cut,vertexconstraint);
441 SetGoodHitChi2(goodHitChi2,vertexconstraint);
442 SetTrackChi2Cut(trackChi2Cut,vertexconstraint);
443 SetMaxDist(maxdist,vertexconstraint);
446 void AliHLTTPCConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_t vc)
448 //Sets cuts of tracklets. Right now this is only:
449 //maxangle: Maximum angle when forming segments (if trackletlength > 2)
452 SetMaxAngleTracklet(maxangle, vc);
455 void AliHLTTPCConfMapper::ClusterLoop()
457 //Loop over hits, starting at outermost padrow, and trying to build segments.
459 //Check if there are not enough clusters to make a track in this sector
460 //Can happen in pp events.
461 if(fClustersUnused < fMinPoints[fVertexConstraint])
464 Int_t rowsegm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
465 AliHLTTPCConfMapPoint *hit;
467 //Loop over rows, and try to create tracks from the hits.
468 //Starts at the outermost row, and loops as long as a track can be build, due to length.
470 for(rowsegm = fRowMax; rowsegm >= lastrow; rowsegm--)
472 if(fRow[(rowsegm-fRowMin)].first && ((AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first)->GetPadRow() < fRowMin + 1)
475 for(hit = (AliHLTTPCConfMapPoint*)fRow[(rowsegm-fRowMin)].first; hit!=0; hit=hit->GetNextRowHit())
477 if(hit->GetUsage() == true)
488 void AliHLTTPCConfMapper::CreateTrack(AliHLTTPCConfMapPoint *hit)
490 //Tries to create a track from the initial hit given by ClusterLoop()
492 AliHLTTPCConfMapPoint *closesthit = NULL;
493 AliHLTTPCConfMapTrack *track = NULL;
496 Int_t tracks = fNTracks;
499 track = (AliHLTTPCConfMapTrack*)fTrack->NextTrack();
501 //reset hit parameters:
504 UInt_t *trackhitnumber = track->GetHitNumbers();
506 //set conformal coordinates if we are looking for non vertex tracks
507 if(!fVertexConstraint)
509 hit->SetAllCoord(hit);
512 //fill fit parameters of initial track:
513 track->UpdateParam(hit); //here the number of hits is incremented.
514 trackhitnumber[track->GetNumberOfPoints()-1] = hit->GetHitNumber();
519 for(point=1; point<fTrackletLength[fVertexConstraint]; point++)
521 if((closesthit = GetNextNeighbor(hit)))
524 // Calculate track length in sz plane
525 dx = ((AliHLTTPCConfMapPoint*)closesthit)->GetX() - ((AliHLTTPCConfMapPoint*)hit)->GetX();
526 dy = ((AliHLTTPCConfMapPoint*)closesthit)->GetY() - ((AliHLTTPCConfMapPoint*)hit)->GetY();
527 //track->fLength += (Double_t)sqrt ( dx * dx + dy * dy ) ;
528 Double_t length = track->GetLength()+(Double_t)sqrt ( dx * dx + dy * dy );
529 track->SetLength(length);
531 //closesthit->SetS(track->fLength);
532 closesthit->SetS(track->GetLength());
534 //update fit parameters
535 track->UpdateParam(closesthit);
536 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
542 //closest hit does not exist:
543 track->DeleteCandidate();
544 fTrack->RemoveLast();
546 point = fTrackletLength[fVertexConstraint];
550 //tracklet is long enough to be extended to a track
551 if(track->GetNumberOfPoints() == fTrackletLength[fVertexConstraint])
554 track->SetProperties(true);
556 if(TrackletAngle(track) > fMaxAngleTracklet[fVertexConstraint])
557 {//proof if the first points seem to be a beginning of a track
558 track->SetProperties(false);
559 track->DeleteCandidate();
560 fTrack->RemoveLast();
564 else//good tracklet ->proceed, follow the trackfit
568 //define variables to keep the total chi:
569 Double_t xyChi2 = track->GetChiSq1();
570 Double_t szChi2 = track->GetChiSq2();
572 for(point = fTrackletLength[fVertexConstraint]; point <= fNumRowSegment; point++)
574 track->SetChiSq1(fHitChi2Cut[fVertexConstraint]);
575 closesthit = GetNextNeighbor((AliHLTTPCConfMapPoint*)track->GetLastHit(),track);
580 Double_t lxyChi2 = track->GetChiSq1()-track->GetChiSq2();
582 closesthit->SetXYChi2(lxyChi2);
584 //update track length:
585 track->SetLength(closesthit->GetS());
586 szChi2 += track->GetChiSq2();
587 closesthit->SetSZChi2(track->GetChiSq2());
589 track->UpdateParam(closesthit);
590 trackhitnumber[track->GetNumberOfPoints()-1] = closesthit->GetHitNumber();
592 //add closest hit to track
593 closesthit->SetUsage(true);
594 closesthit->SetTrackNumber(tracks-1);
600 //closest hit does not exist
601 point = fNumRowSegment; //continue with next hit in segment
607 track->SetChiSq1(xyChi2);
608 track->SetChiSq2(szChi2);
609 Double_t normalizedchi2 = (track->GetChiSq1()+track->GetChiSq2())/track->GetNumberOfPoints();
611 //remove tracks with not enough points already now
612 if(track->GetNumberOfPoints() < fMinPoints[fVertexConstraint] || normalizedchi2 > fTrackChi2Cut[fVertexConstraint])
614 track->SetProperties(false);
616 track->DeleteCandidate();
617 fTrack->RemoveLast();
623 fClustersUnused -= track->GetNumberOfPoints();
624 track->ComesFromMainVertex(fVertexConstraint);
625 //mark track as main vertex track or not
626 track->SetSector(2); //only needed for testing purposes.
627 track->SetRowRange(fRowMin,fRowMax);
629 if(fVertexConstraint)
640 AliHLTTPCConfMapPoint *AliHLTTPCConfMapper::GetNextNeighbor(AliHLTTPCConfMapPoint *starthit,
641 AliHLTTPCConfMapTrack *track)
643 //When forming segments: Finds closest hit to input hit
644 //When forming tracks: Find closest hit to track fit.
646 Double_t dist,closestdist = fMaxDist[fVertexConstraint];
648 AliHLTTPCConfMapPoint *hit = NULL;
649 AliHLTTPCConfMapPoint *closesthit = NULL;
657 Int_t maxrow = starthit->GetPadRow()-1;
660 if(track) //finding hit close to trackfit
662 minrow = starthit->GetPadRow()-fRowScopeTrack[fVertexConstraint];
666 minrow = starthit->GetPadRow()-fRowScopeTracklet[fVertexConstraint];
670 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};
671 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};
676 return 0; //reached the last padrow under consideration
681 for(subrowsegm=maxrow; subrowsegm>=minrow; subrowsegm--)
683 //loop over subsegments, in the order defined above.
684 for(Int_t i=0; i<9; i++)
686 subphisegm = starthit->GetPhiIndex() + loopphi[i];
688 if(subphisegm < 0 || subphisegm >= fNumPhiSegment)
692 subphisegm += fNumPhiSegment;
694 else if(subphisegm >=fNumPhiSegment)
695 subphisegm -= fNumPhiSegment;
697 //loop over sub eta segments
699 subetasegm = starthit->GetEtaIndex() + loopeta[i];
701 if(subetasegm < 0 || subetasegm >=fNumEtaSegment)
702 continue;//segment exceeds bounds->skip it
704 //loop over hits in this sub segment:
705 volumeIndex=(subrowsegm-fRowMin)*fNumPhiEtaSegmentPlusOne +
706 subphisegm*fNumEtaSegmentPlusOne + subetasegm;
710 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::GetNextNeighbor","Memory")<<AliHLTTPCLog::kDec<<
711 "VolumeIndex error "<<volumeIndex<<ENDLOG;
714 for(hit = (AliHLTTPCConfMapPoint*)fVolume[volumeIndex].first;
715 hit!=0; hit = hit->GetNextVolumeHit())
719 {//hit was not used before
721 //set conformal mapping if looking for nonvertex tracks:
722 if(!fVertexConstraint)
724 hit->SetAllCoord(starthit);
727 if(track)//track search - look for nearest neighbor to extrapolated track
729 // BEGINN ############################################## MODIFIY JMT
731 if (fVertexConstraint) {
732 if(!VerifyRange(starthit,hit))
736 if(!VerifyRange(starthit,hit))
739 // END ################################################# MODIFIY JMT
740 testhit = EvaluateHit(starthit,hit,track);
742 if(testhit == 0)//chi2 not good enough, keep looking
744 else if(testhit==2)//chi2 good enough, return it
747 closesthit = hit;//chi2 acceptable, but keep looking
751 else //tracklet search, look for nearest neighbor
754 if((dist=CalcDistance(starthit,hit)) < closestdist)
756 // BEGINN ############################################## MODIFIY JMT
758 if (fVertexConstraint) {
759 if(!VerifyRange(starthit,hit))
763 if(!VerifyRange(starthit,hit))
766 // END ################################################# MODIFIY JMT
770 //if this hit is good enough, return it:
771 if(closestdist < fGoodDist)
775 continue;//sub hit was farther away than a hit before
779 }//hit not used before
781 else continue; //sub hit was used before
783 }//loop over hits in sub segment
785 }//loop over sub segments
792 if(closesthit)// && closestdist < mMaxDist)
798 Int_t AliHLTTPCConfMapper::EvaluateHit(AliHLTTPCConfMapPoint *starthit,AliHLTTPCConfMapPoint *hit,AliHLTTPCConfMapTrack *track)
800 //Check if space point gives a fit with acceptable chi2.
802 Double_t temp,dxy,lchi2,dx,dy,slocal,dsz,lszChi2;
803 temp = (track->GetA2Xy()*hit->GetXprime()-hit->GetYprime()+track->GetA1Xy());
804 dxy = temp*temp/(track->GetA2Xy()*track->GetA2Xy() + 1.);
807 lchi2 = (dxy*hit->GetXYWeight());
809 if(lchi2 > track->GetChiSq1())//chi2 was worse than before.
812 //calculate s and the distance hit-line
813 dx = starthit->GetX()-hit->GetX();
814 dy = starthit->GetY()-hit->GetY();
815 //slocal = track->fLength+sqrt(dx*dx+dy*dy);
816 slocal = track->GetLength()+sqrt(dx*dx+dy*dy);
818 temp = (track->GetA2Sz()*slocal-hit->GetZ()+track->GetA1Sz());
819 dsz = temp*temp/(track->GetA2Sz()*track->GetA2Sz()+1);
822 lszChi2 = dsz*hit->GetZWeight();
826 //check whether chi2 is better than previous one:
827 if(lchi2 < track->GetChiSq1())
829 track->SetChiSq1(lchi2);
830 track->SetChiSq2(lszChi2);
834 //if chi2 good enough, stop here:
835 if(lchi2 < fGoodHitChi2[fVertexConstraint])
845 Double_t AliHLTTPCConfMapper::CalcDistance(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
847 //Return distance between two clusters, defined by Pablo
849 Double_t phidiff = fabs( hit1->GetPhi() - hit2->GetPhi() );
850 if (phidiff > AliHLTTPCTransform::Pi()) phidiff = AliHLTTPCTransform::TwoPi() - phidiff;
852 return AliHLTTPCTransform::ToDeg()*fabs((Float_t)((hit1->GetPadRow() - hit2->GetPadRow()) *
853 (phidiff + fabs( hit1->GetEta() - hit2->GetEta()))));
856 Bool_t AliHLTTPCConfMapper::VerifyRange(const AliHLTTPCConfMapPoint *hit1,const AliHLTTPCConfMapPoint *hit2) const
858 //Check if the hit are within reasonable range in phi and eta
859 Double_t dphi,deta;//maxphi=0.1,maxeta=0.1;
860 dphi = fabs(hit1->GetPhi() - hit2->GetPhi());
861 if(dphi > AliHLTTPCTransform::Pi()) dphi = fabs(AliHLTTPCTransform::TwoPi() - dphi);
862 if(dphi > fMaxPhi) return false;
864 deta = fabs(hit1->GetEta() - hit2->GetEta());
865 if(deta > fMaxEta) return false;
871 Double_t AliHLTTPCConfMapper::TrackletAngle(AliHLTTPCConfMapTrack *track,Int_t n) const
873 // Returns the angle 'between' the last three points (started at point number n) on this track.
875 if(n > track->GetNumberOfPoints())
876 n = track->GetNumberOfPoints();
884 Double_t angle1,angle2;
886 for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
888 AliHLTTPCConfMapPoint *p = (AliHLTTPCConfMapPoint*)track->GetCurrentHit();
889 if( (n-1) == counter)
894 else if( (n-2) == counter)
899 else if( (n-3) == counter)
907 angle1 = atan2(x2[1]-x3[1],x2[0]-x3[0]);
908 angle2 = atan2(x1[1]-x2[1],x1[0]-x2[0]);
910 return fabs(angle1-angle2);
915 Double_t angle1,angle2;
916 TObjArray *hits = track->GetHits();
918 if (n > track->GetNumberOfPoints()) {
919 n = track->GetNumberOfPoints();
926 x1[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetX();
927 x1[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-3))->GetY();
929 x2[0] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetX() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetX();
930 x2[1] = ((AliHLTTPCConfMapPoint *)hits->At(n-1))->GetY() - ((AliHLTTPCConfMapPoint *)hits->At(n-2))->GetY();
932 angle1 = atan2(x1[1],x1[0]);
933 angle2 = atan2(x2[1],x1[0]);
934 return fabs(angle1-angle2);
938 Int_t AliHLTTPCConfMapper::FillTracks()
940 //Fill track parameters. Which basically means do a fit of helix in real space,
941 //which should be done in order to get nice tracks.
943 Int_t numoftracks = fNTracks;
946 LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
947 "No tracks found!!"<<ENDLOG;
951 LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
952 "Number of found tracks: "<<fNTracks<<ENDLOG;
955 for(Int_t i=0; i<numoftracks; i++)
957 AliHLTTPCConfMapTrack *track = (AliHLTTPCConfMapTrack*)fTrack->GetTrack(i);
958 track->Fill(fVertex,fMaxDca);
963 Double_t AliHLTTPCConfMapper::CpuTime()
965 //Return the Cputime in seconds.
967 gettimeofday( &tv, NULL );
968 return tv.tv_sec+(((Double_t)tv.tv_usec)/1000000.);